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 96994 fe2fdd5d3aae80b06464b133fea832bbe1246df6
parent 96993 87e09d2f6098a2b353547619918097070d2ab9b1
child 96995 8cc7aa5c0c95098537e6b769de88bdacff8d4aba
push id10811
push usereakhgari@mozilla.com
push dateTue, 19 Jun 2012 03:49:42 +0000
treeherdermozilla-inbound@fe2fdd5d3aae [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;