From df4351d75c9c5d026290d0fc91c242debffd88df Mon Sep 17 00:00:00 2001 From: "cbiesinger@web.de" Date: Wed, 27 Jul 2005 12:38:38 +0000 Subject: [PATCH] Bug 286811 don't add ("xul") error pages to global history r=bz sr=darin a=bsmedberg --- docshell/base/nsDocShell.cpp | 29 +++++++++++++++++------------ docshell/base/nsDocShell.h | 6 ++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 6f4b2f478b7a..c467bfe886ff 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3024,10 +3024,10 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, // Create an shistory entry for the old load, if we have a channel if (aFailedChannel) { mURIResultedInDocument = PR_TRUE; - OnLoadingSite(aFailedChannel, PR_TRUE); + OnLoadingSite(aFailedChannel, PR_TRUE, PR_FALSE); } else if (aURI) { mURIResultedInDocument = PR_TRUE; - OnNewURI(aURI, nsnull, mLoadType, PR_TRUE); + OnNewURI(aURI, nsnull, mLoadType, PR_TRUE, PR_FALSE); } nsCAutoString url; @@ -3735,7 +3735,7 @@ nsDocShell::SetTitle(const PRUnichar * aTitle) treeOwnerAsWin->SetTitle(aTitle); } - if (mGlobalHistory && mCurrentURI) { + if (mGlobalHistory && mCurrentURI && mLoadType != LOAD_ERROR_PAGE) { mGlobalHistory->SetPageTitle(mCurrentURI, nsDependentString(aTitle)); } @@ -6977,7 +6977,8 @@ nsDocShell::SetupReferrerFromChannel(nsIChannel * aChannel) PRBool nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, - PRUint32 aLoadType, PRBool aFireOnLocationChange) + PRUint32 aLoadType, PRBool aFireOnLocationChange, + PRBool aAddToGlobalHistory) { NS_ASSERTION(aURI, "uri is null"); #ifdef PR_LOGGING @@ -7108,12 +7109,14 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, } // Update Global history - // Get the referrer uri from the channel - nsCOMPtr referrer; - nsCOMPtr httpchannel(do_QueryInterface(aChannel)); - if (httpchannel) - httpchannel->GetReferrer(getter_AddRefs(referrer)); - AddToGlobalHistory(aURI, PR_FALSE, referrer); + if (aAddToGlobalHistory) { + // Get the referrer uri from the channel + nsCOMPtr referrer; + nsCOMPtr httpchannel(do_QueryInterface(aChannel)); + if (httpchannel) + httpchannel->GetReferrer(getter_AddRefs(referrer)); + AddToGlobalHistory(aURI, PR_FALSE, referrer); + } } // If this was a history load, update the index in @@ -7131,7 +7134,8 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, } PRBool -nsDocShell::OnLoadingSite(nsIChannel * aChannel, PRBool aFireOnLocationChange) +nsDocShell::OnLoadingSite(nsIChannel * aChannel, PRBool aFireOnLocationChange, + PRBool aAddToGlobalHistory) { nsCOMPtr uri; // If this a redirect, use the final url (uri) @@ -7148,7 +7152,8 @@ nsDocShell::OnLoadingSite(nsIChannel * aChannel, PRBool aFireOnLocationChange) aChannel->GetOriginalURI(getter_AddRefs(uri)); NS_ENSURE_TRUE(uri, PR_FALSE); - return OnNewURI(uri, aChannel, mLoadType, aFireOnLocationChange); + return OnNewURI(uri, aChannel, mLoadType, aFireOnLocationChange, + aAddToGlobalHistory); } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 8aef4e271096..ba3d3511d8bf 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -304,7 +304,8 @@ protected: // FireOnLocationChange is called. // In all other cases PR_FALSE is returned. PRBool OnLoadingSite(nsIChannel * aChannel, - PRBool aFireOnLocationChange); + PRBool aFireOnLocationChange, + PRBool aAddToGlobalHistory = PR_TRUE); // Returns PR_TRUE if would have called FireOnLocationChange, // but did not because aFireOnLocationChange was false on entry. @@ -312,7 +313,8 @@ protected: // FireOnLocationChange is called. // In all other cases PR_FALSE is returned. PRBool OnNewURI(nsIURI * aURI, nsIChannel * aChannel, PRUint32 aLoadType, - PRBool aFireOnLocationChange); + PRBool aFireOnLocationChange, + PRBool aAddToGlobalHistory = PR_TRUE); virtual void SetReferrerURI(nsIURI * aURI);