Bug 723003 - nsLoginManager.js uses global Private Browsing state to make decisions; r=ehsan

This commit is contained in:
Saurabh Anand 2012-07-19 18:45:14 +05:30
parent acf9bca19f
commit b4eeb30e75

View File

@ -8,6 +8,7 @@ const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
function LoginManager() {
this.init();
@ -71,31 +72,6 @@ LoginManager.prototype = {
return this.__storage;
},
// Private Browsing Service
// If the service is not available, null will be returned.
__privateBrowsingService : undefined,
get _privateBrowsingService() {
if (this.__privateBrowsingService == undefined) {
if ("@mozilla.org/privatebrowsing;1" in Cc)
this.__privateBrowsingService = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
else
this.__privateBrowsingService = null;
}
return this.__privateBrowsingService;
},
// Whether we are in private browsing mode
get _inPrivateBrowsing() {
var pbSvc = this._privateBrowsingService;
if (pbSvc)
return pbSvc.privateBrowsingEnabled;
else
return false;
},
_prefBranch : null, // Preferences service
_nsLoginInfo : null, // Constructor for nsILoginInfo implementation
@ -795,16 +771,16 @@ LoginManager.prototype = {
return prompterSvc;
}
if (this._inPrivateBrowsing) {
var doc = form.ownerDocument;
var win = doc.defaultView;
if (PrivateBrowsingUtils.isWindowPrivate(win)) {
// We won't do anything in private browsing mode anyway,
// so there's no need to perform further checks.
this.log("(form submission ignored in private browsing mode)");
return;
}
var doc = form.ownerDocument;
var win = doc.defaultView;
// If password saving is disabled (globally or for host), bail out now.
if (!this._remember)
return;
@ -1035,7 +1011,7 @@ LoginManager.prototype = {
this.log("fillDocument processing " + forms.length +
" forms on " + doc.documentURI);
var autofillForm = !this._inPrivateBrowsing &&
var autofillForm = !PrivateBrowsingUtils.isWindowPrivate(doc.defaultView) &&
this._prefBranch.getBoolPref("autofillForms");
var previousActionOrigin = null;
var foundLogins = null;