Chromium Code Reviews| Index: components/autofill/core/browser/credit_card.cc |
| diff --git a/components/autofill/core/browser/credit_card.cc b/components/autofill/core/browser/credit_card.cc |
| index f9e44afb86d3849c5ebab32c67a329270b5f9d62..88defbd65762e1d9ac3213252a75f1c1cfb99bb5 100644 |
| --- a/components/autofill/core/browser/credit_card.cc |
| +++ b/components/autofill/core/browser/credit_card.cc |
| @@ -81,6 +81,12 @@ base::string16 TypeForFill(const std::string& type) { |
| return base::string16(); |
| } |
| +bool IsInThePast(int month, int year) { |
|
Mathieu
2016/04/27 12:09:24
Could you use CreditCard::IsExpired? https://code.
please use gerrit instead
2016/04/27 18:05:44
Done.
|
| + base::Time::Exploded today; |
| + base::Time::Now().LocalExplode(&today); |
| + return today.year > year || (today.year == year && today.month > month); |
| +} |
| + |
| } // namespace |
| CreditCard::CreditCard(const std::string& guid, const std::string& origin) |
| @@ -265,6 +271,19 @@ CreditCard::ServerStatus CreditCard::GetServerStatus() const { |
| return server_status_; |
| } |
| +bool CreditCard::ShouldUpdateExpiration() const { |
| + switch (record_type()) { |
| + case LOCAL_CARD: |
| + return IsInThePast(expiration_month(), expiration_year()); |
| + case MASKED_SERVER_CARD: |
| + case FULL_SERVER_CARD: |
| + return server_status_ == EXPIRED || |
| + IsInThePast(expiration_month(), expiration_year()); |
| + } |
| + NOTREACHED(); |
| + return false; |
| +} |
| + |
| base::string16 CreditCard::GetRawInfo(ServerFieldType type) const { |
| DCHECK_EQ(CREDIT_CARD, AutofillType(type).group()); |
| switch (type) { |