Chromium Code Reviews| Index: components/autofill/content/renderer/password_form_conversion_utils.cc |
| diff --git a/components/autofill/content/renderer/password_form_conversion_utils.cc b/components/autofill/content/renderer/password_form_conversion_utils.cc |
| index d32b9caef2f5a95d1c7ef7e25fb780f7d3bee1a2..3c22cc0c7b596ed3f921426802af4966c05a2901 100644 |
| --- a/components/autofill/content/renderer/password_form_conversion_utils.cc |
| +++ b/components/autofill/content/renderer/password_form_conversion_utils.cc |
| @@ -25,11 +25,11 @@ namespace { |
| // hands in the air and giving up with a given form. |
| static const size_t kMaxPasswords = 3; |
| -// Helper to determine which password is the main one, and which is |
| -// an old password (e.g on a "make new password" form), if any. |
| +// Helper to determine which password is the main one, and which is the new |
|
Ilya Sherman
2014/07/01 03:08:47
Hmm, it's not entirely clear what a "main" passwor
engedy
2014/07/03 13:34:19
Done.
|
| +// password (e.g., on a sign-up or change password form), if any. |
| bool LocateSpecificPasswords(std::vector<WebInputElement> passwords, |
| WebInputElement* password, |
| - WebInputElement* old_password) { |
| + WebInputElement* new_password) { |
| switch (passwords.size()) { |
| case 1: |
| // Single password, easy. |
| @@ -37,12 +37,14 @@ bool LocateSpecificPasswords(std::vector<WebInputElement> passwords, |
| break; |
| case 2: |
| if (passwords[0].value() == passwords[1].value()) { |
| - // Treat two identical passwords as a single password. |
| - *password = passwords[0]; |
| + // Two identical passwords: assume we are seeing a new password with a |
|
vabr (Chromium)
2014/06/30 10:07:20
Did you consider what happens when the values are
engedy
2014/07/03 13:34:19
We have discussed this with Vaclav to great length
vabr (Chromium)
2014/07/03 14:42:56
Thinking about (2) from a bigger distance, I think
engedy
2014/07/03 18:47:36
Done.
|
| + // confirmation. This can be either a sign-up form or a password change |
| + // form that does not ask for the old password. |
| + *new_password = passwords[0]; |
| } else { |
| // Assume first is old password, second is new (no choice but to guess). |
| - *old_password = passwords[0]; |
| - *password = passwords[1]; |
| + *password = passwords[0]; |
| + *new_password = passwords[1]; |
| } |
| break; |
| case 3: |
| @@ -51,12 +53,14 @@ bool LocateSpecificPasswords(std::vector<WebInputElement> passwords, |
| // All three passwords the same? Just treat as one and hope. |
| *password = passwords[0]; |
| } else if (passwords[0].value() == passwords[1].value()) { |
| - // Two the same and one different -> old password is duplicated one. |
| - *old_password = passwords[0]; |
| + // Strange that the new password comes first, but trust more in that the |
| + // field is duplicated more rather than in the ordering of fields. |
|
vabr (Chromium)
2014/06/30 10:07:20
(typo?) second "more"
engedy
2014/07/03 13:34:19
Done.
|
| *password = passwords[2]; |
| + *new_password = passwords[0]; |
| } else if (passwords[1].value() == passwords[2].value()) { |
| - *old_password = passwords[0]; |
| - *password = passwords[1]; |
| + // New password is the duplicated one, and comes second. Makes sense. |
| + *password = passwords[0]; |
| + *new_password = passwords[1]; |
| } else { |
| // Three different passwords, or first and last match with middle |
| // different. No idea which is which, so no luck. |
| @@ -69,8 +73,7 @@ bool LocateSpecificPasswords(std::vector<WebInputElement> passwords, |
| return true; |
| } |
| -// Get information about a login form that encapsulated in the |
| -// PasswordForm struct. |
| +// Get information about a login form encapsulated in a PasswordForm struct. |
| void GetPasswordForm(const WebFormElement& form, PasswordForm* password_form) { |
| WebInputElement latest_input_element; |
| std::vector<WebInputElement> passwords; |
| @@ -127,8 +130,8 @@ void GetPasswordForm(const WebFormElement& form, PasswordForm* password_form) { |
| return; |
| WebInputElement password; |
| - WebInputElement old_password; |
| - if (!LocateSpecificPasswords(passwords, &password, &old_password)) |
| + WebInputElement new_password; |
| + if (!LocateSpecificPasswords(passwords, &password, &new_password)) |
| return; |
| // We want to keep the path but strip any authentication data, as well as |
| @@ -151,9 +154,9 @@ void GetPasswordForm(const WebFormElement& form, PasswordForm* password_form) { |
| password_form->password_value = password.value(); |
| password_form->password_autocomplete_set = password.autoComplete(); |
| } |
| - if (!old_password.isNull()) { |
| - password_form->old_password_element = old_password.nameForAutofill(); |
| - password_form->old_password_value = old_password.value(); |
| + if (!new_password.isNull()) { |
| + password_form->new_password_element = new_password.nameForAutofill(); |
| + password_form->new_password_value = new_password.value(); |
| } |
| password_form->scheme = PasswordForm::SCHEME_HTML; |