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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 361 } |
362 | 362 |
363 password_manager_->UpdateFormManagers(); | 363 password_manager_->UpdateFormManagers(); |
364 } | 364 } |
365 | 365 |
366 void PasswordFormManager::Update( | 366 void PasswordFormManager::Update( |
367 const autofill::PasswordForm& credentials_to_update) { | 367 const autofill::PasswordForm& credentials_to_update) { |
368 if (observed_form_.IsPossibleChangePasswordForm()) { | 368 if (observed_form_.IsPossibleChangePasswordForm()) { |
369 FormStructure form_structure(credentials_to_update.form_data); | 369 FormStructure form_structure(credentials_to_update.form_data); |
370 UploadChangePasswordForm(autofill::NEW_PASSWORD, | 370 UploadChangePasswordForm(autofill::NEW_PASSWORD, |
371 form_structure.FormSignature()); | 371 form_structure.FormSignatureAsStr()); |
372 } | 372 } |
373 base::string16 password_to_save = pending_credentials_.password_value; | 373 base::string16 password_to_save = pending_credentials_.password_value; |
374 bool skip_zero_click = pending_credentials_.skip_zero_click; | 374 bool skip_zero_click = pending_credentials_.skip_zero_click; |
375 pending_credentials_ = credentials_to_update; | 375 pending_credentials_ = credentials_to_update; |
376 pending_credentials_.password_value = password_to_save; | 376 pending_credentials_.password_value = password_to_save; |
377 pending_credentials_.skip_zero_click = skip_zero_click; | 377 pending_credentials_.skip_zero_click = skip_zero_click; |
378 pending_credentials_.preferred = true; | 378 pending_credentials_.preferred = true; |
379 is_new_login_ = false; | 379 is_new_login_ = false; |
380 ProcessUpdate(); | 380 ProcessUpdate(); |
381 std::vector<PasswordForm> more_credentials_to_update; | 381 std::vector<PasswordForm> more_credentials_to_update; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 return; | 708 return; |
709 | 709 |
710 FormStructure pending_structure(pending->form_data); | 710 FormStructure pending_structure(pending->form_data); |
711 FormStructure observed_structure(observed.form_data); | 711 FormStructure observed_structure(observed.form_data); |
712 | 712 |
713 // Ignore |pending_structure| if its FormData has no fields. This is to | 713 // Ignore |pending_structure| if its FormData has no fields. This is to |
714 // weed out those credentials that were saved before FormData was added | 714 // weed out those credentials that were saved before FormData was added |
715 // to PasswordForm. Even without this check, these FormStructure's won't | 715 // to PasswordForm. Even without this check, these FormStructure's won't |
716 // be uploaded, but it makes it hard to see if we are encountering | 716 // be uploaded, but it makes it hard to see if we are encountering |
717 // unexpected errors. | 717 // unexpected errors. |
718 if (pending_structure.FormSignature() != observed_structure.FormSignature()) { | 718 if (pending_structure.FormSignatureAsStr() != |
| 719 observed_structure.FormSignatureAsStr()) { |
719 // Only upload if this is the first time the password has been used. | 720 // Only upload if this is the first time the password has been used. |
720 // Otherwise the credentials have been used on the same field before so | 721 // Otherwise the credentials have been used on the same field before so |
721 // they aren't from an account creation form. | 722 // they aren't from an account creation form. |
722 // Also bypass uploading if the username was edited. Offering generation | 723 // Also bypass uploading if the username was edited. Offering generation |
723 // in cases where we currently save the wrong username isn't great. | 724 // in cases where we currently save the wrong username isn't great. |
724 // TODO(gcasto): Determine if generation should be offered in this case. | 725 // TODO(gcasto): Determine if generation should be offered in this case. |
725 if (pending->times_used == 1 && selected_username_.empty()) { | 726 if (pending->times_used == 1 && selected_username_.empty()) { |
726 if (UploadPasswordForm(pending->form_data, pending->username_element, | 727 if (UploadPasswordForm(pending->form_data, pending->username_element, |
727 autofill::ACCOUNT_CREATION_PASSWORD, | 728 autofill::ACCOUNT_CREATION_PASSWORD, |
728 observed_structure.FormSignature())) { | 729 observed_structure.FormSignatureAsStr())) { |
729 pending->generation_upload_status = | 730 pending->generation_upload_status = |
730 autofill::PasswordForm::POSITIVE_SIGNAL_SENT; | 731 autofill::PasswordForm::POSITIVE_SIGNAL_SENT; |
731 } | 732 } |
732 } | 733 } |
733 } else if (pending->generation_upload_status == | 734 } else if (pending->generation_upload_status == |
734 autofill::PasswordForm::POSITIVE_SIGNAL_SENT) { | 735 autofill::PasswordForm::POSITIVE_SIGNAL_SENT) { |
735 // A signal was sent that this was an account creation form, but the | 736 // A signal was sent that this was an account creation form, but the |
736 // credential is now being used on the same form again. This cancels out | 737 // credential is now being used on the same form again. This cancels out |
737 // the previous vote. | 738 // the previous vote. |
738 if (UploadPasswordForm(pending->form_data, base::string16(), | 739 if (UploadPasswordForm(pending->form_data, base::string16(), |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 credentials_to_update->back().password_value = | 1400 credentials_to_update->back().password_value = |
1400 pending_credentials_.password_value; | 1401 pending_credentials_.password_value; |
1401 } | 1402 } |
1402 } | 1403 } |
1403 } | 1404 } |
1404 | 1405 |
1405 return old_primary_key; | 1406 return old_primary_key; |
1406 } | 1407 } |
1407 | 1408 |
1408 } // namespace password_manager | 1409 } // namespace password_manager |
OLD | NEW |