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 "components/password_manager/core/browser/password_manager.h" | 5 #include "components/password_manager/core/browser/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" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const char kSpdyProxyRealm[] = "/SpdyProxy"; | 29 const char kSpdyProxyRealm[] = "/SpdyProxy"; |
| 30 | 30 |
| 31 // This routine is called when PasswordManagers are constructed. | 31 // This routine is called when PasswordManagers are constructed. |
| 32 // | 32 // |
| 33 // Currently we report metrics only once at startup. We require | 33 // Currently we report metrics only once at startup. We require |
| 34 // that this is only ever called from a single thread in order to | 34 // that this is only ever called from a single thread in order to |
| 35 // avoid needing to lock (a static boolean flag is then sufficient to | 35 // avoid needing to lock (a static boolean flag is then sufficient to |
| 36 // guarantee running only once). | 36 // guarantee running only once). |
| 37 void ReportMetrics(bool password_manager_enabled) { | 37 void ReportMetrics(bool password_manager_enabled, |
| 38 bool password_manager_enable_automatic_passwords_saving) { | |
|
vabr (Chromium)
2014/04/28 09:13:14
I don't think we need UMA metrics until we expose
rchtara
2014/04/28 11:28:29
Done.
| |
| 38 static base::PlatformThreadId initial_thread_id = | 39 static base::PlatformThreadId initial_thread_id = |
| 39 base::PlatformThread::CurrentId(); | 40 base::PlatformThread::CurrentId(); |
| 40 DCHECK(initial_thread_id == base::PlatformThread::CurrentId()); | 41 DCHECK(initial_thread_id == base::PlatformThread::CurrentId()); |
| 41 | 42 |
| 43 | |
|
vabr (Chromium)
2014/04/28 09:13:14
nit: Please remove this blank line.
rchtara
2014/04/28 11:28:29
Done.
| |
| 42 static bool ran_once = false; | 44 static bool ran_once = false; |
| 43 if (ran_once) | 45 if (ran_once) |
| 44 return; | 46 return; |
| 45 ran_once = true; | 47 ran_once = true; |
| 46 | 48 |
| 47 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); | 49 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); |
| 50 UMA_HISTOGRAM_BOOLEAN("PasswordManager.EnableAutomaticPasswordsSaving", | |
| 51 password_manager_enable_automatic_passwords_saving); | |
| 48 } | 52 } |
| 49 | 53 |
| 50 } // namespace | 54 } // namespace |
| 51 | 55 |
| 52 const char PasswordManager::kOtherPossibleUsernamesExperiment[] = | 56 const char PasswordManager::kOtherPossibleUsernamesExperiment[] = |
| 53 "PasswordManagerOtherPossibleUsernames"; | 57 "PasswordManagerOtherPossibleUsernames"; |
| 54 | 58 |
| 55 // static | 59 // static |
| 56 void PasswordManager::RegisterProfilePrefs( | 60 void PasswordManager::RegisterProfilePrefs( |
| 57 user_prefs::PrefRegistrySyncable* registry) { | 61 user_prefs::PrefRegistrySyncable* registry) { |
| 58 registry->RegisterBooleanPref( | 62 registry->RegisterBooleanPref( |
| 59 prefs::kPasswordManagerEnabled, | 63 prefs::kPasswordManagerEnabled, |
| 60 true, | 64 true, |
| 61 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 65 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 62 registry->RegisterBooleanPref( | 66 registry->RegisterBooleanPref( |
| 67 prefs::kPasswordManagerEnableAutomaticPasswordsSaving, | |
|
vabr (Chromium)
2014/04/28 09:13:14
As noted in one of the comments above, please remo
rchtara
2014/04/28 11:28:29
Done.
| |
| 68 false, | |
| 69 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 70 registry->RegisterBooleanPref( | |
| 63 prefs::kPasswordManagerAllowShowPasswords, | 71 prefs::kPasswordManagerAllowShowPasswords, |
| 64 true, | 72 true, |
| 65 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 66 registry->RegisterListPref(prefs::kPasswordManagerGroupsForDomains, | 74 registry->RegisterListPref(prefs::kPasswordManagerGroupsForDomains, |
| 67 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 75 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 68 } | 76 } |
| 69 | 77 |
| 70 PasswordManager::PasswordManager(PasswordManagerClient* client) | 78 PasswordManager::PasswordManager(PasswordManagerClient* client) |
| 71 : client_(client), driver_(client->GetDriver()) { | 79 : client_(client), driver_(client->GetDriver()) { |
| 72 DCHECK(client_); | 80 DCHECK(client_); |
| 73 DCHECK(driver_); | 81 DCHECK(driver_); |
| 74 password_manager_enabled_.Init(prefs::kPasswordManagerEnabled, | 82 password_manager_enabled_.Init(prefs::kPasswordManagerEnabled, |
| 75 client_->GetPrefs()); | 83 client_->GetPrefs()); |
| 76 | 84 |
| 77 ReportMetrics(*password_manager_enabled_); | 85 BooleanPrefMember enable_automatic_passwords_saving_pref; |
|
vabr (Chromium)
2014/04/28 09:13:14
Ditto: As noted in one of the comments above, plea
rchtara
2014/04/28 11:28:29
Done.
| |
| 86 enable_automatic_passwords_saving_pref.Init( | |
| 87 prefs::kPasswordManagerEnableAutomaticPasswordsSaving, | |
| 88 client_->GetPrefs()); | |
| 89 enable_automatic_passwords_saving_ = *enable_automatic_passwords_saving_pref; | |
| 90 if (client_->IsAutomaticPasswordsSavingEnabled()) | |
| 91 enable_automatic_passwords_saving_ = true; | |
| 92 | |
| 93 ReportMetrics(*password_manager_enabled_, | |
| 94 enable_automatic_passwords_saving_); | |
| 78 } | 95 } |
| 79 | 96 |
| 80 PasswordManager::~PasswordManager() { | 97 PasswordManager::~PasswordManager() { |
| 81 FOR_EACH_OBSERVER(LoginModelObserver, observers_, OnLoginModelDestroying()); | 98 FOR_EACH_OBSERVER(LoginModelObserver, observers_, OnLoginModelDestroying()); |
| 82 } | 99 } |
| 83 | 100 |
| 84 void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) { | 101 void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) { |
| 85 for (ScopedVector<PasswordFormManager>::iterator iter = | 102 for (ScopedVector<PasswordFormManager>::iterator iter = |
| 86 pending_login_managers_.begin(); | 103 pending_login_managers_.begin(); |
| 87 iter != pending_login_managers_.end(); ++iter) { | 104 iter != pending_login_managers_.end(); ++iter) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 // password saving enabled. | 280 // password saving enabled. |
| 264 PasswordStore::AuthorizationPromptPolicy prompt_policy = | 281 PasswordStore::AuthorizationPromptPolicy prompt_policy = |
| 265 *password_manager_enabled_ ? PasswordStore::ALLOW_PROMPT | 282 *password_manager_enabled_ ? PasswordStore::ALLOW_PROMPT |
| 266 : PasswordStore::DISALLOW_PROMPT; | 283 : PasswordStore::DISALLOW_PROMPT; |
| 267 | 284 |
| 268 manager->FetchMatchingLoginsFromPasswordStore(prompt_policy); | 285 manager->FetchMatchingLoginsFromPasswordStore(prompt_policy); |
| 269 } | 286 } |
| 270 } | 287 } |
| 271 | 288 |
| 272 bool PasswordManager::ShouldPromptUserToSavePassword() const { | 289 bool PasswordManager::ShouldPromptUserToSavePassword() const { |
| 273 return provisional_save_manager_->IsNewLogin() && | 290 return !enable_automatic_passwords_saving_ && |
| 291 provisional_save_manager_->IsNewLogin() && | |
| 274 !provisional_save_manager_->HasGeneratedPassword() && | 292 !provisional_save_manager_->HasGeneratedPassword() && |
| 275 !provisional_save_manager_->IsPendingCredentialsPublicSuffixMatch(); | 293 !provisional_save_manager_->IsPendingCredentialsPublicSuffixMatch(); |
| 276 } | 294 } |
| 277 | 295 |
| 278 void PasswordManager::OnPasswordFormsRendered( | 296 void PasswordManager::OnPasswordFormsRendered( |
| 279 const std::vector<PasswordForm>& visible_forms) { | 297 const std::vector<PasswordForm>& visible_forms) { |
| 280 if (!provisional_save_manager_.get()) | 298 if (!provisional_save_manager_.get()) |
| 281 return; | 299 return; |
| 282 | 300 |
| 283 DCHECK(IsSavingEnabled()); | 301 DCHECK(IsSavingEnabled()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 observers_, | 405 observers_, |
| 388 OnAutofillDataAvailable(preferred_match.username_value, | 406 OnAutofillDataAvailable(preferred_match.username_value, |
| 389 preferred_match.password_value)); | 407 preferred_match.password_value)); |
| 390 break; | 408 break; |
| 391 } | 409 } |
| 392 | 410 |
| 393 client_->PasswordWasAutofilled(best_matches); | 411 client_->PasswordWasAutofilled(best_matches); |
| 394 } | 412 } |
| 395 | 413 |
| 396 } // namespace password_manager | 414 } // namespace password_manager |
| OLD | NEW |