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 145d7a04dd692d4c82c087076cd385bd6b86fae4..285a5876883491ddf9681cbf8a4fecbcb2905883 100644 |
--- a/components/autofill/core/browser/autofill_field.cc |
+++ b/components/autofill/core/browser/autofill_field.cc |
@@ -531,7 +531,8 @@ bool AutofillField::FillFormField(const AutofillField& field, |
return false; |
} |
- if (type.GetStorableType() == PHONE_HOME_NUMBER) { |
+ if (type.GetStorableType() == PHONE_HOME_NUMBER || |
+ type.GetStorableType() == PHONE_HOME_WHOLE_NUMBER) { |
FillPhoneNumberField(field, value, field_data); |
return true; |
} else if (field_data->form_control_type == "select-one") { |
@@ -556,21 +557,28 @@ base::string16 AutofillField::GetPhoneNumberValue( |
const FormFieldData& field_data) { |
// Check to see if the size field matches the "prefix" or "suffix" size. |
// If so, return the appropriate substring. |
- if (number.length() != |
- PhoneNumber::kPrefixLength + PhoneNumber::kSuffixLength) { |
- return number; |
- } |
+ if (number.length() == |
Mathieu
2016/01/26 14:43:01
In which cases will the phone number size be 7? I'
sebsg
2016/01/26 23:56:26
Done.
|
+ PhoneNumber::kPrefixLength + PhoneNumber::kSuffixLength) { |
+ if (field.phone_part() == AutofillField::PHONE_PREFIX || |
+ field_data.max_length == PhoneNumber::kPrefixLength) { |
+ return number.substr(PhoneNumber::kPrefixOffset, |
+ PhoneNumber::kPrefixLength); |
+ } |
- if (field.phone_part() == AutofillField::PHONE_PREFIX || |
- field_data.max_length == PhoneNumber::kPrefixLength) { |
- return |
- number.substr(PhoneNumber::kPrefixOffset, PhoneNumber::kPrefixLength); |
+ if (field.phone_part() == AutofillField::PHONE_SUFFIX || |
+ field_data.max_length == PhoneNumber::kSuffixLength) { |
+ return number.substr(PhoneNumber::kSuffixOffset, |
+ PhoneNumber::kSuffixLength); |
+ } |
} |
- if (field.phone_part() == AutofillField::PHONE_SUFFIX || |
- field_data.max_length == PhoneNumber::kSuffixLength) { |
- return |
- number.substr(PhoneNumber::kSuffixOffset, PhoneNumber::kSuffixLength); |
+ // Check to see if the max length of the field matches the "city and number" |
+ // size. If |number| exceeds that size, cut the first part to provide a valid |
+ // number for the field. |
+ if (field_data.max_length == PhoneNumber::kCityAndNumberLength && |
Mathieu
2016/01/26 14:43:02
Why should we check for max_length == 10? It feels
sebsg
2016/01/26 23:56:26
I thought it was safer that way, to only cut the f
|
+ number.length() > field_data.max_length) { |
+ return number.substr(number.length() - field_data.max_length, |
+ field_data.max_length); |
} |
return number; |