Chromium Code Reviews| 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 8ce07fadb38eec39d1fbf6a35f29084be853d1f7..9d3f9b97c03c34ef151570232fca3701046fef57 100644 |
| --- a/components/password_manager/core/browser/password_form_manager.cc |
| +++ b/components/password_manager/core/browser/password_form_manager.cc |
| @@ -136,6 +136,17 @@ bool PasswordFormManager::DoesManage(const PasswordForm& form, |
| return true; |
| } |
| +void PasswordFormManager::Update( |
| + const base::string16& username_to_remove, |
| + const PasswordStore::AuthorizationPromptPolicy& prompt_policy, |
| + bool remove_candidate_from_store) { |
|
vabr (Chromium)
2014/04/04 10:51:40
I suggest not taking care of removing the candidat
|
| + username_to_remove_ = username_to_remove; |
| + remove_candidate_from_store_ = remove_candidate_from_store; |
| + |
| + state_ = PRE_MATCHING_PHASE; |
| + FetchMatchingLoginsFromPasswordStore(prompt_policy); |
| +} |
| + |
| bool PasswordFormManager::IsBlacklisted() { |
| DCHECK_EQ(state_, POST_MATCHING_PHASE); |
| if (preferred_match_ && preferred_match_->blacklisted_by_user) |
| @@ -428,8 +439,35 @@ void PasswordFormManager::OnRequestDone( |
| manager_action_ = kManagerActionNone; |
| else |
| manager_action_ = kManagerActionAutofilled; |
| - password_manager_->Autofill(observed_form_, best_matches_, |
| - *preferred_match_, wait_for_username); |
| + |
| + if (username_to_remove_.size() == 0) { |
|
vabr (Chromium)
2014/04/04 10:51:40
Let's revert changes to this method completely. If
|
| + password_manager_->Autofill( |
| + observed_form_, best_matches_, *preferred_match_, wait_for_username); |
| + } else { |
| + PasswordStore* password_store = client_->GetPasswordStore(); |
| + if (!password_store) { |
| + username_to_remove_.clear(); |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + PasswordFormMap::iterator it = best_matches_.find(username_to_remove_); |
| + |
| + if (it != best_matches_.end()) { |
| + if (remove_candidate_from_store_) |
| + password_store->RemoveLogin(*(it->second)); |
| + |
| + best_matches_.erase(it); |
| + if (best_matches_.size() > 0) { |
| + preferred_match_ = best_matches_.begin()->second; |
| + password_manager_->Autofill(observed_form_, |
| + best_matches_, |
| + *preferred_match_, |
| + wait_for_username); |
| + } |
| + } |
| + username_to_remove_.clear(); |
| + } |
| } |
| void PasswordFormManager::OnGetPasswordStoreResults( |