Fix for bug 197127. r=alecf, sr=heikki. Mark clicked JS urls as hidden in global history. Don't let clicked data urls enter global history.

This commit is contained in:
nisheeth%netscape.com 2003-03-25 23:13:10 +00:00
Родитель fe452130d5
Коммит ee81a80f02
1 изменённых файлов: 21 добавлений и 11 удалений

Просмотреть файл

@ -6379,7 +6379,6 @@ nsDocShell::ShouldAddToGlobalHistory(nsIURI * aURI, PRBool * aShouldAdd)
PRBool isMailbox = PR_FALSE; PRBool isMailbox = PR_FALSE;
PRBool isViewSource = PR_FALSE; PRBool isViewSource = PR_FALSE;
PRBool isChrome = PR_FALSE; PRBool isChrome = PR_FALSE;
PRBool isJavascript = PR_FALSE;
PRBool isData = PR_FALSE; PRBool isData = PR_FALSE;
NS_ENSURE_SUCCESS(aURI->SchemeIs("about", &isAbout), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(aURI->SchemeIs("about", &isAbout), NS_ERROR_FAILURE);
@ -6389,11 +6388,9 @@ nsDocShell::ShouldAddToGlobalHistory(nsIURI * aURI, PRBool * aShouldAdd)
NS_ENSURE_SUCCESS(aURI->SchemeIs("view-source", &isViewSource), NS_ENSURE_SUCCESS(aURI->SchemeIs("view-source", &isViewSource),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("chrome", &isChrome), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(aURI->SchemeIs("chrome", &isChrome), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("javascript", &isJavascript), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aURI->SchemeIs("data", &isData), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(aURI->SchemeIs("data", &isData), NS_ERROR_FAILURE);
if (isAbout || isImap || isNews || isMailbox || isViewSource || isChrome if (isAbout || isImap || isNews || isMailbox || isViewSource || isChrome || isData)
|| isJavascript || isData)
return NS_OK; return NS_OK;
*aShouldAdd = PR_TRUE; *aShouldAdd = PR_TRUE;
@ -6471,16 +6468,29 @@ nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aHidden)
nsCAutoString spec; nsCAutoString spec;
NS_ENSURE_SUCCESS(aURI->GetSpec(spec), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(aURI->GetSpec(spec), NS_ERROR_FAILURE);
PRBool isJavascript;
NS_ENSURE_SUCCESS(aURI->SchemeIs("javascript", &isJavascript), NS_ERROR_FAILURE);
nsCOMPtr<nsIBrowserHistory> browserHistory;
if (isJavascript || aHidden) {
browserHistory = do_QueryInterface(mGlobalHistory);
}
// If this is a JS url, hide it in global history so that
// it doesn't show up in the autocomplete dropdown. AddPage()
// contains logic to unhide urls if they are typed, so this call
// to HidePage() needs to be before the AddPage() call.
// See bug 197127 and bug 161531 for more details.
if (isJavascript && browserHistory) {
browserHistory->HidePage(spec.get());
}
NS_ENSURE_SUCCESS(mGlobalHistory->AddPage(spec.get()), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(mGlobalHistory->AddPage(spec.get()), NS_ERROR_FAILURE);
// this is a redirect, so hide the page from // this is a redirect, hide the page from
// being enumerated in history // being enumerated in history
if (aHidden) { if (aHidden && browserHistory) {
nsCOMPtr<nsIBrowserHistory> browserHistory = browserHistory->HidePage(spec.get());
do_QueryInterface(mGlobalHistory);
if (browserHistory) {
browserHistory->HidePage(spec.get());
}
} }
return NS_OK; return NS_OK;
} }