Bug 1646808 - Add inline docs for promptToSavePassword and _updateLogin. r=severin
authorSam Foster <sfoster@mozilla.com>
Thu, 18 Jun 2020 19:26:21 +0000
changeset 536399 becb8f58dec10bd062a712f5d1d5c3636d082581
parent 536398 ef81294f5db79b7f249fefe43a58e466ae36a272
child 536400 3401f250ac61fd3c0b4633f6dfb1f27b1c84b8c8
push id119434
push usersfoster@mozilla.com
push dateThu, 18 Jun 2020 20:32:56 +0000
treeherderautoland@becb8f58dec1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseverin
bugs1646808
milestone79.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 1646808 - Add inline docs for promptToSavePassword and _updateLogin. r=severin Differential Revision: https://phabricator.services.mozilla.com/D80230
toolkit/components/passwordmgr/LoginManagerParent.jsm
toolkit/components/passwordmgr/LoginManagerPrompter.jsm
--- a/toolkit/components/passwordmgr/LoginManagerParent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerParent.jsm
@@ -61,17 +61,17 @@ let gGeneratedPasswordsByPrincipalOrigin
  * @type LoginRecipesParent
  * @deprecated
  */
 let gRecipeManager = null;
 
 /**
  * Tracks the last time the user cancelled the master password prompt,
  *  to avoid spamming master password prompts on autocomplete searches.
- * TODO: Bug XXX - Should be `Number.NEGATIVE_INFINITY`.
+ * TODO: Bug 1646805 - Should be `Number.NEGATIVE_INFINITY`.
  */
 let gLastMPLoginCancelled = Math.NEGATIVE_INFINITY;
 
 let gGeneratedPasswordObserver = {
   addedObserver: false,
 
   observe(subject, topic, data) {
     if (topic == "last-pb-context-exited") {
--- a/toolkit/components/passwordmgr/LoginManagerPrompter.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerPrompter.jsm
@@ -67,16 +67,37 @@ class LoginManagerPrompter {
   get classID() {
     return Components.ID("{c47ff942-9678-44a5-bc9b-05e0d676c79c}");
   }
 
   get QueryInterface() {
     return ChromeUtils.generateQI([Ci.nsILoginManagerPrompter]);
   }
 
+  /**
+   * Called when we detect a password or username that is not yet saved as
+   * an existing login.
+   *
+   * @param {Element} aBrowser
+   *                  The browser element that the request came from.
+   * @param {nsILoginInfo} aLogin
+   *                       The new login from the page form.
+   * @param {boolean} [dismissed = false]
+   *                  If the prompt should be automatically dismissed on being shown.
+   * @param {boolean} [notifySaved = false]
+   *                  Whether the notification should indicate that a login has been saved
+   * @param {string} [autoSavedLoginGuid = ""]
+   *                 A guid value for the old login to be removed if the changes match it
+   *                 to a different login
+   * @param {object} possibleValues
+   *                 Contains values from anything that we think, but are not sure, might be
+   *                 a username or password.  Has two properties, 'usernames' and 'passwords'.
+   * @param {Set<String>} possibleValues.usernames
+   * @param {Set<String>} possibleValues.passwords
+   */
   promptToSavePassword(
     aBrowser,
     aLogin,
     dismissed = false,
     notifySaved = false,
     autoFilledLoginGuid = "",
     possibleValues = {
       usernames: new Set(),
@@ -760,16 +781,19 @@ class LoginManagerPrompter {
         aNewLogin.passwordField
       );
       LoginManagerPrompter._updateLogin(selectedLogin, newLoginWithUsername);
     }
   }
 
   /* ---------- Internal Methods ---------- */
 
+  /**
+   * Helper method to update and persist an existing nsILoginInfo object with new property values.
+   */
   static _updateLogin(login, aNewLogin) {
     var now = Date.now();
     var propBag = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
       Ci.nsIWritablePropertyBag
     );
     propBag.setProperty("formActionOrigin", aNewLogin.formActionOrigin);
     propBag.setProperty("origin", aNewLogin.origin);
     propBag.setProperty("password", aNewLogin.password);