Chromium Code Reviews| 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 "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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |