Bug 722994 - globalOverlay.js uses global Private Browsing state to control display of a prompt; r=ehsan
☠☠ backed out by 19bfe36cace8 ☠ ☠
authorSaurabh Anand <saurabhanandiit@gmail.com>
Tue, 19 Jun 2012 01:57:26 +0530
changeset 101794 fe2fdd5d3aae80b06464b133fea832bbe1246df6
parent 101793 87e09d2f6098a2b353547619918097070d2ab9b1
child 101795 8cc7aa5c0c95098537e6b769de88bdacff8d4aba
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs722994
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
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
toolkit/content/globalOverlay.js
--- a/toolkit/content/globalOverlay.js
+++ b/toolkit/content/globalOverlay.js
@@ -11,28 +11,29 @@ 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
-  }
-
+  let chromeWin  = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                         .getInterface(Ci.nsIWebNavigation)
+                         .QueryInterface(Ci.nsIDocShellTreeItem)
+                         .rootTreeItem
+                         .QueryInterface(Ci.nsIInterfaceRequestor)
+                         .getInterface(Ci.nsIDOMWindow)
+                         .wrappedJSObject;
+  
+  if (chromeWin != null) 
+    inPrivateBrowsing = chromeWin.gPrivateBrowsingUI.privateWindow;
+  
   // 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)
 #endif
     if (typeof(aPromptFunction) == "function" && !aPromptFunction())
       return false;