Bug 715673 - Hande browser-lastwindow-close events. r=mfinkle

This commit is contained in:
Brian Nicholson 2012-01-09 11:56:30 -08:00
parent 01ee52648b
commit 9ed4be4301

View File

@ -489,8 +489,27 @@ var BrowserApp = {
},
quit: function quit() {
window.QueryInterface(Ci.nsIDOMChromeWindow).minimize();
window.close();
// 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 != window)
lastBrowser = false;
}
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);
}
window.QueryInterface(Ci.nsIDOMChromeWindow).minimize();
window.close();
},
saveAsPDF: function saveAsPDF(aBrowser) {