diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index a568b86454a..043acea5b3a 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -77,6 +77,7 @@ #include "nsISHistoryInternal.h" #include "nsIPrincipal.h" #include "nsIHistoryEntry.h" +#include "nsISHistoryListener.h" // Editor-related #include "nsIEditingSession.h" @@ -2340,6 +2341,7 @@ nsDocShell::LoadURI(const PRUnichar * aURI, NS_IMETHODIMP nsDocShell::Reload(PRUint32 aReloadFlags) { + nsresult rv; NS_ASSERTION(((aReloadFlags & 0xf) == 0), "Reload command not updated to use load flags!"); @@ -2351,7 +2353,22 @@ nsDocShell::Reload(PRUint32 aReloadFlags) else if (aReloadFlags & LOAD_FLAGS_CHARSET_CHANGE) type = LOAD_RELOAD_CHARSET_CHANGE; - nsresult rv; + // Send notifications to the HistoryListener if any, about the impending reload + nsCOMPtr rootSH; + rv = GetRootSessionHistory(getter_AddRefs(rootSH)); + nsCOMPtr shistInt(do_QueryInterface(rootSH)); + PRBool canReload = PR_TRUE; + if (rootSH) { + nsCOMPtr listener; + shistInt->GetListener(getter_AddRefs(listener)); + if (listener) { + listener->OnHistoryReload(mCurrentURI, aReloadFlags, &canReload); + } + } + + if (!canReload) + return NS_OK; + /* If you change this part of code, make sure bug 45297 does not re-occur */ if (mOSHE) rv = LoadHistoryEntry(mOSHE, type); diff --git a/mozilla/xpfe/components/shistory/public/nsISHistoryInternal.idl b/mozilla/xpfe/components/shistory/public/nsISHistoryInternal.idl index 74f0bb02630..f21d67b910b 100644 --- a/mozilla/xpfe/components/shistory/public/nsISHistoryInternal.idl +++ b/mozilla/xpfe/components/shistory/public/nsISHistoryInternal.idl @@ -42,6 +42,7 @@ #include "nsISHTransaction.idl" #include "nsIDocShell.idl" +interface nsISHistoryListener; %{C++ #define NS_SHISTORY_INTERNAL_CID \ @@ -72,16 +73,21 @@ interface nsISHistoryInternal: nsISupports */ attribute nsIDocShell rootDocShell; - /** - * Update the index maintained by sessionHistory - */ - void updateIndex(); + /** + * Update the index maintained by sessionHistory + */ + void updateIndex(); - /** - * Replace the nsISHEntry at a particular index - * @param aIndex - The index at which the entry shoud be replaced - * @param aReplaceEntry - The replacement entry for the index. - */ - void replaceEntry(in long aIndex, in nsISHEntry aReplaceEntry); + /** + * Replace the nsISHEntry at a particular index + * @param aIndex - The index at which the entry shoud be replaced + * @param aReplaceEntry - The replacement entry for the index. + */ + void replaceEntry(in long aIndex, in nsISHEntry aReplaceEntry); + + /** + * Get handle to the history listener + */ + readonly attribute nsISHistoryListener listener; }; diff --git a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp index d83ce3d3c26..42a628b5b06 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp +++ b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp @@ -440,6 +440,17 @@ nsSHistory::ReplaceEntry(PRInt32 aIndex, nsISHEntry * aReplaceEntry) return rv; } +/* Get a handle to the Session history listener */ +NS_IMETHODIMP +nsSHistory::GetListener(nsISHistoryListener ** aListener) +{ + NS_ENSURE_ARG_POINTER(aListener); + if (mListener) + CallQueryReferent(mListener.get(), aListener); + // Don't addref aListener. It is a weak pointer. + return NS_OK; +} + //***************************************************************************** // nsSHistory: nsIWebNavigation //*****************************************************************************