Bug 502307 - Closing multiple tabs in the last browser window with Private Browsing enabled yields no warning regardless of preference setting (further fix); r=enndeakin,dao ui-r=faaborg

This commit is contained in:
Ehsan Akhgari 2009-08-19 11:16:08 +04:30
parent a8a1885d3d
commit 2923130b61
2 changed files with 18 additions and 11 deletions

View File

@ -5719,13 +5719,17 @@ function warnAboutClosingWindow() {
os.notifyObservers(null, "browser-lastwindow-close-granted", null);
#ifdef XP_MACOSX
// OS X doesn't quit the application when the last window is closed, but keeps
// the session alive. Hence don't prompt users to save tabs, but warn about
// closing multiple tabs.
return gBrowser.warnAboutClosingTabs(true);
// On OS X, always warn about closing multiple tabs, as closing the
// last window won't quit the application.
#else
return true;
// If we're inside auto-started private browsing mode, always warn
// about closing multiple tabs (bug 502307).
if (gPrivateBrowsingUI.privateBrowsingEnabled &&
gPrivateBrowsingUI.autoStarted)
#endif
return gBrowser.warnAboutClosingTabs(true);
return true;
}
var MailIntegration = {
@ -7038,6 +7042,10 @@ let gPrivateBrowsingUI = {
get privateBrowsingEnabled PBUI_get_privateBrowsingEnabled() {
return this._privateBrowsingService.privateBrowsingEnabled;
},
get autoStarted PBUI_get_autoStarted() {
return this._privateBrowsingService.autoStarted;
}
};

View File

@ -13,19 +13,18 @@ function closeWindow(aClose, aPromptFunction)
break;
}
var inPrivateBrowsing = false;
try {
var showPromptOverride = false;
if ("@mozilla.org/privatebrowsing;1" in Components.classes) {
var pbSvc = Components.classes["@mozilla.org/privatebrowsing;1"]
.getService(Components.interfaces.nsIPrivateBrowsingService);
inPrivateBrowsing = pbSvc.privateBrowsingEnabled;
} catch(e) {
// safe to ignore
showPromptOverride = pbSvc.privateBrowsingEnabled &&
pbSvc.autoStarted;
}
// If we're down to the last window and someone tries to shut down, check to make sure we can!
if (windowCount == 1 && !canQuitApplication())
return false;
else if (windowCount != 1 || inPrivateBrowsing)
else if (windowCount != 1 || showPromptOverride)
#endif
if (typeof(aPromptFunction) == "function" && !aPromptFunction())
return false;