Bug 1610353 - [2.0] Connect Gecko backend to GeckoView onLoginUsed API. r=MattN
authorEugen Sawin <esawin@mozilla.com>
Thu, 23 Jan 2020 20:03:47 +0000
changeset 511529 1152d253beb2046e3d829899d79ce5f00f9dfe64
parent 511528 d45cb482844208fa91c7f821bfe398c2def06592
child 511530 282778a58d0b3b676d77a56235259514e074d959
push id37049
push userrmaries@mozilla.com
push dateFri, 24 Jan 2020 03:50:24 +0000
treeherdermozilla-central@e05793f68994 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1610353
milestone74.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 1610353 - [2.0] Connect Gecko backend to GeckoView onLoginUsed API. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D60441
mobile/android/modules/geckoview/GeckoViewLoginStorage.jsm
toolkit/components/passwordmgr/storage-geckoview.js
--- a/mobile/android/modules/geckoview/GeckoViewLoginStorage.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewLoginStorage.jsm
@@ -110,25 +110,40 @@ const GeckoViewLoginStorage = {
     debug`fetchLogins for ${aDomain}`;
 
     return EventDispatcher.instance.sendRequestForResult({
       type: "GeckoView:LoginStorage:Fetch",
       domain: aDomain,
     });
   },
 
+  /**
+   * Delegates login entry saving to the attached LoginStorage GeckoView delegate.
+   * Call this when a new login entry or a new password for an existing login
+   * entry has been submitted.
+   *
+   * @param aLogin The {LoginEntry} to be saved.
+   */
   onLoginSave(aLogin) {
     debug`onLoginSave ${aLogin}`;
 
     EventDispatcher.instance.sendRequest({
       type: "GeckoView:LoginStorage:Save",
       login: aLogin,
     });
   },
 
+  /**
+   * Delegates login entry password usage to the attached LoginStorage GeckoView
+   * delegate.
+   * Call this when the password of an existing login entry, as returned by
+   * fetchLogins, has been used for autofill.
+   *
+   * @param aLogin The {LoginEntry} whose password was used.
+   */
   onLoginPasswordUsed(aLogin) {
     debug`onLoginUsed ${aLogin}`;
 
     EventDispatcher.instance.sendRequest({
       type: "GeckoView:LoginStorage:Used",
       usedFields: UsedField.PASSWORD,
       login: aLogin,
     });
--- a/toolkit/components/passwordmgr/storage-geckoview.js
+++ b/toolkit/components/passwordmgr/storage-geckoview.js
@@ -11,27 +11,21 @@
 const { XPCOMUtils } = ChromeUtils.import(
   "resource://gre/modules/XPCOMUtils.jsm"
 );
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const { LoginManagerStorage_json } = ChromeUtils.import(
   "resource://gre/modules/storage-json.js"
 );
 
-ChromeUtils.defineModuleGetter(
-  this,
-  "GeckoViewLoginStorage",
-  "resource://gre/modules/GeckoViewLoginStorage.jsm"
-);
-
-ChromeUtils.defineModuleGetter(
-  this,
-  "LoginHelper",
-  "resource://gre/modules/LoginHelper.jsm"
-);
+XPCOMUtils.defineLazyModuleGetters(this, {
+  GeckoViewLoginStorage: "resource://gre/modules/GeckoViewLoginStorage.jsm",
+  LoginHelper: "resource://gre/modules/LoginHelper.jsm",
+  LoginEntry: "resource://gre/modules/GeckoViewLoginStorage.jsm",
+});
 
 class LoginManagerStorage_geckoview extends LoginManagerStorage_json {
   get classID() {
     return Components.ID("{337f317f-f713-452a-962d-db831c785fec}");
   }
   get QueryInterface() {
     return ChromeUtils.generateQI([Ci.nsILoginManagerStorage]);
   }
@@ -74,17 +68,17 @@ class LoginManagerStorage_geckoview exte
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   }
 
   modifyLogin(oldLogin, newLoginData) {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   }
 
   recordPasswordUse(login) {
-    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
+    GeckoViewLoginStorage.onLoginPasswordUsed(LoginEntry.fromLoginInfo(login));
   }
 
   getAllLogins() {
     throw Cr.NS_ERROR_NOT_IMPLEMENTED;
   }
 
   /**
    * Returns an array of all saved logins that can be decrypted.