 Chromium Code Reviews
 Chromium Code Reviews Issue 22040002:
  [Autofill] Add a separate enumeration for HTML field type hints.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 22040002:
  [Autofill] Add a separate enumeration for HTML field type hints.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: components/autofill/core/browser/autofill_profile.cc | 
| diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc | 
| index 80c2ab35a96cb67654e3596ecaa3556de9442c7e..220a20ba44baae1d9d39052364c74daa78c7a928 100644 | 
| --- a/components/autofill/core/browser/autofill_profile.cc | 
| +++ b/components/autofill/core/browser/autofill_profile.cc | 
| @@ -33,11 +33,13 @@ namespace { | 
| // Like |AutofillType::GetEquivalentFieldType()|, but also returns |NAME_FULL| | 
| // for first, middle, and last name field types. | 
| NativeFieldType GetEquivalentFieldTypeCollapsingNames(NativeFieldType type) { | 
| - if (type == NAME_FIRST || type == NAME_MIDDLE || type == NAME_LAST || | 
| - type == NAME_MIDDLE_INITIAL) | 
| + NativeFieldType equivalent_type = | 
| + AutofillType(type).GetEquivalentNativeType(); | 
| 
Evan Stade
2013/08/05 18:47:24
this fn seems a little bit hoop-jumpy. Would it be
 
Ilya Sherman
2013/08/06 05:05:39
It's not quite the same unless we also check for N
 
Evan Stade
2013/08/06 18:39:59
I think the original way is fine now that I unders
 
Ilya Sherman
2013/08/06 23:04:56
Done.
 | 
| + | 
| + if (AutofillType(equivalent_type).group() == NAME) | 
| return NAME_FULL; | 
| - return AutofillType::GetEquivalentFieldType(type); | 
| + return equivalent_type; | 
| } | 
| // Fills |distinguishing_fields| with a list of fields to use when creating | 
| @@ -124,7 +126,7 @@ base::string16 GetFormGroupInfo(const FormGroup& form_group, | 
| const AutofillType& type, | 
| const std::string& app_locale) { | 
| return app_locale.empty() ? | 
| - form_group.GetRawInfo(type.native_type()) : | 
| + form_group.GetRawInfo(type.GetEquivalentNativeType()) : | 
| form_group.GetInfo(type, app_locale); | 
| } | 
| @@ -275,12 +277,11 @@ void AutofillProfile::GetMatchingTypes( | 
| } | 
| base::string16 AutofillProfile::GetRawInfo(NativeFieldType type) const { | 
| - NativeFieldType return_type = AutofillType::GetEquivalentFieldType(type); | 
| - const FormGroup* form_group = FormGroupForType(AutofillType(return_type)); | 
| + const FormGroup* form_group = FormGroupForType(AutofillType(type)); | 
| if (!form_group) | 
| return base::string16(); | 
| - return form_group->GetRawInfo(return_type); | 
| + return form_group->GetRawInfo(type); | 
| } | 
| void AutofillProfile::SetRawInfo(NativeFieldType type, | 
| @@ -292,13 +293,11 @@ void AutofillProfile::SetRawInfo(NativeFieldType type, | 
| base::string16 AutofillProfile::GetInfo(const AutofillType& type, | 
| const std::string& app_locale) const { | 
| - NativeFieldType return_type = | 
| - AutofillType::GetEquivalentFieldType(type.native_type()); | 
| - const FormGroup* form_group = FormGroupForType(AutofillType(return_type)); | 
| + const FormGroup* form_group = FormGroupForType(type); | 
| if (!form_group) | 
| return base::string16(); | 
| - return form_group->GetInfo(AutofillType(return_type), app_locale); | 
| + return form_group->GetInfo(type, app_locale); | 
| } | 
| bool AutofillProfile::SetInfo(const AutofillType& type, | 
| @@ -363,8 +362,7 @@ void AutofillProfile::FillFormField(const AutofillField& field, | 
| DCHECK_NE(CREDIT_CARD, type.group()); | 
| DCHECK(field_data); | 
| - if (type.native_type() == PHONE_HOME_NUMBER || | 
| - type.native_type() == PHONE_BILLING_NUMBER) { | 
| + if (type.GetEquivalentNativeType() == PHONE_HOME_NUMBER) { | 
| FillPhoneNumberField(field, variant, app_locale, field_data); | 
| } else if (field_data->form_control_type == "select-one") { | 
| FillSelectControl(type, app_locale, field_data); |