Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: components/autofill/core/browser/autofill_field.cc

Issue 1639563002: [Autofill] Fill from the last digits when filling a phone number with a maximum length. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698