Bug 1197974 - Force Gecko to exit when explicitly quitting; r=mfinkle

Currently we "quit" by closing the last window, but this bug makes us
not quit Gecko automatically when the last window closes. Therefore we
should force Gecko to quit. This patch also makes our quit code
consistent with the addon restart code at [1], i.e. using
nsIAppShell::Quit to quit and sending the "quit-application-requested"
notification. The previous notification,
"browser-lastwindow-close-requested", appears to only be used on
desktop.

[1] mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js?rev=f61c3cc0eb8b#6287
This commit is contained in:
Jim Chen 2015-09-18 09:17:11 -04:00
parent 797447c09d
commit a12a517734

View File

@ -1339,23 +1339,13 @@ var BrowserApp = {
this.gmpInstallManager.uninit();
}
// Figure out if there's at least one other browser window around.
let lastBrowser = true;
let e = Services.wm.getEnumerator("navigator:browser");
while (e.hasMoreElements() && lastBrowser) {
let win = e.getNext();
if (!win.closed && win != window)
lastBrowser = 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");
if (lastBrowser) {
// Let everyone know we are closing the last browser window
let closingCanceled = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(closingCanceled, "browser-lastwindow-close-requested", null);
if (closingCanceled.data)
return;
Services.obs.notifyObservers(null, "browser-lastwindow-close-granted", null);
// Quit aborted.
if (cancelQuit.data) {
return;
}
// Tell session store to forget about this window
@ -1365,8 +1355,8 @@ var BrowserApp = {
}
BrowserApp.sanitize(aClear.sanitize, function() {
window.QueryInterface(Ci.nsIDOMChromeWindow).minimize();
window.close();
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eForceQuit);
});
},