| Index: components/password_manager/core/browser/password_manager.cc
|
| diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc
|
| index 16ba3f4c78134008e21ea486775a7d0992c3d763..022b3bc504c4368cd286da5ee6d2e403518567af 100644
|
| --- a/components/password_manager/core/browser/password_manager.cc
|
| +++ b/components/password_manager/core/browser/password_manager.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/platform_thread.h"
|
| +#include "components/autofill/core/browser/autofill_manager.h"
|
| #include "components/autofill/core/common/password_autofill_util.h"
|
| #include "components/password_manager/core/browser/password_form_manager.h"
|
| #include "components/password_manager/core/browser/password_manager_client.h"
|
| @@ -257,13 +258,59 @@ void PasswordManager::OnPasswordFormsParsed(
|
| this, client_, driver_, *iter, ssl_valid);
|
| pending_login_managers_.push_back(manager);
|
|
|
| - // Avoid prompting the user for access to a password if they don't have
|
| - // password saving enabled.
|
| - PasswordStore::AuthorizationPromptPolicy prompt_policy =
|
| - *password_manager_enabled_ ? PasswordStore::ALLOW_PROMPT
|
| - : PasswordStore::DISALLOW_PROMPT;
|
| + manager->FetchMatchingLoginsFromPasswordStore(GetPromptPolicy());
|
| + }
|
| +}
|
| +
|
| +void PasswordManager::OnRemoveSavedPasswordAndUpdateManagers(
|
| + PasswordForm password_form) {
|
| + PasswordStore* password_store = client_->GetPasswordStore();
|
| + if (!password_store) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
|
|
| - manager->FetchMatchingLoginsFromPasswordStore(prompt_policy);
|
| + password_form.username_value =
|
| + driver_->GetAutofillManager()->username_to_remove();
|
| +
|
| + // The |passwordform| doesn't have to much exactly the PasswordForm that is
|
| + // in the store. But both of them need to have the same username. Because
|
| + // an exact copy is needed to perform a deletion from the password store, and
|
| + // because every PasswordFormManager holds a copy of all the PasswordForms,
|
| + // this copy could be used in the deletion process.
|
| +
|
| + bool removed = false;
|
| + for (ScopedVector<PasswordFormManager>::iterator iter =
|
| + pending_login_managers_.begin();
|
| + iter != pending_login_managers_.end();
|
| + ++iter) {
|
| + // A PasswordFormManager that manages the |passwordform| AND where that
|
| + // has a PasswordForm with the key |password_form.username_value| in its
|
| + // best_matches_ needs to be find to get the PasswordForm we're looking
|
| + // for.
|
| + if ((*iter)->DoesManage(password_form,
|
| + PasswordFormManager::ACTION_MATCH_REQUIRED)) {
|
| + PasswordFormMap best_matches = (*iter)->best_matches();
|
| + PasswordFormMap::iterator match =
|
| + best_matches.find(password_form.username_value);
|
| + if (match != best_matches.end()) {
|
| + password_store->RemoveLogin(*(match->second));
|
| + removed = true;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| +
|
| + if (!removed) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| +
|
| + for (ScopedVector<PasswordFormManager>::iterator iter =
|
| + pending_login_managers_.begin();
|
| + iter != pending_login_managers_.end();
|
| + ++iter) {
|
| + (*iter)->Update(GetPromptPolicy());
|
| }
|
| }
|
|
|
| @@ -390,3 +437,8 @@ void PasswordManager::Autofill(
|
|
|
| client_->PasswordWasAutofilled(best_matches);
|
| }
|
| +
|
| +PasswordStore::AuthorizationPromptPolicy PasswordManager::GetPromptPolicy() {
|
| + return *password_manager_enabled_ ? PasswordStore::ALLOW_PROMPT
|
| + : PasswordStore::DISALLOW_PROMPT;
|
| +}
|
|
|