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

Side by Side Diff: chrome/browser/password_manager/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: deletion is working Created 6 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/password_manager/password_manager.h" 5 #include "chrome/browser/password_manager/password_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "chrome/browser/password_manager/password_form_manager.h" 14 #include "chrome/browser/password_manager/password_form_manager.h"
15 #include "chrome/browser/password_manager/password_manager_delegate.h" 15 #include "chrome/browser/password_manager/password_manager_delegate.h"
16 #include "chrome/browser/password_manager/password_manager_metrics_util.h" 16 #include "chrome/browser/password_manager/password_manager_metrics_util.h"
17 #include "chrome/browser/password_manager/password_store.h"
18 #include "chrome/browser/password_manager/password_store_factory.h"
17 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" 20 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h"
19 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/chrome_version_info.h" 22 #include "chrome/common/chrome_version_info.h"
21 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
22 #include "components/autofill/core/common/autofill_messages.h" 24 #include "components/autofill/core/common/autofill_messages.h"
23 #include "components/user_prefs/pref_registry_syncable.h" 25 #include "components/user_prefs/pref_registry_syncable.h"
24 #include "content/public/browser/navigation_details.h" 26 #include "content/public/browser/navigation_details.h"
25 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 258
257 bool PasswordManager::OnMessageReceived(const IPC::Message& message) { 259 bool PasswordManager::OnMessageReceived(const IPC::Message& message) {
258 bool handled = true; 260 bool handled = true;
259 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) 261 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message)
260 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed, 262 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed,
261 OnPasswordFormsParsed) 263 OnPasswordFormsParsed)
262 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, 264 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered,
263 OnPasswordFormsRendered) 265 OnPasswordFormsRendered)
264 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, 266 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted,
265 OnPasswordFormSubmitted) 267 OnPasswordFormSubmitted)
268 IPC_MESSAGE_HANDLER(AutofillHostMsg_RemovePasswordSuggestion,
269 OnRemovePasswordSuggestion)
266 IPC_MESSAGE_UNHANDLED(handled = false) 270 IPC_MESSAGE_UNHANDLED(handled = false)
267 IPC_END_MESSAGE_MAP() 271 IPC_END_MESSAGE_MAP()
268 return handled; 272 return handled;
269 } 273 }
270 274
271 void PasswordManager::OnPasswordFormSubmitted( 275 void PasswordManager::OnPasswordFormSubmitted(
272 const PasswordForm& password_form) { 276 const PasswordForm& password_form) {
273 ProvisionallySavePassword(password_form); 277 ProvisionallySavePassword(password_form);
274 for (size_t i = 0; i < submission_callbacks_.size(); ++i) { 278 for (size_t i = 0; i < submission_callbacks_.size(); ++i) {
275 submission_callbacks_[i].Run(password_form); 279 submission_callbacks_[i].Run(password_form);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } else { 349 } else {
346 delegate_->AddSavePasswordInfoBarIfPermitted( 350 delegate_->AddSavePasswordInfoBarIfPermitted(
347 provisional_save_manager_.release()); 351 provisional_save_manager_.release());
348 } 352 }
349 } else { 353 } else {
350 provisional_save_manager_->Save(); 354 provisional_save_manager_->Save();
351 provisional_save_manager_.reset(); 355 provisional_save_manager_.reset();
352 } 356 }
353 } 357 }
354 358
359 void PasswordManager::OnRemovePasswordSuggestion(
360 const PasswordForm& password_form) {
361 scoped_refptr<PasswordStore> password_store =
362 PasswordStoreFactory::GetForProfile(delegate_->GetProfile(),
363 Profile::EXPLICIT_ACCESS);
vabr (Chromium) 2014/02/05 20:34:20 nit: Add a comment that we use EXPLICIT_ACCESS bec
364
365 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
366 ManagePasswordsBubbleUIController::FromWebContents(web_contents());
367 if (manage_passwords_bubble_ui_controller)
368 manage_passwords_bubble_ui_controller->RemoveFromBestMatches(password_form);
369 password_store->RemoveLogin(password_form);
370 }
371
355 void PasswordManager::PossiblyInitializeUsernamesExperiment( 372 void PasswordManager::PossiblyInitializeUsernamesExperiment(
356 const PasswordFormMap& best_matches) const { 373 const PasswordFormMap& best_matches) const {
357 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) 374 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment))
358 return; 375 return;
359 376
360 bool other_possible_usernames_exist = false; 377 bool other_possible_usernames_exist = false;
361 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); 378 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin();
362 it != best_matches.end(); ++it) { 379 it != best_matches.end(); ++it) {
363 if (!it->second->other_possible_usernames.empty()) { 380 if (!it->second->other_possible_usernames.empty()) {
364 other_possible_usernames_exist = true; 381 other_possible_usernames_exist = true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 441 }
425 442
426 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = 443 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
427 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); 444 ManagePasswordsBubbleUIController::FromWebContents(web_contents());
428 if (manage_passwords_bubble_ui_controller && 445 if (manage_passwords_bubble_ui_controller &&
429 CommandLine::ForCurrentProcess()->HasSwitch( 446 CommandLine::ForCurrentProcess()->HasSwitch(
430 switches::kEnableSavePasswordBubble)) { 447 switches::kEnableSavePasswordBubble)) {
431 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); 448 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches);
432 } 449 }
433 } 450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698