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