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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 const std::string& app_locale, | 193 const std::string& app_locale, |
193 int* num); | 194 int* num); |
194 | 195 |
195 // Returns whether the credit card is expired based on |current_time|. | 196 // Returns whether the credit card is expired based on |current_time|. |
196 bool IsExpired(const base::Time& current_time) const; | 197 bool IsExpired(const base::Time& current_time) const; |
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 private: | 202 private: |
| 203 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationDateFromString); |
| 204 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationYearFromString); |
| 205 |
202 // FormGroup: | 206 // FormGroup: |
203 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; | 207 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; |
204 | 208 |
205 // The type of the card to fill in to the page, e.g. 'Mastercard'. | 209 // The type of the card to fill in to the page, e.g. 'Mastercard'. |
206 base::string16 TypeForFill() const; | 210 base::string16 TypeForFill() const; |
207 | 211 |
208 // The month and year are zero if not present. | 212 // The month and year are zero if not present. |
209 int Expiration4DigitYear() const { return expiration_year_; } | 213 int Expiration4DigitYear() const { return expiration_year_; } |
210 int Expiration2DigitYear() const { return expiration_year_ % 100; } | 214 int Expiration2DigitYear() const { return expiration_year_ % 100; } |
211 base::string16 ExpirationMonthAsString() const; | 215 base::string16 ExpirationMonthAsString() const; |
212 base::string16 Expiration4DigitYearAsString() const; | 216 base::string16 Expiration4DigitYearAsString() const; |
213 base::string16 Expiration2DigitYearAsString() const; | 217 base::string16 Expiration2DigitYearAsString() const; |
214 | 218 |
215 // Sets |expiration_month_| to the integer conversion of |text| and returns | 219 // Sets |expiration_month_| to the integer conversion of |text| and returns |
216 // whether the operation was successful. | 220 // whether the operation was successful. |
217 bool SetExpirationMonthFromString(const base::string16& text, | 221 bool SetExpirationMonthFromString(const base::string16& text, |
218 const std::string& app_locale); | 222 const std::string& app_locale); |
219 | 223 |
220 // Sets |expiration_year_| to the integer conversion of |text|. | 224 // Sets |expiration_year_| to the integer conversion of |text|. Will handle |
| 225 // 4-digit year or 2-digit year (eventually converted to 4-digit year). |
221 void SetExpirationYearFromString(const base::string16& text); | 226 void SetExpirationYearFromString(const base::string16& text); |
222 | 227 |
| 228 // Sets |expiration_year_| and |expiration_month_| to the integer conversion |
| 229 // of |text|. Will handle mmyy, mmyyyy, mm-yyyy and mm-yy as well as single |
| 230 // digit months, with various separators. |
| 231 void SetExpirationDateFromString(const base::string16& text); |
| 232 |
223 // See enum definition above. | 233 // See enum definition above. |
224 RecordType record_type_; | 234 RecordType record_type_; |
225 | 235 |
226 // The credit card number. For MASKED_SERVER_CARDs, this number will | 236 // The credit card number. For MASKED_SERVER_CARDs, this number will |
227 // just contain the last four digits of the card number. | 237 // just contain the last four digits of the card number. |
228 base::string16 number_; | 238 base::string16 number_; |
229 | 239 |
230 // The cardholder's name. May be empty. | 240 // The cardholder's name. May be empty. |
231 base::string16 name_on_card_; | 241 base::string16 name_on_card_; |
232 | 242 |
(...skipping 22 matching lines...) Expand all Loading... |
255 extern const char kDiscoverCard[]; | 265 extern const char kDiscoverCard[]; |
256 extern const char kGenericCard[]; | 266 extern const char kGenericCard[]; |
257 extern const char kJCBCard[]; | 267 extern const char kJCBCard[]; |
258 extern const char kMasterCard[]; | 268 extern const char kMasterCard[]; |
259 extern const char kUnionPay[]; | 269 extern const char kUnionPay[]; |
260 extern const char kVisaCard[]; | 270 extern const char kVisaCard[]; |
261 | 271 |
262 } // namespace autofill | 272 } // namespace autofill |
263 | 273 |
264 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 274 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
OLD | NEW |