| 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 c5b696e933c2721bda73b265aeddc2e89b5d1a89..22db6f754d9f8e3231bf0847b73148271ddc9aec 100644
|
| --- a/components/autofill/core/browser/autofill_field.cc
|
| +++ b/components/autofill/core/browser/autofill_field.cc
|
| @@ -299,6 +299,23 @@ void FillPhoneNumberField(const AutofillField& field,
|
| field_data->value = value;
|
| }
|
|
|
| +// 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_start_index_| 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_start_index() < value.length())
|
| + value = value.substr(field.credit_card_number_start_index());
|
| +
|
| + 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,
|
| @@ -397,7 +414,8 @@ AutofillField::AutofillField()
|
| heuristic_type_(UNKNOWN_TYPE),
|
| html_type_(HTML_TYPE_UNKNOWN),
|
| html_mode_(HTML_MODE_NONE),
|
| - phone_part_(IGNORED) {
|
| + phone_part_(IGNORED),
|
| + credit_card_number_start_index_(0) {
|
| }
|
|
|
| AutofillField::AutofillField(const FormFieldData& field,
|
| @@ -408,10 +426,12 @@ AutofillField::AutofillField(const FormFieldData& field,
|
| heuristic_type_(UNKNOWN_TYPE),
|
| html_type_(HTML_TYPE_UNKNOWN),
|
| html_mode_(HTML_MODE_NONE),
|
| - phone_part_(IGNORED) {
|
| + phone_part_(IGNORED),
|
| + credit_card_number_start_index_(0) {
|
| }
|
|
|
| -AutofillField::~AutofillField() {}
|
| +AutofillField::~AutofillField() {
|
| +}
|
|
|
| void AutofillField::set_heuristic_type(ServerFieldType type) {
|
| if (type >= 0 && type < MAX_VALID_FIELD_TYPE &&
|
| @@ -487,6 +507,9 @@ bool AutofillField::FillFormField(const AutofillField& field,
|
| } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) {
|
| FillStreetAddress(value, address_language_code, field_data);
|
| return true;
|
| + } else if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
|
| + FillCreditCardNumberField(field, value, field_data);
|
| + return true;
|
| }
|
|
|
| field_data->value = value;
|
|
|