OLD | NEW |
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 // Used to map Chrome card types to Payment Request API basic card payment spec |
| 22 // types and icons. https://w3c.github.io/webpayments-methods-card/#method-id |
| 23 struct PaymentRequestData { |
| 24 const char* card_type; |
| 25 const char* basic_card_payment_type; |
| 26 const int icon_resource_id; |
| 27 }; |
| 28 |
20 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of | 29 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of |
21 // the three, at least). | 30 // the three, at least). |
22 bool IsCJKName(const base::string16& name); | 31 bool IsCJKName(const base::string16& name); |
23 | 32 |
24 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name | 33 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name |
25 // splitting. | 34 // splitting. |
26 // Returns the different name parts (given, middle and family names) of the full | 35 // Returns the different name parts (given, middle and family names) of the full |
27 // |name| passed as a parameter. | 36 // |name| passed as a parameter. |
28 NameParts SplitName(const base::string16& name); | 37 NameParts SplitName(const base::string16& name); |
29 | 38 |
30 // Concatenates the name parts together in the correct order (based on script), | 39 // Concatenates the name parts together in the correct order (based on script), |
31 // and returns the result. | 40 // and returns the result. |
32 base::string16 JoinNameParts(const base::string16& given, | 41 base::string16 JoinNameParts(const base::string16& given, |
33 const base::string16& middle, | 42 const base::string16& middle, |
34 const base::string16& family); | 43 const base::string16& family); |
35 | 44 |
36 // Returns true iff |full_name| is a concatenation of some combination of the | 45 // Returns true iff |full_name| is a concatenation of some combination of the |
37 // first/middle/last (incl. middle initial) in |profile|. | 46 // first/middle/last (incl. middle initial) in |profile|. |
38 bool ProfileMatchesFullName(const base::string16 full_name, | 47 bool ProfileMatchesFullName(const base::string16 full_name, |
39 const autofill::AutofillProfile& profile); | 48 const autofill::AutofillProfile& profile); |
40 | 49 |
| 50 // Returns the Payment Request API basic card payment spec data for the provided |
| 51 // autofill credit card |type|. Will set the type and the icon to "generic" for |
| 52 // any unrecognized type. |
| 53 const PaymentRequestData& GetPaymentRequestData(const std::string& type); |
| 54 |
| 55 // Returns the autofill credit card type string for the provided Payment Request |
| 56 // API basic card payment spec |type|. |
| 57 const char* GetCardTypeForBasicCardPaymentType(const std::string& type); |
| 58 |
41 } // namespace data_util | 59 } // namespace data_util |
42 } // namespace autofill | 60 } // namespace autofill |
43 | 61 |
44 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ | 62 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ |
OLD | NEW |