Chromium Code Reviews| 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..e5370dafaf48f04bcacd0ede9b76c8c2283a47c9 100644 |
| --- a/components/autofill/core/browser/autofill_field.cc |
| +++ b/components/autofill/core/browser/autofill_field.cc |
| @@ -280,21 +280,8 @@ bool FillCreditCardTypeSelectControl(const base::string16& value, |
| void FillPhoneNumberField(const AutofillField& field, |
| const base::string16& number, |
| FormFieldData* field_data) { |
| - // Check to see if the size field matches the "prefix" or "suffix" sizes and |
| - // fill accordingly. |
| - base::string16 value = number; |
| - if (number.length() == |
| - PhoneNumber::kPrefixLength + PhoneNumber::kSuffixLength) { |
| - if (field.phone_part() == AutofillField::PHONE_PREFIX || |
| - field_data->max_length == PhoneNumber::kPrefixLength) { |
| - value = number.substr(PhoneNumber::kPrefixOffset, |
| - PhoneNumber::kPrefixLength); |
| - } else if (field.phone_part() == AutofillField::PHONE_SUFFIX || |
| - field_data->max_length == PhoneNumber::kSuffixLength) { |
| - value = number.substr(PhoneNumber::kSuffixOffset, |
| - PhoneNumber::kSuffixLength); |
| - } |
| - } |
| + base::string16 value; |
| + AutofillField::GetPhoneNumberValue(field, number, field_data, &value); |
| field_data->value = value; |
|
Ilya Sherman
2014/09/03 00:55:49
nit: You can shorten this to
AutofillField::Ge
ziran.sun
2014/09/04 13:10:25
Done.
|
| } |
| @@ -493,4 +480,27 @@ bool AutofillField::FillFormField(const AutofillField& field, |
| return true; |
| } |
| +// Get value for phone number. The value could be |number|, or possibly an |
| +// appropriate substring of |number| if it's for phone prefix or suffix field. |
| +void AutofillField::GetPhoneNumberValue(const AutofillField& field, |
| + const base::string16& number, |
| + FormFieldData* field_data, |
| + base::string16* value) { |
| + // Check to see if the size field matches the "prefix" or "suffix" sizes and |
| + // substract the value accordingly. |
|
Ilya Sherman
2014/09/03 00:55:49
nit: Let's update this to something like "Check to
ziran.sun
2014/09/04 13:10:25
Done.
|
| + *value = number; |
| + if (number.length() == |
| + PhoneNumber::kPrefixLength + PhoneNumber::kSuffixLength) { |
|
Ilya Sherman
2014/09/03 00:55:49
nit: Please indent this line by four more spaces.
ziran.sun
2014/09/04 13:10:25
Done.
|
| + if (field.phone_part() == AutofillField::PHONE_PREFIX || |
| + field_data->max_length == PhoneNumber::kPrefixLength) { |
| + *value = |
| + number.substr(PhoneNumber::kPrefixOffset, PhoneNumber::kPrefixLength); |
| + } else if (field.phone_part() == AutofillField::PHONE_SUFFIX || |
| + field_data->max_length == PhoneNumber::kSuffixLength) { |
| + *value = |
| + number.substr(PhoneNumber::kSuffixOffset, PhoneNumber::kSuffixLength); |
| + } |
| + } |
| +} |
| + |
| } // namespace autofill |