diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index bd6ecebffb3..62f03934ad6 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -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) { diff --git a/mozilla/xpfe/components/history/public/nsIBrowserHistory.idl b/mozilla/xpfe/components/history/public/nsIBrowserHistory.idl index f3b0fa30275..48a416484a2 100644 --- a/mozilla/xpfe/components/history/public/nsIBrowserHistory.idl +++ b/mozilla/xpfe/components/history/public/nsIBrowserHistory.idl @@ -81,7 +81,7 @@ interface nsIBrowserHistory : nsISupports * lastPageVisited * the most recently visited page */ - readonly attribute string lastPageVisited; + attribute string lastPageVisited; /** diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp index 85cbdd7eef8..fbdc0f97b5e 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp @@ -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); diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.h b/mozilla/xpfe/components/history/src/nsGlobalHistory.h index 0b673a9ce92..64510255c8b 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.h +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.h @@ -327,7 +327,6 @@ protected: // misc unrelated stuff // nsCOMPtr mBundle; - nsresult SaveLastPageVisited(const char *); // pseudo-constants. although the global history really is a // singleton, we'll use this metaphor to be consistent.