| 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_form_manager.h" | 5 #include "components/password_manager/core/browser/password_form_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 does_look_like_signup_form_ = credentials.does_look_like_signup_form; | 412 does_look_like_signup_form_ = credentials.does_look_like_signup_form; |
| 413 | 413 |
| 414 if (form_fetcher_->GetState() == FormFetcher::State::NOT_WAITING) | 414 if (form_fetcher_->GetState() == FormFetcher::State::NOT_WAITING) |
| 415 CreatePendingCredentials(); | 415 CreatePendingCredentials(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void PasswordFormManager::Save() { | 418 void PasswordFormManager::Save() { |
| 419 DCHECK_EQ(FormFetcher::State::NOT_WAITING, form_fetcher_->GetState()); | 419 DCHECK_EQ(FormFetcher::State::NOT_WAITING, form_fetcher_->GetState()); |
| 420 DCHECK(!client_->IsIncognito()); | 420 DCHECK(!client_->IsIncognito()); |
| 421 | 421 |
| 422 metrics_util::LogPasswordAcceptedSaveUpdateSubmissionIndicatorEvent( |
| 423 submitted_form_->submission_event); |
| 424 |
| 422 if ((user_action_ == kUserActionNone) && | 425 if ((user_action_ == kUserActionNone) && |
| 423 DidPreferenceChange(best_matches_, pending_credentials_.username_value)) { | 426 DidPreferenceChange(best_matches_, pending_credentials_.username_value)) { |
| 424 SetUserAction(kUserActionChoose); | 427 SetUserAction(kUserActionChoose); |
| 425 } | 428 } |
| 426 base::Optional<PasswordForm> old_primary_key; | 429 base::Optional<PasswordForm> old_primary_key; |
| 427 if (is_new_login_) { | 430 if (is_new_login_) { |
| 428 SanitizePossibleUsernames(&pending_credentials_); | 431 SanitizePossibleUsernames(&pending_credentials_); |
| 429 pending_credentials_.date_created = base::Time::Now(); | 432 pending_credentials_.date_created = base::Time::Now(); |
| 430 SendVotesOnSave(); | 433 SendVotesOnSave(); |
| 431 form_saver_->Save(pending_credentials_, best_matches_, | 434 form_saver_->Save(pending_credentials_, best_matches_, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 444 pending_credentials_.type == PasswordForm::TYPE_GENERATED) { | 447 pending_credentials_.type == PasswordForm::TYPE_GENERATED) { |
| 445 metrics_util::LogPasswordGenerationSubmissionEvent( | 448 metrics_util::LogPasswordGenerationSubmissionEvent( |
| 446 metrics_util::PASSWORD_USED); | 449 metrics_util::PASSWORD_USED); |
| 447 } | 450 } |
| 448 | 451 |
| 449 password_manager_->UpdateFormManagers(); | 452 password_manager_->UpdateFormManagers(); |
| 450 } | 453 } |
| 451 | 454 |
| 452 void PasswordFormManager::Update( | 455 void PasswordFormManager::Update( |
| 453 const autofill::PasswordForm& credentials_to_update) { | 456 const autofill::PasswordForm& credentials_to_update) { |
| 457 metrics_util::LogPasswordAcceptedSaveUpdateSubmissionIndicatorEvent( |
| 458 submitted_form_->submission_event); |
| 454 if (observed_form_.IsPossibleChangePasswordForm()) { | 459 if (observed_form_.IsPossibleChangePasswordForm()) { |
| 455 FormStructure form_structure(credentials_to_update.form_data); | 460 FormStructure form_structure(credentials_to_update.form_data); |
| 456 UploadPasswordVote(observed_form_, autofill::NEW_PASSWORD, | 461 UploadPasswordVote(observed_form_, autofill::NEW_PASSWORD, |
| 457 form_structure.FormSignatureAsStr()); | 462 form_structure.FormSignatureAsStr()); |
| 458 } | 463 } |
| 459 base::string16 password_to_save = pending_credentials_.password_value; | 464 base::string16 password_to_save = pending_credentials_.password_value; |
| 460 bool skip_zero_click = pending_credentials_.skip_zero_click; | 465 bool skip_zero_click = pending_credentials_.skip_zero_click; |
| 461 pending_credentials_ = credentials_to_update; | 466 pending_credentials_ = credentials_to_update; |
| 462 pending_credentials_.password_value = password_to_save; | 467 pending_credentials_.password_value = password_to_save; |
| 463 pending_credentials_.skip_zero_click = skip_zero_click; | 468 pending_credentials_.skip_zero_click = skip_zero_click; |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 credentials_to_update->back().password_value = | 1411 credentials_to_update->back().password_value = |
| 1407 pending_credentials_.password_value; | 1412 pending_credentials_.password_value; |
| 1408 } | 1413 } |
| 1409 } | 1414 } |
| 1410 } | 1415 } |
| 1411 | 1416 |
| 1412 return old_primary_key; | 1417 return old_primary_key; |
| 1413 } | 1418 } |
| 1414 | 1419 |
| 1415 } // namespace password_manager | 1420 } // namespace password_manager |
| OLD | NEW |