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

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

Issue 17099006: Validate saved credit card number in interactive autocomplete (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge master Created 7 years, 6 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 b63d627c4f4dc943f036cc5088db3f56f07b9354..125879443da737254df5c713e93840c26ce31806 100644
--- a/components/autofill/core/browser/credit_card.cc
+++ b/components/autofill/core/browser/credit_card.cc
@@ -17,6 +17,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/time.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_regexes.h"
#include "components/autofill/core/browser/autofill_type.h"
@@ -586,6 +587,12 @@ bool CreditCard::IsComplete() const {
expiration_year_ != 0;
}
+bool CreditCard::IsValid() const {
+ return autofill::IsValidCreditCardNumber(number_) &&
+ autofill::IsValidCreditCardExpirationDate(
+ expiration_year_, expiration_month_, base::Time::Now());
+}
+
void CreditCard::GetSupportedTypes(FieldTypeSet* supported_types) const {
supported_types->insert(CREDIT_CARD_NAME);
supported_types->insert(CREDIT_CARD_NUMBER);
« no previous file with comments | « components/autofill/core/browser/credit_card.h ('k') | components/autofill/core/browser/credit_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698