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

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

Issue 2888803003: [Payments] Use Autofill assets on Android Payment Request (Closed)
Patch Set: AppCompatResources in more places Created 3 years, 6 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_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "components/autofill/core/browser/field_types.h" 15 #include "components/autofill/core/browser/field_types.h"
16 #include "components/grit/components_scaled_resources.h" 16 #include "components/grit/components_scaled_resources.h"
17 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
18 #include "third_party/icu/source/common/unicode/uscript.h" 18 #include "third_party/icu/source/common/unicode/uscript.h"
19 #include "third_party/re2/src/re2/re2.h" 19 #include "third_party/re2/src/re2/re2.h"
20 20
21 namespace autofill { 21 namespace autofill {
22 namespace data_util { 22 namespace data_util {
23 23
24 namespace { 24 namespace {
25 // Mappings from Chrome card types to Payment Request API basic card payment 25 // Mappings from Chrome card types to Payment Request API basic card payment
26 // spec types and icons. Note that "generic" is not in the spec. 26 // spec types and icons. Note that "generic" is not in the spec.
27 // https://w3c.github.io/webpayments-methods-card/#method-id 27 // https://w3c.github.io/webpayments-methods-card/#method-id
28 #if defined(OS_ANDROID)
29 // On Android, use the PR-specific resource IDs.
30 const PaymentRequestData kPaymentRequestData[]{
31 {"americanExpressCC", "amex", IDR_AUTOFILL_PR_AMEX, IDS_AUTOFILL_CC_AMEX},
32 {"dinersCC", "diners", IDR_AUTOFILL_PR_DINERS, IDS_AUTOFILL_CC_DINERS},
33 {"discoverCC", "discover", IDR_AUTOFILL_PR_DISCOVER,
34 IDS_AUTOFILL_CC_DISCOVER},
35 {"jcbCC", "jcb", IDR_AUTOFILL_PR_JCB, IDS_AUTOFILL_CC_JCB},
36 {"masterCardCC", "mastercard", IDR_AUTOFILL_PR_MASTERCARD,
37 IDS_AUTOFILL_CC_MASTERCARD},
38 {"mirCC", "mir", IDR_AUTOFILL_PR_MIR, IDS_AUTOFILL_CC_MIR},
39 {"unionPayCC", "unionpay", IDR_AUTOFILL_PR_UNIONPAY,
40 IDS_AUTOFILL_CC_UNION_PAY},
41 {"visaCC", "visa", IDR_AUTOFILL_PR_VISA, IDS_AUTOFILL_CC_VISA},
42 };
43 const PaymentRequestData kGenericPaymentRequestData = {
44 "genericCC", "generic", IDR_AUTOFILL_PR_GENERIC, IDS_AUTOFILL_CC_GENERIC};
45 #else // !defined(OS_ANDROID)
46 // On other platforms, use the Autofill resource IDs.
47 const PaymentRequestData kPaymentRequestData[]{ 28 const PaymentRequestData kPaymentRequestData[]{
48 {"americanExpressCC", "amex", IDR_AUTOFILL_CC_AMEX, IDS_AUTOFILL_CC_AMEX}, 29 {"americanExpressCC", "amex", IDR_AUTOFILL_CC_AMEX, IDS_AUTOFILL_CC_AMEX},
49 {"dinersCC", "diners", IDR_AUTOFILL_CC_DINERS, IDS_AUTOFILL_CC_DINERS}, 30 {"dinersCC", "diners", IDR_AUTOFILL_CC_DINERS, IDS_AUTOFILL_CC_DINERS},
50 {"discoverCC", "discover", IDR_AUTOFILL_CC_DISCOVER, 31 {"discoverCC", "discover", IDR_AUTOFILL_CC_DISCOVER,
51 IDS_AUTOFILL_CC_DISCOVER}, 32 IDS_AUTOFILL_CC_DISCOVER},
52 {"jcbCC", "jcb", IDR_AUTOFILL_CC_JCB, IDS_AUTOFILL_CC_JCB}, 33 {"jcbCC", "jcb", IDR_AUTOFILL_CC_JCB, IDS_AUTOFILL_CC_JCB},
53 {"masterCardCC", "mastercard", IDR_AUTOFILL_CC_MASTERCARD, 34 {"masterCardCC", "mastercard", IDR_AUTOFILL_CC_MASTERCARD,
54 IDS_AUTOFILL_CC_MASTERCARD}, 35 IDS_AUTOFILL_CC_MASTERCARD},
55 {"mirCC", "mir", IDR_AUTOFILL_CC_MIR, IDS_AUTOFILL_CC_MIR}, 36 {"mirCC", "mir", IDR_AUTOFILL_CC_MIR, IDS_AUTOFILL_CC_MIR},
56 {"unionPayCC", "unionpay", IDR_AUTOFILL_CC_UNIONPAY, 37 {"unionPayCC", "unionpay", IDR_AUTOFILL_CC_UNIONPAY,
57 IDS_AUTOFILL_CC_UNION_PAY}, 38 IDS_AUTOFILL_CC_UNION_PAY},
58 {"visaCC", "visa", IDR_AUTOFILL_CC_VISA, IDS_AUTOFILL_CC_VISA}, 39 {"visaCC", "visa", IDR_AUTOFILL_CC_VISA, IDS_AUTOFILL_CC_VISA},
59 }; 40 };
60 const PaymentRequestData kGenericPaymentRequestData = { 41 const PaymentRequestData kGenericPaymentRequestData = {
61 "genericCC", "generic", IDR_AUTOFILL_CC_GENERIC, IDS_AUTOFILL_CC_GENERIC}; 42 "genericCC", "generic", IDR_AUTOFILL_CC_GENERIC, IDS_AUTOFILL_CC_GENERIC};
62 #endif
63 43
64 const char* const name_prefixes[] = { 44 const char* const name_prefixes[] = {
65 "1lt", "1st", "2lt", "2nd", "3rd", "admiral", "capt", 45 "1lt", "1st", "2lt", "2nd", "3rd", "admiral", "capt",
66 "captain", "col", "cpt", "dr", "gen", "general", "lcdr", 46 "captain", "col", "cpt", "dr", "gen", "general", "lcdr",
67 "lt", "ltc", "ltg", "ltjg", "maj", "major", "mg", 47 "lt", "ltc", "ltg", "ltjg", "maj", "major", "mg",
68 "mr", "mrs", "ms", "pastor", "prof", "rep", "reverend", 48 "mr", "mrs", "ms", "pastor", "prof", "rep", "reverend",
69 "rev", "sen", "st"}; 49 "rev", "sen", "st"};
70 50
71 const char* const name_suffixes[] = {"b.a", "ba", "d.d.s", "dds", "i", "ii", 51 const char* const name_suffixes[] = {"b.a", "ba", "d.d.s", "dds", "i", "ii",
72 "iii", "iv", "ix", "jr", "m.a", "m.d", 52 "iii", "iv", "ix", "jr", "m.a", "m.d",
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 432
453 return re2::RE2::FullMatch(country_code, "^[A-Z]{2}$"); 433 return re2::RE2::FullMatch(country_code, "^[A-Z]{2}$");
454 } 434 }
455 435
456 bool IsValidCountryCode(const base::string16& country_code) { 436 bool IsValidCountryCode(const base::string16& country_code) {
457 return IsValidCountryCode(base::UTF16ToUTF8(country_code)); 437 return IsValidCountryCode(base::UTF16ToUTF8(country_code));
458 } 438 }
459 439
460 } // namespace data_util 440 } // namespace data_util
461 } // namespace autofill 441 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/android/resource_id.h ('k') | components/resources/autofill_scaled_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698