Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: components/autofill/core/browser/credit_card.cc

Issue 1867523003: [Autofill] Suggest expired credit cards last. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored CC suggestions to use IsExpired Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 649a81267fc9bc2b1cbda27b5c1cb4fb45857f53..d0e56c2cf4299b2a55817e1599cb03d6ba233641 100644
--- a/components/autofill/core/browser/credit_card.cc
+++ b/components/autofill/core/browser/credit_card.cc
@@ -647,6 +647,16 @@ bool CreditCard::IsValid() const {
expiration_year_, expiration_month_, base::Time::Now());
}
+bool CreditCard::IsExpired(base::Time::Exploded time) const {
+ // Credit cards with no saved expiration are never considered expired.
+ if (expiration_month_ == 0 && expiration_year_ == 0)
+ return false;
+
+ // Credit cards expire at the end of the specified month.
+ return expiration_year_ < time.year ||
+ (expiration_year_ == time.year && expiration_month_ < time.month);
+}
+
void CreditCard::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
supported_types->insert(CREDIT_CARD_NAME_FULL);
supported_types->insert(CREDIT_CARD_NAME_FIRST);

Powered by Google App Engine
This is Rietveld 408576698