Bug 1200472 - Make LoginManagerParent._searchAndDedupeLogins public and static. r=sfoster
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Thu, 14 Nov 2019 22:55:14 +0000
changeset 502094 877779162b15b1cf31b69187a7eb6be1d834f3df
parent 502093 d38c2fbd306bbb7ea365cef72acef93996cc034b
child 502095 2e5826c18532792aa955c670e4a7d6f3919c3ff8
push id36805
push useraiakab@mozilla.com
push dateFri, 15 Nov 2019 09:53:19 +0000
treeherdermozilla-central@1e1617c67238 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs1200472
milestone72.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 1200472 - Make LoginManagerParent._searchAndDedupeLogins public and static. r=sfoster To allow easier access from LoginManagerContextMenu.jsm since it didn't rely on `this` anyways. Depends on D51353 Differential Revision: https://phabricator.services.mozilla.com/D52629
toolkit/components/passwordmgr/LoginManagerParent.jsm
--- a/toolkit/components/passwordmgr/LoginManagerParent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerParent.jsm
@@ -127,17 +127,17 @@ class LoginManagerParent extends JSWindo
   /**
    * @param {origin} formOrigin
    * @param {object} options
    * @param {origin?} options.formActionOrigin To match on. Omit this argument to match all action origins.
    * @param {origin?} options.httpRealm To match on. Omit this argument to match all realms.
    * @param {boolean} options.acceptDifferentSubdomains Include results for eTLD+1 matches
    * @param {boolean} options.ignoreActionAndRealm Include all form and HTTP auth logins for the site
    */
-  _searchAndDedupeLogins(
+  static searchAndDedupeLogins(
     formOrigin,
     {
       acceptDifferentSubdomains,
       formActionOrigin,
       httpRealm,
       ignoreActionAndRealm,
     } = {}
   ) {
@@ -356,17 +356,17 @@ class LoginManagerParent extends JSWindo
 
     // Autocomplete results do not need to match actionOrigin or exact origin.
     let logins = null;
     if (guid) {
       logins = LoginHelper.searchLoginsWithObject({
         guid,
       });
     } else {
-      logins = this._searchAndDedupeLogins(formOrigin, {
+      logins = LoginManagerParent.searchAndDedupeLogins(formOrigin, {
         formActionOrigin: actionOrigin,
         ignoreActionAndRealm: true,
         acceptDifferentSubdomains: LoginHelper.includeOtherSubdomainsInLookup,
       });
     }
 
     log("sendLoginDataToChild:", logins.length, "deduped logins");
     // Convert the array of nsILoginInfo to vanilla JS objects since nsILoginInfo
@@ -422,17 +422,17 @@ class LoginManagerParent extends JSWindo
 
       // We have a list of results for a shorter search string, so just
       // filter them further based on the new search string.
       logins = LoginHelper.vanillaObjectsToLogins(previousResult.logins);
     } else {
       log("Creating new autocomplete search result.");
 
       // Autocomplete results do not need to match actionOrigin or exact origin.
-      logins = this._searchAndDedupeLogins(formOrigin, {
+      logins = LoginManagerParent.searchAndDedupeLogins(formOrigin, {
         formActionOrigin: actionOrigin,
         ignoreActionAndRealm: true,
         acceptDifferentSubdomains: LoginHelper.includeOtherSubdomainsInLookup,
       });
     }
 
     let matchingLogins = logins.filter(function(fullMatch) {
       let match = fullMatch.username;
@@ -612,17 +612,17 @@ class LoginManagerParent extends JSWindo
         log("The filled login matches the form submission. Nothing to change.");
         recordLoginUse(loginsForGuid[0]);
         return;
       }
     }
 
     // Below here we have one login per hostPort + action + username with the
     // matching scheme being preferred.
-    let logins = this._searchAndDedupeLogins(origin, {
+    let logins = LoginManagerParent.searchAndDedupeLogins(origin, {
       formActionOrigin,
     });
 
     let generatedPW = gGeneratedPasswordsByPrincipalOrigin.get(origin);
     let autoSavedStorageGUID = "";
     if (generatedPW && generatedPW.storageGUID) {
       autoSavedStorageGUID = generatedPW.storageGUID;
     }
@@ -860,17 +860,17 @@ class LoginManagerParent extends JSWindo
       log("autocomplete_field telemetry event recorded");
       generatedPW.filled = true;
     }
 
     if (!loginToChange) {
       // Check if we already have a login saved for this site since we don't want to overwrite it in
       // case the user still needs their old password to successfully complete a password change.
       // An empty formActionOrigin is used as a wildcard to not restrict to action matches.
-      let logins = this._searchAndDedupeLogins(formOrigin, {
+      let logins = LoginManagerParent.searchAndDedupeLogins(formOrigin, {
         acceptDifferentSubdomains: false,
         httpRealm: null,
         ignoreActionAndRealm: false,
       });
 
       let matchedLogin = logins.find(login =>
         formLoginWithoutUsername.matches(login, true)
       );