diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 74cce7a6253..0e1bef68f5c 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -5416,6 +5416,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, nsCOMPtr inputStream; nsCOMPtr referrerURI; nsCOMPtr cacheKey; + nsCOMPtr cacheToken; if (aChannel) { nsCOMPtr cacheChannel(do_QueryInterface(aChannel)); @@ -5424,6 +5425,7 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, */ if (cacheChannel) { cacheChannel->GetCacheKey(getter_AddRefs(cacheKey)); + cacheChannel->GetCacheToken(getter_AddRefs(cacheToken)); } nsCOMPtr httpChannel(do_QueryInterface(aChannel)); @@ -5441,6 +5443,13 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, nsnull, // LayoutHistory state cacheKey); // CacheKey entry->SetReferrerURI(referrerURI); + /* If cache got a 'no-store', ask SH not to store + * HistoryLayoutState. By default, SH will set this + * flag to PR_TRUE and save HistoryLayoutState. + */ + if (!cacheToken) + entry->SetSaveHistoryStateFlag(PR_FALSE); + // If no Session History component is available in the parent DocShell @@ -5534,10 +5543,16 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType) NS_IMETHODIMP nsDocShell::PersistLayoutHistoryState() { - nsresult - rv = - NS_OK; + nsresult rv = NS_OK; + + if (mOSHE) { + PRBool saveHistoryState = PR_TRUE; + mOSHE->GetSaveHistoryStateFlag(&saveHistoryState); + // Don't capture historystate and save it in history + // if the page asked not to do so. + if (!saveHistoryState) + return NS_OK; nsCOMPtr shell; rv = GetPresShell(getter_AddRefs(shell)); diff --git a/mozilla/xpfe/components/shistory/public/nsISHEntry.idl b/mozilla/xpfe/components/shistory/public/nsISHEntry.idl index ac23daf51b8..a3bc772715c 100644 --- a/mozilla/xpfe/components/shistory/public/nsISHEntry.idl +++ b/mozilla/xpfe/components/shistory/public/nsISHEntry.idl @@ -74,6 +74,9 @@ attribute unsigned long ID; /** attribute to set and get the cache key for the entry */ attribute nsISupports cacheKey; +/** attribute to indicate whether layoutHistoryState should be saved */ +attribute boolean saveHistoryStateFlag; + /** Additional ways to create an entry */ void create(in nsIURI aURI, in wstring aTitle, in nsIDOMDocument aDocument, in nsIInputStream aInputStream, in nsILayoutHistoryState aHistoryLayoutState, diff --git a/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp b/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp index 309e067227a..a35257b54e4 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp +++ b/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp @@ -223,6 +223,20 @@ NS_IMETHODIMP nsSHEntry::SetCacheKey(nsISupports* aCacheKey) return NS_OK; } +NS_IMETHODIMP nsSHEntry::GetSaveHistoryStateFlag(PRBool * aFlag) +{ + NS_ENSURE_ARG_POINTER(aFlag); + + *aFlag = mSaveHistoryState; + return NS_OK; +} + +NS_IMETHODIMP nsSHEntry::SetSaveHistoryStateFlag(PRBool aFlag) +{ + mSaveHistoryState = aFlag; + return NS_OK; +} + nsresult nsSHEntry::Create(nsIURI * aURI, const PRUnichar * aTitle, nsIDOMDocument * aDOMDocument, nsIInputStream * aInputStream, nsILayoutHistoryState * aHistoryLayoutState, @@ -243,6 +257,9 @@ nsSHEntry::Create(nsIURI * aURI, const PRUnichar * aTitle, nsIDOMDocument * aDOM // all subframe navigations, sets the flag to true. SetIsSubFrame(PR_FALSE); + // By default we save HistoryLayoutState + SetSaveHistoryStateFlag(PR_TRUE); + return NS_OK; } diff --git a/mozilla/xpfe/components/shistory/src/nsSHEntry.h b/mozilla/xpfe/components/shistory/src/nsSHEntry.h index 62ede83dd56..f42a8f1da3f 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHEntry.h +++ b/mozilla/xpfe/components/shistory/src/nsSHEntry.h @@ -65,6 +65,7 @@ private: PRUint32 mLoadType; PRUint32 mID; PRBool mIsFrameNavigation; + PRBool mSaveHistoryState; nsCOMPtr mCacheKey; nsISHEntry * mParent; // weak reference };