Bug 58613 "last page visited" cannot handle framed pages properly

patch by ian@arlen.demon.co.uk r=timeless sr=alecf
This commit is contained in:
timeless%mozdev.org 2003-06-22 17:46:13 +00:00
parent 2edb25ce92
commit c8e1cc4cb0
4 changed files with 23 additions and 21 deletions

View File

@ -6542,6 +6542,26 @@ nsDocShell::AddToGlobalHistory(nsIURI * aURI, PRBool aHidden)
NS_ENSURE_SUCCESS(mGlobalHistory->AddPage(spec.get()), NS_ERROR_FAILURE);
// Only save last page visited if it is not a frame and one of the
// startup, new window or new tab prefs is set to last page visited.
// See bug 58613 for more details.
if (mPrefs && !IsFrame()) {
PRInt32 choice = 0;
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.startup.page", &choice))) {
if (choice != 2) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.windows.loadOnNewWindow", &choice))) {
if (choice != 2)
mPrefs->GetIntPref("browser.tabs.loadOnNewTab", &choice);
}
}
}
if (choice == 2) {
browserHistory = do_QueryInterface(mGlobalHistory);
if (browserHistory)
browserHistory->SetLastPageVisited(spec.get());
}
}
// this is a redirect, hide the page from
// being enumerated in history
if (aHidden && browserHistory) {

View File

@ -81,7 +81,7 @@ interface nsIBrowserHistory : nsISupports
* lastPageVisited
* the most recently visited page
*/
readonly attribute string lastPageVisited;
attribute string lastPageVisited;
/**

View File

@ -106,9 +106,6 @@ nsIPrefBranch* nsGlobalHistory::gPrefBranch = nsnull;
#define PREF_BRANCH_BASE "browser."
#define PREF_BROWSER_HISTORY_EXPIRE_DAYS "history_expire_days"
#define PREF_BROWSER_STARTUP_PAGE "startup.page"
#define PREF_BROWSER_TABS_LOADONNEWTAB "tabs.loadOnNewTab"
#define PREF_BROWSER_WINDOWS_LOADONNEWWINDOW "windows.loadOnNewWindow"
#define PREF_AUTOCOMPLETE_ONLY_TYPED "urlbar.matchOnlyTyped"
#define PREF_AUTOCOMPLETE_ENABLED "urlbar.autocomplete.enabled"
@ -615,20 +612,6 @@ nsGlobalHistory::AddPage(const char *aURL)
nsresult rv = AddPageToDatabase(aURL, GetNow());
NS_ENSURE_SUCCESS(rv, rv);
if (gPrefBranch) {
PRInt32 choice = 0;
gPrefBranch->GetIntPref(PREF_BROWSER_STARTUP_PAGE, &choice);
if (choice != 2) {
gPrefBranch->GetIntPref(PREF_BROWSER_WINDOWS_LOADONNEWWINDOW, &choice);
if (choice != 2)
gPrefBranch->GetIntPref(PREF_BROWSER_TABS_LOADONNEWTAB, &choice);
}
if (choice == 2) {
rv = SaveLastPageVisited(aURL);
NS_ENSURE_SUCCESS(rv, rv);
}
}
return NS_OK;
}
@ -1195,8 +1178,8 @@ nsGlobalHistory::IsVisited(const char *aURL, PRBool *_retval)
return NS_OK;
}
nsresult
nsGlobalHistory::SaveLastPageVisited(const char *aURL)
NS_IMETHODIMP
nsGlobalHistory::SetLastPageVisited(const char *aURL)
{
NS_ENSURE_TRUE(aURL, NS_ERROR_FAILURE);
NS_ENSURE_STATE(mMetaRow);

View File

@ -327,7 +327,6 @@ protected:
// misc unrelated stuff
//
nsCOMPtr<nsIStringBundle> mBundle;
nsresult SaveLastPageVisited(const char *);
// pseudo-constants. although the global history really is a
// singleton, we'll use this metaphor to be consistent.