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" | 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 Loading... | |
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 Loading... | |
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( | |
363 delegate_->GetProfile(), Profile::EXPLICIT_ACCESS); | |
364 password_store.get()->RemoveLogin(password_form); | |
vabr (Chromium)
2014/01/13 14:46:29
You don't need .get() when using the operator -> .
riadh.chtara
2014/01/13 20:34:10
Done.
vabr (Chromium)
2014/01/14 14:11:02
Does not seem done -- there is still the ".get()"
| |
365 } | |
366 | |
355 void PasswordManager::PossiblyInitializeUsernamesExperiment( | 367 void PasswordManager::PossiblyInitializeUsernamesExperiment( |
356 const PasswordFormMap& best_matches) const { | 368 const PasswordFormMap& best_matches) const { |
357 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) | 369 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) |
358 return; | 370 return; |
359 | 371 |
360 bool other_possible_usernames_exist = false; | 372 bool other_possible_usernames_exist = false; |
361 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); | 373 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); |
362 it != best_matches.end(); ++it) { | 374 it != best_matches.end(); ++it) { |
363 if (!it->second->other_possible_usernames.empty()) { | 375 if (!it->second->other_possible_usernames.empty()) { |
364 other_possible_usernames_exist = true; | 376 other_possible_usernames_exist = true; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 } | 436 } |
425 | 437 |
426 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = | 438 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = |
427 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); | 439 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); |
428 if (manage_passwords_bubble_ui_controller && | 440 if (manage_passwords_bubble_ui_controller && |
429 CommandLine::ForCurrentProcess()->HasSwitch( | 441 CommandLine::ForCurrentProcess()->HasSwitch( |
430 switches::kEnableSavePasswordBubble)) { | 442 switches::kEnableSavePasswordBubble)) { |
431 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); | 443 manage_passwords_bubble_ui_controller->OnPasswordAutofilled(best_matches); |
432 } | 444 } |
433 } | 445 } |
OLD | NEW |