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

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

Issue 133893004: Allow deleting autofill password suggestions on Shift+Delete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 6 years, 9 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 107ce1e8bed13772209c7acd4296619f58ebea77..527953ed2d2819fef52b45de78482e8fef1d238a 100644
--- a/components/password_manager/core/browser/password_manager.cc
+++ b/components/password_manager/core/browser/password_manager.cc
@@ -267,6 +267,65 @@ void PasswordManager::OnPasswordFormsParsed(
}
}
+void PasswordManager::OnRemovePasswordSuggestion(
+ const PasswordForm& password_form,
+ std::vector<PasswordForm> updated_password_forms) {
+
+ // Deleting the PasswordFormManager for the current |password_form| to avoid
+ // that we have two PasswordFormManager for it:
+ // AutofillHostMsg_PasswordFormsParsed is going to be received in the near
+ // future to update the current form and this is going to generate a new
+ // PasswordFormManager.
+
+ // 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;
+ std::vector<PasswordFormManager*> not_yet_updated;
+ bool removed = false;
+ for (ScopedVector<PasswordFormManager>::iterator iter =
+ pending_login_managers_.begin();
+ iter != pending_login_managers_.end();
+ ++iter) {
+
+ if ((*iter)->DoesManage(password_form,
+ PasswordFormManager::ACTION_MATCH_REQUIRED)) {
+ if (!removed) {
+ (*iter)->Update(password_form.username_value, prompt_policy, true);
+ removed = true;
+ } else {
+ (*iter)->Update(password_form.username_value, prompt_policy, false);
+ }
+ } else {
+ not_yet_updated.push_back(*iter);
+ }
+ }
+
+ if (removed) {
+ std::set<PasswordForm*> already_updated;
+ for (std::vector<PasswordFormManager*>::iterator
+ form_manager_update_candidate = not_yet_updated.begin();
+ form_manager_update_candidate != not_yet_updated.end();
+ ++form_manager_update_candidate) {
+ for (std::vector<PasswordForm>::iterator form_update_condidate =
+ updated_password_forms.begin();
+ form_update_condidate != updated_password_forms.end();
+ ++form_update_condidate) {
+ if ((already_updated.find(&(*form_update_condidate)) ==
+ already_updated.end()) &&
+ ((*form_manager_update_candidate)
+ ->DoesManage(*form_update_condidate,
+ PasswordFormManager::ACTION_MATCH_REQUIRED))) {
+ (*form_manager_update_candidate)
+ ->Update(password_form.username_value, prompt_policy, false);
+ already_updated.insert(&(*form_update_condidate));
+ }
+ }
+ }
+ }
+}
+
bool PasswordManager::ShouldPromptUserToSavePassword() const {
return provisional_save_manager_->IsNewLogin() &&
!provisional_save_manager_->HasGeneratedPassword() &&

Powered by Google App Engine
This is Rietveld 408576698