Fix for bug 90224. Send nsISHistoryListener notifications for Reload. r=mcafee, sr=rpotts.

This commit is contained in:
radha%netscape.com 2002-02-08 00:20:26 +00:00
Родитель f4255ecb62
Коммит 711f85c478
3 изменённых файлов: 45 добавлений и 11 удалений

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

@ -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<nsISHistory> rootSH;
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
nsCOMPtr<nsISHistoryInternal> shistInt(do_QueryInterface(rootSH));
PRBool canReload = PR_TRUE;
if (rootSH) {
nsCOMPtr<nsISHistoryListener> 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);

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

@ -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;
};

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

@ -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
//*****************************************************************************