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

Side by Side Diff: components/password_manager/core/browser/password_manager.cc

Issue 380713003: PasswordManager - update "password_manager_enabled_" pref name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Trybots failure (rebase was needed) Created 6 years, 5 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 "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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 } // namespace 56 } // namespace
57 57
58 const char PasswordManager::kOtherPossibleUsernamesExperiment[] = 58 const char PasswordManager::kOtherPossibleUsernamesExperiment[] =
59 "PasswordManagerOtherPossibleUsernames"; 59 "PasswordManagerOtherPossibleUsernames";
60 60
61 // static 61 // static
62 void PasswordManager::RegisterProfilePrefs( 62 void PasswordManager::RegisterProfilePrefs(
63 user_prefs::PrefRegistrySyncable* registry) { 63 user_prefs::PrefRegistrySyncable* registry) {
64 registry->RegisterBooleanPref( 64 registry->RegisterBooleanPref(
65 prefs::kPasswordManagerEnabled, 65 prefs::kPasswordManagerSavingEnabled,
66 true, 66 true,
67 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 67 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
68 registry->RegisterBooleanPref( 68 registry->RegisterBooleanPref(
69 prefs::kPasswordManagerAllowShowPasswords, 69 prefs::kPasswordManagerAllowShowPasswords,
70 true, 70 true,
71 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 71 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
72 registry->RegisterListPref(prefs::kPasswordManagerGroupsForDomains, 72 registry->RegisterListPref(prefs::kPasswordManagerGroupsForDomains,
73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
74 } 74 }
75 75
76 PasswordManager::PasswordManager(PasswordManagerClient* client) 76 PasswordManager::PasswordManager(PasswordManagerClient* client)
77 : client_(client), driver_(client->GetDriver()) { 77 : client_(client), driver_(client->GetDriver()) {
78 DCHECK(client_); 78 DCHECK(client_);
79 DCHECK(driver_); 79 DCHECK(driver_);
80 password_manager_enabled_.Init(prefs::kPasswordManagerEnabled, 80 saving_passwords_enabled_.Init(prefs::kPasswordManagerSavingEnabled,
81 client_->GetPrefs()); 81 client_->GetPrefs());
82 82
83 ReportMetrics(*password_manager_enabled_); 83 ReportMetrics(*saving_passwords_enabled_);
84 } 84 }
85 85
86 PasswordManager::~PasswordManager() { 86 PasswordManager::~PasswordManager() {
87 FOR_EACH_OBSERVER(LoginModelObserver, observers_, OnLoginModelDestroying()); 87 FOR_EACH_OBSERVER(LoginModelObserver, observers_, OnLoginModelDestroying());
88 } 88 }
89 89
90 void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) { 90 void PasswordManager::SetFormHasGeneratedPassword(const PasswordForm& form) {
91 DCHECK(IsSavingEnabledForCurrentPage()); 91 DCHECK(IsSavingEnabledForCurrentPage());
92 92
93 for (ScopedVector<PasswordFormManager>::iterator iter = 93 for (ScopedVector<PasswordFormManager>::iterator iter =
(...skipping 16 matching lines...) Expand all
110 manager->SetHasGeneratedPassword(); 110 manager->SetHasGeneratedPassword();
111 // TODO(gcasto): Add UMA stats to track this. 111 // TODO(gcasto): Add UMA stats to track this.
112 } 112 }
113 113
114 bool PasswordManager::IsEnabledForCurrentPage() const { 114 bool PasswordManager::IsEnabledForCurrentPage() const {
115 return !driver_->DidLastPageLoadEncounterSSLErrors() && 115 return !driver_->DidLastPageLoadEncounterSSLErrors() &&
116 client_->IsPasswordManagerEnabledForCurrentPage(); 116 client_->IsPasswordManagerEnabledForCurrentPage();
117 } 117 }
118 118
119 bool PasswordManager::IsSavingEnabledForCurrentPage() const { 119 bool PasswordManager::IsSavingEnabledForCurrentPage() const {
120 return *password_manager_enabled_ && !driver_->IsOffTheRecord() && 120 return *saving_passwords_enabled_ && !driver_->IsOffTheRecord() &&
121 IsEnabledForCurrentPage(); 121 IsEnabledForCurrentPage();
122 } 122 }
123 123
124 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { 124 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) {
125 bool is_saving_enabled = IsSavingEnabledForCurrentPage(); 125 bool is_saving_enabled = IsSavingEnabledForCurrentPage();
126 126
127 scoped_ptr<BrowserSavePasswordProgressLogger> logger; 127 scoped_ptr<BrowserSavePasswordProgressLogger> logger;
128 if (client_->IsLoggingActive()) { 128 if (client_->IsLoggingActive()) {
129 logger.reset(new BrowserSavePasswordProgressLogger(client_)); 129 logger.reset(new BrowserSavePasswordProgressLogger(client_));
130 logger->LogMessage(Logger::STRING_PROVISIONALLY_SAVE_PASSWORD_METHOD); 130 logger->LogMessage(Logger::STRING_PROVISIONALLY_SAVE_PASSWORD_METHOD);
131 logger->LogPasswordForm(Logger::STRING_PROVISIONALLY_SAVE_PASSWORD_FORM, 131 logger->LogPasswordForm(Logger::STRING_PROVISIONALLY_SAVE_PASSWORD_FORM,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 continue; // The current form is already managed. 349 continue; // The current form is already managed.
350 350
351 bool ssl_valid = iter->origin.SchemeIsSecure(); 351 bool ssl_valid = iter->origin.SchemeIsSecure();
352 PasswordFormManager* manager = 352 PasswordFormManager* manager =
353 new PasswordFormManager(this, client_, driver_, *iter, ssl_valid); 353 new PasswordFormManager(this, client_, driver_, *iter, ssl_valid);
354 pending_login_managers_.push_back(manager); 354 pending_login_managers_.push_back(manager);
355 355
356 // Avoid prompting the user for access to a password if they don't have 356 // Avoid prompting the user for access to a password if they don't have
357 // password saving enabled. 357 // password saving enabled.
358 PasswordStore::AuthorizationPromptPolicy prompt_policy = 358 PasswordStore::AuthorizationPromptPolicy prompt_policy =
359 *password_manager_enabled_ ? PasswordStore::ALLOW_PROMPT 359 *saving_passwords_enabled_ ? PasswordStore::ALLOW_PROMPT
360 : PasswordStore::DISALLOW_PROMPT; 360 : PasswordStore::DISALLOW_PROMPT;
361 361
362 manager->FetchMatchingLoginsFromPasswordStore(prompt_policy); 362 manager->FetchMatchingLoginsFromPasswordStore(prompt_policy);
363 } 363 }
364 } 364 }
365 365
366 bool PasswordManager::ShouldPromptUserToSavePassword() const { 366 bool PasswordManager::ShouldPromptUserToSavePassword() const {
367 return !client_->IsAutomaticPasswordSavingEnabled() && 367 return !client_->IsAutomaticPasswordSavingEnabled() &&
368 provisional_save_manager_->IsNewLogin() && 368 provisional_save_manager_->IsNewLogin() &&
369 !provisional_save_manager_->HasGeneratedPassword() && 369 !provisional_save_manager_->HasGeneratedPassword() &&
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 observers_, 522 observers_,
523 OnAutofillDataAvailable(preferred_match.username_value, 523 OnAutofillDataAvailable(preferred_match.username_value,
524 preferred_match.password_value)); 524 preferred_match.password_value));
525 break; 525 break;
526 } 526 }
527 527
528 client_->PasswordWasAutofilled(best_matches); 528 client_->PasswordWasAutofilled(best_matches);
529 } 529 }
530 530
531 } // namespace password_manager 531 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698