| Index: components/autofill/core/browser/credit_card_field.cc
|
| diff --git a/components/autofill/core/browser/credit_card_field.cc b/components/autofill/core/browser/credit_card_field.cc
|
| index a9fe79e7c85bc5fd840c2761c053133b68a2d5c4..0e8d25dbfa58483b0badab61796a48d2e6a59a9d 100644
|
| --- a/components/autofill/core/browser/credit_card_field.cc
|
| +++ b/components/autofill/core/browser/credit_card_field.cc
|
| @@ -18,6 +18,8 @@
|
| #include "components/autofill/core/browser/autofill_regexes.h"
|
| #include "components/autofill/core/browser/autofill_scanner.h"
|
| #include "components/autofill/core/browser/field_types.h"
|
| +#include "grit/components_strings.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
|
|
| namespace autofill {
|
|
|
| @@ -60,7 +62,7 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
|
|
| // Credit card fields can appear in many different orders.
|
| // We loop until no more credit card related fields are found, see |break| at
|
| - // bottom of the loop.
|
| + // the bottom of the loop.
|
| for (int fields = 0; !scanner->IsEnd(); ++fields) {
|
| // Ignore gift card fields.
|
| if (ParseField(scanner, base::UTF8ToUTF16(kGiftCardRe), nullptr))
|
| @@ -89,11 +91,10 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
| }
|
|
|
| // Check for a credit card type (Visa, MasterCard, etc.) field.
|
| - if (!credit_card_field->type_ &&
|
| - ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kCardTypeRe),
|
| - MATCH_DEFAULT | MATCH_SELECT,
|
| - &credit_card_field->type_)) {
|
| + // All CC type fields encountered so far have been of type select.
|
| + if (!credit_card_field->type_ && LikelyCardTypeSelectField(scanner)) {
|
| + credit_card_field->type_ = scanner->Cursor();
|
| + scanner->Advance();
|
| continue;
|
| }
|
|
|
| @@ -150,14 +151,6 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
| return nullptr;
|
| }
|
|
|
| - // Some pages (e.g. ExpediaBilling.html) have a "card description"
|
| - // field; we parse this field but ignore it.
|
| - // We also ignore any other fields within a credit card block that
|
| - // start with "card", under the assumption that they are related to
|
| - // the credit card section being processed but are uninteresting to us.
|
| - if (ParseField(scanner, base::UTF8ToUTF16(kCardIgnoredRe), nullptr))
|
| - continue;
|
| -
|
| break;
|
| }
|
|
|
| @@ -247,6 +240,23 @@ bool CreditCardField::LikelyCardYearSelectField(AutofillScanner* scanner) {
|
| FindConsecutiveStrings(years_to_check, field->option_contents));
|
| }
|
|
|
| +// static
|
| +bool CreditCardField::LikelyCardTypeSelectField(AutofillScanner* scanner) {
|
| + if (scanner->IsEnd())
|
| + return false;
|
| +
|
| + AutofillField* field = scanner->Cursor();
|
| + if (!MatchesFormControlType(field->form_control_type, MATCH_SELECT))
|
| + return false;
|
| +
|
| + return AutofillField::FindValueInSelectControl(
|
| + *field, l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA),
|
| + nullptr) ||
|
| + AutofillField::FindValueInSelectControl(
|
| + *field, l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD),
|
| + nullptr);
|
| +}
|
| +
|
| CreditCardField::CreditCardField()
|
| : cardholder_(nullptr),
|
| cardholder_last_(nullptr),
|
|
|