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

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

Issue 1814883002: [Autofill] Check for full state name and abbreviation when determining types to upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 9 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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_field.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698