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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 15401005: Force at least first and last name for CREDIT_CARD_NAME when using Wallet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Evan's review Created 7 years, 7 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 | Annotate | Revision Log
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 "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 238
239 // Signals that the user has opted in to geolocation services. Factored out 239 // Signals that the user has opted in to geolocation services. Factored out
240 // into a separate method because all interaction with the geolocation provider 240 // into a separate method because all interaction with the geolocation provider
241 // needs to happen on the IO thread, which is not the thread 241 // needs to happen on the IO thread, which is not the thread
242 // AutofillDialogController lives on. 242 // AutofillDialogController lives on.
243 void UserDidOptIntoLocationServices() { 243 void UserDidOptIntoLocationServices() {
244 content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices(); 244 content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
245 } 245 }
246 246
247 bool IsCardHolderNameValidForWallet(const string16& name) {
248 base::string16 whitespace_collapsed_name = CollapseWhitespace(name, true);
249 std::vector<base::string16> split_name;
250 SplitString(whitespace_collapsed_name, ' ', &split_name);
251 return split_name.size() >= 2;
252 }
253
247 } // namespace 254 } // namespace
248 255
249 AutofillDialogController::~AutofillDialogController() {} 256 AutofillDialogController::~AutofillDialogController() {}
250 257
251 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 258 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
252 if (popup_controller_) 259 if (popup_controller_)
253 popup_controller_->Hide(); 260 popup_controller_->Hide();
254 261
255 GetMetricLogger().LogDialogInitialUserState( 262 GetMetricLogger().LogDialogInitialUserState(
256 GetDialogType(), initial_user_state_); 263 GetDialogType(), initial_user_state_);
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR], 1113 field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR],
1107 field_values[CREDIT_CARD_EXP_MONTH], 1114 field_values[CREDIT_CARD_EXP_MONTH],
1108 base::Time::Now())) { 1115 base::Time::Now())) {
1109 invalid_messages[CREDIT_CARD_EXP_MONTH] = 1116 invalid_messages[CREDIT_CARD_EXP_MONTH] =
1110 ASCIIToUTF16("more complicated message"); 1117 ASCIIToUTF16("more complicated message");
1111 invalid_messages[CREDIT_CARD_EXP_4_DIGIT_YEAR] = 1118 invalid_messages[CREDIT_CARD_EXP_4_DIGIT_YEAR] =
1112 ASCIIToUTF16("more complicated message"); 1119 ASCIIToUTF16("more complicated message");
1113 } 1120 }
1114 } 1121 }
1115 1122
1123 // Wallet requires a first and last name.
1124 if (field_values.count(CREDIT_CARD_NAME)) {
Evan Stade 2013/05/23 23:28:40 can you put this in InputValidityMessage()? Inputs
ahutter 2013/05/24 18:36:02 Done.
1125 if (IsPayingWithWallet() &&
1126 !IsCardHolderNameValidForWallet(field_values[CREDIT_CARD_NAME])) {
1127 invalid_messages[CREDIT_CARD_NAME] =
1128 l10n_util::GetStringUTF16(
1129 IDS_AUTOFILL_DIALOG_VALIDATION_WALLET_REQUIRES_TWO_NAMES);
1130 }
1131 }
1132
1116 // If there is a credit card number and a CVC, validate them together. 1133 // If there is a credit card number and a CVC, validate them together.
1117 if (field_values.count(CREDIT_CARD_NUMBER) && 1134 if (field_values.count(CREDIT_CARD_NUMBER) &&
1118 field_values.count(CREDIT_CARD_VERIFICATION_CODE) && 1135 field_values.count(CREDIT_CARD_VERIFICATION_CODE) &&
1119 InputIsValid(CREDIT_CARD_NUMBER, field_values[CREDIT_CARD_NUMBER])) { 1136 InputIsValid(CREDIT_CARD_NUMBER, field_values[CREDIT_CARD_NUMBER])) {
1120 if (!autofill::IsValidCreditCardSecurityCode( 1137 if (!autofill::IsValidCreditCardSecurityCode(
1121 field_values[CREDIT_CARD_VERIFICATION_CODE], 1138 field_values[CREDIT_CARD_VERIFICATION_CODE],
1122 field_values[CREDIT_CARD_NUMBER])) { 1139 field_values[CREDIT_CARD_NUMBER])) {
1123 invalid_messages[CREDIT_CARD_VERIFICATION_CODE] = 1140 invalid_messages[CREDIT_CARD_VERIFICATION_CODE] =
1124 ASCIIToUTF16("CVC doesn't match card type!"); 1141 ASCIIToUTF16("CVC doesn't match card type!");
1125 } 1142 }
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 2593 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
2577 } 2594 }
2578 2595
2579 // Has Wallet items. 2596 // Has Wallet items.
2580 return has_autofill_profiles ? 2597 return has_autofill_profiles ?
2581 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 2598 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
2582 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 2599 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
2583 } 2600 }
2584 2601
2585 } // namespace autofill 2602 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698