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

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: 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
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 trimmed_name;
249 TrimWhitespace(name, TRIM_ALL, &trimmed_name);
250 base::string16 whitespace_collapsed_name = CollapseWhitespace(trimmed_name,
Evan Stade 2013/05/23 16:40:37 collapsewhitespace trims (so I don't think you nee
ahutter 2013/05/23 23:19:11 Done.
251 true);
252 std::vector<base::string16> split_name;
253 SplitString(whitespace_collapsed_name, ' ', &split_name);
254 return split_name.size() >= 2;
255 }
256
247 } // namespace 257 } // namespace
248 258
249 AutofillDialogController::~AutofillDialogController() {} 259 AutofillDialogController::~AutofillDialogController() {}
250 260
251 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() { 261 AutofillDialogControllerImpl::~AutofillDialogControllerImpl() {
252 if (popup_controller_) 262 if (popup_controller_)
253 popup_controller_->Hide(); 263 popup_controller_->Hide();
254 264
255 GetMetricLogger().LogDialogInitialUserState( 265 GetMetricLogger().LogDialogInitialUserState(
256 GetDialogType(), initial_user_state_); 266 GetDialogType(), initial_user_state_);
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR], 1119 field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR],
1110 field_values[CREDIT_CARD_EXP_MONTH], 1120 field_values[CREDIT_CARD_EXP_MONTH],
1111 base::Time::Now())) { 1121 base::Time::Now())) {
1112 invalid_messages[CREDIT_CARD_EXP_MONTH] = 1122 invalid_messages[CREDIT_CARD_EXP_MONTH] =
1113 ASCIIToUTF16("more complicated message"); 1123 ASCIIToUTF16("more complicated message");
1114 invalid_messages[CREDIT_CARD_EXP_4_DIGIT_YEAR] = 1124 invalid_messages[CREDIT_CARD_EXP_4_DIGIT_YEAR] =
1115 ASCIIToUTF16("more complicated message"); 1125 ASCIIToUTF16("more complicated message");
1116 } 1126 }
1117 } 1127 }
1118 1128
1129 // Wallet requires a first and last name.
1130 if (field_values.count(CREDIT_CARD_NAME)) {
1131 if (IsPayingWithWallet() &&
1132 !IsCardHolderNameValidForWallet(field_values[CREDIT_CARD_NAME])) {
1133 invalid_messages[CREDIT_CARD_NAME] =
1134 ASCIIToUTF16("Google Wallet requires a first and last name");
Evan Stade 2013/05/23 16:40:37 i10n
ahutter 2013/05/23 23:19:11 Done.
1135 }
1136 }
1137
1119 // If there is a credit card number and a CVC, validate them together. 1138 // If there is a credit card number and a CVC, validate them together.
1120 if (field_values.count(CREDIT_CARD_NUMBER) && 1139 if (field_values.count(CREDIT_CARD_NUMBER) &&
1121 field_values.count(CREDIT_CARD_VERIFICATION_CODE) && 1140 field_values.count(CREDIT_CARD_VERIFICATION_CODE) &&
1122 InputIsValid(CREDIT_CARD_NUMBER, field_values[CREDIT_CARD_NUMBER])) { 1141 InputIsValid(CREDIT_CARD_NUMBER, field_values[CREDIT_CARD_NUMBER])) {
1123 if (!autofill::IsValidCreditCardSecurityCode( 1142 if (!autofill::IsValidCreditCardSecurityCode(
1124 field_values[CREDIT_CARD_VERIFICATION_CODE], 1143 field_values[CREDIT_CARD_VERIFICATION_CODE],
1125 field_values[CREDIT_CARD_NUMBER])) { 1144 field_values[CREDIT_CARD_NUMBER])) {
1126 invalid_messages[CREDIT_CARD_VERIFICATION_CODE] = 1145 invalid_messages[CREDIT_CARD_VERIFICATION_CODE] =
1127 ASCIIToUTF16("CVC doesn't match card type!"); 1146 ASCIIToUTF16("CVC doesn't match card type!");
1128 } 1147 }
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; 2593 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL;
2575 } 2594 }
2576 2595
2577 // Has Wallet items. 2596 // Has Wallet items.
2578 return has_autofill_profiles ? 2597 return has_autofill_profiles ?
2579 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : 2598 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL :
2580 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; 2599 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL;
2581 } 2600 }
2582 2601
2583 } // namespace autofill 2602 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698