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

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

Issue 1885773002: [Autofill] Don't fill expiration date of expired credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit 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/autofill_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 6f4908cecc766c1c9e6ea251ddb3d18737f7e9c7..ac9695dc1376f07a7ac5d1262ec52f82c9141279 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -174,6 +174,14 @@ void SelectRightNameType(const ServerFieldTypeSet& old_types,
}
}
+bool IsCreditCardExpirationType(ServerFieldType type) {
+ return type == CREDIT_CARD_EXP_MONTH ||
+ type == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
+ type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
+ type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR ||
+ type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR;
+}
+
} // namespace
AutofillManager::AutofillManager(
@@ -1450,6 +1458,12 @@ void AutofillManager::FillOrPreviewDataModelForm(
// should be non-empty and vice versa.
value = unmask_request_.user_response.cvc;
DCHECK_EQ(&unmask_request_.card == &data_model, !value.empty());
+ } else if (is_credit_card && IsCreditCardExpirationType(
+ cached_field->Type().GetStorableType()) &&
+ static_cast<const CreditCard*>(&data_model)
+ ->IsExpired(base::Time::Now())) {
+ // Don't fill expired cards expiration date.
+ value = base::string16();
}
// Must match ForEachMatchingFormField() in form_autofill_util.cc.

Powered by Google App Engine
This is Rietveld 408576698