mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1369456 - Replace nsSessionStartup.js with SessionStartup.jsm. r=florian
MozReview-Commit-ID: 53Mu4zb9X1C --HG-- rename : browser/components/sessionstore/nsSessionStartup.js => browser/components/sessionstore/SessionStartup.jsm extra : rebase_source : 5b4f5c2e45841a5ee9123386e8657d8c262ba416
This commit is contained in:
parent
8dbf61da1e
commit
5b4e355993
@ -53,6 +53,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||||||
ReaderParent: "resource:///modules/ReaderParent.jsm",
|
ReaderParent: "resource:///modules/ReaderParent.jsm",
|
||||||
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
|
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
|
||||||
Sanitizer: "resource:///modules/Sanitizer.jsm",
|
Sanitizer: "resource:///modules/Sanitizer.jsm",
|
||||||
|
SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
|
||||||
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
|
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
|
||||||
SchedulePressure: "resource:///modules/SchedulePressure.jsm",
|
SchedulePressure: "resource:///modules/SchedulePressure.jsm",
|
||||||
ShortcutUtils: "resource://gre/modules/ShortcutUtils.jsm",
|
ShortcutUtils: "resource://gre/modules/ShortcutUtils.jsm",
|
||||||
@ -141,7 +142,6 @@ XPCOMUtils.defineLazyServiceGetters(this, {
|
|||||||
gDNSService: ["@mozilla.org/network/dns-service;1", "nsIDNSService"],
|
gDNSService: ["@mozilla.org/network/dns-service;1", "nsIDNSService"],
|
||||||
gSerializationHelper: ["@mozilla.org/network/serialization-helper;1", "nsISerializationHelper"],
|
gSerializationHelper: ["@mozilla.org/network/serialization-helper;1", "nsISerializationHelper"],
|
||||||
Marionette: ["@mozilla.org/remote/marionette;1", "nsIMarionette"],
|
Marionette: ["@mozilla.org/remote/marionette;1", "nsIMarionette"],
|
||||||
SessionStartup: ["@mozilla.org/browser/sessionstartup;1", "nsISessionStartup"],
|
|
||||||
WindowsUIUtils: ["@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"],
|
WindowsUIUtils: ["@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ const startupPhases = {
|
|||||||
"MainProcessSingleton.js",
|
"MainProcessSingleton.js",
|
||||||
|
|
||||||
// Bugs to fix: The following components shouldn't be initialized that early.
|
// Bugs to fix: The following components shouldn't be initialized that early.
|
||||||
"nsSessionStartup.js", // bug 1369456
|
|
||||||
"PushComponents.js", // bug 1369436
|
"PushComponents.js", // bug 1369436
|
||||||
]),
|
]),
|
||||||
modules: new Set([
|
modules: new Set([
|
||||||
|
@ -12,6 +12,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||||||
HomePage: "resource:///modules/HomePage.jsm",
|
HomePage: "resource:///modules/HomePage.jsm",
|
||||||
LaterRun: "resource:///modules/LaterRun.jsm",
|
LaterRun: "resource:///modules/LaterRun.jsm",
|
||||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
|
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
|
||||||
|
SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
|
||||||
ShellService: "resource:///modules/ShellService.jsm",
|
ShellService: "resource:///modules/ShellService.jsm",
|
||||||
UpdatePing: "resource://gre/modules/UpdatePing.jsm"
|
UpdatePing: "resource://gre/modules/UpdatePing.jsm"
|
||||||
});
|
});
|
||||||
@ -510,9 +511,7 @@ nsBrowserContentHandler.prototype = {
|
|||||||
// into account because that requires waiting for the session file
|
// into account because that requires waiting for the session file
|
||||||
// to be read. If a crash occurs after updating, before restarting,
|
// to be read. If a crash occurs after updating, before restarting,
|
||||||
// we may open the startPage in addition to restoring the session.
|
// we may open the startPage in addition to restoring the session.
|
||||||
var ss = Cc["@mozilla.org/browser/sessionstartup;1"]
|
willRestoreSession = SessionStartup.isAutomaticRestoreEnabled();
|
||||||
.getService(Ci.nsISessionStartup);
|
|
||||||
willRestoreSession = ss.isAutomaticRestoreEnabled();
|
|
||||||
|
|
||||||
overridePage = Services.urlFormatter.formatURLPref("startup.homepage_override_url");
|
overridePage = Services.urlFormatter.formatURLPref("startup.homepage_override_url");
|
||||||
if (prefb.prefHasUserValue("app.update.postupdate")) {
|
if (prefb.prefHasUserValue("app.update.postupdate")) {
|
||||||
|
@ -132,6 +132,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||||||
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
|
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
|
||||||
Sanitizer: "resource:///modules/Sanitizer.jsm",
|
Sanitizer: "resource:///modules/Sanitizer.jsm",
|
||||||
SavantShieldStudy: "resource:///modules/SavantShieldStudy.jsm",
|
SavantShieldStudy: "resource:///modules/SavantShieldStudy.jsm",
|
||||||
|
SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
|
||||||
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
|
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
|
||||||
ShellService: "resource:///modules/ShellService.jsm",
|
ShellService: "resource:///modules/ShellService.jsm",
|
||||||
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
|
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
|
||||||
@ -702,6 +703,8 @@ BrowserGlue.prototype = {
|
|||||||
// runs on startup, before the first command line handler is invoked
|
// runs on startup, before the first command line handler is invoked
|
||||||
// (i.e. before the first window is opened)
|
// (i.e. before the first window is opened)
|
||||||
_beforeUIStartup: function BG__beforeUIStartup() {
|
_beforeUIStartup: function BG__beforeUIStartup() {
|
||||||
|
SessionStartup.init();
|
||||||
|
|
||||||
// check if we're in safe mode
|
// check if we're in safe mode
|
||||||
if (Services.appinfo.inSafeMode) {
|
if (Services.appinfo.inSafeMode) {
|
||||||
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
|
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
|
||||||
@ -2160,13 +2163,8 @@ BrowserGlue.prototype = {
|
|||||||
let promptCount =
|
let promptCount =
|
||||||
usePromptLimit ? Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount") : 0;
|
usePromptLimit ? Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount") : 0;
|
||||||
|
|
||||||
let willRecoverSession = false;
|
let willRecoverSession =
|
||||||
try {
|
(SessionStartup.sessionType == SessionStartup.RECOVER_SESSION);
|
||||||
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].
|
|
||||||
getService(Ci.nsISessionStartup);
|
|
||||||
willRecoverSession =
|
|
||||||
(ss.sessionType == Ci.nsISessionStartup.RECOVER_SESSION);
|
|
||||||
} catch (ex) { /* never mind; suppose SessionStore is broken */ }
|
|
||||||
|
|
||||||
// startup check, check all assoc
|
// startup check, check all assoc
|
||||||
let isDefault = false;
|
let isDefault = false;
|
||||||
|
@ -30,16 +30,15 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||||||
ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||||
ChromeUtils.import("resource://gre/modules/AsyncShutdown.jsm");
|
ChromeUtils.import("resource://gre/modules/AsyncShutdown.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "RunState",
|
|
||||||
"resource:///modules/sessionstore/RunState.jsm");
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
|
XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
|
||||||
"@mozilla.org/base/telemetry;1", "nsITelemetry");
|
"@mozilla.org/base/telemetry;1", "nsITelemetry");
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "sessionStartup",
|
|
||||||
"@mozilla.org/browser/sessionstartup;1", "nsISessionStartup");
|
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||||
ChromeUtils.defineModuleGetter(this, "SessionWorker",
|
RunState: "resource:///modules/sessionstore/RunState.jsm",
|
||||||
"resource:///modules/sessionstore/SessionWorker.jsm");
|
SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
|
||||||
ChromeUtils.defineModuleGetter(this, "SessionStore",
|
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
|
||||||
"resource:///modules/sessionstore/SessionStore.jsm");
|
SessionWorker: "resource:///modules/sessionstore/SessionWorker.jsm",
|
||||||
|
});
|
||||||
|
|
||||||
const PREF_UPGRADE_BACKUP = "browser.sessionstore.upgradeBackup.latestBuildID";
|
const PREF_UPGRADE_BACKUP = "browser.sessionstore.upgradeBackup.latestBuildID";
|
||||||
const PREF_MAX_UPGRADE_BACKUPS = "browser.sessionstore.upgradeBackup.maxUpgradeBackups";
|
const PREF_MAX_UPGRADE_BACKUPS = "browser.sessionstore.upgradeBackup.maxUpgradeBackups";
|
||||||
@ -384,7 +383,7 @@ var SessionFileInternal = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let performShutdownCleanup = isFinalWrite &&
|
let performShutdownCleanup = isFinalWrite &&
|
||||||
!sessionStartup.isAutomaticRestoreEnabled();
|
!SessionStartup.isAutomaticRestoreEnabled();
|
||||||
|
|
||||||
this._attempts++;
|
this._attempts++;
|
||||||
let options = {isFinalWrite, performShutdownCleanup};
|
let options = {isFinalWrite, performShutdownCleanup};
|
||||||
|
@ -29,9 +29,10 @@
|
|||||||
* browser.startup.page is set to 3.
|
* browser.startup.page is set to 3.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var EXPORTED_SYMBOLS = ["SessionStartup"];
|
||||||
|
|
||||||
/* :::::::: Constants and Helpers ::::::::::::::: */
|
/* :::::::: Constants and Helpers ::::::::::::::: */
|
||||||
|
|
||||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
||||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "SessionFile",
|
ChromeUtils.defineModuleGetter(this, "SessionFile",
|
||||||
@ -45,13 +46,14 @@ ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils",
|
|||||||
|
|
||||||
const STATE_RUNNING_STR = "running";
|
const STATE_RUNNING_STR = "running";
|
||||||
|
|
||||||
|
const TYPE_NO_SESSION = 0;
|
||||||
|
const TYPE_RECOVER_SESSION = 1;
|
||||||
|
const TYPE_RESUME_SESSION = 2;
|
||||||
|
const TYPE_DEFER_SESSION = 3;
|
||||||
|
|
||||||
// 'browser.startup.page' preference value to resume the previous session.
|
// 'browser.startup.page' preference value to resume the previous session.
|
||||||
const BROWSER_STARTUP_RESUME_SESSION = 3;
|
const BROWSER_STARTUP_RESUME_SESSION = 3;
|
||||||
|
|
||||||
function debug(aMsg) {
|
|
||||||
aMsg = ("SessionStartup: " + aMsg).replace(/\S{80}/g, "$&\n");
|
|
||||||
Services.console.logStringMessage(aMsg);
|
|
||||||
}
|
|
||||||
function warning(aMsg, aException) {
|
function warning(aMsg, aException) {
|
||||||
let consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
|
let consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
|
||||||
consoleMsg.init(aMsg, aException.fileName, null, aException.lineNumber, 0, Ci.nsIScriptError.warningFlag, "component javascript");
|
consoleMsg.init(aMsg, aException.fileName, null, aException.lineNumber, 0, Ci.nsIScriptError.warningFlag, "component javascript");
|
||||||
@ -71,14 +73,15 @@ var gOnceInitializedDeferred = (function() {
|
|||||||
|
|
||||||
/* :::::::: The Service ::::::::::::::: */
|
/* :::::::: The Service ::::::::::::::: */
|
||||||
|
|
||||||
function SessionStartup() {
|
var SessionStartup = {
|
||||||
}
|
NO_SESSION: TYPE_NO_SESSION,
|
||||||
|
RECOVER_SESSION: TYPE_RECOVER_SESSION,
|
||||||
SessionStartup.prototype = {
|
RESUME_SESSION: TYPE_RESUME_SESSION,
|
||||||
|
DEFER_SESSION: TYPE_DEFER_SESSION,
|
||||||
|
|
||||||
// the state to restore at startup
|
// the state to restore at startup
|
||||||
_initialState: null,
|
_initialState: null,
|
||||||
_sessionType: Ci.nsISessionStartup.NO_SESSION,
|
_sessionType: TYPE_NO_SESSION,
|
||||||
_initialized: false,
|
_initialized: false,
|
||||||
|
|
||||||
// Stores whether the previous session crashed.
|
// Stores whether the previous session crashed.
|
||||||
@ -161,7 +164,7 @@ SessionStartup.prototype = {
|
|||||||
|
|
||||||
if (this._initialState == null) {
|
if (this._initialState == null) {
|
||||||
// No valid session found.
|
// No valid session found.
|
||||||
this._sessionType = Ci.nsISessionStartup.NO_SESSION;
|
this._sessionType = this.NO_SESSION;
|
||||||
Services.obs.notifyObservers(null, "sessionstore-state-finalized");
|
Services.obs.notifyObservers(null, "sessionstore-state-finalized");
|
||||||
gOnceInitializedDeferred.resolve();
|
gOnceInitializedDeferred.resolve();
|
||||||
return;
|
return;
|
||||||
@ -222,21 +225,21 @@ SessionStartup.prototype = {
|
|||||||
|
|
||||||
// set the startup type
|
// set the startup type
|
||||||
if (this._previousSessionCrashed && resumeFromCrash)
|
if (this._previousSessionCrashed && resumeFromCrash)
|
||||||
this._sessionType = Ci.nsISessionStartup.RECOVER_SESSION;
|
this._sessionType = this.RECOVER_SESSION;
|
||||||
else if (!this._previousSessionCrashed && this._resumeSessionEnabled)
|
else if (!this._previousSessionCrashed && this._resumeSessionEnabled)
|
||||||
this._sessionType = Ci.nsISessionStartup.RESUME_SESSION;
|
this._sessionType = this.RESUME_SESSION;
|
||||||
else if (this._initialState)
|
else if (this._initialState)
|
||||||
this._sessionType = Ci.nsISessionStartup.DEFER_SESSION;
|
this._sessionType = this.DEFER_SESSION;
|
||||||
else
|
else
|
||||||
this._initialState = null; // reset the state
|
this._initialState = null; // reset the state
|
||||||
|
|
||||||
Services.obs.addObserver(this, "sessionstore-windows-restored", true);
|
Services.obs.addObserver(this, "sessionstore-windows-restored", true);
|
||||||
|
|
||||||
if (this._sessionType != Ci.nsISessionStartup.NO_SESSION)
|
if (this._sessionType != this.NO_SESSION)
|
||||||
Services.obs.addObserver(this, "browser:purge-session-history", true);
|
Services.obs.addObserver(this, "browser:purge-session-history", true);
|
||||||
|
|
||||||
// We're ready. Notify everyone else.
|
// We're ready. Notify everyone else.
|
||||||
Services.obs.notifyObservers(null, "sessionstore-state-finalized");
|
Services.obs.notifyObservers(null, "sessionstore-state-finalized");
|
||||||
|
|
||||||
gOnceInitializedDeferred.resolve();
|
gOnceInitializedDeferred.resolve();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -246,22 +249,6 @@ SessionStartup.prototype = {
|
|||||||
*/
|
*/
|
||||||
observe: function sss_observe(aSubject, aTopic, aData) {
|
observe: function sss_observe(aSubject, aTopic, aData) {
|
||||||
switch (aTopic) {
|
switch (aTopic) {
|
||||||
case "app-startup":
|
|
||||||
Services.obs.addObserver(this, "final-ui-startup", true);
|
|
||||||
Services.obs.addObserver(this, "quit-application", true);
|
|
||||||
break;
|
|
||||||
case "final-ui-startup":
|
|
||||||
Services.obs.removeObserver(this, "final-ui-startup");
|
|
||||||
Services.obs.removeObserver(this, "quit-application");
|
|
||||||
this.init();
|
|
||||||
break;
|
|
||||||
case "quit-application":
|
|
||||||
// no reason for initializing at this point (cf. bug 409115)
|
|
||||||
Services.obs.removeObserver(this, "final-ui-startup");
|
|
||||||
Services.obs.removeObserver(this, "quit-application");
|
|
||||||
if (this._sessionType != Ci.nsISessionStartup.NO_SESSION)
|
|
||||||
Services.obs.removeObserver(this, "browser:purge-session-history");
|
|
||||||
break;
|
|
||||||
case "sessionstore-windows-restored":
|
case "sessionstore-windows-restored":
|
||||||
Services.obs.removeObserver(this, "sessionstore-windows-restored");
|
Services.obs.removeObserver(this, "sessionstore-windows-restored");
|
||||||
// free _initialState after nsSessionStore is done with it
|
// free _initialState after nsSessionStore is done with it
|
||||||
@ -271,7 +258,7 @@ SessionStartup.prototype = {
|
|||||||
case "browser:purge-session-history":
|
case "browser:purge-session-history":
|
||||||
Services.obs.removeObserver(this, "browser:purge-session-history");
|
Services.obs.removeObserver(this, "browser:purge-session-history");
|
||||||
// reset all state on sanitization
|
// reset all state on sanitization
|
||||||
this._sessionType = Ci.nsISessionStartup.NO_SESSION;
|
this._sessionType = this.NO_SESSION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -319,8 +306,8 @@ SessionStartup.prototype = {
|
|||||||
* @returns bool
|
* @returns bool
|
||||||
*/
|
*/
|
||||||
_willRestore() {
|
_willRestore() {
|
||||||
return this._sessionType == Ci.nsISessionStartup.RECOVER_SESSION ||
|
return this._sessionType == this.RECOVER_SESSION ||
|
||||||
this._sessionType == Ci.nsISessionStartup.RESUME_SESSION;
|
this._sessionType == this.RESUME_SESSION;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -371,11 +358,7 @@ SessionStartup.prototype = {
|
|||||||
return this._previousSessionCrashed;
|
return this._previousSessionCrashed;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ........ QueryInterface .............. */
|
|
||||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
|
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
|
||||||
Ci.nsISupportsWeakReference,
|
Ci.nsISupportsWeakReference]),
|
||||||
Ci.nsISessionStartup]),
|
|
||||||
classID: Components.ID("{ec7a6c20-e081-11da-8ad9-0800200c9a66}")
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SessionStartup]);
|
|
@ -163,7 +163,6 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
|||||||
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
|
ChromeUtils.import("resource://gre/modules/osfile.jsm", this);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetters(this, {
|
XPCOMUtils.defineLazyServiceGetters(this, {
|
||||||
gSessionStartup: ["@mozilla.org/browser/sessionstartup;1", "nsISessionStartup"],
|
|
||||||
gScreenManager: ["@mozilla.org/gfx/screenmanager;1", "nsIScreenManager"],
|
gScreenManager: ["@mozilla.org/gfx/screenmanager;1", "nsIScreenManager"],
|
||||||
Telemetry: ["@mozilla.org/base/telemetry;1", "nsITelemetry"],
|
Telemetry: ["@mozilla.org/base/telemetry;1", "nsITelemetry"],
|
||||||
});
|
});
|
||||||
@ -181,6 +180,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||||||
SessionCookies: "resource:///modules/sessionstore/SessionCookies.jsm",
|
SessionCookies: "resource:///modules/sessionstore/SessionCookies.jsm",
|
||||||
SessionFile: "resource:///modules/sessionstore/SessionFile.jsm",
|
SessionFile: "resource:///modules/sessionstore/SessionFile.jsm",
|
||||||
SessionSaver: "resource:///modules/sessionstore/SessionSaver.jsm",
|
SessionSaver: "resource:///modules/sessionstore/SessionSaver.jsm",
|
||||||
|
SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm",
|
||||||
TabAttributes: "resource:///modules/sessionstore/TabAttributes.jsm",
|
TabAttributes: "resource:///modules/sessionstore/TabAttributes.jsm",
|
||||||
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
|
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
|
||||||
TabState: "resource:///modules/sessionstore/TabState.jsm",
|
TabState: "resource:///modules/sessionstore/TabState.jsm",
|
||||||
@ -639,10 +639,10 @@ var SessionStoreInternal = {
|
|||||||
initSession() {
|
initSession() {
|
||||||
TelemetryStopwatch.start("FX_SESSION_RESTORE_STARTUP_INIT_SESSION_MS");
|
TelemetryStopwatch.start("FX_SESSION_RESTORE_STARTUP_INIT_SESSION_MS");
|
||||||
let state;
|
let state;
|
||||||
let ss = gSessionStartup;
|
let ss = SessionStartup;
|
||||||
|
|
||||||
if (ss.doRestore() ||
|
if (ss.doRestore() ||
|
||||||
ss.sessionType == Ci.nsISessionStartup.DEFER_SESSION) {
|
ss.sessionType == ss.DEFER_SESSION) {
|
||||||
state = ss.state;
|
state = ss.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,7 +650,7 @@ var SessionStoreInternal = {
|
|||||||
try {
|
try {
|
||||||
// If we're doing a DEFERRED session, then we want to pull pinned tabs
|
// If we're doing a DEFERRED session, then we want to pull pinned tabs
|
||||||
// out so they can be restored.
|
// out so they can be restored.
|
||||||
if (ss.sessionType == Ci.nsISessionStartup.DEFER_SESSION) {
|
if (ss.sessionType == ss.DEFER_SESSION) {
|
||||||
let [iniState, remainingState] = this._prepDataForDeferredRestore(state);
|
let [iniState, remainingState] = this._prepDataForDeferredRestore(state);
|
||||||
// If we have a iniState with windows, that means that we have windows
|
// If we have a iniState with windows, that means that we have windows
|
||||||
// with app tabs to restore.
|
// with app tabs to restore.
|
||||||
@ -1159,7 +1159,7 @@ var SessionStoreInternal = {
|
|||||||
// We're starting with a single private window. Save the state we
|
// We're starting with a single private window. Save the state we
|
||||||
// actually wanted to restore so that we can do it later in case
|
// actually wanted to restore so that we can do it later in case
|
||||||
// the user opens another, non-private window.
|
// the user opens another, non-private window.
|
||||||
this._deferredInitialState = gSessionStartup.state;
|
this._deferredInitialState = SessionStartup.state;
|
||||||
|
|
||||||
// Nothing to restore now, notify observers things are complete.
|
// Nothing to restore now, notify observers things are complete.
|
||||||
Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED);
|
Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED);
|
||||||
@ -1310,7 +1310,7 @@ var SessionStoreInternal = {
|
|||||||
// We are ready for initialization as soon as the session file has been
|
// We are ready for initialization as soon as the session file has been
|
||||||
// read from disk and the initial window's delayed startup has finished.
|
// read from disk and the initial window's delayed startup has finished.
|
||||||
this._promiseReadyForInitialization =
|
this._promiseReadyForInitialization =
|
||||||
Promise.all([promise, gSessionStartup.onceInitialized]);
|
Promise.all([promise, SessionStartup.onceInitialized]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't call this.onLoad since initialization
|
// We can't call this.onLoad since initialization
|
||||||
@ -4585,7 +4585,7 @@ var SessionStoreInternal = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is going to take a state as provided at startup (via
|
* This is going to take a state as provided at startup (via
|
||||||
* nsISessionStartup.state) and split it into 2 parts. The first part
|
* SessionStartup.state) and split it into 2 parts. The first part
|
||||||
* (defaultState) will be a state that should still be restored at startup,
|
* (defaultState) will be a state that should still be restored at startup,
|
||||||
* while the second part (state) is a state that should be saved for later.
|
* while the second part (state) is a state that should be saved for later.
|
||||||
* defaultState will be comprised of windows with only pinned tabs, extracted
|
* defaultState will be comprised of windows with only pinned tabs, extracted
|
||||||
@ -4596,12 +4596,12 @@ var SessionStoreInternal = {
|
|||||||
* to restore the previous session (publicly exposed as restoreLastSession).
|
* to restore the previous session (publicly exposed as restoreLastSession).
|
||||||
*
|
*
|
||||||
* @param state
|
* @param state
|
||||||
* The state, presumably from nsISessionStartup.state
|
* The state, presumably from SessionStartup.state
|
||||||
* @returns [defaultState, state]
|
* @returns [defaultState, state]
|
||||||
*/
|
*/
|
||||||
_prepDataForDeferredRestore: function ssi_prepDataForDeferredRestore(state) {
|
_prepDataForDeferredRestore: function ssi_prepDataForDeferredRestore(state) {
|
||||||
// Make sure that we don't modify the global state as provided by
|
// Make sure that we don't modify the global state as provided by
|
||||||
// nsSessionStartup.state.
|
// SessionStartup.state.
|
||||||
state = Cu.cloneInto(state, {});
|
state = Cu.cloneInto(state, {});
|
||||||
|
|
||||||
let defaultState = { windows: [], selectedWindow: 1 };
|
let defaultState = { windows: [], selectedWindow: 1 };
|
||||||
|
@ -9,17 +9,6 @@ BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
|
|||||||
|
|
||||||
JAR_MANIFESTS += ['jar.mn']
|
JAR_MANIFESTS += ['jar.mn']
|
||||||
|
|
||||||
XPIDL_SOURCES += [
|
|
||||||
'nsISessionStartup.idl',
|
|
||||||
]
|
|
||||||
|
|
||||||
XPIDL_MODULE = 'sessionstore'
|
|
||||||
|
|
||||||
EXTRA_COMPONENTS += [
|
|
||||||
'nsSessionStartup.js',
|
|
||||||
'nsSessionStartup.manifest',
|
|
||||||
]
|
|
||||||
|
|
||||||
EXTRA_JS_MODULES.sessionstore = [
|
EXTRA_JS_MODULES.sessionstore = [
|
||||||
'ContentRestore.jsm',
|
'ContentRestore.jsm',
|
||||||
'ContentSessionStore.jsm',
|
'ContentSessionStore.jsm',
|
||||||
@ -31,6 +20,7 @@ EXTRA_JS_MODULES.sessionstore = [
|
|||||||
'SessionFile.jsm',
|
'SessionFile.jsm',
|
||||||
'SessionMigration.jsm',
|
'SessionMigration.jsm',
|
||||||
'SessionSaver.jsm',
|
'SessionSaver.jsm',
|
||||||
|
'SessionStartup.jsm',
|
||||||
'SessionStorage.jsm',
|
'SessionStorage.jsm',
|
||||||
'SessionStore.jsm',
|
'SessionStore.jsm',
|
||||||
'SessionWorker.js',
|
'SessionWorker.js',
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* nsISessionStore keeps track of the current browsing state - i.e.
|
|
||||||
* tab history, cookies, scroll state, form data, and window features
|
|
||||||
* - and allows to restore everything into one window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
[scriptable, uuid(934697e4-3807-47f8-b6c9-6caa8d83ccd1)]
|
|
||||||
interface nsISessionStartup: nsISupports
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Return a promise that is resolved once initialization
|
|
||||||
* is complete.
|
|
||||||
*/
|
|
||||||
readonly attribute jsval onceInitialized;
|
|
||||||
|
|
||||||
// Get session state
|
|
||||||
readonly attribute jsval state;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether there is a pending session restore. Should only be
|
|
||||||
* called after initialization has completed.
|
|
||||||
*/
|
|
||||||
boolean doRestore();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether automatic session restoration is enabled for this
|
|
||||||
* launch of the browser. This does not include crash restoration, and will
|
|
||||||
* return false if restoration will only be caused by a crash.
|
|
||||||
*/
|
|
||||||
boolean isAutomaticRestoreEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a boolean or a promise that resolves to a boolean, indicating
|
|
||||||
* whether we will restore a session that ends up replacing the homepage.
|
|
||||||
* True guarantees that we'll restore a session; false means that we
|
|
||||||
* /probably/ won't do so.
|
|
||||||
* The browser uses this to avoid unnecessarily loading the homepage when
|
|
||||||
* restoring a session.
|
|
||||||
*/
|
|
||||||
readonly attribute jsval willOverrideHomepage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* What type of session we're restoring.
|
|
||||||
* NO_SESSION There is no data available from the previous session
|
|
||||||
* RECOVER_SESSION The last session crashed. It will either be restored or
|
|
||||||
* about:sessionrestore will be shown.
|
|
||||||
* RESUME_SESSION The previous session should be restored at startup
|
|
||||||
* DEFER_SESSION The previous session is fine, but it shouldn't be restored
|
|
||||||
* without explicit action (with the exception of pinned tabs)
|
|
||||||
*/
|
|
||||||
const unsigned long NO_SESSION = 0;
|
|
||||||
const unsigned long RECOVER_SESSION = 1;
|
|
||||||
const unsigned long RESUME_SESSION = 2;
|
|
||||||
const unsigned long DEFER_SESSION = 3;
|
|
||||||
|
|
||||||
readonly attribute unsigned long sessionType;
|
|
||||||
readonly attribute bool previousSessionCrashed;
|
|
||||||
};
|
|
@ -1,10 +0,0 @@
|
|||||||
# This component must restrict its registration for the app-startup category
|
|
||||||
# to the specific list of apps that use it so it doesn't get loaded in xpcshell.
|
|
||||||
# Thus we restrict it to these apps:
|
|
||||||
#
|
|
||||||
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
|
||||||
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
|
|
||||||
|
|
||||||
component {ec7a6c20-e081-11da-8ad9-0800200c9a66} nsSessionStartup.js
|
|
||||||
contract @mozilla.org/browser/sessionstartup;1 {ec7a6c20-e081-11da-8ad9-0800200c9a66}
|
|
||||||
category app-startup nsSessionStartup service,@mozilla.org/browser/sessionstartup;1 application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
|
|
@ -1,5 +1,7 @@
|
|||||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm", {});
|
const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm", {});
|
||||||
|
ChromeUtils.defineModuleGetter(this, "SessionStartup",
|
||||||
|
"resource:///modules/sessionstore/SessionStartup.jsm");
|
||||||
|
|
||||||
// Call a function once initialization of SessionStartup is complete
|
// Call a function once initialization of SessionStartup is complete
|
||||||
function afterSessionStartupInitialization(cb) {
|
function afterSessionStartupInitialization(cb) {
|
||||||
@ -13,6 +15,7 @@ function afterSessionStartupInitialization(cb) {
|
|||||||
do_throw(ex);
|
do_throw(ex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Services.obs.addObserver(observer, "sessionstore-state-finalized");
|
||||||
|
|
||||||
// We need the Crash Monitor initialized for sessionstartup to run
|
// We need the Crash Monitor initialized for sessionstartup to run
|
||||||
// successfully.
|
// successfully.
|
||||||
@ -20,12 +23,7 @@ function afterSessionStartupInitialization(cb) {
|
|||||||
CrashMonitor.init();
|
CrashMonitor.init();
|
||||||
|
|
||||||
// Start sessionstartup initialization.
|
// Start sessionstartup initialization.
|
||||||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
|
SessionStartup.init();
|
||||||
getService(Ci.nsIObserver);
|
|
||||||
Services.obs.addObserver(startup, "final-ui-startup");
|
|
||||||
Services.obs.addObserver(startup, "quit-application");
|
|
||||||
Services.obs.notifyObservers(null, "final-ui-startup");
|
|
||||||
Services.obs.addObserver(observer, "sessionstore-state-finalized");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compress the source file using lz4 and put the result to destination file.
|
// Compress the source file using lz4 and put the result to destination file.
|
||||||
|
@ -15,11 +15,8 @@ function run_test() {
|
|||||||
// and remove sessionstore.js
|
// and remove sessionstore.js
|
||||||
let oldExtSessionFile = SessionFile.Paths.clean.replace("jsonlz4", "js");
|
let oldExtSessionFile = SessionFile.Paths.clean.replace("jsonlz4", "js");
|
||||||
writeCompressedFile(oldExtSessionFile, SessionFile.Paths.clean).then(() => {
|
writeCompressedFile(oldExtSessionFile, SessionFile.Paths.clean).then(() => {
|
||||||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
|
|
||||||
getService(Ci.nsISessionStartup);
|
|
||||||
|
|
||||||
afterSessionStartupInitialization(function cb() {
|
afterSessionStartupInitialization(function cb() {
|
||||||
Assert.equal(startup.sessionType, Ci.nsISessionStartup.NO_SESSION);
|
Assert.equal(SessionStartup.sessionType, SessionStartup.NO_SESSION);
|
||||||
do_test_finished();
|
do_test_finished();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,21 +2,19 @@
|
|||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
|
||||||
// Test nsISessionStartup.sessionType in the following scenario:
|
// Test SessionStartup.sessionType in the following scenario:
|
||||||
// - no sessionstore.js;
|
// - no sessionstore.js;
|
||||||
// - the session store has been loaded, so no need to go
|
// - the session store has been loaded, so no need to go
|
||||||
// through the synchronous fallback
|
// through the synchronous fallback
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
do_get_profile();
|
|
||||||
// Initialize the profile (the session startup uses it)
|
// Initialize the profile (the session startup uses it)
|
||||||
|
do_get_profile();
|
||||||
|
|
||||||
do_test_pending();
|
do_test_pending();
|
||||||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
|
|
||||||
getService(Ci.nsISessionStartup);
|
|
||||||
|
|
||||||
afterSessionStartupInitialization(function cb() {
|
afterSessionStartupInitialization(function cb() {
|
||||||
Assert.equal(startup.sessionType, Ci.nsISessionStartup.NO_SESSION);
|
Assert.equal(SessionStartup.sessionType, SessionStartup.NO_SESSION);
|
||||||
do_test_finished();
|
do_test_finished();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
|
||||||
// Test nsISessionStartup.sessionType in the following scenario:
|
// Test SessionStartup.sessionType in the following scenario:
|
||||||
// - valid sessionstore.js;
|
// - valid sessionstore.js;
|
||||||
// - valid sessionCheckpoints.json with all checkpoints;
|
// - valid sessionCheckpoints.json with all checkpoints;
|
||||||
// - the session store has been loaded
|
// - the session store has been loaded
|
||||||
@ -21,11 +21,8 @@ function run_test() {
|
|||||||
// and remove sessionstore.js
|
// and remove sessionstore.js
|
||||||
let oldExtSessionFile = SessionFile.Paths.clean.replace("jsonlz4", "js");
|
let oldExtSessionFile = SessionFile.Paths.clean.replace("jsonlz4", "js");
|
||||||
writeCompressedFile(oldExtSessionFile, SessionFile.Paths.clean).then(() => {
|
writeCompressedFile(oldExtSessionFile, SessionFile.Paths.clean).then(() => {
|
||||||
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
|
|
||||||
getService(Ci.nsISessionStartup);
|
|
||||||
|
|
||||||
afterSessionStartupInitialization(function cb() {
|
afterSessionStartupInitialization(function cb() {
|
||||||
Assert.equal(startup.sessionType, Ci.nsISessionStartup.DEFER_SESSION);
|
Assert.equal(SessionStartup.sessionType, SessionStartup.DEFER_SESSION);
|
||||||
do_test_finished();
|
do_test_finished();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -242,8 +242,6 @@
|
|||||||
@RESPATH@/components/ProcessSingleton.manifest
|
@RESPATH@/components/ProcessSingleton.manifest
|
||||||
@RESPATH@/components/MainProcessSingleton.js
|
@RESPATH@/components/MainProcessSingleton.js
|
||||||
@RESPATH@/components/ContentProcessSingleton.js
|
@RESPATH@/components/ContentProcessSingleton.js
|
||||||
@RESPATH@/browser/components/nsSessionStartup.manifest
|
|
||||||
@RESPATH@/browser/components/nsSessionStartup.js
|
|
||||||
@RESPATH@/components/nsURLFormatter.manifest
|
@RESPATH@/components/nsURLFormatter.manifest
|
||||||
@RESPATH@/components/nsURLFormatter.js
|
@RESPATH@/components/nsURLFormatter.js
|
||||||
@RESPATH@/components/txEXSLTRegExFunctions.manifest
|
@RESPATH@/components/txEXSLTRegExFunctions.manifest
|
||||||
|
@ -289,7 +289,7 @@ class TestUrlFinder(unittest.TestCase):
|
|||||||
'path1',
|
'path1',
|
||||||
None
|
None
|
||||||
],
|
],
|
||||||
'dist/bin/browser/components/nsSessionStartup.js': [
|
'dist/bin/browser/components/nsBrowserGlue.js': [
|
||||||
'path2',
|
'path2',
|
||||||
None
|
None
|
||||||
],
|
],
|
||||||
@ -334,7 +334,7 @@ class TestUrlFinder(unittest.TestCase):
|
|||||||
|
|
||||||
paths = [
|
paths = [
|
||||||
('jar:file:///home/worker/workspace/build/application/' + app_name + '/' + omnijar_name + '!/components/MainProcessSingleton.js', 'path1'),
|
('jar:file:///home/worker/workspace/build/application/' + app_name + '/' + omnijar_name + '!/components/MainProcessSingleton.js', 'path1'),
|
||||||
('jar:file:///home/worker/workspace/build/application/' + app_name + '/browser/' + omnijar_name + '!/components/nsSessionStartup.js', 'path2'),
|
('jar:file:///home/worker/workspace/build/application/' + app_name + '/browser/' + omnijar_name + '!/components/nsBrowserGlue.js', 'path2'),
|
||||||
('jar:file:///home/worker/workspace/build/application/' + app_name + '/browser/features/firefox@getpocket.com.xpi!/bootstrap.js', 'path4'),
|
('jar:file:///home/worker/workspace/build/application/' + app_name + '/browser/features/firefox@getpocket.com.xpi!/bootstrap.js', 'path4'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "Services",
|
ChromeUtils.defineModuleGetter(this, "Services",
|
||||||
"resource://gre/modules/Services.jsm");
|
"resource://gre/modules/Services.jsm");
|
||||||
ChromeUtils.defineModuleGetter(this, "setTimeout",
|
ChromeUtils.defineModuleGetter(this, "setTimeout",
|
||||||
"resource://gre/modules/Timer.jsm");
|
"resource://gre/modules/Timer.jsm");
|
||||||
|
ChromeUtils.defineModuleGetter(this, "SessionStartup",
|
||||||
|
"resource:///modules/sessionstore/SessionStartup.jsm");
|
||||||
ChromeUtils.defineModuleGetter(this, "StartupPerformance",
|
ChromeUtils.defineModuleGetter(this, "StartupPerformance",
|
||||||
"resource:///modules/sessionstore/StartupPerformance.jsm");
|
"resource:///modules/sessionstore/StartupPerformance.jsm");
|
||||||
|
|
||||||
@ -49,11 +49,9 @@ const sessionRestoreTest = {
|
|||||||
if (StartupPerformance.isRestored) {
|
if (StartupPerformance.isRestored) {
|
||||||
this.onReady(true);
|
this.onReady(true);
|
||||||
} else {
|
} else {
|
||||||
let sessionStartup = Cc["@mozilla.org/browser/sessionstartup;1"]
|
SessionStartup.onceInitialized.then(() => {
|
||||||
.getService(Ci.nsISessionStartup);
|
if (SessionStartup.sessionType == SessionStartup.NO_SESSION ||
|
||||||
sessionStartup.onceInitialized.then(() => {
|
SessionStartup.sessionType == SessionStartup.DEFER_SESSION) {
|
||||||
if (sessionStartup.sessionType == Ci.nsISessionStartup.NO_SESSION
|
|
||||||
|| sessionStartup.sessionType == Ci.nsISessionStartup.DEFER_SESSION) {
|
|
||||||
this.onReady(false);
|
this.onReady(false);
|
||||||
} else {
|
} else {
|
||||||
Services.obs.addObserver(this, StartupPerformance.RESTORED_TOPIC);
|
Services.obs.addObserver(this, StartupPerformance.RESTORED_TOPIC);
|
||||||
|
Loading…
Reference in New Issue
Block a user