| 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..9edfef2324075b2ccf3f333ea6b17d798b8cdc67 100644
|
| --- a/components/autofill/core/browser/credit_card_field.cc
|
| +++ b/components/autofill/core/browser/credit_card_field.cc
|
| @@ -11,7 +11,6 @@
|
| #include "base/strings/string16.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| -#include "base/strings/utf_string_conversions.h"
|
| #include "base/time/time.h"
|
| #include "components/autofill/core/browser/autofill_field.h"
|
| #include "components/autofill/core/browser/autofill_regex_constants.h"
|
| @@ -31,7 +30,7 @@ const size_t kMaxValidCardNumberSize = 19;
|
|
|
| // Look for the vector |regex_needles| in |haystack|. Returns true if a
|
| // consecutive section of |haystack| matches |regex_needles|.
|
| -bool FindConsecutiveStrings(const std::vector<base::string16>& regex_needles,
|
| +bool FindConsecutiveStrings(const std::vector<std::string>& regex_needles,
|
| const std::vector<base::string16>& haystack) {
|
| if (regex_needles.empty() ||
|
| haystack.empty() ||
|
| @@ -91,9 +90,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 +100,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 +124,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 +132,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 +209,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 +220,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;
|
| @@ -252,11 +246,11 @@ bool CreditCardField::LikelyCardYearSelectField(AutofillScanner* scanner) {
|
| time_now.UTCExplode(&time_exploded);
|
|
|
| const int kYearsToMatch = 3;
|
| - std::vector<base::string16> years_to_check;
|
| + std::vector<std::string> years_to_check;
|
| for (int year = time_exploded.year;
|
| year < time_exploded.year + kYearsToMatch;
|
| ++year) {
|
| - years_to_check.push_back(base::IntToString16(year));
|
| + years_to_check.push_back(base::IntToString(year));
|
| }
|
| return (FindConsecutiveStrings(years_to_check, field->option_values) ||
|
| FindConsecutiveStrings(years_to_check, field->option_contents));
|
| @@ -285,16 +279,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 +370,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 +383,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 +406,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 +416,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 +434,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;
|
|
|