Bug 1533557 - _prefBranch removed and _remember accesses replaced with LoginHelper.enabled. r=MattN
authorRiz <rizwansyed357@protonmail.com>
Thu, 21 Mar 2019 08:45:02 +0000
changeset 465462 44458c3f63f63a58947c48239e2485643748376b
parent 465461 3f760b5978708d239025d2db7c2201bc95c71963
child 465463 6e51da6dffece10be590d5e3ec22b1f756733c59
push id112507
push usermozilla@noorenberghe.ca
push dateThu, 21 Mar 2019 23:47:55 +0000
treeherdermozilla-inbound@44458c3f63f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1533557
milestone68.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 1533557 - _prefBranch removed and _remember accesses replaced with LoginHelper.enabled. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D24427
toolkit/components/passwordmgr/LoginManager.jsm
--- a/toolkit/components/passwordmgr/LoginManager.jsm
+++ b/toolkit/components/passwordmgr/LoginManager.jsm
@@ -54,36 +54,28 @@ LoginManager.prototype = {
   },
 
 
   /* ---------- private members ---------- */
 
 
 
   _storage: null, // Storage component which contains the saved logins
-  _prefBranch: null, // Preferences service
-  _remember: true,  // mirrors signon.rememberSignons preference
 
 
   /**
    * Initialize the Login Manager. Automatically called when service
    * is created.
    *
    * Note: Service created in /browser/base/content/browser.js,
    *       delayedStartup()
    */
   init() {
     // Cache references to current |this| in utility objects
     this._observer._pwmgr            = this;
-
-    // Preferences. Add observer so we get notified of changes.
-    this._prefBranch = Services.prefs.getBranch("signon.");
-    this._prefBranch.addObserver("rememberSignons", this._observer);
-
-    this._remember = this._prefBranch.getBoolPref("rememberSignons");
     this._autoCompleteLookupPromise = null;
 
     // Form submit observer checks forms for new logins and pw changes.
     Services.obs.addObserver(this._observer, "xpcom-shutdown");
 
     if (Services.appinfo.processType ===
         Services.appinfo.PROCESS_TYPE_DEFAULT) {
       Services.obs.addObserver(this._observer, "passwordmgr-storage-replace");
@@ -113,29 +105,18 @@ LoginManager.prototype = {
   _observer: {
     _pwmgr: null,
 
     QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
                                             Ci.nsISupportsWeakReference]),
 
     // nsIObserver
     observe(subject, topic, data) {
-      if (topic == "nsPref:changed") {
-        var prefName = data;
-        log.debug("got change to", prefName, "preference");
-
-        if (prefName == "rememberSignons") {
-          this._pwmgr._remember =
-              this._pwmgr._prefBranch.getBoolPref("rememberSignons");
-        } else {
-          log.debug("Oops! Pref not handled, change ignored.");
-        }
-      } else if (topic == "xpcom-shutdown") {
+      if (topic == "xpcom-shutdown") {
         delete this._pwmgr._storage;
-        delete this._pwmgr._prefBranch;
         this._pwmgr = null;
       } else if (topic == "passwordmgr-storage-replace") {
         (async () => {
           await this._pwmgr._storage.terminate();
           this._pwmgr._initStorage();
           await this._pwmgr.initializationPromise;
           Services.obs.notifyObservers(null,
                                        "passwordmgr-storage-replace-complete");
@@ -179,17 +160,17 @@ LoginManager.prototype = {
     clearAndGetHistogram("PWMGR_NUM_HTTPAUTH_PASSWORDS").add(
       this.countLogins("", null, "")
     );
     Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_BLOCKLIST_NUM_SITES");
     Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_NUM_SAVED_PASSWORDS");
 
     // This is a boolean histogram, and not a flag, because we don't want to
     // record any value if _gatherTelemetry is not called.
-    clearAndGetHistogram("PWMGR_SAVING_ENABLED").add(this._remember);
+    clearAndGetHistogram("PWMGR_SAVING_ENABLED").add(LoginHelper.enabled);
     Services.obs.notifyObservers(null, "weave:telemetry:histogram", "PWMGR_SAVING_ENABLED");
 
     // Don't try to get logins if MP is enabled, since we don't want to show a MP prompt.
     if (!this.isLoggedIn) {
       return;
     }
 
     let logins = this.getAllLogins({});
@@ -449,17 +430,17 @@ LoginManager.prototype = {
   },
 
 
   /**
    * Check to see if user has disabled saving logins for the origin.
    */
   getLoginSavingEnabled(origin) {
     log.debug("Checking if logins to", origin, "can be saved.");
-    if (!this._remember) {
+    if (!LoginHelper.enabled) {
       return false;
     }
 
     let uri = Services.io.newURI(origin);
     return Services.perms.testPermission(uri, PERMISSION_SAVE_LOGINS) != Services.perms.DENY_ACTION;
   },
 
 
@@ -543,17 +524,17 @@ LoginManager.prototype = {
 
     if (isPasswordField && aSearchString) {
       // Return empty result on password fields with password already filled.
       let acLookupPromise = this._autoCompleteLookupPromise = Promise.resolve({ logins: [] });
       acLookupPromise.then(completeSearch.bind(this, acLookupPromise));
       return;
     }
 
-    if (!this._remember) {
+    if (!LoginHelper.enabled) {
       let acLookupPromise = this._autoCompleteLookupPromise = Promise.resolve({ logins: [] });
       acLookupPromise.then(completeSearch.bind(this, acLookupPromise));
       return;
     }
 
     log.debug("AutoCompleteSearch invoked. Search is:", aSearchString);
 
     let previousResult;