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

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

Issue 622773002: [Autofill] Autofill fails to show suggestions for credit card split across fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed ObfuscatedCreditCardNumber() from AutofillManager. Created 6 years, 2 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 877e62815c42a37964b35359f86393c5579f4ccc..3db11c84460e2c4d57735c409ccf86ff3bc175a8 100644
--- a/components/autofill/core/browser/autofill_field.cc
+++ b/components/autofill/core/browser/autofill_field.cc
@@ -276,33 +276,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,
@@ -487,7 +460,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);
@@ -497,7 +470,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;
}
@@ -507,8 +480,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() !=
@@ -517,13 +489,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);
}
@@ -531,4 +503,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

Powered by Google App Engine
This is Rietveld 408576698