diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 6cc2f8f9a9a7..da01d284bed5 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -953,14 +953,15 @@ function delayedStartup() var shell = getShellService(); if (shell) { var shouldCheck = shell.shouldCheckDefaultBrowser; - var willRestoreSession = false; + var willRecoverSession = false; try { var ss = Cc["@mozilla.org/browser/sessionstartup;1"]. getService(Ci.nsISessionStartup); - willRestoreSession = ss.doRestore(); + willRecoverSession = + (ss.sessionType == Ci.nsISessionStartup.RECOVER_SESSION); } catch (ex) { /* never mind; suppose SessionStore is broken */ } - if (shouldCheck && !shell.isDefaultBrowser(true) && !willRestoreSession) { + if (shouldCheck && !shell.isDefaultBrowser(true) && !willRecoverSession) { var brandBundle = document.getElementById("bundle_brand"); var shellBundle = document.getElementById("bundle_shell"); diff --git a/browser/components/sessionstore/nsISessionStartup.idl b/browser/components/sessionstore/nsISessionStartup.idl index 6281f190a7c7..6574fc5367f0 100644 --- a/browser/components/sessionstore/nsISessionStartup.idl +++ b/browser/components/sessionstore/nsISessionStartup.idl @@ -43,7 +43,7 @@ * - and allows to restore everything into one window. */ -[scriptable, uuid(22496a00-227b-11db-a98b-0800200c9a66)] +[scriptable, uuid(c0b185e7-0d21-46ac-8eee-7b5065ee7ecd)] interface nsISessionStartup: nsISupports { // Get session state as string @@ -53,4 +53,15 @@ interface nsISessionStartup: nsISupports * Determine if session should be restored */ boolean doRestore(); + + /** + * What type of session we're restoring. If we have a session, we're + * either restoring state from a crash or restoring state that the user + * requested we save on shutdown. + */ + const unsigned long NO_SESSION = 0; + const unsigned long RECOVER_SESSION = 1; + const unsigned long RESUME_SESSION = 2; + + readonly attribute unsigned long sessionType; }; diff --git a/browser/components/sessionstore/src/nsSessionStartup.js b/browser/components/sessionstore/src/nsSessionStartup.js index 803035159447..755654f0c2d6 100644 --- a/browser/components/sessionstore/src/nsSessionStartup.js +++ b/browser/components/sessionstore/src/nsSessionStartup.js @@ -87,6 +87,7 @@ SessionStartup.prototype = { // the state to restore at startup _iniString: null, + _sessionType: Ci.nsISessionStartup.NO_SESSION, /* ........ Global Event Handlers .............. */ @@ -127,17 +128,22 @@ SessionStartup.prototype = { catch (ex) { debug("The session file is invalid: " + ex); } } } - + // prompt and check prefs - this._doRestore = this._lastSessionCrashed ? this._doRecoverSession() : this._doResumeSession(); - if (this._iniString && !this._doRestore) { - this._iniString = null; // reset the state string + if (this._iniString) { + if (this._lastSessionCrashed && this._doRecoverSession()) + this._sessionType = Ci.nsISessionStartup.RECOVER_SESSION; + else if (!this._lastSessionCrashed && this._doResumeSession()) + this._sessionType = Ci.nsISessionStartup.RESUME_SESSION; + else + this._iniString = null; // reset the state string } + if (this._prefBranch.getBoolPref("sessionstore.resume_session_once")) { this._prefBranch.setBoolPref("sessionstore.resume_session_once", false); } - if (this.doRestore()) { + if (this._sessionType != Ci.nsISessionStartup.NO_SESSION) { // wait for the first browser window to open var observerService = Cc["@mozilla.org/observer-service;1"]. getService(Ci.nsIObserverService); @@ -219,7 +225,14 @@ SessionStartup.prototype = { * @returns bool */ doRestore: function sss_doRestore() { - return this._doRestore && this._iniString != null; + return this._sessionType != Ci.nsISessionStartup.NO_SESSION; + }, + + /** + * Get the type of pending session store, if any. + */ + get sessionType() { + return this._sessionType; }, /* ........ Auxiliary Functions .............. */