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

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

Issue 2285523002: Add support for method selection in the Payment Request UI on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clear dictionaries before parsing. Created 4 years, 3 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_
7 7
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "grit/components_scaled_resources.h"
10 11
11 namespace autofill { 12 namespace autofill {
12 namespace data_util { 13 namespace data_util {
13 14
14 struct NameParts { 15 struct NameParts {
15 base::string16 given; 16 base::string16 given;
16 base::string16 middle; 17 base::string16 middle;
17 base::string16 family; 18 base::string16 family;
18 }; 19 };
19 20
21 // Mapping from Chrome card types to Payment Request API basic card payment spec
22 // types and icons. Note that "generic" is not in the spec.
23 // https://w3c.github.io/webpayments-methods-card/#method-id
24 const struct PaymentRequestData {
25 const char* card_type;
26 const char* basic_card_payment_type;
27 const int icon_resource_id;
28 } kPaymentRequestData[]{
Evan Stade 2016/08/29 20:34:06 seems like this should be in the .cc file rather t
Justin Donnelly 2016/08/30 15:21:25 Done.
29 {"genericCC", "generic", IDR_AUTOFILL_PR_GENERIC},
30
Evan Stade 2016/08/29 20:34:06 is this blank line intentional? seems weird
Justin Donnelly 2016/08/30 15:21:25 Removed (it made sense to me that it separated the
31 {"americanExpressCC", "amex", IDR_AUTOFILL_PR_AMEX},
32 {"dinersCC", "diners", IDR_AUTOFILL_PR_DINERS},
33 {"discoverCC", "discover", IDR_AUTOFILL_PR_DISCOVER},
34 {"jcbCC", "jcb", IDR_AUTOFILL_PR_JCB},
35 {"masterCardCC", "mastercard", IDR_AUTOFILL_PR_MASTERCARD},
36 {"unionPayCC", "unionpay", IDR_AUTOFILL_PR_UNIONPAY},
37 {"visaCC", "visa", IDR_AUTOFILL_PR_VISA},
38 };
39
20 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of 40 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of
21 // the three, at least). 41 // the three, at least).
22 bool IsCJKName(const base::string16& name); 42 bool IsCJKName(const base::string16& name);
23 43
24 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name 44 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name
25 // splitting. 45 // splitting.
26 // Returns the different name parts (given, middle and family names) of the full 46 // Returns the different name parts (given, middle and family names) of the full
27 // |name| passed as a parameter. 47 // |name| passed as a parameter.
28 NameParts SplitName(const base::string16& name); 48 NameParts SplitName(const base::string16& name);
29 49
30 // Concatenates the name parts together in the correct order (based on script), 50 // Concatenates the name parts together in the correct order (based on script),
31 // and returns the result. 51 // and returns the result.
32 base::string16 JoinNameParts(const base::string16& given, 52 base::string16 JoinNameParts(const base::string16& given,
33 const base::string16& middle, 53 const base::string16& middle,
34 const base::string16& family); 54 const base::string16& family);
35 55
36 // Returns true iff |full_name| is a concatenation of some combination of the 56 // Returns true iff |full_name| is a concatenation of some combination of the
37 // first/middle/last (incl. middle initial) in |profile|. 57 // first/middle/last (incl. middle initial) in |profile|.
38 bool ProfileMatchesFullName(const base::string16 full_name, 58 bool ProfileMatchesFullName(const base::string16 full_name,
39 const autofill::AutofillProfile& profile); 59 const autofill::AutofillProfile& profile);
40 60
61 // Returns the Payment Request API basic card payment spec data for the provided
62 // autofill credit card |type|. Will set the type and the icon to "generic" for
63 // any unrecognized type.
64 const PaymentRequestData& GetPaymentRequestData(const std::string& type);
65
66 // Returns the autofill credit card type string for the provided Payment Request
67 // API basic card payment spec |type|.
68 const char* GetCardTypeForBasicCardPaymentType(const std::string& type);
69
41 } // namespace data_util 70 } // namespace data_util
42 } // namespace autofill 71 } // namespace autofill
43 72
44 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ 73 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698