OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 180 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
181 registry->RegisterBooleanPref( | 181 registry->RegisterBooleanPref( |
182 prefs::kAutofillWalletSyncExperimentEnabled, | 182 prefs::kAutofillWalletSyncExperimentEnabled, |
183 false, | 183 false, |
184 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 184 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
185 // TODO(estade): Should this be syncable? | 185 // TODO(estade): Should this be syncable? |
186 registry->RegisterBooleanPref( | 186 registry->RegisterBooleanPref( |
187 prefs::kAutofillWalletImportEnabled, | 187 prefs::kAutofillWalletImportEnabled, |
188 true, | 188 true, |
189 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 189 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 190 // This choice is made on a per-device basis, so it's not syncable. |
| 191 registry->RegisterBooleanPref( |
| 192 prefs::kAutofillWalletImportStorageCheckboxState, |
| 193 true, |
| 194 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
190 #if defined(OS_MACOSX) | 195 #if defined(OS_MACOSX) |
191 registry->RegisterBooleanPref( | 196 registry->RegisterBooleanPref( |
192 prefs::kAutofillAuxiliaryProfilesEnabled, | 197 prefs::kAutofillAuxiliaryProfilesEnabled, |
193 true, | 198 true, |
194 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 199 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
195 #else // defined(OS_MACOSX) | 200 #else // defined(OS_MACOSX) |
196 registry->RegisterBooleanPref( | 201 registry->RegisterBooleanPref( |
197 prefs::kAutofillAuxiliaryProfilesEnabled, | 202 prefs::kAutofillAuxiliaryProfilesEnabled, |
198 false, | 203 false, |
199 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 204 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 714 |
710 // Forward form structures to the password generation manager to detect | 715 // Forward form structures to the password generation manager to detect |
711 // account creation forms. | 716 // account creation forms. |
712 driver_->DetectAccountCreationForms(form_structures_.get()); | 717 driver_->DetectAccountCreationForms(form_structures_.get()); |
713 | 718 |
714 // If the corresponding flag is set, annotate forms with the predicted types. | 719 // If the corresponding flag is set, annotate forms with the predicted types. |
715 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); | 720 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); |
716 } | 721 } |
717 | 722 |
718 void AutofillManager::OnUnmaskResponse(const UnmaskResponse& response) { | 723 void AutofillManager::OnUnmaskResponse(const UnmaskResponse& response) { |
719 unmasking_cvc_ = response.cvc; | 724 unmask_response_ = response; |
720 // TODO(estade): use month/year. | 725 // TODO(estade): use month/year. |
721 real_pan_client_.UnmaskCard(unmasking_card_, base::UTF16ToASCII(response.cvc), | 726 real_pan_client_.UnmaskCard(unmasking_card_, base::UTF16ToASCII(response.cvc), |
722 response.risk_data); | 727 response.risk_data); |
723 } | 728 } |
724 | 729 |
725 void AutofillManager::OnUnmaskPromptClosed() { | 730 void AutofillManager::OnUnmaskPromptClosed() { |
726 real_pan_client_.CancelRequest(); | 731 real_pan_client_.CancelRequest(); |
727 driver_->RendererShouldClearPreviewedForm(); | 732 driver_->RendererShouldClearPreviewedForm(); |
728 unmasking_card_ = CreditCard(); | 733 unmasking_card_ = CreditCard(); |
729 unmasking_cvc_.clear(); | 734 unmask_response_ = UnmaskResponse(); |
730 } | 735 } |
731 | 736 |
732 IdentityProvider* AutofillManager::GetIdentityProvider() { | 737 IdentityProvider* AutofillManager::GetIdentityProvider() { |
733 return client()->GetIdentityProvider(); | 738 return client()->GetIdentityProvider(); |
734 } | 739 } |
735 | 740 |
736 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) { | 741 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) { |
737 if (!real_pan.empty()) { | 742 if (!real_pan.empty()) { |
738 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); | 743 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); |
739 unmasking_card_.SetNumber(base::UTF8ToUTF16(real_pan)); | 744 unmasking_card_.SetNumber(base::UTF8ToUTF16(real_pan)); |
740 personal_data_->UpdateServerCreditCard(unmasking_card_); | 745 if (unmask_response_.should_store_pan) |
| 746 personal_data_->UpdateServerCreditCard(unmasking_card_); |
| 747 |
741 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_, | 748 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_, |
742 unmasking_card_); | 749 unmasking_card_); |
743 } | 750 } |
744 | 751 |
745 client()->OnUnmaskVerificationResult(!real_pan.empty()); | 752 client()->OnUnmaskVerificationResult(!real_pan.empty()); |
746 } | 753 } |
747 | 754 |
748 void AutofillManager::OnDidEndTextFieldEditing() { | 755 void AutofillManager::OnDidEndTextFieldEditing() { |
749 external_delegate_->DidEndTextFieldEditing(); | 756 external_delegate_->DidEndTextFieldEditing(); |
750 } | 757 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 size_t use_variant = 0; | 1065 size_t use_variant = 0; |
1059 if (result.fields[i].SameFieldAs(field) || | 1066 if (result.fields[i].SameFieldAs(field) || |
1060 field_group_type == initiating_group_type) { | 1067 field_group_type == initiating_group_type) { |
1061 use_variant = variant; | 1068 use_variant = variant; |
1062 } | 1069 } |
1063 base::string16 value = data_model->GetInfoForVariant( | 1070 base::string16 value = data_model->GetInfoForVariant( |
1064 cached_field->Type(), use_variant, app_locale_); | 1071 cached_field->Type(), use_variant, app_locale_); |
1065 if (is_credit_card && | 1072 if (is_credit_card && |
1066 cached_field->Type().GetStorableType() == | 1073 cached_field->Type().GetStorableType() == |
1067 CREDIT_CARD_VERIFICATION_CODE) { | 1074 CREDIT_CARD_VERIFICATION_CODE) { |
1068 // If this is |unmasking_card_|, |unmasking_cvc_| should be non-empty | 1075 // If this is |unmasking_card_|, |unmask_response_,cvc| should be |
1069 // and vice versa. | 1076 // non-empty and vice versa. |
1070 DCHECK_EQ(&unmasking_card_ == data_model, !unmasking_cvc_.empty()); | 1077 value = unmask_response_.cvc; |
1071 value = unmasking_cvc_; | 1078 DCHECK_EQ(&unmasking_card_ == data_model, value.empty()); |
1072 } | 1079 } |
1073 | 1080 |
1074 // Must match ForEachMatchingFormField() in form_autofill_util.cc. | 1081 // Must match ForEachMatchingFormField() in form_autofill_util.cc. |
1075 // Only notify autofilling of empty fields and the field that initiated | 1082 // Only notify autofilling of empty fields and the field that initiated |
1076 // the filling (note that "select-one" controls may not be empty but will | 1083 // the filling (note that "select-one" controls may not be empty but will |
1077 // still be autofilled). | 1084 // still be autofilled). |
1078 bool should_notify = | 1085 bool should_notify = |
1079 !is_credit_card && | 1086 !is_credit_card && |
1080 !value.empty() && | 1087 !value.empty() && |
1081 (result.fields[i].SameFieldAs(field) || | 1088 (result.fields[i].SameFieldAs(field) || |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 return false; | 1401 return false; |
1395 | 1402 |
1396 // Disregard forms that we wouldn't ever autofill in the first place. | 1403 // Disregard forms that we wouldn't ever autofill in the first place. |
1397 if (!form.ShouldBeParsed()) | 1404 if (!form.ShouldBeParsed()) |
1398 return false; | 1405 return false; |
1399 | 1406 |
1400 return true; | 1407 return true; |
1401 } | 1408 } |
1402 | 1409 |
1403 } // namespace autofill | 1410 } // namespace autofill |
OLD | NEW |