Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
|
vabr (Chromium)
2014/01/10 18:40:00
Don't remove this header, it declares, e.g., Platf
| |
| 14 #include "chrome/browser/password_manager/password_form_manager.h" | 13 #include "chrome/browser/password_manager/password_form_manager.h" |
| 15 #include "chrome/browser/password_manager/password_manager_delegate.h" | 14 #include "chrome/browser/password_manager/password_manager_delegate.h" |
| 16 #include "chrome/browser/password_manager/password_manager_metrics_util.h" | 15 #include "chrome/browser/password_manager/password_manager_metrics_util.h" |
| 16 #include "chrome/browser/password_manager/password_store.h" | |
| 17 #include "chrome/browser/password_manager/password_store_factory.h" | |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 19 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "components/autofill/core/common/autofill_messages.h" | 23 #include "components/autofill/core/common/autofill_messages.h" |
| 23 #include "components/user_prefs/pref_registry_syncable.h" | 24 #include "components/user_prefs/pref_registry_syncable.h" |
| 24 #include "content/public/browser/navigation_details.h" | 25 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
| 26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 257 |
| 257 bool PasswordManager::OnMessageReceived(const IPC::Message& message) { | 258 bool PasswordManager::OnMessageReceived(const IPC::Message& message) { |
| 258 bool handled = true; | 259 bool handled = true; |
| 259 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) | 260 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) |
| 260 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed, | 261 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed, |
| 261 OnPasswordFormsParsed) | 262 OnPasswordFormsParsed) |
| 262 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, | 263 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered, |
| 263 OnPasswordFormsRendered) | 264 OnPasswordFormsRendered) |
| 264 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, | 265 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted, |
| 265 OnPasswordFormSubmitted) | 266 OnPasswordFormSubmitted) |
| 267 IPC_MESSAGE_HANDLER(AutofillHostMsg_RemovePasswordSuggestion, | |
| 268 OnRemovePasswordSuggestion) | |
| 266 IPC_MESSAGE_UNHANDLED(handled = false) | 269 IPC_MESSAGE_UNHANDLED(handled = false) |
| 267 IPC_END_MESSAGE_MAP() | 270 IPC_END_MESSAGE_MAP() |
| 268 return handled; | 271 return handled; |
| 269 } | 272 } |
| 270 | 273 |
| 271 void PasswordManager::OnPasswordFormSubmitted( | 274 void PasswordManager::OnPasswordFormSubmitted( |
| 272 const PasswordForm& password_form) { | 275 const PasswordForm& password_form) { |
| 273 ProvisionallySavePassword(password_form); | 276 ProvisionallySavePassword(password_form); |
| 274 for (size_t i = 0; i < submission_callbacks_.size(); ++i) { | 277 for (size_t i = 0; i < submission_callbacks_.size(); ++i) { |
| 275 submission_callbacks_[i].Run(password_form); | 278 submission_callbacks_[i].Run(password_form); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 } else { | 348 } else { |
| 346 delegate_->AddSavePasswordInfoBarIfPermitted( | 349 delegate_->AddSavePasswordInfoBarIfPermitted( |
| 347 provisional_save_manager_.release()); | 350 provisional_save_manager_.release()); |
| 348 } | 351 } |
| 349 } else { | 352 } else { |
| 350 provisional_save_manager_->Save(); | 353 provisional_save_manager_->Save(); |
| 351 provisional_save_manager_.reset(); | 354 provisional_save_manager_.reset(); |
| 352 } | 355 } |
| 353 } | 356 } |
| 354 | 357 |
| 358 void PasswordManager::OnRemovePasswordSuggestion( | |
| 359 const PasswordForm& password_form) { | |
|
vabr (Chromium)
2014/01/10 18:40:00
"const PasswordForm&" does not match the argument
| |
| 360 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( | |
|
vabr (Chromium)
2014/01/10 18:40:00
Please either make password_store a scoped_refptr<
| |
| 361 delegate_->GetProfile(), Profile::EXPLICIT_ACCESS).get(); | |
| 362 password_store->RemoveLogin(password_form) | |
| 363 | |
|
vabr (Chromium)
2014/01/10 18:40:00
nit: Please remove this empty line.
| |
| 364 } | |
| 365 | |
| 355 void PasswordManager::PossiblyInitializeUsernamesExperiment( | 366 void PasswordManager::PossiblyInitializeUsernamesExperiment( |
| 356 const PasswordFormMap& best_matches) const { | 367 const PasswordFormMap& best_matches) const { |
| 357 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) | 368 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) |
| 358 return; | 369 return; |
| 359 | 370 |
| 360 bool other_possible_usernames_exist = false; | 371 bool other_possible_usernames_exist = false; |
| 361 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); | 372 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); |
| 362 it != best_matches.end(); ++it) { | 373 it != best_matches.end(); ++it) { |
| 363 if (!it->second->other_possible_usernames.empty()) { | 374 if (!it->second->other_possible_usernames.empty()) { |
| 364 other_possible_usernames_exist = true; | 375 other_possible_usernames_exist = true; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 } | 435 } |
| 425 | 436 |
| 426 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = | 437 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = |
| 427 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); | 438 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); |
| 428 if (manage_passwords_bubble_ui_controller && | 439 if (manage_passwords_bubble_ui_controller && |
| 429 CommandLine::ForCurrentProcess()->HasSwitch( | 440 CommandLine::ForCurrentProcess()->HasSwitch( |
| 430 switches::kEnableSavePasswordBubble)) { | 441 switches::kEnableSavePasswordBubble)) { |
| 431 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); | 442 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); |
| 432 } | 443 } |
| 433 } | 444 } |
| OLD | NEW |