Bug 723004 - Port nsLoginManagerPrompter to the per-window private browsing API; r=dolske
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 12 Oct 2012 21:49:26 -0400
changeset 110132 5091701dcc45
parent 110131 b680d000682f
child 110133 7f47eacb16e3
push id16363
push usereakhgari@mozilla.com
push dateSat, 13 Oct 2012 12:47:37 +0000
treeherdermozilla-inbound@5091701dcc45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs723004
milestone19.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 723004 - Port nsLoginManagerPrompter to the per-window private browsing API; r=dolske
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -4,16 +4,17 @@
 
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 /*
  * LoginManagerPromptFactory
  *
  * Implements nsIPromptFactory
  *
  * Invoked by [toolkit/components/prompts/src/nsPrompter.js]
  */
@@ -240,23 +241,25 @@ LoginManagerPrompter.prototype = {
             } catch (e) { }
         }
         return this.__ellipsis;
     },
 
 
     // Whether we are in private browsing mode
     get _inPrivateBrowsing() {
-      // The Private Browsing service might not be available.
-      try {
-        var pbs = Cc["@mozilla.org/privatebrowsing;1"].
-                  getService(Ci.nsIPrivateBrowsingService);
-        return pbs.privateBrowsingEnabled;
-      } catch (e) {
-        return false;
+      if (this._window) {
+        return PrivateBrowsingUtils.isWindowPrivate(this._window);
+      } else {
+        // If we don't that we're in private browsing mode if the caller did
+        // not provide a window.  The callers which really care about this
+        // will indeed pass down a window to us, and for those who don't,
+        // we can just assume that we don't want to save the entered login
+        // information.
+        return true;
       }
     },
 
 
     /*
      * log
      *
      * Internal function for logging debug messages to the Error Console window.