Bug 1333567 - Send the notification expected by the session store when restarting, too. r?sebastian
Since
bug 1228593, the mobile session store
- once again flushes its data when we are quitting, to make sure the latest state (including any potential cleaning of history/tabs) is flushed to disk
- ignores windows/tabs closing as a byproduct of shutdown
The latter point is dependent on a new shutdown notification introduced in that bug. Because we forgot to add that notification to the restart code used for add-on updates, in that case the session store currently doesn't enter shutdown mode and therefore records the window being closed during shutdown before flushing its data to disk, which means that all open tabs are lost.
MozReview-Commit-ID: LgtdQoYwacM
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1378,17 +1378,17 @@ var BrowserApp = {
let evt = document.createEvent("UIEvents");
evt.initUIEvent("TabSelect", true, false, window, null);
aTab.browser.dispatchEvent(evt);
},
quit: function quit(aClear = { sanitize: {}, dontSaveSession: false }) {
// Notify all windows that an application quit has been requested.
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
+ Services.obs.notifyObservers(cancelQuit, "quit-application-requested", null);
// Quit aborted.
if (cancelQuit.data) {
return;
}
Services.obs.notifyObservers(null, "quit-application-proceeding", null);
@@ -5476,16 +5476,17 @@ var XPInstallObserver = {
label: Strings.browser.GetStringFromName("notificationRestart.button"),
callback: function() {
// Notify all windows that an application quit has been requested
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
// If nothing aborted, quit the app
if (cancelQuit.data == false) {
+ Services.obs.notifyObservers(null, "quit-application-proceeding", null);
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
}
},
positive: true
}];
let message = Strings.browser.GetStringFromName("notificationRestart.normal");
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -998,20 +998,22 @@ SessionStore.prototype = {
} else {
log("_saveState() writing empty normal data");
}
this._writeFile(this._sessionFile, this._sessionFileTemp, normalData, aAsync);
// If we have private data, send it to Java; otherwise, send null to
// indicate that there is no private data
let window = Services.wm.getMostRecentWindow("navigator:browser");
- window.WindowEventDispatcher.sendRequest({
- type: "PrivateBrowsing:Data",
- session: (privateData.windows.length > 0 && privateData.windows[0].tabs.length > 0) ? JSON.stringify(privateData) : null
- });
+ if (window) { // can be null if we're restarting
+ window.WindowEventDispatcher.sendRequest({
+ type: "PrivateBrowsing:Data",
+ session: (privateData.windows.length > 0 && privateData.windows[0].tabs.length > 0) ? JSON.stringify(privateData) : null
+ });
+ }
this._lastSaveTime = Date.now();
},
_getCurrentState: function ss_getCurrentState() {
this._forEachBrowserWindow((aWindow) => {
this._collectWindowData(aWindow);
});