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

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

Issue 2829503002: [Payments] Normalize Shipping Address sent to merchant on Desktop. (Closed)
Patch Set: Be more strict on country code Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_data_util.h" 5 #include "components/autofill/core/browser/autofill_data_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/i18n/char_iterator.h" 10 #include "base/i18n/char_iterator.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "components/autofill/core/browser/field_types.h" 14 #include "components/autofill/core/browser/field_types.h"
15 #include "components/grit/components_scaled_resources.h" 15 #include "components/grit/components_scaled_resources.h"
16 #include "third_party/icu/source/common/unicode/uscript.h" 16 #include "third_party/icu/source/common/unicode/uscript.h"
17 #include "third_party/re2/src/re2/re2.h"
17 18
18 namespace autofill { 19 namespace autofill {
19 namespace data_util { 20 namespace data_util {
20 21
21 namespace { 22 namespace {
22 // Mappings from Chrome card types to Payment Request API basic card payment 23 // Mappings from Chrome card types to Payment Request API basic card payment
23 // spec types and icons. Note that "generic" is not in the spec. 24 // spec types and icons. Note that "generic" is not in the spec.
24 // https://w3c.github.io/webpayments-methods-card/#method-id 25 // https://w3c.github.io/webpayments-methods-card/#method-id
25 const PaymentRequestData kPaymentRequestData[]{ 26 const PaymentRequestData kPaymentRequestData[]{
26 {"americanExpressCC", "amex", IDR_AUTOFILL_PR_AMEX}, 27 {"americanExpressCC", "amex", IDR_AUTOFILL_PR_AMEX},
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 const char* GetCardTypeForBasicCardPaymentType( 413 const char* GetCardTypeForBasicCardPaymentType(
413 const std::string& basic_card_payment_type) { 414 const std::string& basic_card_payment_type) {
414 for (const PaymentRequestData& data : kPaymentRequestData) { 415 for (const PaymentRequestData& data : kPaymentRequestData) {
415 if (basic_card_payment_type == data.basic_card_payment_type) { 416 if (basic_card_payment_type == data.basic_card_payment_type) {
416 return data.card_type; 417 return data.card_type;
417 } 418 }
418 } 419 }
419 return kGenericPaymentRequestData.card_type; 420 return kGenericPaymentRequestData.card_type;
420 } 421 }
421 422
423 bool IsValidCountryCode(const std::string& country_code) {
424 if (country_code.size() != 2)
425 return false;
426
427 return re2::RE2::FullMatch(country_code, "^[A-Z]{2}$");
428 }
429
430 bool IsValidCountryCode(const base::string16& country_code) {
431 return IsValidCountryCode(base::UTF16ToUTF8(country_code));
432 }
433
422 } // namespace data_util 434 } // namespace data_util
423 } // namespace autofill 435 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_data_util.h ('k') | components/autofill/core/browser/autofill_data_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698