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" | |
11 | 10 |
12 namespace autofill { | 11 namespace autofill { |
13 namespace data_util { | 12 namespace data_util { |
14 | 13 |
15 struct NameParts { | 14 struct NameParts { |
16 base::string16 given; | 15 base::string16 given; |
17 base::string16 middle; | 16 base::string16 middle; |
18 base::string16 family; | 17 base::string16 family; |
19 }; | 18 }; |
20 | 19 |
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 | |
29 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of | 20 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of |
30 // the three, at least). | 21 // the three, at least). |
31 bool IsCJKName(const base::string16& name); | 22 bool IsCJKName(const base::string16& name); |
32 | 23 |
33 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name | 24 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name |
34 // splitting. | 25 // splitting. |
35 // Returns the different name parts (given, middle and family names) of the full | 26 // Returns the different name parts (given, middle and family names) of the full |
36 // |name| passed as a parameter. | 27 // |name| passed as a parameter. |
37 NameParts SplitName(const base::string16& name); | 28 NameParts SplitName(const base::string16& name); |
38 | 29 |
39 // Concatenates the name parts together in the correct order (based on script), | 30 // Concatenates the name parts together in the correct order (based on script), |
40 // and returns the result. | 31 // and returns the result. |
41 base::string16 JoinNameParts(const base::string16& given, | 32 base::string16 JoinNameParts(const base::string16& given, |
42 const base::string16& middle, | 33 const base::string16& middle, |
43 const base::string16& family); | 34 const base::string16& family); |
44 | 35 |
45 // Returns true iff |full_name| is a concatenation of some combination of the | 36 // Returns true iff |full_name| is a concatenation of some combination of the |
46 // first/middle/last (incl. middle initial) in |profile|. | 37 // first/middle/last (incl. middle initial) in |profile|. |
47 bool ProfileMatchesFullName(const base::string16 full_name, | 38 bool ProfileMatchesFullName(const base::string16 full_name, |
48 const autofill::AutofillProfile& profile); | 39 const autofill::AutofillProfile& profile); |
49 | 40 |
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 | |
59 } // namespace data_util | 41 } // namespace data_util |
60 } // namespace autofill | 42 } // namespace autofill |
61 | 43 |
62 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ | 44 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_ |
OLD | NEW |