Chromium Code Reviews| Index: components/autofill/core/browser/address.cc |
| diff --git a/components/autofill/core/browser/address.cc b/components/autofill/core/browser/address.cc |
| index 428d9f5283efe815adacbcd2901d5d59f181acf6..ef76286ca461e2053716ec99fa77f9eb9d826e4f 100644 |
| --- a/components/autofill/core/browser/address.cc |
| +++ b/components/autofill/core/browser/address.cc |
| @@ -13,8 +13,11 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "components/autofill/core/browser/autofill_country.h" |
| #include "components/autofill/core/browser/autofill_field.h" |
| +#include "components/autofill/core/browser/autofill_profile.h" |
| #include "components/autofill/core/browser/autofill_type.h" |
| #include "components/autofill/core/browser/country_names.h" |
| +#include "components/autofill/core/browser/state_names.h" |
| +#include "components/autofill/core/common/autofill_l10n_util.h" |
| namespace autofill { |
| @@ -198,6 +201,26 @@ void Address::GetMatchingTypes(const base::string16& text, |
| std::string country_code = CountryNames::GetInstance()->GetCountryCode(text); |
| if (!country_code.empty() && country_code_ == country_code) |
| matching_types->insert(ADDRESS_HOME_COUNTRY); |
| + |
| + // Check to see if the |text| could be the full name or abbreviation of a |
| + // state. |
| + base::string16 canon_text = AutofillProfile::CanonicalizeProfileString(text); |
| + base::string16 state_name; |
| + base::string16 state_abbreviation; |
| + state_names::GetNameAndAbbreviation(canon_text, &state_name, |
| + &state_abbreviation); |
| + if (!state_name.empty() || !state_abbreviation.empty()) { |
|
Mathieu
2016/03/18 13:56:04
At this point, we're pretty certain the field is a
sebsg
2016/03/18 14:25:54
It was to be cautious and also consistent with all
Mathieu
2016/03/18 14:35:20
Another case of the New York, New York case is Que
|
| + l10n::CaseInsensitiveCompare compare; |
| + base::string16 canon_profile_state = |
| + AutofillProfile::CanonicalizeProfileString( |
| + GetInfo(AutofillType(ADDRESS_HOME_STATE), app_locale)); |
| + if ((!state_name.empty() && |
| + compare.StringsEqual(state_name, canon_profile_state)) || |
| + (!state_abbreviation.empty() && |
| + compare.StringsEqual(state_abbreviation, canon_profile_state))) { |
| + matching_types->insert(ADDRESS_HOME_STATE); |
| + } |
| + } |
| } |
| void Address::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { |