Chromium Code Reviews| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 // Returns true if all field types have valid values set and the card is not | 167 // Returns true if all field types have valid values set and the card is not |
| 168 // expired. MASKED_SERVER_CARDs will never be valid because the number is | 168 // expired. MASKED_SERVER_CARDs will never be valid because the number is |
| 169 // not complete. | 169 // not complete. |
| 170 bool IsValid() const; | 170 bool IsValid() const; |
| 171 | 171 |
| 172 // Returns the credit card number. | 172 // Returns the credit card number. |
| 173 const base::string16& number() const { return number_; } | 173 const base::string16& number() const { return number_; } |
| 174 // Sets |number_| to |number| and computes the appropriate card |type_|. | 174 // Sets |number_| to |number| and computes the appropriate card |type_|. |
| 175 void SetNumber(const base::string16& number); | 175 void SetNumber(const base::string16& number); |
| 176 | 176 |
| 177 // Logs the number of days since the credit card was last used and records its | 177 // Returns the date(MM/DD) when the credit card was last used in autofill. |
| 178 // use. | 178 base::string16 LastUsedDateAsString( |
| 179 bool show_time_detail, | |
|
Jared Saul
2017/01/18 18:43:44
Based on outcome of my previous comment, should th
jiahuiguo
2017/01/18 22:18:13
Done.
| |
| 180 bool show_expiration_date, | |
|
Jared Saul
2017/01/18 18:43:44
super nit: Likewise, show_expiration_date has come
jiahuiguo
2017/01/18 22:18:13
Done.
| |
| 181 const std::string& app_locale) const; | |
| 182 | |
| 183 // Logs the number of days since the credit card was last used and records | |
| 184 // its use. | |
| 179 void RecordAndLogUse(); | 185 void RecordAndLogUse(); |
| 180 | 186 |
| 181 // Converts a string representation of a month (such as "February" or "feb." | 187 // Converts a string representation of a month (such as "February" or "feb." |
| 182 // or "2") into a numeric value in [1, 12]. Returns true on successful | 188 // or "2") into a numeric value in [1, 12]. Returns true on successful |
| 183 // conversion or false if a month was not recognized. | 189 // conversion or false if a month was not recognized. |
| 184 static bool ConvertMonth(const base::string16& month, | 190 static bool ConvertMonth(const base::string16& month, |
| 185 const std::string& app_locale, | 191 const std::string& app_locale, |
| 186 int* num); | 192 int* num); |
| 187 | 193 |
| 194 base::string16 GetShortMonthLabel(int32_t zero_base_month_index, | |
| 195 const std::string& app_locale) const; | |
| 196 | |
| 188 // Returns whether the credit card is expired based on |current_time|. | 197 // Returns whether the credit card is expired based on |current_time|. |
| 189 bool IsExpired(const base::Time& current_time) const; | 198 bool IsExpired(const base::Time& current_time) const; |
| 190 | 199 |
| 191 // Whether the card expiration date should be updated. | 200 // Whether the card expiration date should be updated. |
| 192 bool ShouldUpdateExpiration(const base::Time& current_time) const; | 201 bool ShouldUpdateExpiration(const base::Time& current_time) const; |
| 193 | 202 |
| 194 const std::string& billing_address_id() const { return billing_address_id_; } | 203 const std::string& billing_address_id() const { return billing_address_id_; } |
| 195 void set_billing_address_id(const std::string& id) { | 204 void set_billing_address_id(const std::string& id) { |
| 196 billing_address_id_ = id; | 205 billing_address_id_ = id; |
| 197 } | 206 } |
| 198 | 207 |
| 199 private: | 208 private: |
| 200 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationDateFromString); | 209 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationDateFromString); |
| 201 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationYearFromString); | 210 FRIEND_TEST_ALL_PREFIXES(CreditCardTest, SetExpirationYearFromString); |
| 202 | 211 |
| 203 // FormGroup: | 212 // FormGroup: |
| 204 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; | 213 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; |
| 205 | 214 |
| 206 // The type of the card to fill in to the page, e.g. 'Mastercard'. | 215 // The type of the card to fill in to the page, e.g. 'Mastercard'. |
| 207 base::string16 TypeForFill() const; | 216 base::string16 TypeForFill() const; |
| 208 | 217 |
| 209 // The month and year are zero if not present. | 218 // The month and year are zero if not present. |
| 210 int Expiration4DigitYear() const { return expiration_year_; } | 219 int Expiration4DigitYear() const { return expiration_year_; } |
| 211 int Expiration2DigitYear() const { return expiration_year_ % 100; } | 220 int Expiration2DigitYear() const { return expiration_year_ % 100; } |
| 212 base::string16 ExpirationMonthAsString() const; | 221 base::string16 ExpirationMonthAsString() const; |
| 213 base::string16 Expiration4DigitYearAsString() const; | 222 base::string16 Expiration4DigitYearAsString() const; |
| 214 base::string16 Expiration2DigitYearAsString() const; | 223 base::string16 Expiration2DigitYearAsString() const; |
| 215 | 224 |
| 225 // Padding month and day info to exactly 2 digits | |
|
Jared Saul
2017/01/18 18:43:44
nit: Add period; looks like that's the norm around
jiahuiguo
2017/01/18 22:18:13
Done.
| |
| 226 base::string16 PadTo2Digit(int32_t dateInfo) const; | |
|
Mathieu
2017/01/18 14:42:15
can this be in the anonymous namespace in the cc f
Mathieu
2017/01/18 14:42:15
nit: date_info
jiahuiguo
2017/01/18 22:18:13
Done.
jiahuiguo
2017/01/18 22:18:13
Good point, done.
| |
| 227 | |
| 216 // Sets |expiration_month_| to the integer conversion of |text| and returns | 228 // Sets |expiration_month_| to the integer conversion of |text| and returns |
| 217 // whether the operation was successful. | 229 // whether the operation was successful. |
| 218 bool SetExpirationMonthFromString(const base::string16& text, | 230 bool SetExpirationMonthFromString(const base::string16& text, |
| 219 const std::string& app_locale); | 231 const std::string& app_locale); |
| 220 | 232 |
| 221 // Sets |expiration_year_| to the integer conversion of |text|. Will handle | 233 // 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). | 234 // 4-digit year or 2-digit year (eventually converted to 4-digit year). |
| 223 void SetExpirationYearFromString(const base::string16& text); | 235 void SetExpirationYearFromString(const base::string16& text); |
| 224 | 236 |
| 225 // Sets |expiration_year_| and |expiration_month_| to the integer conversion | 237 // Sets |expiration_year_| and |expiration_month_| to the integer conversion |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 extern const char kGenericCard[]; | 278 extern const char kGenericCard[]; |
| 267 extern const char kJCBCard[]; | 279 extern const char kJCBCard[]; |
| 268 extern const char kMasterCard[]; | 280 extern const char kMasterCard[]; |
| 269 extern const char kMirCard[]; | 281 extern const char kMirCard[]; |
| 270 extern const char kUnionPay[]; | 282 extern const char kUnionPay[]; |
| 271 extern const char kVisaCard[]; | 283 extern const char kVisaCard[]; |
| 272 | 284 |
| 273 } // namespace autofill | 285 } // namespace autofill |
| 274 | 286 |
| 275 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 287 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
| OLD | NEW |