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> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 bool IsEmpty(const std::string& app_locale) const; | 105 bool IsEmpty(const std::string& app_locale) const; |
106 | 106 |
107 // Returns true if all field types have valid values set. | 107 // Returns true if all field types have valid values set. |
108 bool IsComplete() const; | 108 bool IsComplete() const; |
109 | 109 |
110 // Returns true if all field types have valid values set and the card is not | 110 // Returns true if all field types have valid values set and the card is not |
111 // expired. | 111 // expired. |
112 bool IsValid() const; | 112 bool IsValid() const; |
113 | 113 |
114 // Returns the credit card number. | 114 // Returns the credit card number. |
115 const base::string16& number() const { return number_; } | 115 base::string16 GetNumber() const; |
116 | 116 |
117 private: | 117 private: |
118 // FormGroup: | 118 // FormGroup: |
119 virtual void GetSupportedTypes( | 119 virtual void GetSupportedTypes( |
120 ServerFieldTypeSet* supported_types) const OVERRIDE; | 120 ServerFieldTypeSet* supported_types) const OVERRIDE; |
121 | 121 |
122 // The month and year are zero if not present. | 122 // The month and year are zero if not present. |
123 int Expiration4DigitYear() const { return expiration_year_; } | 123 int Expiration4DigitYear() const { return expiration_year_; } |
124 int Expiration2DigitYear() const { return expiration_year_ % 100; } | 124 int Expiration2DigitYear() const { return expiration_year_ % 100; } |
125 base::string16 ExpirationMonthAsString() const; | 125 base::string16 ExpirationMonthAsString() const; |
126 base::string16 Expiration4DigitYearAsString() const; | 126 base::string16 Expiration4DigitYearAsString() const; |
127 base::string16 Expiration2DigitYearAsString() const; | 127 base::string16 Expiration2DigitYearAsString() const; |
128 | 128 |
129 // Sets |expiration_month_| to the integer conversion of |text|. | 129 // Sets |expiration_month_| to the integer conversion of |text|. |
130 void SetExpirationMonthFromString(const base::string16& text, | 130 void SetExpirationMonthFromString(const base::string16& text, |
131 const std::string& app_locale); | 131 const std::string& app_locale); |
132 | 132 |
133 // Sets |expiration_year_| to the integer conversion of |text|. | 133 // Sets |expiration_year_| to the integer conversion of |text|. |
134 void SetExpirationYearFromString(const base::string16& text); | 134 void SetExpirationYearFromString(const base::string16& text); |
135 | 135 |
136 enum Part { first_part, second_part, third_part, last_part, full_number }; | |
137 | |
136 // Sets |number_| to |number| and computes the appropriate card |type_|. | 138 // Sets |number_| to |number| and computes the appropriate card |type_|. |
137 void SetNumber(const base::string16& number); | 139 void SetNumber(const base::string16& number, |
140 const Part& part = autofill::CreditCard::full_number); | |
138 | 141 |
139 // These setters verify that the month and year are within appropriate | 142 // These setters verify that the month and year are within appropriate |
140 // ranges. | 143 // ranges. |
141 void SetExpirationMonth(int expiration_month); | 144 void SetExpirationMonth(int expiration_month); |
142 void SetExpirationYear(int expiration_year); | 145 void SetExpirationYear(int expiration_year); |
143 | 146 |
144 base::string16 number_; // The credit card number. | 147 base::string16 number_part1_; // The credit card number part 1 (0-3). |
148 base::string16 number_part2_; // The credit card number part 2 (4-7). | |
149 base::string16 number_part3_; // The credit card number part 3 (8-12). | |
150 base::string16 number_part4_; // The credit card number part 4 (12-End). | |
Ilya Sherman
2014/07/25 03:37:49
These shouldn't be necessary. The card number sho
Pritam Nikam
2014/07/26 11:29:50
Done.
| |
145 base::string16 name_on_card_; // The cardholder's name. | 151 base::string16 name_on_card_; // The cardholder's name. |
146 std::string type_; // The type of the card. | 152 std::string type_; // The type of the card. |
147 | 153 |
148 // These members are zero if not present. | 154 // These members are zero if not present. |
149 int expiration_month_; | 155 int expiration_month_; |
150 int expiration_year_; | 156 int expiration_year_; |
151 }; | 157 }; |
152 | 158 |
153 // So we can compare CreditCards with EXPECT_EQ(). | 159 // So we can compare CreditCards with EXPECT_EQ(). |
154 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card); | 160 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card); |
155 | 161 |
156 // The string identifiers for credit card icon resources. | 162 // The string identifiers for credit card icon resources. |
157 extern const char* const kAmericanExpressCard; | 163 extern const char* const kAmericanExpressCard; |
158 extern const char* const kDinersCard; | 164 extern const char* const kDinersCard; |
159 extern const char* const kDiscoverCard; | 165 extern const char* const kDiscoverCard; |
160 extern const char* const kGenericCard; | 166 extern const char* const kGenericCard; |
161 extern const char* const kJCBCard; | 167 extern const char* const kJCBCard; |
162 extern const char* const kMasterCard; | 168 extern const char* const kMasterCard; |
163 extern const char* const kUnionPay; | 169 extern const char* const kUnionPay; |
164 extern const char* const kVisaCard; | 170 extern const char* const kVisaCard; |
165 | 171 |
166 } // namespace autofill | 172 } // namespace autofill |
167 | 173 |
168 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 174 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
OLD | NEW |