OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CREDIT_CARD_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "components/autofill/core/browser/autofill_data_model.h" | 14 #include "components/autofill/core/browser/autofill_data_model.h" |
15 #include "components/autofill/core/browser/field_types.h" | |
16 | 15 |
17 namespace autofill { | 16 namespace autofill { |
18 | 17 |
19 struct FormFieldData; | 18 struct FormFieldData; |
20 | 19 |
21 // A form group that stores credit card information. | 20 // A form group that stores credit card information. |
22 class CreditCard : public AutofillDataModel { | 21 class CreditCard : public AutofillDataModel { |
23 public: | 22 public: |
24 CreditCard(const std::string& guid, const std::string& origin); | 23 CreditCard(const std::string& guid, const std::string& origin); |
25 | 24 |
(...skipping 14 matching lines...) Expand all Loading... |
40 // Returns the internal representation of credit card type corresponding to | 39 // Returns the internal representation of credit card type corresponding to |
41 // the given |number|. The credit card type is determined purely according to | 40 // the given |number|. The credit card type is determined purely according to |
42 // the Issuer Identification Number (IIN), a.k.a. the "Bank Identification | 41 // the Issuer Identification Number (IIN), a.k.a. the "Bank Identification |
43 // Number (BIN)", which is parsed from the relevant prefix of the |number|. | 42 // Number (BIN)", which is parsed from the relevant prefix of the |number|. |
44 // This function performs no additional validation checks on the |number|. | 43 // This function performs no additional validation checks on the |number|. |
45 // Hence, the returned type for both the valid card "4111-1111-1111-1111" and | 44 // Hence, the returned type for both the valid card "4111-1111-1111-1111" and |
46 // the invalid card "4garbage" will be Visa, which has an IIN of 4. | 45 // the invalid card "4garbage" will be Visa, which has an IIN of 4. |
47 static std::string GetCreditCardType(const base::string16& number); | 46 static std::string GetCreditCardType(const base::string16& number); |
48 | 47 |
49 // FormGroup: | 48 // FormGroup: |
50 virtual void GetMatchingTypes(const base::string16& text, | 49 virtual void GetMatchingTypes( |
51 const std::string& app_locale, | 50 const base::string16& text, |
52 FieldTypeSet* matching_types) const OVERRIDE; | 51 const std::string& app_locale, |
53 virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE; | 52 ServerFieldTypeSet* matching_types) const OVERRIDE; |
54 virtual void SetRawInfo(AutofillFieldType type, | 53 virtual base::string16 GetRawInfo(ServerFieldType type) const OVERRIDE; |
| 54 virtual void SetRawInfo(ServerFieldType type, |
55 const base::string16& value) OVERRIDE; | 55 const base::string16& value) OVERRIDE; |
56 virtual base::string16 GetInfo(AutofillFieldType type, | 56 virtual base::string16 GetInfo(const AutofillType& type, |
57 const std::string& app_locale) const OVERRIDE; | 57 const std::string& app_locale) const OVERRIDE; |
58 virtual bool SetInfo(AutofillFieldType type, | 58 virtual bool SetInfo(const AutofillType& type, |
59 const base::string16& value, | 59 const base::string16& value, |
60 const std::string& app_locale) OVERRIDE; | 60 const std::string& app_locale) OVERRIDE; |
61 | 61 |
62 // AutofillDataModel: | 62 // AutofillDataModel: |
63 virtual void FillFormField(const AutofillField& field, | 63 virtual void FillFormField(const AutofillField& field, |
64 size_t variant, | 64 size_t variant, |
65 const std::string& app_locale, | 65 const std::string& app_locale, |
66 FormFieldData* field_data) const OVERRIDE; | 66 FormFieldData* field_data) const OVERRIDE; |
67 | 67 |
68 // Credit card preview summary, for example: ******1234, Exp: 01/2020 | 68 // Credit card preview summary, for example: ******1234, Exp: 01/2020 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 // Returns true if all field types have valid values set and the card is not | 116 // Returns true if all field types have valid values set and the card is not |
117 // expired. | 117 // expired. |
118 bool IsValid() const; | 118 bool IsValid() const; |
119 | 119 |
120 // Returns the credit card number. | 120 // Returns the credit card number. |
121 const base::string16& number() const { return number_; } | 121 const base::string16& number() const { return number_; } |
122 | 122 |
123 private: | 123 private: |
124 // FormGroup: | 124 // FormGroup: |
125 virtual void GetSupportedTypes(FieldTypeSet* supported_types) const OVERRIDE; | 125 virtual void GetSupportedTypes( |
| 126 ServerFieldTypeSet* supported_types) const OVERRIDE; |
126 | 127 |
127 // The month and year are zero if not present. | 128 // The month and year are zero if not present. |
128 int Expiration4DigitYear() const { return expiration_year_; } | 129 int Expiration4DigitYear() const { return expiration_year_; } |
129 int Expiration2DigitYear() const { return expiration_year_ % 100; } | 130 int Expiration2DigitYear() const { return expiration_year_ % 100; } |
130 base::string16 ExpirationMonthAsString() const; | 131 base::string16 ExpirationMonthAsString() const; |
131 base::string16 Expiration4DigitYearAsString() const; | 132 base::string16 Expiration4DigitYearAsString() const; |
132 base::string16 Expiration2DigitYearAsString() const; | 133 base::string16 Expiration2DigitYearAsString() const; |
133 | 134 |
134 // Sets |expiration_month_| to the integer conversion of |text|. | 135 // Sets |expiration_month_| to the integer conversion of |text|. |
135 void SetExpirationMonthFromString(const base::string16& text, | 136 void SetExpirationMonthFromString(const base::string16& text, |
(...skipping 28 matching lines...) Expand all Loading... |
164 extern const char* const kDiscoverCard; | 165 extern const char* const kDiscoverCard; |
165 extern const char* const kGenericCard; | 166 extern const char* const kGenericCard; |
166 extern const char* const kJCBCard; | 167 extern const char* const kJCBCard; |
167 extern const char* const kMasterCard; | 168 extern const char* const kMasterCard; |
168 extern const char* const kUnionPay; | 169 extern const char* const kUnionPay; |
169 extern const char* const kVisaCard; | 170 extern const char* const kVisaCard; |
170 | 171 |
171 } // namespace autofill | 172 } // namespace autofill |
172 | 173 |
173 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 174 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
OLD | NEW |