| Index: components/autofill/core/browser/autofill_field.cc
|
| diff --git a/components/autofill/core/browser/autofill_field.cc b/components/autofill/core/browser/autofill_field.cc
|
| index 8822bd883098f5510d60cc48209e481d71518a1b..4f49ff06d27cb9a7302e5c95ba92a3e0cb1694f0 100644
|
| --- a/components/autofill/core/browser/autofill_field.cc
|
| +++ b/components/autofill/core/browser/autofill_field.cc
|
| @@ -274,33 +274,6 @@ bool FillCreditCardTypeSelectControl(const base::string16& value,
|
| return false;
|
| }
|
|
|
| -// Set |field_data|'s value to |number|, or possibly an appropriate substring of
|
| -// |number|. The |field| specifies the type of the phone and whether this is a
|
| -// phone prefix or suffix.
|
| -void FillPhoneNumberField(const AutofillField& field,
|
| - const base::string16& number,
|
| - FormFieldData* field_data) {
|
| - field_data->value =
|
| - AutofillField::GetPhoneNumberValue(field, number, *field_data);
|
| -}
|
| -
|
| -// Set |field_data|'s value to |number|, or possibly an appropriate substring
|
| -// of |number| for cases where credit card number splits across multiple HTML
|
| -// form input fields.
|
| -// The |field| specifies the |credit_card_number_offset_| to the substring
|
| -// within credit card number.
|
| -void FillCreditCardNumberField(const AutofillField& field,
|
| - const base::string16& number,
|
| - FormFieldData* field_data) {
|
| - base::string16 value = number;
|
| -
|
| - // |field|'s max_length truncates credit card number to fit within.
|
| - if (field.credit_card_number_offset() < value.length())
|
| - value = value.substr(field.credit_card_number_offset());
|
| -
|
| - field_data->value = value;
|
| -}
|
| -
|
| // Fills in the select control |field| with |value|. If an exact match is not
|
| // found, falls back to alternate filling strategies based on the |type|.
|
| bool FillSelectControl(const AutofillType& type,
|
| @@ -482,7 +455,7 @@ bool AutofillField::FillFormField(const AutofillField& field,
|
| AutofillType type = field.Type();
|
|
|
| if (type.GetStorableType() == PHONE_HOME_NUMBER) {
|
| - FillPhoneNumberField(field, value, field_data);
|
| + field_data->value = AutofillField::GetPhoneNumberValue(field, value);
|
| return true;
|
| } else if (field_data->form_control_type == "select-one") {
|
| return FillSelectControl(type, value, app_locale, field_data);
|
| @@ -492,7 +465,7 @@ bool AutofillField::FillFormField(const AutofillField& field,
|
| FillStreetAddress(value, address_language_code, field_data);
|
| return true;
|
| } else if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
|
| - FillCreditCardNumberField(field, value, field_data);
|
| + field_data->value = AutofillField::GetCreditCardNumberValue(field, value);
|
| return true;
|
| }
|
|
|
| @@ -502,8 +475,7 @@ bool AutofillField::FillFormField(const AutofillField& field,
|
|
|
| base::string16 AutofillField::GetPhoneNumberValue(
|
| const AutofillField& field,
|
| - const base::string16& number,
|
| - const FormFieldData& field_data) {
|
| + const base::string16& number) {
|
| // Check to see if the size field matches the "prefix" or "suffix" size.
|
| // If so, return the appropriate substring.
|
| if (number.length() !=
|
| @@ -512,13 +484,13 @@ base::string16 AutofillField::GetPhoneNumberValue(
|
| }
|
|
|
| if (field.phone_part() == AutofillField::PHONE_PREFIX ||
|
| - field_data.max_length == PhoneNumber::kPrefixLength) {
|
| + field.max_length == PhoneNumber::kPrefixLength) {
|
| return
|
| number.substr(PhoneNumber::kPrefixOffset, PhoneNumber::kPrefixLength);
|
| }
|
|
|
| if (field.phone_part() == AutofillField::PHONE_SUFFIX ||
|
| - field_data.max_length == PhoneNumber::kSuffixLength) {
|
| + field.max_length == PhoneNumber::kSuffixLength) {
|
| return
|
| number.substr(PhoneNumber::kSuffixOffset, PhoneNumber::kSuffixLength);
|
| }
|
| @@ -526,4 +498,18 @@ base::string16 AutofillField::GetPhoneNumberValue(
|
| return number;
|
| }
|
|
|
| +// The |field| specifies the |credit_card_number_offset()| to the substring
|
| +// within credit card number.
|
| +base::string16 AutofillField::GetCreditCardNumberValue(
|
| + const AutofillField& field,
|
| + const base::string16& number) {
|
| + base::string16 value = number;
|
| +
|
| + // |field|'s max_length truncates credit card number to fit within.
|
| + if (field.credit_card_number_offset() < value.length())
|
| + value = value.substr(field.credit_card_number_offset());
|
| +
|
| + return value;
|
| +}
|
| +
|
| } // namespace autofill
|
|
|