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

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

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Added AddressComboboxModel unittests and fixed more compile issues. Created 3 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
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/validation.h" 5 #include "components/autofill/core/browser/validation.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 if (card.number().empty()) 135 if (card.number().empty())
136 status |= CREDIT_CARD_NO_NUMBER; 136 status |= CREDIT_CARD_NO_NUMBER;
137 137
138 if (card.GetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), 138 if (card.GetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL),
139 app_locale) 139 app_locale)
140 .empty()) { 140 .empty()) {
141 status |= CREDIT_CARD_NO_CARDHOLDER; 141 status |= CREDIT_CARD_NO_CARDHOLDER;
142 } 142 }
143 143
144 if (card.billing_address_id().empty()) {
sebsg 2017/05/02 22:58:55 This would be a bit more involved but we might wan
MAD 2017/05/03 16:15:19 Done.
145 status |= CREDIT_CARD_NO_BILLING_ADDRESS;
146 }
147
144 return status; 148 return status;
145 } 149 }
146 150
147 base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status) { 151 base::string16 GetCompletionMessageForCard(CreditCardCompletionStatus status) {
148 switch (status) { 152 switch (status) {
149 case CREDIT_CARD_COMPLETE: 153 case CREDIT_CARD_COMPLETE:
150 return base::string16(); 154 return base::string16();
151 case CREDIT_CARD_EXPIRED: 155 case CREDIT_CARD_EXPIRED:
152 return l10n_util::GetStringUTF16( 156 return l10n_util::GetStringUTF16(
153 IDS_PAYMENTS_VALIDATION_INVALID_CREDIT_CARD_EXPIRED); 157 IDS_PAYMENTS_VALIDATION_INVALID_CREDIT_CARD_EXPIRED);
154 case CREDIT_CARD_NO_CARDHOLDER: 158 case CREDIT_CARD_NO_CARDHOLDER:
155 return l10n_util::GetStringUTF16(IDS_PAYMENTS_NAME_ON_CARD_REQUIRED); 159 return l10n_util::GetStringUTF16(IDS_PAYMENTS_NAME_ON_CARD_REQUIRED);
156 case CREDIT_CARD_NO_NUMBER: 160 case CREDIT_CARD_NO_NUMBER:
157 return l10n_util::GetStringUTF16( 161 return l10n_util::GetStringUTF16(
158 IDS_PAYMENTS_CARD_NUMBER_INVALID_VALIDATION_MESSAGE); 162 IDS_PAYMENTS_CARD_NUMBER_INVALID_VALIDATION_MESSAGE);
163 case CREDIT_CARD_NO_BILLING_ADDRESS:
164 return l10n_util::GetStringUTF16(
165 IDS_PAYMENTS_CARD_BILLING_ADDRESS_REQUIRED);
159 default: 166 default:
160 // Multiple things are missing 167 // Multiple things are missing
161 return l10n_util::GetStringUTF16(IDS_PAYMENTS_MORE_INFORMATION_REQUIRED); 168 return l10n_util::GetStringUTF16(IDS_PAYMENTS_MORE_INFORMATION_REQUIRED);
162 } 169 }
163 } 170 }
164 171
165 bool IsValidEmailAddress(const base::string16& text) { 172 bool IsValidEmailAddress(const base::string16& text) {
166 // E-Mail pattern as defined by the WhatWG. (4.10.7.1.5 E-Mail state) 173 // E-Mail pattern as defined by the WhatWG. (4.10.7.1.5 E-Mail state)
167 const base::string16 kEmailPattern = base::ASCIIToUTF16( 174 const base::string16 kEmailPattern = base::ASCIIToUTF16(
168 "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" 175 "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return AMEX_CVC_LENGTH; 372 return AMEX_CVC_LENGTH;
366 373
367 return GENERAL_CVC_LENGTH; 374 return GENERAL_CVC_LENGTH;
368 } 375 }
369 376
370 bool IsUPIVirtualPaymentAddress(const base::string16& value) { 377 bool IsUPIVirtualPaymentAddress(const base::string16& value) {
371 return MatchesPattern(value, base::ASCIIToUTF16(kUPIVirtualPaymentAddressRe)); 378 return MatchesPattern(value, base::ASCIIToUTF16(kUPIVirtualPaymentAddressRe));
372 } 379 }
373 380
374 } // namespace autofill 381 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698