d398e476b683cba4e2f71792a03f4c974071b335
[platform/framework/web/crosswalk-tizen.git] /
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_
7
8 #include "base/strings/string16.h"
9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "grit/components_scaled_resources.h"
11
12 namespace autofill {
13 namespace data_util {
14
15 struct NameParts {
16   base::string16 given;
17   base::string16 middle;
18   base::string16 family;
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
29 // Returns true if |name| looks like a CJK name (or some kind of mish-mash of
30 // the three, at least).
31 bool IsCJKName(const base::string16& name);
32
33 // TODO(crbug.com/586510): Investigate the use of app_locale to do better name
34 // splitting.
35 // Returns the different name parts (given, middle and family names) of the full
36 // |name| passed as a parameter.
37 NameParts SplitName(const base::string16& name);
38
39 // Concatenates the name parts together in the correct order (based on script),
40 // and returns the result.
41 base::string16 JoinNameParts(const base::string16& given,
42                              const base::string16& middle,
43                              const base::string16& family);
44
45 // Returns true iff |full_name| is a concatenation of some combination of the
46 // first/middle/last (incl. middle initial) in |profile|.
47 bool ProfileMatchesFullName(const base::string16 full_name,
48                             const autofill::AutofillProfile& profile);
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
59 }  // namespace data_util
60 }  // namespace autofill
61
62 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DATA_UTIL_H_