Chromium Code Reviews| Index: chrome/browser/password_manager/password_form_manager.cc |
| diff --git a/chrome/browser/password_manager/password_form_manager.cc b/chrome/browser/password_manager/password_form_manager.cc |
| index dd904cf7a61a884ef80945c96c8ae7eb122127df..05f24913ec3770916664988d9ba3e38c782c3886 100644 |
| --- a/chrome/browser/password_manager/password_form_manager.cc |
| +++ b/chrome/browser/password_manager/password_form_manager.cc |
| @@ -35,6 +35,7 @@ PasswordFormManager::PasswordFormManager(Profile* profile, |
| observed_form_(observed_form), |
| is_new_login_(true), |
| has_generated_password_(false), |
| + remover_(false), |
| password_manager_(password_manager), |
| preferred_match_(NULL), |
| state_(PRE_MATCHING_PHASE), |
| @@ -109,6 +110,24 @@ bool PasswordFormManager::DoesManage(const PasswordForm& form, |
| return true; |
| } |
| +void PasswordFormManager::RemoveAndUpdate(const string16& username_to_remove) { |
|
vabr (Chromium)
2014/03/07 23:43:36
This is duplicated code: RemoveAndUpdate and Updat
riadh.chtara
2014/03/14 17:16:08
Done.
|
| + remover_ = true; |
| + only_update_ = false; |
| + username_to_remove_ = username_to_remove; |
| + |
| + state_ = PRE_MATCHING_PHASE; |
| + FetchMatchingLoginsFromPasswordStore(); |
| +} |
| + |
| +void PasswordFormManager::Update(const string16& username_to_remove) { |
| + remover_ = true; |
| + only_update_ = true; |
| + username_to_remove_ = username_to_remove; |
| + |
| + state_ = PRE_MATCHING_PHASE; |
| + FetchMatchingLoginsFromPasswordStore(); |
| +} |
| + |
| bool PasswordFormManager::IsBlacklisted() { |
| DCHECK_EQ(state_, POST_MATCHING_PHASE); |
| if (preferred_match_ && preferred_match_->blacklisted_by_user) |
| @@ -263,7 +282,9 @@ void PasswordFormManager::FetchMatchingLoginsFromPasswordStore() { |
| NOTREACHED(); |
| return; |
| } |
| - password_store->GetLogins(observed_form_, this); |
| + PasswordForm f = observed_form_; |
|
vabr (Chromium)
2014/03/07 23:43:36
Could you please explain to me why do we need to d
riadh.chtara
2014/03/14 18:06:18
I thought that using GetLogins with a PasswordForm
|
| + f.username_value = string16(); |
| + password_store->GetLogins(f, this); |
| } |
| bool PasswordFormManager::HasCompletedMatching() { |
| @@ -382,8 +403,37 @@ void PasswordFormManager::OnRequestDone( |
| manager_action_ = kManagerActionNone; |
| else |
| manager_action_ = kManagerActionAutofilled; |
| - password_manager_->Autofill(observed_form_, best_matches_, |
| - *preferred_match_, wait_for_username); |
| + |
| + if (!remover_) { |
| + password_manager_->Autofill( |
| + observed_form_, best_matches_, *preferred_match_, wait_for_username); |
| + } else { |
| + remover_ = false; |
| + PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
| + profile_, Profile::EXPLICIT_ACCESS).get(); |
| + if (!password_store) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + PasswordFormMap::iterator it = best_matches_.find(username_to_remove_); |
| + |
| + if (it != best_matches_.end()) { |
| + if (!only_update_) |
| + 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); |
| + } |
| + |
| + } |
| + |
| + } |
| } |
| void PasswordFormManager::OnPasswordStoreRequestDone( |