Bug 723004 - Port nsLoginManagerPrompter to the per-window private browsing API; r=dolske

This commit is contained in:
Ehsan Akhgari 2012-10-12 21:49:26 -04:00
parent 3eff91e626
commit e771ad5957

View File

@ -9,6 +9,7 @@ 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
@ -245,13 +246,15 @@ LoginManagerPrompter.prototype = {
// 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;
}
},