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

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

Issue 2673753005: [Payments] Basic validation in the credit card editor. (Closed)
Patch Set: more tests Created 3 years, 10 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 32d65452ea8b95e3a58d5643eed5d433379b4587..5b002bc3fed84ba4484ab541eaa1199584230ce1 100644
--- a/components/autofill/core/browser/credit_card.cc
+++ b/components/autofill/core/browser/credit_card.cc
@@ -664,50 +664,6 @@ bool CreditCard::IsValid() const {
AutofillClock::Now());
}
-void CreditCard::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
- supported_types->insert(CREDIT_CARD_NAME_FULL);
- supported_types->insert(CREDIT_CARD_NAME_FIRST);
- supported_types->insert(CREDIT_CARD_NAME_LAST);
- supported_types->insert(CREDIT_CARD_NUMBER);
- supported_types->insert(CREDIT_CARD_TYPE);
- supported_types->insert(CREDIT_CARD_EXP_MONTH);
- supported_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR);
- supported_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR);
- supported_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR);
- supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR);
-}
-
-base::string16 CreditCard::ExpirationMonthAsString() const {
- if (expiration_month_ == 0)
- return base::string16();
-
- base::string16 month = base::IntToString16(expiration_month_);
- if (expiration_month_ >= 10)
- return month;
-
- base::string16 zero = ASCIIToUTF16("0");
- zero.append(month);
- return zero;
-}
-
-base::string16 CreditCard::TypeForFill() const {
- return ::autofill::TypeForFill(type_);
-}
-
-base::string16 CreditCard::Expiration4DigitYearAsString() const {
- if (expiration_year_ == 0)
- return base::string16();
-
- return base::IntToString16(Expiration4DigitYear());
-}
-
-base::string16 CreditCard::Expiration2DigitYearAsString() const {
- if (expiration_year_ == 0)
- return base::string16();
-
- return base::IntToString16(Expiration2DigitYear());
-}
-
bool CreditCard::SetExpirationMonthFromString(const base::string16& text,
const std::string& app_locale) {
base::string16 trimmed;
@@ -775,6 +731,50 @@ void CreditCard::SetExpirationDateFromString(const base::string16& text) {
SetExpirationYear(num);
}
+void CreditCard::GetSupportedTypes(ServerFieldTypeSet* supported_types) const {
+ supported_types->insert(CREDIT_CARD_NAME_FULL);
+ supported_types->insert(CREDIT_CARD_NAME_FIRST);
+ supported_types->insert(CREDIT_CARD_NAME_LAST);
+ supported_types->insert(CREDIT_CARD_NUMBER);
+ supported_types->insert(CREDIT_CARD_TYPE);
+ supported_types->insert(CREDIT_CARD_EXP_MONTH);
+ supported_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR);
+ supported_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR);
+ supported_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR);
+ supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR);
+}
+
+base::string16 CreditCard::ExpirationMonthAsString() const {
+ if (expiration_month_ == 0)
+ return base::string16();
+
+ base::string16 month = base::IntToString16(expiration_month_);
+ if (expiration_month_ >= 10)
+ return month;
+
+ base::string16 zero = ASCIIToUTF16("0");
+ zero.append(month);
+ return zero;
+}
+
+base::string16 CreditCard::TypeForFill() const {
+ return ::autofill::TypeForFill(type_);
+}
+
+base::string16 CreditCard::Expiration4DigitYearAsString() const {
+ if (expiration_year_ == 0)
+ return base::string16();
+
+ return base::IntToString16(Expiration4DigitYear());
+}
+
+base::string16 CreditCard::Expiration2DigitYearAsString() const {
+ if (expiration_year_ == 0)
+ return base::string16();
+
+ return base::IntToString16(Expiration2DigitYear());
+}
+
void CreditCard::SetNumber(const base::string16& number) {
number_ = number;

Powered by Google App Engine
This is Rietveld 408576698