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 <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/gtest_prod_util.h" |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "components/autofill/core/browser/autofill_data_model.h" | 17 #include "components/autofill/core/browser/autofill_data_model.h" |
17 | 18 |
18 namespace autofill { | 19 namespace autofill { |
19 | 20 |
20 // A midline horizontal ellipsis (U+22EF). | 21 // A midline horizontal ellipsis (U+22EF). |
21 extern const base::char16 kMidlineEllipsis[]; | 22 extern const base::char16 kMidlineEllipsis[]; |
22 | 23 |
23 // A form group that stores credit card information. | 24 // A form group that stores credit card information. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 198 |
198 // Whether the card expiration date should be updated. | 199 // Whether the card expiration date should be updated. |
199 bool ShouldUpdateExpiration(const base::Time& current_time) const; | 200 bool ShouldUpdateExpiration(const base::Time& current_time) const; |
200 | 201 |
201 const std::string& billing_address_id() const { return billing_address_id_; } | 202 const std::string& billing_address_id() const { return billing_address_id_; } |
202 void set_billing_address_id(const std::string& id) { | 203 void set_billing_address_id(const std::string& id) { |
203 billing_address_id_ = id; | 204 billing_address_id_ = id; |
204 } | 205 } |
205 | 206 |
206 private: | 207 private: |
| 208 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationDateFromString); |
| 209 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationYearFromString); |
| 210 |
207 // FormGroup: | 211 // FormGroup: |
208 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; | 212 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; |
209 | 213 |
210 // The type of the card to fill in to the page, e.g. 'Mastercard'. | 214 // The type of the card to fill in to the page, e.g. 'Mastercard'. |
211 base::string16 TypeForFill() const; | 215 base::string16 TypeForFill() const; |
212 | 216 |
213 // The month and year are zero if not present. | 217 // The month and year are zero if not present. |
214 int Expiration4DigitYear() const { return expiration_year_; } | 218 int Expiration4DigitYear() const { return expiration_year_; } |
215 int Expiration2DigitYear() const { return expiration_year_ % 100; } | 219 int Expiration2DigitYear() const { return expiration_year_ % 100; } |
216 base::string16 ExpirationMonthAsString() const; | 220 base::string16 ExpirationMonthAsString() const; |
217 base::string16 Expiration4DigitYearAsString() const; | 221 base::string16 Expiration4DigitYearAsString() const; |
218 base::string16 Expiration2DigitYearAsString() const; | 222 base::string16 Expiration2DigitYearAsString() const; |
219 | 223 |
220 // Sets |expiration_month_| to the integer conversion of |text| and returns | 224 // Sets |expiration_month_| to the integer conversion of |text| and returns |
221 // whether the operation was successful. | 225 // whether the operation was successful. |
222 bool SetExpirationMonthFromString(const base::string16& text, | 226 bool SetExpirationMonthFromString(const base::string16& text, |
223 const std::string& app_locale); | 227 const std::string& app_locale); |
224 | 228 |
225 // Sets |expiration_year_| to the integer conversion of |text|. | 229 // Sets |expiration_year_| to the integer conversion of |text|. Will handle |
| 230 // 4-digit year or 2-digit year (eventually converted to 4-digit year). |
226 void SetExpirationYearFromString(const base::string16& text); | 231 void SetExpirationYearFromString(const base::string16& text); |
227 | 232 |
| 233 // Sets |expiration_year_| and |expiration_month_| to the integer conversion |
| 234 // of |text|. Will handle mmyy, mmyyyy, mm-yyyy and mm-yy as well as single |
| 235 // digit months, with various separators. |
| 236 void SetExpirationDateFromString(const base::string16& text); |
| 237 |
228 // See enum definition above. | 238 // See enum definition above. |
229 RecordType record_type_; | 239 RecordType record_type_; |
230 | 240 |
231 // The credit card number. For MASKED_SERVER_CARDs, this number will | 241 // The credit card number. For MASKED_SERVER_CARDs, this number will |
232 // just contain the last four digits of the card number. | 242 // just contain the last four digits of the card number. |
233 base::string16 number_; | 243 base::string16 number_; |
234 | 244 |
235 // The cardholder's name. May be empty. | 245 // The cardholder's name. May be empty. |
236 base::string16 name_on_card_; | 246 base::string16 name_on_card_; |
237 | 247 |
(...skipping 25 matching lines...) Expand all Loading... |
263 extern const char kDiscoverCard[]; | 273 extern const char kDiscoverCard[]; |
264 extern const char kGenericCard[]; | 274 extern const char kGenericCard[]; |
265 extern const char kJCBCard[]; | 275 extern const char kJCBCard[]; |
266 extern const char kMasterCard[]; | 276 extern const char kMasterCard[]; |
267 extern const char kUnionPay[]; | 277 extern const char kUnionPay[]; |
268 extern const char kVisaCard[]; | 278 extern const char kVisaCard[]; |
269 | 279 |
270 } // namespace autofill | 280 } // namespace autofill |
271 | 281 |
272 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 282 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
OLD | NEW |