Bug 1334012 - Move Login AutoComplete to its own interface. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 03 May 2019 00:08:12 +0000
changeset 531223 59549c837955397b4d7da4f1c1f1656868f7f05b
parent 531222 d6416b8998419c628c2383cf768bf2c5845931bf
child 531224 22980cfa0285de0d9ca08eb7824bb528a8cab43c
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1334012
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 1334012 - Move Login AutoComplete to its own interface. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D29694
toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
toolkit/components/passwordmgr/LoginManager.jsm
toolkit/components/passwordmgr/components.conf
toolkit/components/passwordmgr/moz.build
toolkit/components/passwordmgr/nsILoginAutoCompleteSearch.idl
toolkit/components/passwordmgr/nsILoginManager.idl
toolkit/components/satchel/AutoCompletePopup.jsm
toolkit/components/satchel/nsFormFillController.cpp
toolkit/components/satchel/nsFormFillController.h
--- a/toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
+++ b/toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
@@ -1,34 +1,46 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
- * nsIAutoCompleteResult implementation for saved logins.
+ * nsIAutoCompleteResult and nsILoginAutoCompleteSearch implementations for saved logins.
  */
 
 "use strict";
 
-var EXPORTED_SYMBOLS = ["LoginAutoCompleteResult"];
+var EXPORTED_SYMBOLS = [
+  "LoginAutoComplete",
+  "LoginAutoCompleteResult",
+];
 
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
+ChromeUtils.defineModuleGetter(this, "BrowserUtils",
+                               "resource://gre/modules/BrowserUtils.jsm");
+ChromeUtils.defineModuleGetter(this, "InsecurePasswordUtils",
+                               "resource://gre/modules/InsecurePasswordUtils.jsm");
+ChromeUtils.defineModuleGetter(this, "LoginFormFactory",
+                               "resource://gre/modules/LoginFormFactory.jsm");
 ChromeUtils.defineModuleGetter(this, "LoginHelper",
                                "resource://gre/modules/LoginHelper.jsm");
+ChromeUtils.defineModuleGetter(this, "LoginManagerContent",
+                               "resource://gre/modules/LoginManagerContent.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "formFillController",
                                    "@mozilla.org/satchel/form-fill-controller;1",
                                    Ci.nsIFormFillController);
 
 XPCOMUtils.defineLazyGetter(this, "log", () => {
   return LoginHelper.createLogger("LoginAutoCompleteResult");
 });
 
+
 // nsIAutoCompleteResult implementation
 function LoginAutoCompleteResult(aSearchString, matchingLogins, {isSecure, messageManager, isPasswordField, hostname}) {
   function loginSort(a, b) {
     let userA = a.username.toLowerCase();
     let userB = b.username.toLowerCase();
 
     if (userA < userB) {
       return -1;
@@ -231,8 +243,113 @@ LoginAutoCompleteResult.prototype = {
         this._messageManager.sendAsyncMessage("PasswordManager:removeLogin",
                                               { login: vanilla });
       } else {
         Services.logins.removeLogin(removedLogin);
       }
     }
   },
 };
+
+function LoginAutoComplete() {}
+LoginAutoComplete.prototype = {
+  classID: Components.ID("{2bdac17c-53f1-4896-a521-682ccdeef3a8}"),
+  QueryInterface: ChromeUtils.generateQI([Ci.nsILoginAutoCompleteSearch]),
+
+  _autoCompleteLookupPromise: null,
+
+  /**
+   * Yuck. This is called directly by satchel:
+   * nsFormFillController::StartSearch()
+   * [toolkit/components/satchel/nsFormFillController.cpp]
+   *
+   * We really ought to have a simple way for code to register an
+   * auto-complete provider, and not have satchel calling pwmgr directly.
+   *
+   * @param {string} aSearchString The value typed in the field.
+   * @param {nsIAutoCompleteResult} aPreviousResult
+   * @param {HTMLInputElement} aElement
+   * @param {nsIFormAutoCompleteObserver} aCallback
+   */
+  startSearch(aSearchString, aPreviousResult, aElement, aCallback) {
+    let {isNullPrincipal} = aElement.nodePrincipal;
+    // Show the insecure login warning in the passwords field on null principal documents.
+    let isSecure = !isNullPrincipal;
+    // Avoid loading InsecurePasswordUtils.jsm in a sandboxed document (e.g. an ad. frame) if we
+    // already know it has a null principal and will therefore get the insecure autocomplete
+    // treatment.
+    // InsecurePasswordUtils doesn't handle the null principal case as not secure because we don't
+    // want the same treatment:
+    // * The web console warnings will be confusing (as they're primarily about http:) and not very
+    //   useful if the developer intentionally sandboxed the document.
+    // * The site identity insecure field warning would require LoginManagerContent being loaded and
+    //   listening to some of the DOM events we're ignoring in null principal documents. For memory
+    //   reasons it's better to not load LMC at all for these sandboxed frames. Also, if the top-
+    //   document is sandboxing a document, it probably doesn't want that sandboxed document to be
+    //   able to affect the identity icon in the address bar by adding a password field.
+    if (isSecure) {
+      let form = LoginFormFactory.createFromField(aElement);
+      isSecure = InsecurePasswordUtils.isFormSecure(form);
+    }
+    let isPasswordField = aElement.type == "password";
+    let hostname = aElement.ownerDocument.documentURIObject.host;
+
+    let completeSearch = (autoCompleteLookupPromise, { logins, messageManager }) => {
+      // If the search was canceled before we got our
+      // results, don't bother reporting them.
+      if (this._autoCompleteLookupPromise !== autoCompleteLookupPromise) {
+        return;
+      }
+
+      this._autoCompleteLookupPromise = null;
+      let results = new LoginAutoCompleteResult(aSearchString, logins, {
+        messageManager,
+        isSecure,
+        isPasswordField,
+        hostname,
+      });
+      aCallback.onSearchCompletion(results);
+    };
+
+    if (isNullPrincipal) {
+      // Don't search login storage when the field has a null principal as we don't want to fill
+      // logins for the `location` in this case.
+      let acLookupPromise = this._autoCompleteLookupPromise = Promise.resolve({ logins: [] });
+      acLookupPromise.then(completeSearch.bind(this, acLookupPromise));
+      return;
+    }
+
+    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 (!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;
+    if (aPreviousResult) {
+      previousResult = {
+        searchString: aPreviousResult.searchString,
+        logins: aPreviousResult.wrappedJSObject.logins,
+      };
+    } else {
+      previousResult = null;
+    }
+
+    let rect = BrowserUtils.getElementBoundingScreenRect(aElement);
+    let acLookupPromise = this._autoCompleteLookupPromise =
+      LoginManagerContent._autoCompleteSearchAsync(aSearchString, previousResult,
+                                                   aElement, rect);
+    acLookupPromise.then(completeSearch.bind(this, acLookupPromise)).catch(log.error);
+  },
+
+  stopSearch() {
+    this._autoCompleteLookupPromise = null;
+  },
+};
--- a/toolkit/components/passwordmgr/LoginManager.jsm
+++ b/toolkit/components/passwordmgr/LoginManager.jsm
@@ -4,36 +4,37 @@
 
 "use strict";
 
 const PERMISSION_SAVE_LOGINS = "login-saving";
 
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-ChromeUtils.defineModuleGetter(this, "BrowserUtils",
-                               "resource://gre/modules/BrowserUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "LoginHelper",
                                "resource://gre/modules/LoginHelper.jsm");
 ChromeUtils.defineModuleGetter(this, "LoginFormFactory",
                                "resource://gre/modules/LoginFormFactory.jsm");
 ChromeUtils.defineModuleGetter(this, "LoginManagerContent",
                                "resource://gre/modules/LoginManagerContent.jsm");
-ChromeUtils.defineModuleGetter(this, "LoginAutoCompleteResult",
-                               "resource://gre/modules/LoginAutoCompleteResult.jsm");
 ChromeUtils.defineModuleGetter(this, "InsecurePasswordUtils",
                                "resource://gre/modules/InsecurePasswordUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "log", () => {
   let logger = LoginHelper.createLogger("nsLoginManager");
   return logger;
 });
 
 const MS_PER_DAY = 24 * 60 * 60 * 1000;
 
+if (Services.appinfo.processType !== Services.appinfo.PROCESS_TYPE_DEFAULT) {
+  throw new Error("LoginManager.jsm should only run in the parent process");
+}
+
+
 function LoginManager() {
   this.init();
 }
 
 LoginManager.prototype = {
 
   classID: Components.ID("{cb9e0de8-3598-4ed7-857b-827f011ad5d8}"),
   QueryInterface: ChromeUtils.generateQI([Ci.nsILoginManager,
@@ -51,43 +52,34 @@ LoginManager.prototype = {
     }
 
     throw new Components.Exception("Interface not available", Cr.NS_ERROR_NO_INTERFACE);
   },
 
 
   /* ---------- private members ---------- */
 
-
-
   _storage: null, // Storage component which contains the saved logins
 
 
   /**
    * Initialize the Login Manager. Automatically called when service
    * is created.
    *
-   * Note: Service created in /browser/base/content/browser.js,
-   *       delayedStartup()
+   * Note: Service created in BrowserGlue#_scheduleStartupIdleTasks()
    */
   init() {
     // Cache references to current |this| in utility objects
     this._observer._pwmgr            = this;
-    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");
+    Services.obs.addObserver(this._observer, "xpcom-shutdown");
+    Services.obs.addObserver(this._observer, "passwordmgr-storage-replace");
 
-      // Initialize storage so that asynchronous data loading can start.
-      this._initStorage();
-    }
+    // Initialize storage so that asynchronous data loading can start.
+    this._initStorage();
 
     Services.obs.addObserver(this._observer, "gather-telemetry");
   },
 
   _initStorage() {
     this._storage = Cc["@mozilla.org/login-manager/storage/default;1"]
                     .createInstance(Ci.nsILoginManagerStorage);
     this.initializationPromise = this._storage.initialize();
@@ -459,106 +451,11 @@ LoginManager.prototype = {
       Services.perms.remove(uri, PERMISSION_SAVE_LOGINS);
     } else {
       Services.perms.add(uri, PERMISSION_SAVE_LOGINS, Services.perms.DENY_ACTION);
     }
 
     log.debug("Login saving for", origin, "now enabled?", enabled);
     LoginHelper.notifyStorageChanged(enabled ? "hostSavingEnabled" : "hostSavingDisabled", origin);
   },
-
-  /**
-   * Yuck. This is called directly by satchel:
-   * nsFormFillController::StartSearch()
-   * [toolkit/components/satchel/nsFormFillController.cpp]
-   *
-   * We really ought to have a simple way for code to register an
-   * auto-complete provider, and not have satchel calling pwmgr directly.
-   */
-  autoCompleteSearchAsync(aSearchString, aPreviousResult,
-                          aElement, aCallback) {
-    // aPreviousResult is an nsIAutoCompleteResult, aElement is
-    // HTMLInputElement
-
-    let {isNullPrincipal} = aElement.nodePrincipal;
-    // Show the insecure login warning in the passwords field on null principal documents.
-    let isSecure = !isNullPrincipal;
-    // Avoid loading InsecurePasswordUtils.jsm in a sandboxed document (e.g. an ad. frame) if we
-    // already know it has a null principal and will therefore get the insecure autocomplete
-    // treatment.
-    // InsecurePasswordUtils doesn't handle the null principal case as not secure because we don't
-    // want the same treatment:
-    // * The web console warnings will be confusing (as they're primarily about http:) and not very
-    //   useful if the developer intentionally sandboxed the document.
-    // * The site identity insecure field warning would require LoginManagerContent being loaded and
-    //   listening to some of the DOM events we're ignoring in null principal documents. For memory
-    //   reasons it's better to not load LMC at all for these sandboxed frames. Also, if the top-
-    //   document is sandboxing a document, it probably doesn't want that sandboxed document to be
-    //   able to affect the identity icon in the address bar by adding a password field.
-    if (isSecure) {
-      let form = LoginFormFactory.createFromField(aElement);
-      isSecure = InsecurePasswordUtils.isFormSecure(form);
-    }
-    let isPasswordField = aElement.type == "password";
-    let hostname = aElement.ownerDocument.documentURIObject.host;
-
-    let completeSearch = (autoCompleteLookupPromise, { logins, messageManager }) => {
-      // If the search was canceled before we got our
-      // results, don't bother reporting them.
-      if (this._autoCompleteLookupPromise !== autoCompleteLookupPromise) {
-        return;
-      }
-
-      this._autoCompleteLookupPromise = null;
-      let results = new LoginAutoCompleteResult(aSearchString, logins, {
-        messageManager,
-        isSecure,
-        isPasswordField,
-        hostname,
-      });
-      aCallback.onSearchCompletion(results);
-    };
-
-    if (isNullPrincipal) {
-      // Don't search login storage when the field has a null principal as we don't want to fill
-      // logins for the `location` in this case.
-      let acLookupPromise = this._autoCompleteLookupPromise = Promise.resolve({ logins: [] });
-      acLookupPromise.then(completeSearch.bind(this, acLookupPromise));
-      return;
-    }
-
-    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 (!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;
-    if (aPreviousResult) {
-      previousResult = { searchString: aPreviousResult.searchString,
-                         logins: aPreviousResult.wrappedJSObject.logins };
-    } else {
-      previousResult = null;
-    }
-
-    let rect = BrowserUtils.getElementBoundingScreenRect(aElement);
-    let acLookupPromise = this._autoCompleteLookupPromise =
-      LoginManagerContent._autoCompleteSearchAsync(aSearchString, previousResult,
-                                                   aElement, rect);
-    acLookupPromise.then(completeSearch.bind(this, acLookupPromise))
-                             .catch(Cu.reportError);
-  },
-
-  stopSearch() {
-    this._autoCompleteLookupPromise = null;
-  },
 }; // end of LoginManager implementation
 
 var EXPORTED_SYMBOLS = ["LoginManager"];
--- a/toolkit/components/passwordmgr/components.conf
+++ b/toolkit/components/passwordmgr/components.conf
@@ -13,16 +13,22 @@ Classes = [
     },
     {
         'cid': '{749e62f4-60ae-4569-a8a2-de78b649660e}',
         'contract_ids': ['@mozilla.org/passwordmanager/authpromptfactory;1'],
         'jsm': 'resource://gre/modules/LoginManagerPrompter.jsm',
         'constructor': 'LoginManagerPromptFactory',
     },
     {
+        'cid': '{2bdac17c-53f1-4896-a521-682ccdeef3a8}',
+        'contract_ids': ['@mozilla.org/login-manager/autocompletesearch;1'],
+        'jsm': 'resource://gre/modules/LoginAutoCompleteResult.jsm',
+        'constructor': 'LoginAutoComplete',
+    },
+    {
         'cid': '{8aa66d77-1bbb-45a6-991e-b8f47751c291}',
         'contract_ids': ['@mozilla.org/login-manager/prompter;1'],
         'jsm': 'resource://gre/modules/LoginManagerPrompter.jsm',
         'constructor': 'LoginManagerPrompter',
     },
     {
         'cid': '{0f2f347c-1e4f-40cc-8efd-792dea70a85e}',
         'contract_ids': ['@mozilla.org/login-manager/loginInfo;1'],
--- a/toolkit/components/passwordmgr/moz.build
+++ b/toolkit/components/passwordmgr/moz.build
@@ -13,16 +13,17 @@ XPCSHELL_TESTS_MANIFESTS += ['test/unit/
 
 TESTING_JS_MODULES += [
     # Make this file available from the "resource:" URI of the test environment.
     'test/browser/form_basic.html',
     'test/LoginTestUtils.jsm',
 ]
 
 XPIDL_SOURCES += [
+    'nsILoginAutoCompleteSearch.idl',
     'nsILoginInfo.idl',
     'nsILoginManager.idl',
     'nsILoginManagerCrypto.idl',
     'nsILoginManagerPrompter.idl',
     'nsILoginManagerStorage.idl',
     'nsILoginMetaInfo.idl',
 ]
 
copy from toolkit/components/passwordmgr/nsILoginManager.idl
copy to toolkit/components/passwordmgr/nsILoginAutoCompleteSearch.idl
--- a/toolkit/components/passwordmgr/nsILoginManager.idl
+++ b/toolkit/components/passwordmgr/nsILoginAutoCompleteSearch.idl
@@ -1,276 +1,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-
 #include "nsISupports.idl"
 
-interface nsIURI;
-interface nsILoginInfo;
 interface nsIAutoCompleteResult;
 interface nsIFormAutoCompleteObserver;
-interface nsIPropertyBag;
 
 webidl HTMLInputElement;
 
-[scriptable, uuid(38c7f6af-7df9-49c7-b558-2776b24e6cc1)]
-interface nsILoginManager : nsISupports {
-  /**
-   * This promise is resolved when initialization is complete, and is rejected
-   * in case initialization failed.  This includes the initial loading of the
-   * login data as well as any migration from previous versions.
-   *
-   * Calling any method of nsILoginManager before this promise is resolved
-   * might trigger the synchronous initialization fallback.
-   */
-  readonly attribute jsval initializationPromise;
-
-
-  /**
-   * Store a new login in the login manager.
-   *
-   * @param aLogin
-   *        The login to be added.
-   * @return a clone of the login info with the guid set (even if it was not provided)
-   *
-   * Default values for the login's nsILoginMetaInfo properties will be
-   * created. However, if the caller specifies non-default values, they will
-   * be used instead.
-   */
-  nsILoginInfo addLogin(in nsILoginInfo aLogin);
-
-
-  /**
-   * Like addLogin, but asynchronous and for many logins.
-   *
-   * @param aLogins
-   *        A JS Array of nsILoginInfos to add.
-   * @return A promise which resolves with a JS Array of cloned logins with
-   *         the guids set.
-   *
-   * Default values for each login's nsILoginMetaInfo properties will be
-   * created. However, if the caller specifies non-default values, they will
-   * be used instead.
-   */
-  jsval addLogins(in jsval aLogins);
-
-  /**
-   * Remove a login from the login manager.
-   *
-   * @param aLogin
-   *        The login to be removed.
-   *
-   * The specified login must exactly match a stored login. However, the
-   * values of any nsILoginMetaInfo properties are ignored.
-   */
-  void removeLogin(in nsILoginInfo aLogin);
-
-
-  /**
-   * Modify an existing login in the login manager.
-   *
-   * @param oldLogin
-   *        The login to be modified.
-   * @param newLoginData
-   *        The new login values (either a nsILoginInfo or nsIProperyBag)
-   *
-   * If newLoginData is a nsILoginInfo, all of the old login's nsILoginInfo
-   * properties are changed to the values from newLoginData (but the old
-   * login's nsILoginMetaInfo properties are unmodified).
-   *
-   * If newLoginData is a nsIPropertyBag, only the specified properties
-   * will be changed. The nsILoginMetaInfo properties of oldLogin can be
-   * changed in this manner.
-   *
-   * If the propertybag contains an item named "timesUsedIncrement", the
-   * login's timesUsed property will be incremented by the item's value.
-   */
-  void modifyLogin(in nsILoginInfo oldLogin, in nsISupports newLoginData);
-
-
-  /**
-   * Remove all logins known to login manager.
-   *
-   * The browser sanitization feature allows the user to clear any stored
-   * passwords. This interface allows that to be done without getting each
-   * login first (which might require knowing the master password).
-   *
-   */
-  void removeAllLogins();
-
-
+[scriptable, uuid(2bdac17c-53f1-4896-a521-682ccdeef3a8)]
+interface nsILoginAutoCompleteSearch : nsISupports {
   /**
-   * Fetch all logins in the login manager. An array is always returned;
-   * if there are no logins the array is empty.
-   *
-   * @param count
-   *        The number of elements in the array. JS callers can simply use
-   *        the array's .length property and omit this param.
-   * @param logins
-   *        An array of nsILoginInfo objects.
-   *
-   * NOTE: This can be called from JS as:
-   *       var logins = pwmgr.getAllLogins();
-   *       (|logins| is an array).
-   */
-  void getAllLogins([optional] out unsigned long count,
-                    [retval, array, size_is(count)] out nsILoginInfo logins);
-
-
-  /**
-   * Obtain a list of all hosts for which password saving is disabled.
-   *
-   * @param count
-   *        The number of elements in the array. JS callers can simply use
-   *        the array's .length property and omit this param.
-   * @param hostnames
-   *        An array of hostname strings, in origin URL format without a
-   *        pathname. For example: "https://www.site.com".
-   *
-   * NOTE: This can be called from JS as:
-   *       var logins = pwmgr.getDisabledAllLogins();
-   */
-  void getAllDisabledHosts([optional] out unsigned long count,
-                    [retval, array, size_is(count)] out wstring hostnames);
-
-
-  /**
-   * Check to see if saving logins has been disabled for a host.
-   *
-   * @param aHost
-   *        The hostname to check. This argument should be in the origin
-   *        URL format, without a pathname. For example: "http://foo.com".
-   */
-  boolean getLoginSavingEnabled(in AString aHost);
-
-
-  /**
-   * Disable (or enable) storing logins for the specified host. When
-   * disabled, the login manager will not prompt to store logins for
-   * that host. Existing logins are not affected.
-   *
-   * @param aHost
-   *        The hostname to set. This argument should be in the origin
-   *        URL format, without a pathname. For example: "http://foo.com".
-   * @param isEnabled
-   *        Specify if saving logins should be enabled (true) or
-   *        disabled (false)
-   */
-  void setLoginSavingEnabled(in AString aHost, in boolean isEnabled);
-
-
-  /**
-   * Search for logins matching the specified criteria. Called when looking
-   * for logins that might be applicable to a form or authentication request.
-   *
-   * @param count
-   *        The number of elements in the array. JS callers can simply use
-   *        the array's .length property, and supply an dummy object for
-   *        this out param. For example: |findLogins({}, hostname, ...)|
-   * @param aHostname
-   *        The hostname to restrict searches to, in URL format. For
-   *        example: "http://www.site.com".
-   *        To find logins for a given nsIURI, you would typically pass in
-   *        its prePath.
-   * @param aActionURL
-   *        For form logins, this argument should be the URL to which the
-   *        form will be submitted. For protocol logins, specify null.
-   *        An empty string ("") will match any value (except null).
-   * @param aHttpRealm
-   *        For protocol logins, this argument should be the HTTP Realm
-   *        for which the login applies. This is obtained from the
-   *        WWW-Authenticate header. See RFC2617. For form logins,
-   *        specify null.
-   *        An empty string ("") will match any value (except null).
-   * @param logins
-   *        An array of nsILoginInfo objects.
-   *
-   * NOTE: This can be called from JS as:
-   *       var logins = pwmgr.findLogins({}, hostname, ...);
-   *
-   */
-  void findLogins(out unsigned long count, in AString aHostname,
-                  in AString aActionURL,   in AString aHttpRealm,
-                  [retval, array, size_is(count)] out nsILoginInfo logins);
-
-
-  /**
-   * Search for logins matching the specified criteria, as with
-   * findLogins(). This interface only returns the number of matching
-   * logins (and not the logins themselves), which allows a caller to
-   * check for logins without causing the user to be prompted for a master
-   * password to decrypt the logins.
-   *
-   * @param aHostname
-   *        The hostname to restrict searches to. Specify an empty string
-   *        to match all hosts. A null value will not match any logins, and
-   *        will thus always return a count of 0.
-   * @param aActionURL
-   *        The URL to which a form login will be submitted. To match any
-   *        form login, specify an empty string. To not match any form
-   *        login, specify null.
-   * @param aHttpRealm
-   *        The HTTP Realm for which the login applies. To match logins for
-   *        any realm, specify an empty string. To not match logins for any
-   *        realm, specify null.
-   */
-  unsigned long countLogins(in AString aHostname, in AString aActionURL,
-                            in AString aHttpRealm);
-
-
-  /**
-   * Generate results for a userfield autocomplete menu.
+   * Generate results for a login field autocomplete menu.
    *
    * NOTE: This interface is provided for use only by the FormFillController,
    *       which calls it directly. This isn't really ideal, it should
    *       probably be callback registered through the FFC.
+   * NOTE: This API is different than nsIAutoCompleteSearch.
    */
-  void autoCompleteSearchAsync(in AString aSearchString,
-                               in nsIAutoCompleteResult aPreviousResult,
-                               in HTMLInputElement aElement,
-                               in nsIFormAutoCompleteObserver aListener);
-
-  /**
-   * Stop a previously-started async search.
-   */
-  void stopSearch();
+  void startSearch(in AString aSearchString,
+                   in nsIAutoCompleteResult aPreviousResult,
+                   in HTMLInputElement aElement,
+                   in nsIFormAutoCompleteObserver aListener);
 
   /**
-   * Search for logins in the login manager. An array is always returned;
-   * if there are no logins the array is empty.
-   *
-   * @param count
-   *        The number of elements in the array. JS callers can simply use
-   *        the array's .length property, and supply an dummy object for
-   *        this out param. For example: |searchLogins({}, matchData)|
-   * @param matchData
-   *        The data used to search. This does not follow the same
-   *        requirements as findLogins for those fields. Wildcard matches are
-   *        simply not specified.
-   * @param logins
-   *        An array of nsILoginInfo objects.
-   *
-   * NOTE: This can be called from JS as:
-   *       var logins = pwmgr.searchLogins({}, matchData);
-   *       (|logins| is an array).
+   * Stop a previously-started search.
    */
-  void searchLogins(out unsigned long count, in nsIPropertyBag matchData,
-                    [retval, array, size_is(count)] out nsILoginInfo logins);
-
- /**
-  * True when a master password prompt is being displayed.
-  */
-  readonly attribute boolean uiBusy;
-
- /**
-  * True when the master password has already been entered, and so a caller
-  * can ask for decrypted logins without triggering a prompt.
-  */
-  readonly attribute boolean isLoggedIn;
+  void stopSearch();
 };
-
-%{C++
-
-#define NS_LOGINMANAGER_CONTRACTID "@mozilla.org/login-manager;1"
-
-%}
--- a/toolkit/components/passwordmgr/nsILoginManager.idl
+++ b/toolkit/components/passwordmgr/nsILoginManager.idl
@@ -1,23 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-
 #include "nsISupports.idl"
 
-interface nsIURI;
 interface nsILoginInfo;
-interface nsIAutoCompleteResult;
-interface nsIFormAutoCompleteObserver;
 interface nsIPropertyBag;
 
-webidl HTMLInputElement;
-
 [scriptable, uuid(38c7f6af-7df9-49c7-b558-2776b24e6cc1)]
 interface nsILoginManager : nsISupports {
   /**
    * This promise is resolved when initialization is complete, and is rejected
    * in case initialization failed.  This includes the initial loading of the
    * login data as well as any migration from previous versions.
    *
    * Calling any method of nsILoginManager before this promise is resolved
@@ -212,34 +206,16 @@ interface nsILoginManager : nsISupports 
    * @param aHttpRealm
    *        The HTTP Realm for which the login applies. To match logins for
    *        any realm, specify an empty string. To not match logins for any
    *        realm, specify null.
    */
   unsigned long countLogins(in AString aHostname, in AString aActionURL,
                             in AString aHttpRealm);
 
-
-  /**
-   * Generate results for a userfield autocomplete menu.
-   *
-   * NOTE: This interface is provided for use only by the FormFillController,
-   *       which calls it directly. This isn't really ideal, it should
-   *       probably be callback registered through the FFC.
-   */
-  void autoCompleteSearchAsync(in AString aSearchString,
-                               in nsIAutoCompleteResult aPreviousResult,
-                               in HTMLInputElement aElement,
-                               in nsIFormAutoCompleteObserver aListener);
-
-  /**
-   * Stop a previously-started async search.
-   */
-  void stopSearch();
-
   /**
    * Search for logins in the login manager. An array is always returned;
    * if there are no logins the array is empty.
    *
    * @param count
    *        The number of elements in the array. JS callers can simply use
    *        the array's .length property, and supply an dummy object for
    *        this out param. For example: |searchLogins({}, matchData)|
--- a/toolkit/components/satchel/AutoCompletePopup.jsm
+++ b/toolkit/components/satchel/AutoCompletePopup.jsm
@@ -145,20 +145,16 @@ this.AutoCompletePopup = {
         this.weakBrowser = null;
         evt.target.removeEventListener("popuphidden", this);
         evt.target.removeEventListener("popupshowing", this);
         break;
       }
     }
   },
 
-  // Along with being called internally by the receiveMessage handler,
-  // this function is also called directly by the login manager, which
-  // uses a single message to fill in the autocomplete results. See
-  // "PasswordManager:autoCompleteLogins".
   showPopupWithResults({ browser, rect, dir, results }) {
     if (!results.length || this.openedPopup) {
       // We shouldn't ever be showing an empty popup, and if we
       // already have a popup open, the old one needs to close before
       // we consider opening a new one.
       return;
     }
 
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -28,17 +28,17 @@
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebNavigation.h"
 #include "nsIContentViewer.h"
 #include "nsIContent.h"
 #include "nsRect.h"
-#include "nsILoginManager.h"
+#include "nsILoginAutoCompleteSearch.h"
 #include "nsToolkitCompsCID.h"
 #include "nsEmbedCID.h"
 #include "nsContentUtils.h"
 #include "nsGenericHTMLElement.h"
 #include "nsILoadContext.h"
 #include "nsIFrame.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsFocusManager.h"
@@ -60,17 +60,17 @@ static nsIFormAutoComplete* GetFormAutoC
     if (NS_SUCCEEDED(rv)) {
       ClearOnShutdown(&sInstance);
       sInitialized = true;
     }
   }
   return sInstance;
 }
 
-NS_IMPL_CYCLE_COLLECTION(nsFormFillController, mController, mLoginManager,
+NS_IMPL_CYCLE_COLLECTION(nsFormFillController, mController, mLoginManagerAC,
                          mLoginReputationService, mFocusedPopup, mDocShells,
                          mPopups, mLastListener, mLastFormAutoComplete)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFormFillController)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFormFillController)
   NS_INTERFACE_MAP_ENTRY(nsIFormFillController)
   NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteInput)
   NS_INTERFACE_MAP_ENTRY(nsIAutoCompleteSearch)
@@ -293,18 +293,18 @@ nsFormFillController::MarkAsLoginManager
     nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedElement();
     if (focusedContent == aInput) {
       if (!mFocusedInput) {
         MaybeStartControllingInput(aInput);
       }
     }
   }
 
-  if (!mLoginManager) {
-    mLoginManager = do_GetService("@mozilla.org/login-manager;1");
+  if (!mLoginManagerAC) {
+    mLoginManagerAC = do_GetService("@mozilla.org/login-manager/autocompletesearch;1");
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFormFillController::MarkAsAutofillField(HTMLInputElement* aInput) {
   /*
@@ -702,29 +702,28 @@ nsFormFillController::StartSearch(const 
   if (mFocusedInput &&
       (mPwmgrInputs.Get(mFocusedInput) ||
        mFocusedInput->ControlType() == NS_FORM_INPUT_PASSWORD)) {
     MOZ_LOG(sLogger, LogLevel::Debug, ("StartSearch: login field"));
 
     // Handle the case where a password field is focused but
     // MarkAsLoginManagerField wasn't called because password manager is
     // disabled.
-    if (!mLoginManager) {
-      mLoginManager = do_GetService("@mozilla.org/login-manager;1");
+    if (!mLoginManagerAC) {
+      mLoginManagerAC = do_GetService("@mozilla.org/login-manager/autocompletesearch;1");
     }
 
-    if (NS_WARN_IF(!mLoginManager)) {
+    if (NS_WARN_IF(!mLoginManagerAC)) {
       return NS_ERROR_FAILURE;
     }
 
     // XXX aPreviousResult shouldn't ever be a historyResult type, since we're
     // not letting satchel manage the field?
     mLastListener = aListener;
-    rv = mLoginManager->AutoCompleteSearchAsync(aSearchString, aPreviousResult,
-                                                mFocusedInput, this);
+    rv = mLoginManagerAC->StartSearch(aSearchString, aPreviousResult, mFocusedInput, this);
     NS_ENSURE_SUCCESS(rv, rv);
   } else {
     MOZ_LOG(sLogger, LogLevel::Debug, ("StartSearch: non-login field"));
     mLastListener = aListener;
 
     nsCOMPtr<nsIAutoCompleteResult> datalistResult;
     if (mFocusedInput) {
       rv = PerformInputListAutoComplete(aSearchString,
@@ -795,18 +794,18 @@ void nsFormFillController::RevalidateDat
 
 NS_IMETHODIMP
 nsFormFillController::StopSearch() {
   // Make sure to stop and clear this, otherwise the controller will prevent
   // mLastFormAutoComplete from being deleted.
   if (mLastFormAutoComplete) {
     mLastFormAutoComplete->StopAutoCompleteSearch();
     mLastFormAutoComplete = nullptr;
-  } else if (mLoginManager) {
-    mLoginManager->StopSearch();
+  } else if (mLoginManagerAC) {
+    mLoginManagerAC->StopSearch();
   }
   return NS_OK;
 }
 
 nsresult nsFormFillController::StartQueryLoginReputation(
     HTMLInputElement* aInput) {
   return NS_OK;
 }
--- a/toolkit/components/satchel/nsFormFillController.h
+++ b/toolkit/components/satchel/nsFormFillController.h
@@ -11,17 +11,17 @@
 #include "nsIAutoCompleteSearch.h"
 #include "nsIAutoCompleteController.h"
 #include "nsIAutoCompletePopup.h"
 #include "nsIFormAutoComplete.h"
 #include "nsIDOMEventListener.h"
 #include "nsCOMPtr.h"
 #include "nsDataHashtable.h"
 #include "nsIDocShell.h"
-#include "nsILoginManager.h"
+#include "nsILoginAutoCompleteSearch.h"
 #include "nsIMutationObserver.h"
 #include "nsTArray.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsILoginReputation.h"
 
 // X.h defines KeyPress
 #ifdef KeyPress
 #  undef KeyPress
@@ -105,17 +105,17 @@ class nsFormFillController final : publi
 
   bool IsTextControl(nsINode* aNode);
 
   nsresult StartQueryLoginReputation(mozilla::dom::HTMLInputElement* aInput);
 
   // members //////////////////////////////////////////
 
   nsCOMPtr<nsIAutoCompleteController> mController;
-  nsCOMPtr<nsILoginManager> mLoginManager;
+  nsCOMPtr<nsILoginAutoCompleteSearch> mLoginManagerAC;
   nsCOMPtr<nsILoginReputationService> mLoginReputationService;
   mozilla::dom::HTMLInputElement* mFocusedInput;
 
   // mListNode is a <datalist> element which, is set, has the form fill
   // controller as a mutation observer for it.
   nsINode* mListNode;
   nsCOMPtr<nsIAutoCompletePopup> mFocusedPopup;