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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 iter != pending_login_managers_.end(); ++iter) { | 133 iter != pending_login_managers_.end(); ++iter) { |
134 if ((*iter)->DoesManage(form) == | 134 if ((*iter)->DoesManage(form) == |
135 PasswordFormManager::RESULT_COMPLETE_MATCH) { | 135 PasswordFormManager::RESULT_COMPLETE_MATCH) { |
136 (*iter)->SetHasGeneratedPassword(); | 136 (*iter)->SetHasGeneratedPassword(); |
137 return; | 137 return; |
138 } | 138 } |
139 } | 139 } |
140 // If there is no corresponding PasswordFormManager, we create one. This is | 140 // If there is no corresponding PasswordFormManager, we create one. This is |
141 // not the common case, and should only happen when there is a bug in our | 141 // not the common case, and should only happen when there is a bug in our |
142 // ability to detect forms. | 142 // ability to detect forms. |
143 bool ssl_valid = form.origin.SchemeIsSecure(); | 143 bool ssl_valid = form.origin.SchemeIsCryptographic(); |
144 PasswordFormManager* manager = new PasswordFormManager( | 144 PasswordFormManager* manager = new PasswordFormManager( |
145 this, client_, driver->AsWeakPtr(), form, ssl_valid); | 145 this, client_, driver->AsWeakPtr(), form, ssl_valid); |
146 pending_login_managers_.push_back(manager); | 146 pending_login_managers_.push_back(manager); |
147 manager->SetHasGeneratedPassword(); | 147 manager->SetHasGeneratedPassword(); |
148 // TODO(gcasto): Add UMA stats to track this. | 148 // TODO(gcasto): Add UMA stats to track this. |
149 } | 149 } |
150 | 150 |
151 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { | 151 void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) { |
152 bool is_saving_enabled = client_->IsSavingEnabledForCurrentPage(); | 152 bool is_saving_enabled = client_->IsSavingEnabledForCurrentPage(); |
153 | 153 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // background. | 250 // background. |
251 if (ShouldDropSyncCredential() && | 251 if (ShouldDropSyncCredential() && |
252 client_->IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), | 252 client_->IsSyncAccountCredential(base::UTF16ToUTF8(form.username_value), |
253 form.signon_realm)) { | 253 form.signon_realm)) { |
254 RecordFailure(SYNC_CREDENTIAL, form.origin, logger.get()); | 254 RecordFailure(SYNC_CREDENTIAL, form.origin, logger.get()); |
255 return; | 255 return; |
256 } | 256 } |
257 | 257 |
258 PasswordForm provisionally_saved_form(form); | 258 PasswordForm provisionally_saved_form(form); |
259 provisionally_saved_form.ssl_valid = | 259 provisionally_saved_form.ssl_valid = |
260 form.origin.SchemeIsSecure() && | 260 form.origin.SchemeIsCryptographic() && |
261 !client_->DidLastPageLoadEncounterSSLErrors(); | 261 !client_->DidLastPageLoadEncounterSSLErrors(); |
262 provisionally_saved_form.preferred = true; | 262 provisionally_saved_form.preferred = true; |
263 if (logger) { | 263 if (logger) { |
264 logger->LogPasswordForm(Logger::STRING_PROVISIONALLY_SAVED_FORM, | 264 logger->LogPasswordForm(Logger::STRING_PROVISIONALLY_SAVED_FORM, |
265 provisionally_saved_form); | 265 provisionally_saved_form); |
266 } | 266 } |
267 PasswordFormManager::OtherPossibleUsernamesAction action = | 267 PasswordFormManager::OtherPossibleUsernamesAction action = |
268 PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES; | 268 PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES; |
269 if (OtherPossibleUsernamesEnabled()) | 269 if (OtherPossibleUsernamesEnabled()) |
270 action = PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES; | 270 action = PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // are password change forms. | 412 // are password change forms. |
413 if (iter->username_element.empty()) { | 413 if (iter->username_element.empty()) { |
414 UMA_HISTOGRAM_BOOLEAN( | 414 UMA_HISTOGRAM_BOOLEAN( |
415 "PasswordManager.EmptyUsernames." | 415 "PasswordManager.EmptyUsernames." |
416 "FormWithoutUsernameFieldIsPasswordChangeForm", | 416 "FormWithoutUsernameFieldIsPasswordChangeForm", |
417 !iter->new_password_element.empty()); | 417 !iter->new_password_element.empty()); |
418 } | 418 } |
419 | 419 |
420 if (logger) | 420 if (logger) |
421 logger->LogFormSignatures(Logger::STRING_ADDING_SIGNATURE, *iter); | 421 logger->LogFormSignatures(Logger::STRING_ADDING_SIGNATURE, *iter); |
422 bool ssl_valid = iter->origin.SchemeIsSecure(); | 422 bool ssl_valid = iter->origin.SchemeIsCryptographic(); |
423 PasswordFormManager* manager = new PasswordFormManager( | 423 PasswordFormManager* manager = new PasswordFormManager( |
424 this, client_, driver->AsWeakPtr(), *iter, ssl_valid); | 424 this, client_, driver->AsWeakPtr(), *iter, ssl_valid); |
425 pending_login_managers_.push_back(manager); | 425 pending_login_managers_.push_back(manager); |
426 | 426 |
427 PasswordStore::AuthorizationPromptPolicy prompt_policy = | 427 PasswordStore::AuthorizationPromptPolicy prompt_policy = |
428 client_->GetAuthorizationPromptPolicy(*iter); | 428 client_->GetAuthorizationPromptPolicy(*iter); |
429 | 429 |
430 manager->FetchMatchingLoginsFromPasswordStore(prompt_policy); | 430 manager->FetchMatchingLoginsFromPasswordStore(prompt_policy); |
431 } | 431 } |
432 | 432 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 predictions[form->ToFormData()] = *(*field); | 660 predictions[form->ToFormData()] = *(*field); |
661 } | 661 } |
662 } | 662 } |
663 } | 663 } |
664 if (predictions.empty()) | 664 if (predictions.empty()) |
665 return; | 665 return; |
666 driver->AutofillDataReceived(predictions); | 666 driver->AutofillDataReceived(predictions); |
667 } | 667 } |
668 | 668 |
669 } // namespace password_manager | 669 } // namespace password_manager |
OLD | NEW |