Bug 722994 - globalOverlay.js uses global Private Browsing state to control display of a prompt; r=ehsan
authorSaurabh Anand <saurabhanandiit@gmail.com>
Wed, 27 Jun 2012 15:14:45 +0530
changeset 97838 bf8f2961d0cc0e48a6d21f67892a9f4743ddc9be
parent 97837 614d3cf8947be7362ab821a2d4e7b19815301c2a
child 97840 9bf5e71c5746664ed69ebea94a6085db968c7ce8
child 97841 4918f2685b05d574f84b90ef973e97dad7ce1542
push id22999
push useremorley@mozilla.com
push dateThu, 28 Jun 2012 08:03:15 +0000
treeherdermozilla-central@bf8f2961d0cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs722994
milestone16.0a1
first release with
nightly linux32
bf8f2961d0cc / 16.0a1 / 20120628010552 / files
nightly linux64
bf8f2961d0cc / 16.0a1 / 20120628010552 / files
nightly mac
bf8f2961d0cc / 16.0a1 / 20120628010552 / files
nightly win32
bf8f2961d0cc / 16.0a1 / 20120628010552 / files
nightly win64
bf8f2961d0cc / 16.0a1 / 20120628010552 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 722994 - globalOverlay.js uses global Private Browsing state to control display of a prompt; r=ehsan
browser/components/nsBrowserGlue.js
toolkit/content/globalOverlay.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -487,23 +487,16 @@ BrowserGlue.prototype = {
 
     this._saveSession = false;
     if (pagecount < 2)
       return;
 
     if (!aQuitType)
       aQuitType = "quit";
 
-    // Never show a prompt inside private browsing mode
-    var inPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
-                            getService(Ci.nsIPrivateBrowsingService).
-                            privateBrowsingEnabled;
-    if (inPrivateBrowsing)
-      return;
-
     var showPrompt = false;
     var mostRecentBrowserWindow;
 
     // browser.warnOnQuit is a hidden global boolean to override all quit prompts
     // browser.showQuitWarning specifically covers quitting
     // browser.warnOnRestart specifically covers app-initiated restarts where we restart the app
     // browser.tabs.warnOnClose is the global "warn when closing multiple tabs" pref
 
@@ -525,16 +518,22 @@ BrowserGlue.prototype = {
       // we should show the window closing warning instead. warnAboutClosing
       // tabs checks browser.tabs.warnOnClose and returns if it's ok to close
       // the window. It doesn't actually close the window.
       mostRecentBrowserWindow = Services.wm.getMostRecentWindow("navigator:browser");
       aCancelQuit.data = !mostRecentBrowserWindow.gBrowser.warnAboutClosingTabs(true);
       return;
     }
 
+    var inPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
+                            getService(Ci.nsIPrivateBrowsingService).
+                            privateBrowsingEnabled;
+    if (inPrivateBrowsing)
+      return;
+
     if (!showPrompt)
       return;
 
     var quitBundle = Services.strings.createBundle("chrome://browser/locale/quitDialog.properties");
     var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
 
     var appName = brandBundle.GetStringFromName("brandShortName");
     var quitTitleString = (aQuitType == "restart" ? "restart" : "quit") + "DialogTitle";
--- a/toolkit/content/globalOverlay.js
+++ b/toolkit/content/globalOverlay.js
@@ -11,32 +11,21 @@ function closeWindow(aClose, aPromptFunc
                      .getService(Components.interfaces.nsIWindowMediator);
   var e = wm.getEnumerator(null);
   
   while (e.hasMoreElements()) {
     var w = e.getNext();
     if (++windowCount == 2) 
       break;
   }
-
-  var inPrivateBrowsing = false;
-  try {
-    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
-  }
-
+  
   // If we're down to the last window and someone tries to shut down, check to make sure we can!
   if (windowCount == 1 && !canQuitApplication("lastwindow"))
     return false;
-  else if (windowCount != 1 || inPrivateBrowsing)
+  else if (windowCount != 1)
 #endif
     if (typeof(aPromptFunction) == "function" && !aPromptFunction())
       return false;
 
   if (aClose)    
     window.close();
   
   return true;