From ee81a80f0265ff9c6fb313f1565092df23ea05a0 Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Tue, 25 Mar 2003 23:13:10 +0000 Subject: [PATCH] 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. --- docshell/base/nsDocShell.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 2f86954d794d..8f582317b2e5 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -6379,7 +6379,6 @@ nsDocShell::ShouldAddToGlobalHistory(nsIURI * aURI, PRBool * aShouldAdd) PRBool isMailbox = PR_FALSE; PRBool isViewSource = PR_FALSE; PRBool isChrome = PR_FALSE; - PRBool isJavascript = PR_FALSE; PRBool isData = PR_FALSE; 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_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); - if (isAbout || isImap || isNews || isMailbox || isViewSource || isChrome - || isJavascript || isData) + if (isAbout || isImap || isNews || isMailbox || isViewSource || isChrome || isData) return NS_OK; *aShouldAdd = PR_TRUE; @@ -6471,16 +6468,29 @@ nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aHidden) nsCAutoString spec; NS_ENSURE_SUCCESS(aURI->GetSpec(spec), NS_ERROR_FAILURE); + PRBool isJavascript; + NS_ENSURE_SUCCESS(aURI->SchemeIs("javascript", &isJavascript), NS_ERROR_FAILURE); + + nsCOMPtr 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); - // this is a redirect, so hide the page from + // this is a redirect, hide the page from // being enumerated in history - if (aHidden) { - nsCOMPtr browserHistory = - do_QueryInterface(mGlobalHistory); - if (browserHistory) { - browserHistory->HidePage(spec.get()); - } + if (aHidden && browserHistory) { + browserHistory->HidePage(spec.get()); } return NS_OK; }