Index: components/password_manager/core/browser/password_form_manager.cc |
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc |
index dc4bf9ac1965a9ce0989811744b23cffc140d326..33a032a0fb18f1a021e85006bae0c6ccd6e1a5d4 100644 |
--- a/components/password_manager/core/browser/password_form_manager.cc |
+++ b/components/password_manager/core/browser/password_form_manager.cc |
@@ -159,7 +159,11 @@ PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage( |
result |= RESULT_ORIGINS_MATCH; |
- if (form.username_element == observed_form_.username_element && |
+ // Autofill predictions can overwrite our default username selection so |
+ // if this form was parsed with autofill predictions then allow the username |
+ // element to be different. |
+ if ((form.parsed_using_autofill_predictions || |
+ form.username_element == observed_form_.username_element) && |
form.password_element == observed_form_.password_element) { |
result |= RESULT_HTML_ATTRIBUTES_MATCH; |
} |
@@ -335,6 +339,8 @@ void PasswordFormManager::ProvisionallySave( |
// User typed in a new, unknown username. |
user_action_ = kUserActionOverrideUsernameAndPassword; |
pending_credentials_ = observed_form_; |
+ if (credentials.parsed_using_autofill_predictions) |
+ pending_credentials_.username_element = credentials.username_element; |
pending_credentials_.username_value = credentials.username_value; |
pending_credentials_.other_possible_usernames = |
credentials.other_possible_usernames; |