| 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 3b24ec38c1851268949aaa7ce297cda4ded4c9d8..55a163f805c8876c0f0acdc99636feed640341be 100644
|
| --- a/components/autofill/core/browser/credit_card_field.cc
|
| +++ b/components/autofill/core/browser/credit_card_field.cc
|
| @@ -40,7 +40,7 @@ bool FindConsecutiveStrings(const std::vector<base::string16>& regex_needles,
|
|
|
| for (size_t i = 0; i < haystack.size() - regex_needles.size() + 1; ++i) {
|
| for (size_t j = 0; j < regex_needles.size(); ++j) {
|
| - if (!MatchesPattern(haystack[i + j], regex_needles[j]))
|
| + if (!MatchesPattern(haystack[i + j], base::UTF16ToUTF8(regex_needles[j])))
|
| break;
|
|
|
| if (j == regex_needles.size() - 1)
|
| @@ -91,9 +91,7 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
| break;
|
|
|
| if (!credit_card_field->cardholder_) {
|
| - if (ParseField(scanner,
|
| - base::UTF8ToUTF16(kNameOnCardRe),
|
| - &credit_card_field->cardholder_)) {
|
| + if (ParseField(scanner, kNameOnCardRe, &credit_card_field->cardholder_)) {
|
| continue;
|
| }
|
|
|
| @@ -103,10 +101,8 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
| // fields. So we search for "name" only when we've already parsed at
|
| // least one other credit card field and haven't yet parsed the
|
| // expiration date (which usually appears at the end).
|
| - if (fields > 0 &&
|
| - !credit_card_field->expiration_month_ &&
|
| - ParseField(scanner,
|
| - base::UTF8ToUTF16(kNameOnCardContextualRe),
|
| + if (fields > 0 && !credit_card_field->expiration_month_ &&
|
| + ParseField(scanner, kNameOnCardContextualRe,
|
| &credit_card_field->cardholder_)) {
|
| continue;
|
| }
|
| @@ -129,7 +125,7 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
| const int kMatchNumAndTel = MATCH_DEFAULT | MATCH_NUMBER | MATCH_TELEPHONE;
|
| if (!credit_card_field->verification_ &&
|
| ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kCardCvcRe),
|
| + kCardCvcRe,
|
| kMatchNumAndTel | MATCH_PASSWORD,
|
| &credit_card_field->verification_)) {
|
| continue;
|
| @@ -137,7 +133,7 @@ scoped_ptr<FormField> CreditCardField::Parse(AutofillScanner* scanner) {
|
|
|
| AutofillField* current_number_field;
|
| if (ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kCardNumberRe),
|
| + kCardNumberRe,
|
| kMatchNumAndTel,
|
| ¤t_number_field)) {
|
| // Avoid autofilling any credit card number field having very low or high
|
| @@ -214,8 +210,7 @@ bool CreditCardField::LikelyCardMonthSelectField(AutofillScanner* scanner) {
|
| return false;
|
|
|
| // Filter out years.
|
| - const base::string16 kNumericalYearRe =
|
| - base::ASCIIToUTF16("[1-9][0-9][0-9][0-9]");
|
| + const char kNumericalYearRe[] = "[1-9][0-9][0-9][0-9]";
|
| for (const auto& value : field->option_values) {
|
| if (MatchesPattern(value, kNumericalYearRe))
|
| return false;
|
| @@ -226,7 +221,7 @@ bool CreditCardField::LikelyCardMonthSelectField(AutofillScanner* scanner) {
|
| }
|
|
|
| // Look for numerical months.
|
| - const base::string16 kNumericalMonthRe = base::ASCIIToUTF16("12");
|
| + const char kNumericalMonthRe[] = "12";
|
| if (MatchesPattern(field->option_values.back(), kNumericalMonthRe) ||
|
| MatchesPattern(field->option_contents.back(), kNumericalMonthRe)) {
|
| return true;
|
| @@ -285,16 +280,16 @@ bool CreditCardField::IsGiftCardField(AutofillScanner* scanner) {
|
| return false;
|
|
|
| size_t saved_cursor = scanner->SaveCursor();
|
| - if (ParseField(scanner, base::UTF8ToUTF16(kDebitCardRe), nullptr)) {
|
| + if (ParseField(scanner, kDebitCardRe, nullptr)) {
|
| scanner->RewindTo(saved_cursor);
|
| return false;
|
| }
|
| - if (ParseField(scanner, base::UTF8ToUTF16(kDebitGiftCardRe), nullptr)) {
|
| + if (ParseField(scanner, kDebitGiftCardRe, nullptr)) {
|
| scanner->RewindTo(saved_cursor);
|
| return false;
|
| }
|
|
|
| - return ParseField(scanner, base::UTF8ToUTF16(kGiftCardRe), nullptr);
|
| + return ParseField(scanner, kGiftCardRe, nullptr);
|
| }
|
|
|
| CreditCardField::CreditCardField()
|
| @@ -376,11 +371,11 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
|
| scanner->RewindTo(month_year_saved_cursor);
|
| const int kMatchTelAndSelect = MATCH_DEFAULT | MATCH_TELEPHONE | MATCH_SELECT;
|
| if (ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kExpirationMonthRe),
|
| + kExpirationMonthRe,
|
| kMatchTelAndSelect,
|
| &expiration_month_) &&
|
| ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kExpirationYearRe),
|
| + kExpirationYearRe,
|
| kMatchTelAndSelect,
|
| &expiration_year_)) {
|
| return true;
|
| @@ -389,11 +384,11 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
|
| // If that fails, look for just MM/YY(YY).
|
| scanner->RewindTo(month_year_saved_cursor);
|
| if (ParseFieldSpecifics(scanner,
|
| - base::ASCIIToUTF16("^mm$"),
|
| + "^mm$",
|
| kMatchTelAndSelect,
|
| &expiration_month_) &&
|
| ParseFieldSpecifics(scanner,
|
| - base::ASCIIToUTF16("^(yy|yyyy)$"),
|
| + "^(yy|yyyy)$",
|
| kMatchTelAndSelect,
|
| &expiration_year_)) {
|
| return true;
|
| @@ -412,7 +407,7 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
|
|
|
| // Try to look for a 2-digit year expiration date.
|
| if (ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kExpirationDate2DigitYearRe),
|
| + kExpirationDate2DigitYearRe,
|
| kMatchTelAndSelect,
|
| &expiration_date_)) {
|
| exp_year_type_ = CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR;
|
| @@ -422,7 +417,7 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
|
|
|
| // Try to look for a generic expiration date field. (2 or 4 digit year)
|
| if (ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kExpirationDateRe),
|
| + kExpirationDateRe,
|
| kMatchTelAndSelect,
|
| &expiration_date_)) {
|
| // If such a field exists, but it cannot fit a 4-digit year expiration
|
| @@ -440,7 +435,7 @@ bool CreditCardField::ParseExpirationDate(AutofillScanner* scanner) {
|
| if (FieldCanFitDataForFieldType(current_field_max_length,
|
| CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR) &&
|
| ParseFieldSpecifics(scanner,
|
| - base::UTF8ToUTF16(kExpirationDate4DigitYearRe),
|
| + kExpirationDate4DigitYearRe,
|
| kMatchTelAndSelect,
|
| &expiration_date_)) {
|
| expiration_month_ = nullptr;
|
|
|