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

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

Issue 1926553002: Prompt for expiration date for local cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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) {

Powered by Google App Engine
This is Rietveld 408576698