| 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 7dfd664f25c5bd1513d6ec0d8714855da07fc1f1..a68f1ec52edf2025a3084eba7b409e4a0a32f96f 100644
|
| --- a/components/password_manager/core/browser/password_form_manager.cc
|
| +++ b/components/password_manager/core/browser/password_form_manager.cc
|
| @@ -289,9 +289,10 @@ void PasswordFormManager::Save() {
|
| LogPasswordGenerationSubmissionEvent(PASSWORD_USED);
|
| }
|
|
|
| - if (IsNewLogin())
|
| + if (IsNewLogin()) {
|
| SaveAsNewLogin(true);
|
| - else
|
| + DeleteEmptyUsernameCredentials();
|
| + } else
|
| UpdateLogin();
|
| }
|
|
|
| @@ -996,6 +997,22 @@ int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
|
| return score;
|
| }
|
|
|
| +void PasswordFormManager::DeleteEmptyUsernameCredentials() {
|
| + if (best_matches_.empty() || pending_credentials_.username_value.empty())
|
| + return;
|
| + PasswordStore* password_store = client_->GetPasswordStore();
|
| + if (!password_store) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + for (auto iter = best_matches_.begin(); iter != best_matches_.end(); ++iter) {
|
| + PasswordForm* form = iter->second;
|
| + if (!form->IsPublicSuffixMatch() && form->username_value.empty() &&
|
| + form->password_value == pending_credentials_.password_value)
|
| + password_store->RemoveLogin(*form);
|
| + }
|
| +}
|
| +
|
| PasswordForm* PasswordFormManager::FindBestMatchForUpdatePassword(
|
| const base::string16& password) const {
|
| if (best_matches_.size() == 1) {
|
|
|