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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 910043002: Add checkbox to card unmasking prompt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: relative Created 5 years, 10 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 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
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 registry->RegisterBooleanPref(
191 prefs::kAutofillWalletImportStorageEnabled,
192 true,
193 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
194 registry->RegisterBooleanPref(
195 prefs::kAutofillWalletImportStorageCheckboxState,
196 true,
197 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
190 #if defined(OS_MACOSX) 198 #if defined(OS_MACOSX)
191 registry->RegisterBooleanPref( 199 registry->RegisterBooleanPref(
192 prefs::kAutofillAuxiliaryProfilesEnabled, 200 prefs::kAutofillAuxiliaryProfilesEnabled,
193 true, 201 true,
194 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 202 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
195 #else // defined(OS_MACOSX) 203 #else // defined(OS_MACOSX)
196 registry->RegisterBooleanPref( 204 registry->RegisterBooleanPref(
197 prefs::kAutofillAuxiliaryProfilesEnabled, 205 prefs::kAutofillAuxiliaryProfilesEnabled,
198 false, 206 false,
199 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 207 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 711
704 // Forward form structures to the password generation manager to detect 712 // Forward form structures to the password generation manager to detect
705 // account creation forms. 713 // account creation forms.
706 driver_->DetectAccountCreationForms(form_structures_.get()); 714 driver_->DetectAccountCreationForms(form_structures_.get());
707 715
708 // If the corresponding flag is set, annotate forms with the predicted types. 716 // If the corresponding flag is set, annotate forms with the predicted types.
709 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get()); 717 driver_->SendAutofillTypePredictionsToRenderer(form_structures_.get());
710 } 718 }
711 719
712 void AutofillManager::OnUnmaskResponse(const UnmaskResponse& response) { 720 void AutofillManager::OnUnmaskResponse(const UnmaskResponse& response) {
713 unmasking_cvc_ = response.cvc; 721 unmask_response_ = response;
714 // TODO(estade): use month/year. 722 // TODO(estade): use month/year.
715 real_pan_client_.UnmaskCard(unmasking_card_, base::UTF16ToASCII(response.cvc), 723 real_pan_client_.UnmaskCard(unmasking_card_, base::UTF16ToASCII(response.cvc),
716 response.risk_data); 724 response.risk_data);
717 } 725 }
718 726
719 void AutofillManager::OnUnmaskPromptClosed() { 727 void AutofillManager::OnUnmaskPromptClosed() {
720 real_pan_client_.CancelRequest(); 728 real_pan_client_.CancelRequest();
721 driver_->RendererShouldClearPreviewedForm(); 729 driver_->RendererShouldClearPreviewedForm();
722 unmasking_card_ = CreditCard(); 730 unmasking_card_ = CreditCard();
723 unmasking_cvc_.clear(); 731 unmask_response_ = UnmaskResponse();
724 } 732 }
725 733
726 IdentityProvider* AutofillManager::GetIdentityProvider() { 734 IdentityProvider* AutofillManager::GetIdentityProvider() {
727 return client()->GetIdentityProvider(); 735 return client()->GetIdentityProvider();
728 } 736 }
729 737
730 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) { 738 void AutofillManager::OnDidGetRealPan(const std::string& real_pan) {
731 if (!real_pan.empty()) { 739 if (!real_pan.empty()) {
732 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD); 740 unmasking_card_.set_record_type(CreditCard::FULL_SERVER_CARD);
733 unmasking_card_.SetNumber(base::UTF8ToUTF16(real_pan)); 741 unmasking_card_.SetNumber(base::UTF8ToUTF16(real_pan));
734 personal_data_->UpdateServerCreditCard(unmasking_card_); 742 if (unmask_response_.should_store_pan)
743 personal_data_->UpdateServerCreditCard(unmasking_card_);
744
735 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_, 745 FillCreditCardForm(unmasking_query_id_, unmasking_form_, unmasking_field_,
736 unmasking_card_); 746 unmasking_card_);
737 } 747 }
738 748
739 client()->OnUnmaskVerificationResult(!real_pan.empty()); 749 client()->OnUnmaskVerificationResult(!real_pan.empty());
740 } 750 }
741 751
742 void AutofillManager::OnDidEndTextFieldEditing() { 752 void AutofillManager::OnDidEndTextFieldEditing() {
743 external_delegate_->DidEndTextFieldEditing(); 753 external_delegate_->DidEndTextFieldEditing();
744 } 754 }
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 size_t use_variant = 0; 1062 size_t use_variant = 0;
1053 if (result.fields[i].SameFieldAs(field) || 1063 if (result.fields[i].SameFieldAs(field) ||
1054 field_group_type == initiating_group_type) { 1064 field_group_type == initiating_group_type) {
1055 use_variant = variant; 1065 use_variant = variant;
1056 } 1066 }
1057 base::string16 value = data_model->GetInfoForVariant( 1067 base::string16 value = data_model->GetInfoForVariant(
1058 cached_field->Type(), use_variant, app_locale_); 1068 cached_field->Type(), use_variant, app_locale_);
1059 if (is_credit_card && 1069 if (is_credit_card &&
1060 cached_field->Type().GetStorableType() == 1070 cached_field->Type().GetStorableType() ==
1061 CREDIT_CARD_VERIFICATION_CODE) { 1071 CREDIT_CARD_VERIFICATION_CODE) {
1062 // If this is |unmasking_card_|, |unmasking_cvc_| should be non-empty 1072 // If this is |unmasking_card_|, |unmask_response_,cvc| should be
1063 // and vice versa. 1073 // non-empty and vice versa.
1064 DCHECK_EQ(&unmasking_card_ == data_model, !unmasking_cvc_.empty()); 1074 value = unmask_response_.cvc;
1065 value = unmasking_cvc_; 1075 DCHECK_EQ(&unmasking_card_ == data_model, value.empty());
1066 } 1076 }
1067 1077
1068 // Must match ForEachMatchingFormField() in form_autofill_util.cc. 1078 // Must match ForEachMatchingFormField() in form_autofill_util.cc.
1069 // Only notify autofilling of empty fields and the field that initiated 1079 // Only notify autofilling of empty fields and the field that initiated
1070 // the filling (note that "select-one" controls may not be empty but will 1080 // the filling (note that "select-one" controls may not be empty but will
1071 // still be autofilled). 1081 // still be autofilled).
1072 bool should_notify = 1082 bool should_notify =
1073 !is_credit_card && 1083 !is_credit_card &&
1074 !value.empty() && 1084 !value.empty() &&
1075 (result.fields[i].SameFieldAs(field) || 1085 (result.fields[i].SameFieldAs(field) ||
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 return false; 1398 return false;
1389 1399
1390 // Disregard forms that we wouldn't ever autofill in the first place. 1400 // Disregard forms that we wouldn't ever autofill in the first place.
1391 if (!form.ShouldBeParsed()) 1401 if (!form.ShouldBeParsed())
1392 return false; 1402 return false;
1393 1403
1394 return true; 1404 return true;
1395 } 1405 }
1396 1406
1397 } // namespace autofill 1407 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698