| 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/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 15 #include "chrome/browser/password_manager/password_form_manager.h" | 15 #include "chrome/browser/password_manager/password_form_manager.h" |
| 16 #include "chrome/browser/password_manager/password_manager_delegate.h" | 16 #include "chrome/browser/password_manager/password_manager_delegate.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "components/autofill/core/common/autofill_messages.h" | 21 #include "components/autofill/core/common/autofill_messages.h" |
| 22 #include "components/user_prefs/pref_registry_syncable.h" | 22 #include "components/user_prefs/pref_registry_syncable.h" |
| 23 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
| 24 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/common/frame_navigate_params.h" | 26 #include "content/public/common/frame_navigate_params.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 | 28 |
| 29 using autofill::PasswordForm; |
| 30 using autofill::PasswordFormMap; |
| 29 using content::UserMetricsAction; | 31 using content::UserMetricsAction; |
| 30 using content::WebContents; | 32 using content::WebContents; |
| 31 using content::PasswordForm; | |
| 32 using content::PasswordFormMap; | |
| 33 | 33 |
| 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PasswordManager); | 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PasswordManager); |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 const char kSpdyProxyRealm[] = "/SpdyProxy"; | 38 const char kSpdyProxyRealm[] = "/SpdyProxy"; |
| 39 const char kOtherPossibleUsernamesExperiment[] = | 39 const char kOtherPossibleUsernamesExperiment[] = |
| 40 "PasswordManagerOtherPossibleUsernames"; | 40 "PasswordManagerOtherPossibleUsernames"; |
| 41 | 41 |
| 42 // This routine is called when PasswordManagers are constructed. | 42 // This routine is called when PasswordManagers are constructed. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 provisional_save_manager_.reset(); | 351 provisional_save_manager_.reset(); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 void PasswordManager::PossiblyInitializeUsernamesExperiment( | 355 void PasswordManager::PossiblyInitializeUsernamesExperiment( |
| 356 const PasswordFormMap& best_matches) const { | 356 const PasswordFormMap& best_matches) const { |
| 357 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) | 357 if (base::FieldTrialList::Find(kOtherPossibleUsernamesExperiment)) |
| 358 return; | 358 return; |
| 359 | 359 |
| 360 bool other_possible_usernames_exist = false; | 360 bool other_possible_usernames_exist = false; |
| 361 for (content::PasswordFormMap::const_iterator it = best_matches.begin(); | 361 for (autofill::PasswordFormMap::const_iterator it = best_matches.begin(); |
| 362 it != best_matches.end(); ++it) { | 362 it != best_matches.end(); ++it) { |
| 363 if (!it->second->other_possible_usernames.empty()) { | 363 if (!it->second->other_possible_usernames.empty()) { |
| 364 other_possible_usernames_exist = true; | 364 other_possible_usernames_exist = true; |
| 365 break; | 365 break; |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 if (!other_possible_usernames_exist) | 369 if (!other_possible_usernames_exist) |
| 370 return; | 370 return; |
| 371 | 371 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 return; | 415 return; |
| 416 } | 416 } |
| 417 default: | 417 default: |
| 418 FOR_EACH_OBSERVER( | 418 FOR_EACH_OBSERVER( |
| 419 LoginModelObserver, | 419 LoginModelObserver, |
| 420 observers_, | 420 observers_, |
| 421 OnAutofillDataAvailable(preferred_match.username_value, | 421 OnAutofillDataAvailable(preferred_match.username_value, |
| 422 preferred_match.password_value)); | 422 preferred_match.password_value)); |
| 423 } | 423 } |
| 424 } | 424 } |
| OLD | NEW |