Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Unified Diff: components/password_manager/core/browser/password_manager.cc

Issue 223133003: Allow deleting autofill password suggestions on Shift+Delete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug fixed Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7ed5ba1cc0bc9d7f1b9a187c3380b3a707d42a4c 100644
--- a/components/password_manager/core/browser/password_manager.cc
+++ b/components/password_manager/core/browser/password_manager.cc
@@ -257,13 +257,56 @@ 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(
+ const PasswordForm& password_form) {
+ PasswordStore* password_store = client_->GetPasswordStore();
+ if (!password_store) {
+ NOTREACHED();
+ return;
+ }
+
+ // 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.
- manager->FetchMatchingLoginsFromPasswordStore(prompt_policy);
+ 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 +433,8 @@ void PasswordManager::Autofill(
client_->PasswordWasAutofilled(best_matches);
}
+
+PasswordStore::AuthorizationPromptPolicy PasswordManager::GetPromptPolicy() {
+ return *password_manager_enabled_ ? PasswordStore::ALLOW_PROMPT
+ : PasswordStore::DISALLOW_PROMPT;
+}

Powered by Google App Engine
This is Rietveld 408576698