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

Unified Diff: chrome/browser/autofill/credit_card_field.cc

Issue 7038003: Refactor autofill form fields. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 7 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: chrome/browser/autofill/credit_card_field.cc
diff --git a/chrome/browser/autofill/credit_card_field.cc b/chrome/browser/autofill/credit_card_field.cc
index b322574e4af05d168c75c8dd2a9fd88b2348919b..d65799f63b5564f140f1d4d870187b7caf4a2d5c 100644
--- a/chrome/browser/autofill/credit_card_field.cc
+++ b/chrome/browser/autofill/credit_card_field.cc
@@ -68,7 +68,9 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
}
}
- if (ParseText(scanner, name_pattern, &credit_card_field->cardholder_))
+ if (ParseText(scanner, name_pattern,
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT,
+ &credit_card_field->cardholder_))
continue;
// As a hard-coded hack for Expedia's billing pages (expedia_checkout.html
@@ -77,8 +79,11 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
// and "clnm".
scanner->SaveCursor();
const AutofillField* first;
- if (!is_ecml && ParseText(scanner, ASCIIToUTF16("^cfnm"), &first) &&
+ if (!is_ecml && ParseText(scanner, ASCIIToUTF16("^cfnm"),
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT,
+ &first) &&
ParseText(scanner, ASCIIToUTF16("^clnm"),
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT,
&credit_card_field->cardholder_last_)) {
credit_card_field->cardholder_ = first;
continue;
@@ -98,7 +103,8 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_CVC_RE);
if (!credit_card_field->verification_ &&
- ParseText(scanner, pattern, &credit_card_field->verification_))
+ ParseText(scanner, pattern, MATCH_NAME | MATCH_LABEL | MATCH_TEXT,
+ &credit_card_field->verification_))
continue;
// TODO(jhawkins): Parse the type select control.
@@ -109,7 +115,8 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_NUMBER_RE);
if (!credit_card_field->number_ &&
- ParseText(scanner, pattern, &credit_card_field->number_))
+ ParseText(scanner, pattern, MATCH_NAME | MATCH_LABEL | MATCH_TEXT,
+ &credit_card_field->number_))
continue;
if (LowerCaseEqualsASCII(scanner->Cursor()->form_control_type, "month")) {
@@ -135,13 +142,16 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
if ((!credit_card_field->expiration_month_ ||
credit_card_field->expiration_month_->IsEmpty()) &&
- ParseText(scanner, pattern, &credit_card_field->expiration_month_)) {
+ ParseText(scanner, pattern,
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT | MATCH_SELECT,
+ &credit_card_field->expiration_month_)) {
if (is_ecml)
pattern = GetEcmlPattern(kEcmlCardExpireYear);
else
pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EXPIRATION_DATE_RE);
if (!ParseText(scanner, pattern,
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT | MATCH_SELECT,
&credit_card_field->expiration_year_)) {
scanner->Rewind();
return NULL;
@@ -150,7 +160,9 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
}
}
- if (ParseText(scanner, GetEcmlPattern(kEcmlCardExpireDay)))
+ if (ParseText(scanner,
+ GetEcmlPattern(kEcmlCardExpireDay),
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT | MATCH_SELECT))
continue;
// Some pages (e.g. ExpediaBilling.html) have a "card description"
@@ -159,7 +171,8 @@ CreditCardField* CreditCardField::Parse(AutofillScanner* scanner,
// start with "card", under the assumption that they are related to
// the credit card section being processed but are uninteresting to us.
if (ParseText(scanner,
- l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_IGNORED_RE)))
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_IGNORED_RE),
+ MATCH_NAME | MATCH_LABEL | MATCH_TEXT))
continue;
break;

Powered by Google App Engine
This is Rietveld 408576698