diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-06 12:48:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:33:43 +0000 |
commit | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (patch) | |
tree | fa14ba0ca8d2683ba2efdabd246dc9b18a1229c6 /chromium/components/autofill/core/browser/geo | |
parent | 79b4f909db1049fca459c07cca55af56a9b54fe3 (diff) | |
download | qtwebengine-chromium-7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3.tar.gz |
BASELINE: Update Chromium to 84.0.4147.141
Change-Id: Ib85eb4cfa1cbe2b2b81e5022c8cad5c493969535
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/autofill/core/browser/geo')
14 files changed, 712 insertions, 414 deletions
diff --git a/chromium/components/autofill/core/browser/geo/address_i18n.cc b/chromium/components/autofill/core/browser/geo/address_i18n.cc index 62be348dcc4..d02f02c6a89 100644 --- a/chromium/components/autofill/core/browser/geo/address_i18n.cc +++ b/chromium/components/autofill/core/browser/geo/address_i18n.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/logging.h" +#include "base/notreached.h" #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "components/autofill/core/browser/autofill_type.h" diff --git a/chromium/components/autofill/core/browser/geo/autofill_country.cc b/chromium/components/autofill/core/browser/geo/autofill_country.cc index 961b1dc7a19..43a02de277f 100644 --- a/chromium/components/autofill/core/browser/geo/autofill_country.cc +++ b/chromium/components/autofill/core/browser/geo/autofill_country.cc @@ -6,11 +6,12 @@ #include <stddef.h> -#include "base/logging.h" #include "base/stl_util.h" #include "base/strings/string_util.h" #include "components/autofill/core/browser/geo/country_data.h" #include "components/autofill/core/browser/geo/country_names.h" +#include "components/autofill/core/common/autofill_internals/log_message.h" +#include "components/autofill/core/common/logging/log_buffer.h" #include "third_party/icu/source/common/unicode/locid.h" #include "ui/base/l10n/l10n_util.h" @@ -86,4 +87,21 @@ AutofillCountry::AutofillCountry(const std::string& country_code, postal_code_label_(postal_code_label), state_label_(state_label) {} +// Prints a formatted log of a |AutofillCountry| to a |LogBuffer|. +LogBuffer& operator<<(LogBuffer& buffer, const AutofillCountry& country) { + buffer << LogMessage::kImportAddressProfileFromFormAddressRequirements; + buffer << Tag{"div"} << Attrib{"class", "country_data"}; + buffer << Tag{"table"}; + buffer << Tr{} << "Country code:" << country.country_code(); + buffer << Tr{} << "Country name:" << country.name(); + buffer << Tr{} << "State required:" << country.requires_state(); + buffer << Tr{} << "Zip required:" << country.requires_zip(); + buffer << Tr{} << "City required:" << country.requires_city(); + buffer << Tr{} << "State label:" << country.state_label(); + buffer << Tr{} << "Postal code label:" << country.postal_code_label(); + buffer << CTag{"table"}; + buffer << CTag{"div"}; + buffer << CTag{}; + return buffer; +} } // namespace autofill diff --git a/chromium/components/autofill/core/browser/geo/autofill_country.h b/chromium/components/autofill/core/browser/geo/autofill_country.h index 002af082e40..fc16ef008d3 100644 --- a/chromium/components/autofill/core/browser/geo/autofill_country.h +++ b/chromium/components/autofill/core/browser/geo/autofill_country.h @@ -14,6 +14,8 @@ namespace autofill { +class LogBuffer; + // Stores data associated with a country. Strings are localized to the app // locale. class AutofillCountry { @@ -47,6 +49,17 @@ class AutofillCountry { return (address_required_fields_ & ADDRESS_REQUIRES_ZIP) != 0; } + // An address line1 is expected in a complete address for this country. + bool requires_line1() const { + return (address_required_fields_ & ADDRESS_REQUIRES_LINE1) != 0; + } + + // True if a complete address is expected to either contain a state or a ZIP + // code. Not true if the address explicitly needs both. + bool requires_zip_or_state() const { + return (address_required_fields_ & ADDRESS_REQUIRES_ZIP_OR_STATE) != 0; + } + private: AutofillCountry(const std::string& country_code, const base::string16& name, @@ -71,6 +84,8 @@ class AutofillCountry { DISALLOW_COPY_AND_ASSIGN(AutofillCountry); }; +LogBuffer& operator<<(LogBuffer& buffer, const AutofillCountry& country); + } // namespace autofill #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_AUTOFILL_COUNTRY_H_ diff --git a/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc b/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc index 94315c13967..655c9e1777a 100644 --- a/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/autofill_country_unittest.cc @@ -58,6 +58,45 @@ TEST(AutofillCountryTest, CountryCodeForLocale) { EXPECT_EQ("US", AutofillCountry::CountryCodeForLocale("es-419")); } +// Test the address requirement methods for the US. +TEST(AutofillCountryTest, UsaAddressRequirements) { + // The US requires a zip, state, city and line1 entry. + AutofillCountry us_autofill_country("US", "en_US"); + + EXPECT_FALSE(us_autofill_country.requires_zip_or_state()); + EXPECT_TRUE(us_autofill_country.requires_zip()); + EXPECT_TRUE(us_autofill_country.requires_state()); + EXPECT_TRUE(us_autofill_country.requires_city()); + EXPECT_TRUE(us_autofill_country.requires_line1()); +} + +// Test the address requirement method for Brazil. +TEST(AutofillCountryTest, BrAddressRequirements) { + // Brazil only requires a zip entry. + AutofillCountry brazil_autofill_country("BR", "en_US"); + + EXPECT_FALSE(brazil_autofill_country.requires_zip_or_state()); + EXPECT_TRUE(brazil_autofill_country.requires_zip()); + EXPECT_TRUE(brazil_autofill_country.requires_state()); + EXPECT_TRUE(brazil_autofill_country.requires_city()); + EXPECT_TRUE(brazil_autofill_country.requires_line1()); +} + +// Test the address requirement method for Turkey. +TEST(AutofillCountryTest, TrAddressRequirements) { + // Brazil only requires a zip entry. + AutofillCountry turkey_autofill_country("TR", "en_US"); + + // Although ZIP codes are existing in Turkey, they are commonly used. + EXPECT_FALSE(turkey_autofill_country.requires_zip()); + // In Turkey, a district is the largest level of the address hierarchy and + // mapped to the Autofill state. + EXPECT_TRUE(turkey_autofill_country.requires_state()); + // And the province as the second largest level is mapped to city. + EXPECT_TRUE(turkey_autofill_country.requires_city()); + EXPECT_TRUE(turkey_autofill_country.requires_line1()); +} + // Test mapping all country codes to country names. TEST(AutofillCountryTest, AllCountryCodesHaveCountryName) { std::set<std::string> expected_failures; diff --git a/chromium/components/autofill/core/browser/geo/country_data.cc b/chromium/components/autofill/core/browser/geo/country_data.cc index a496bf66bb6..a85fba5a745 100644 --- a/chromium/components/autofill/core/browser/geo/country_data.cc +++ b/chromium/components/autofill/core/browser/geo/country_data.cc @@ -39,754 +39,754 @@ const StaticCountryData kCountryData[] = { // clang-format off {"AC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PARISH, - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, + ADDRESS_REQUIRES_LINE1 } }, {"AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_EMIRATE, - ADDRESS_REQUIRES_STATE } }, + ADDRESS_REQUIRES_LINE1_STATE } }, {"AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, + ADDRESS_REQUIRES_LINE1 } }, {"AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"AT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"AU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"AW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"AX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"AZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PARISH, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"BD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"BS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"BT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"BV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"BY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"BZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"CI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, + ADDRESS_REQUIRES_LINE1 } }, {"CV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"CX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"CY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"CZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"DE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"DJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"DK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"DM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"DO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"DZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"EC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"EE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"EG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"EH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"ER", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"ES", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"ET", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"FI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"FJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"FK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"FM", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"FO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"FR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"GB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_COUNTY, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"GE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"GI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, + ADDRESS_REQUIRES_LINE1 } }, {"GL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"GN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"GR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GU", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"GY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"HK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_AREA, - ADDRESS_REQUIRES_STATE } }, + ADDRESS_REQUIRES_LINE1_STATE } }, {"HM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"HN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"HR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"HT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"HU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"ID", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"IE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_COUNTY, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"IL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"IM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"IN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"IO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"IQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"IR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"IS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"IT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"JE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"JM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PARISH, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"JO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"JP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PREFECTURE, - ADDRESS_REQUIRES_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_STATE_ZIP } }, {"KE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"KG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"KH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"KI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"KM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"KN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"KP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"KR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"KW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"KY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_STATE } }, + ADDRESS_REQUIRES_LINE1_STATE } }, {"KZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"LA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"LI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"LY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"MA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"ME", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MH", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"MK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"ML", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"MM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"MO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, + ADDRESS_REQUIRES_LINE1 } }, {"MP", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"MQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"MS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"MT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"MX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"MZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"NA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"NC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"NE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"NF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"NG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"NI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_DEPARTMENT, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"NL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"NO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"NP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"NR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_DISTRICT, - ADDRESS_REQUIRES_STATE } }, + ADDRESS_REQUIRES_LINE1_STATE } }, {"NU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"NZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"OM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"PE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"PF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"PG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"PH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"PK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PR", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"PT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"PW", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"PY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"QA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"RE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"RO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"RS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"RU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"RW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"SA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"SC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"SE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ZIP } }, + ADDRESS_REQUIRES_LINE1_ZIP } }, {"SH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"SM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ZIP } }, + ADDRESS_REQUIRES_LINE1_ZIP } }, {"SN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"SO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"SR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"SS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"ST", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"SV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"SX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"SZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"TA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"TJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"TK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"TN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"TO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"TT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"TV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_ISLAND, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"TW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_COUNTY, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"TZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"UA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"UG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"UM", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"US", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"UY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"UZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"VA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"VC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"VE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_STATE } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE } }, {"VG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, + ADDRESS_REQUIRES_LINE1 } }, {"VI", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, IDS_AUTOFILL_FIELD_LABEL_STATE, - ADDRESS_REQUIRES_CITY_STATE_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP } }, {"VN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"VU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"WF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"WS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"XK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"YE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"YT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"ZA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY_ZIP } }, + ADDRESS_REQUIRES_LINE1_CITY_ZIP } }, {"ZM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, {"ZW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, IDS_AUTOFILL_FIELD_LABEL_PROVINCE, - ADDRESS_REQUIRES_CITY } }, + ADDRESS_REQUIRES_LINE1_CITY } }, // clang-format on }; diff --git a/chromium/components/autofill/core/browser/geo/country_data.h b/chromium/components/autofill/core/browser/geo/country_data.h index 8266102dead..d30783a6276 100644 --- a/chromium/components/autofill/core/browser/geo/country_data.h +++ b/chromium/components/autofill/core/browser/geo/country_data.h @@ -24,20 +24,32 @@ enum AddressRequiredFields { ADDRESS_REQUIRES_CITY = 1 << 0, ADDRESS_REQUIRES_STATE = 1 << 1, ADDRESS_REQUIRES_ZIP = 1 << 2, + ADDRESS_REQUIRES_LINE1 = 1 << 3, + ADDRESS_REQUIRES_ZIP_OR_STATE = 1 << 4, // Composite versions (for data). - ADDRESS_REQUIRES_CITY_STATE = ADDRESS_REQUIRES_CITY | ADDRESS_REQUIRES_STATE, - ADDRESS_REQUIRES_STATE_ZIP = ADDRESS_REQUIRES_STATE | ADDRESS_REQUIRES_ZIP, - ADDRESS_REQUIRES_CITY_ZIP = ADDRESS_REQUIRES_CITY | ADDRESS_REQUIRES_ZIP, - ADDRESS_REQUIRES_CITY_STATE_ZIP = - ADDRESS_REQUIRES_CITY | ADDRESS_REQUIRES_STATE | ADDRESS_REQUIRES_ZIP, - - // Policy for countries that don't have city, state or zip requirements. - ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY = 0, + ADDRESS_REQUIRES_LINE1_CITY = + (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_CITY), + ADDRESS_REQUIRES_LINE1_ZIP = (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_ZIP), + ADDRESS_REQUIRES_LINE1_STATE = + (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_STATE), + + ADDRESS_REQUIRES_LINE1_CITY_STATE = + (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_CITY | ADDRESS_REQUIRES_STATE), + ADDRESS_REQUIRES_LINE1_STATE_ZIP = + (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_STATE | ADDRESS_REQUIRES_ZIP), + ADDRESS_REQUIRES_LINE1_CITY_ZIP = + (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_CITY | ADDRESS_REQUIRES_ZIP), + ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP = + (ADDRESS_REQUIRES_LINE1 | ADDRESS_REQUIRES_CITY | ADDRESS_REQUIRES_STATE | + ADDRESS_REQUIRES_ZIP), + + ADDRESS_REQUIRES_LINE1_CITY_AND_ZIP_OR_STATE = + ADDRESS_REQUIRES_LINE1_CITY | ADDRESS_REQUIRES_ZIP_OR_STATE, // Policy for countries for which we do not have information about valid // address format. - ADDRESS_REQUIREMENTS_UNKNOWN = ADDRESS_REQUIRES_CITY_STATE_ZIP, + ADDRESS_REQUIREMENTS_UNKNOWN = ADDRESS_REQUIRES_LINE1_CITY_STATE_ZIP, }; // This struct describes the address format typical for a particular country. diff --git a/chromium/components/autofill/core/browser/geo/country_names.cc b/chromium/components/autofill/core/browser/geo/country_names.cc index a91e6f3c84f..f632ff8f6ac 100644 --- a/chromium/components/autofill/core/browser/geo/country_names.cc +++ b/chromium/components/autofill/core/browser/geo/country_names.cc @@ -4,21 +4,16 @@ #include "components/autofill/core/browser/geo/country_names.h" -#include <stdint.h> - +#include <map> #include <memory> +#include <utility> #include "base/lazy_instance.h" -#include "base/logging.h" #include "base/memory/singleton.h" -#include "base/stl_util.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "build/build_config.h" +#include "base/synchronization/lock.h" #include "components/autofill/core/browser/geo/country_data.h" -#include "components/autofill/core/common/autofill_l10n_util.h" -#include "third_party/icu/source/common/unicode/unistr.h" -#include "ui/base/l10n/l10n_util.h" namespace autofill { namespace { @@ -28,33 +23,6 @@ namespace { static base::LazyInstance<std::string>::DestructorAtExit g_application_locale = LAZY_INSTANCE_INITIALIZER; -// Returns the ICU sort key corresponding to |str| for the given |collator|. -// Uses |buffer| as temporary storage, and might resize |buffer| as a side- -// effect. |buffer_size| should specify the |buffer|'s size, and is updated if -// the |buffer| is resized. -const std::string GetSortKey(const icu::Collator& collator, - const base::string16& str, - std::unique_ptr<uint8_t[]>* buffer, - int32_t* buffer_size) { - DCHECK(buffer); - DCHECK(buffer_size); - - icu::UnicodeString icu_str(str.c_str(), str.length()); - int32_t expected_size = - collator.getSortKey(icu_str, buffer->get(), *buffer_size); - if (expected_size > *buffer_size) { - // If there wasn't enough space, grow the buffer and try again. - *buffer_size = expected_size; - *buffer = std::make_unique<uint8_t[]>(*buffer_size); - DCHECK(buffer->get()); - - expected_size = collator.getSortKey(icu_str, buffer->get(), *buffer_size); - DCHECK_EQ(*buffer_size, expected_size); - } - - return std::string(reinterpret_cast<const char*>(buffer->get())); -} - // Computes the value for CountryNames::common_names_. std::map<std::string, std::string> GetCommonNames() { std::map<std::string, std::string> common_names; @@ -86,61 +54,6 @@ std::map<std::string, std::string> GetCommonNames() { return common_names; } -// Creates collator for |locale| and sets its attributes as needed. -std::unique_ptr<icu::Collator> CreateCollator(const icu::Locale& locale) { - std::unique_ptr<icu::Collator> collator( - autofill::l10n::GetCollatorForLocale(locale)); - if (!collator) - return nullptr; - - // Compare case-insensitively and ignoring punctuation. - UErrorCode ignored = U_ZERO_ERROR; - collator->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, ignored); - ignored = U_ZERO_ERROR; - collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, ignored); - - return collator; -} - -// If |locale| is different from "en_US", returns a collator for "en_US" and -// sets its attributes as appropriate. Otherwise returns null. -std::unique_ptr<icu::Collator> CreateDefaultCollator( - const icu::Locale& locale) { - icu::Locale default_locale("en_US"); - - if (default_locale != locale) - return CreateCollator(default_locale); - - return nullptr; -} - -// Returns the mapping of country names localized to |locale| to their -// corresponding country codes. The provided |collator| should be suitable for -// the locale. The collator being null is handled gracefully by returning an -// empty map, to account for the very rare cases when the collator fails to -// initialize. -std::map<std::string, std::string> GetLocalizedNames( - const std::string& locale, - const icu::Collator* collator) { - if (!collator) - return std::map<std::string, std::string>(); - - std::map<std::string, std::string> localized_names; - int32_t buffer_size = 1000; - auto buffer = std::make_unique<uint8_t[]>(buffer_size); - - for (const std::string& country_code : - CountryDataMap::GetInstance()->country_codes()) { - base::string16 country_name = - l10n_util::GetDisplayNameForCountry(country_code, locale); - std::string sort_key = - GetSortKey(*collator, country_name, &buffer, &buffer_size); - - localized_names.insert(std::make_pair(sort_key, country_code)); - } - return localized_names; -} - } // namespace // static @@ -162,13 +75,12 @@ void CountryNames::SetLocaleString(const std::string& locale) { } CountryNames::CountryNames(const std::string& locale_name) - : locale_(locale_name.c_str()), - collator_(CreateCollator(locale_)), - default_collator_(CreateDefaultCollator(locale_)), + : application_locale_name_(locale_name), + default_locale_name_(std::string("en_US")), + country_names_for_default_locale_(default_locale_name_), + country_names_for_application_locale_(application_locale_name_), common_names_(GetCommonNames()), - localized_names_(GetLocalizedNames(locale_name, collator_.get())), - default_localized_names_( - GetLocalizedNames("en_US", default_collator_.get())) {} + localized_country_names_cache_(10) {} CountryNames::CountryNames() : CountryNames(g_application_locale.Get()) { DCHECK(!g_application_locale.Get().empty()); @@ -176,7 +88,8 @@ CountryNames::CountryNames() : CountryNames(g_application_locale.Get()) { CountryNames::~CountryNames() = default; -const std::string CountryNames::GetCountryCode(const base::string16& country) { +const std::string CountryNames::GetCountryCode( + const base::string16& country) const { // First, check common country names, including 2- and 3-letter country codes. std::string country_utf8 = base::UTF16ToUTF8(base::ToUpperASCII(country)); const auto result = common_names_.find(country_utf8); @@ -185,37 +98,41 @@ const std::string CountryNames::GetCountryCode(const base::string16& country) { // Next, check country names localized to the current locale. std::string country_code = - GetCountryCodeForLocalizedName(country, localized_names_, *collator_); + country_names_for_application_locale_.GetCountryCode(country); if (!country_code.empty()) return country_code; // Finally, check country names localized to US English, unless done already. - if (default_collator_) { - return GetCountryCodeForLocalizedName(country, default_localized_names_, - *default_collator_); + return country_names_for_default_locale_.GetCountryCode(country); +} + +const std::string CountryNames::GetCountryCodeForLocalizedCountryName( + const base::string16& country, + const std::string& locale_name) { + // Do an unconditional lookup using the default and app_locale. + // Chances are that the name of the country matches the localized one. + std::string result = GetCountryCode(country); + // Terminate if a country code was determined or if the locale matches the + // default ones. + if (!result.empty() || locale_name == application_locale_name_ || + locale_name == default_locale_name_ || locale_name.empty()) { + return result; } + // Acquire a lock for the localization cache. + base::AutoLock lock(localized_country_names_cache_lock_); - return std::string(); -} + // Lookup the CountryName for the locale in the cache. + auto iter = localized_country_names_cache_.Get(locale_name); + if (iter != localized_country_names_cache_.end()) + return iter->second.GetCountryCode(country); -const std::string CountryNames::GetCountryCodeForLocalizedName( - const base::string16& country_name, - const std::map<std::string, std::string>& localized_names, - const icu::Collator& collator) { - // As recommended[1] by ICU, initialize the buffer size to four times the - // source string length. - // [1] http://userguide.icu-project.org/collation/api#TOC-Examples - int32_t buffer_size = country_name.size() * 4; - auto buffer = std::make_unique<uint8_t[]>(buffer_size); - std::string sort_key = - GetSortKey(collator, country_name, &buffer, &buffer_size); - - auto result = localized_names.find(sort_key); - - if (result != localized_names.end()) - return result->second; + CountryNamesForLocale country_names_for_locale(locale_name); + result = country_names_for_locale.GetCountryCode(country); + + // Put the country names for the locale into the cache. + localized_country_names_cache_.Put(locale_name, std::move(result)); - return std::string(); + return result; } } // namespace autofill diff --git a/chromium/components/autofill/core/browser/geo/country_names.h b/chromium/components/autofill/core/browser/geo/country_names.h index 1957936a1b4..92a68c8a49e 100644 --- a/chromium/components/autofill/core/browser/geo/country_names.h +++ b/chromium/components/autofill/core/browser/geo/country_names.h @@ -8,17 +8,18 @@ #include <map> #include <memory> #include <string> -#include <vector> +#include <utility> +#include "base/containers/mru_cache.h" #include "base/macros.h" #include "base/strings/string16.h" -#include "third_party/icu/source/common/unicode/locid.h" -#include "third_party/icu/source/i18n/unicode/coll.h" +#include "base/synchronization/lock.h" +#include "components/autofill/core/browser/geo/country_names_for_locale.h" namespace base { template <typename T> struct DefaultSingletonTraits; -} +} // namespace base namespace autofill { @@ -35,9 +36,26 @@ class CountryNames { // thread, before first using CountryNames. |locale| must not be empty. static void SetLocaleString(const std::string& locale); - // Returns the country code corresponding to |country|, which should be a - // country code or country name localized to |locale_name|. - const std::string GetCountryCode(const base::string16& country); + // Returns the country code corresponding to the |country_name| queried for + // the application and default locale. + const std::string GetCountryCode(const base::string16& country_name) const; + + // Returns the country code for a |country_name| provided with a + // |locale_name|. If no country code can be determined, an empty string is + // returned. The purpose of this method is to translate country names from a + // locale different to one the instance was constructed for. + const std::string GetCountryCodeForLocalizedCountryName( + const base::string16& country_name, + const std::string& locale_name); + +#if defined(UNIT_TEST) + // Returns true if the country names for the locale_name are in the cache. + // Only used for testing. + bool IsCountryNamesForLocaleCachedForTesting(const std::string& locale_name) { + auto iter = localized_country_names_cache_.Get(locale_name); + return iter != localized_country_names_cache_.end(); + } +#endif protected: // Create CountryNames for |locale_name|. Protected for testing. @@ -52,41 +70,34 @@ class CountryNames { friend struct base::DefaultSingletonTraits<CountryNames>; - // Looks up |country_name| in |localized_names|, using |collator| and - // returns the corresponding country code or an empty string if there is - // none. - const std::string GetCountryCodeForLocalizedName( - const base::string16& country_name, - const std::map<std::string, std::string>& localized_names, - const icu::Collator& collator); - - // Returns an ICU collator -- i.e. string comparator -- appropriate for the - // given |locale|, or null if no collator is available. - const icu::Collator* GetCollatorForLocale(const icu::Locale& locale); + // Caches localized country name for a locale that is neither the application + // or default locale. The Cache is keyed by the locale_name and contains + // |CountryNamesForLocale| instances. + using LocalizedCountryNamesCache = + base::MRUCache<std::string, CountryNamesForLocale>; // The locale object for the application locale string. - const icu::Locale locale_; + const std::string application_locale_name_; + + // The locale object for the default locale string. + const std::string default_locale_name_; - // Collator for the application locale. - const std::unique_ptr<icu::Collator> collator_; + // Maps country names localized for the default locale to country codes. + const CountryNamesForLocale country_names_for_default_locale_; - // Collator for the "en_US" locale, if different from the application - // locale, null otherwise. - const std::unique_ptr<icu::Collator> default_collator_; + // Maps country names localized for the application locale to country codes. + const CountryNamesForLocale country_names_for_application_locale_; // Maps from common country names, including 2- and 3-letter country codes, // to the corresponding 2-letter country codes. The keys are uppercase ASCII // strings. const std::map<std::string, std::string> common_names_; - // Maps from localized country names (in the application locale) to their - // corresponding country codes. The keys are ICU collation sort keys - // corresponding to the target localized country name. - const std::map<std::string, std::string> localized_names_; + // A MRU cache to store localized strings for non-default locale lookups. + LocalizedCountryNamesCache localized_country_names_cache_; - // The same as |localized_names_| but for the "en_US" locale. Empty if - // "en_US" is the application locale already. - const std::map<std::string, std::string> default_localized_names_; + // A lock for accessing and manipulating the localization cache. + base::Lock localized_country_names_cache_lock_; DISALLOW_COPY_AND_ASSIGN(CountryNames); }; diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc b/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc new file mode 100644 index 00000000000..2f9a69dafbc --- /dev/null +++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale.cc @@ -0,0 +1,125 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/autofill/core/browser/geo/country_names_for_locale.h" + +#include <map> +#include <utility> + +#include "base/check_op.h" +#include "base/strings/string16.h" +#include "components/autofill/core/browser/geo/country_data.h" +#include "components/autofill/core/common/autofill_l10n_util.h" +#include "third_party/icu/source/common/unicode/locid.h" +#include "ui/base/l10n/l10n_util.h" + +namespace autofill { + +namespace { +// Returns the ICU sort key corresponding to |str| for the given |collator|. +// Uses |buffer| as temporary storage, and might resize |buffer| as a side- +// effect. |buffer_size| should specify the |buffer|'s size, and is updated if +// the |buffer| is resized. +const std::string GetSortKey(const icu::Collator& collator, + const base::string16& str, + std::unique_ptr<uint8_t[]>* buffer, + int32_t* buffer_size) { + DCHECK(buffer); + DCHECK(buffer_size); + + icu::UnicodeString icu_str(str.c_str(), str.length()); + int32_t expected_size = + collator.getSortKey(icu_str, buffer->get(), *buffer_size); + if (expected_size > *buffer_size) { + // If there wasn't enough space, grow the buffer and try again. + *buffer_size = expected_size; + *buffer = std::make_unique<uint8_t[]>(*buffer_size); + DCHECK(buffer->get()); + + expected_size = collator.getSortKey(icu_str, buffer->get(), *buffer_size); + DCHECK_EQ(*buffer_size, expected_size); + } + + return std::string(reinterpret_cast<const char*>(buffer->get())); +} + +// Creates collator for |locale| and sets its attributes as needed. +std::unique_ptr<icu::Collator> CreateCollator(const icu::Locale& locale) { + std::unique_ptr<icu::Collator> collator( + autofill::l10n::GetCollatorForLocale(locale)); + if (!collator) + return nullptr; + + // Compare case-insensitively and ignoring punctuation. + UErrorCode ignored = U_ZERO_ERROR; + collator->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, ignored); + ignored = U_ZERO_ERROR; + collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, ignored); + + return collator; +} + +// Returns the mapping of country names localized to |locale| to their +// corresponding country codes. The provided |collator| should be suitable for +// the locale. The collator being null is handled gracefully by returning an +// empty map, to account for the very rare cases when the collator fails to +// initialize. +std::map<std::string, std::string> GetLocalizedNames( + const std::string& locale, + const icu::Collator* collator) { + if (!collator) + return std::map<std::string, std::string>(); + + std::map<std::string, std::string> localized_names; + int32_t buffer_size = 1000; + auto buffer = std::make_unique<uint8_t[]>(buffer_size); + + for (const std::string& country_code : + CountryDataMap::GetInstance()->country_codes()) { + base::string16 country_name = + l10n_util::GetDisplayNameForCountry(country_code, locale); + std::string sort_key = + GetSortKey(*collator, country_name, &buffer, &buffer_size); + + localized_names.insert(std::make_pair(sort_key, country_code)); + } + return localized_names; +} + +} // namespace + +CountryNamesForLocale::CountryNamesForLocale(const std::string& locale_name) + : locale_name_(locale_name), + collator_(CreateCollator(locale_name_.c_str())), + localized_names_(GetLocalizedNames(locale_name, collator_.get())) {} + +CountryNamesForLocale::~CountryNamesForLocale() = default; + +CountryNamesForLocale::CountryNamesForLocale(CountryNamesForLocale&& source) + : locale_name_(std::move(source.locale_name_)), + collator_(std::move(source.collator_)), + localized_names_(std::move(source.localized_names_)) {} + +const std::string CountryNamesForLocale::GetCountryCode( + const base::string16& country_name) const { + // As recommended[1] by ICU, initialize the buffer size to four times the + // source string length. + // [1] http://userguide.icu-project.org/collation/api#TOC-Examples + if (!collator_) + return std::string(); + + int32_t buffer_size = country_name.size() * 4; + auto buffer = std::make_unique<uint8_t[]>(buffer_size); + std::string sort_key = + GetSortKey(*collator_, country_name, &buffer, &buffer_size); + + auto result = localized_names_.find(sort_key); + + if (result != localized_names_.end()) + return result->second; + + return std::string(); +} + +} // namespace autofill diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale.h b/chromium/components/autofill/core/browser/geo/country_names_for_locale.h new file mode 100644 index 00000000000..4c04eb3a510 --- /dev/null +++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale.h @@ -0,0 +1,49 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_COUNTRY_NAMES_FOR_LOCALE_H_ +#define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_COUNTRY_NAMES_FOR_LOCALE_H_ + +#include <map> +#include <memory> +#include <string> + +#include "base/strings/string16.h" +#include "third_party/icu/source/i18n/unicode/coll.h" + +namespace autofill { + +class CountryNamesForLocale { + public: + // Create |CountryNamesForLocale| for the supplied |locale_name|. + explicit CountryNamesForLocale(const std::string& locale_name); + + CountryNamesForLocale(CountryNamesForLocale&& source); + + ~CountryNamesForLocale(); + + // Returns the country code corresponding to the |country_name| localized to + // |locale_name_|. Returns an empty string if no matching country code can be + // found. + const std::string GetCountryCode(const base::string16& country_name) const; + + private: + // Returns an ICU collator -- i.e. string comparator -- appropriate for the + // given |locale|, or null if no collator is available. + const icu::Collator* GetCollatorForLocale(const icu::Locale& locale); + + // The name of the locale the instance was constructed for. + std::string locale_name_; + + // Collator for the locale. + std::unique_ptr<icu::Collator> collator_; + + // Maps from localized country names in the supplied locale to their + // corresponding country codes. The keys are ICU collation sort keys + // corresponding to the target localized country name. + std::map<std::string, std::string> localized_names_; +}; + +} // namespace autofill +#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_COUNTRY_NAMES_FOR_LOCALE_H_ diff --git a/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc b/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc new file mode 100644 index 00000000000..7c1f994329b --- /dev/null +++ b/chromium/components/autofill/core/browser/geo/country_names_for_locale_unittest.cc @@ -0,0 +1,85 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <string> +#include <utility> + +#include "base/strings/string16.h" +#include "base/strings/utf_string_conversions.h" +#include "components/autofill/core/browser/geo/country_names_for_locale.h" +#include "testing/gtest/include/gtest/gtest.h" + +using base::ASCIIToUTF16; + +namespace autofill { +namespace { + +class TestCountryNamesForLocale : public CountryNamesForLocale { + public: + explicit TestCountryNamesForLocale(const std::string& locale_name) + : CountryNamesForLocale(locale_name) {} + + TestCountryNamesForLocale(TestCountryNamesForLocale&& source) + : CountryNamesForLocale(std::move(source)) {} + + ~TestCountryNamesForLocale() = default; +}; + +} // namespace + +// Test that the correct country code is returned for various locales. +TEST(CountryNamesForLocaleTest, GetCountryCode) { + TestCountryNamesForLocale en_us_names("en_US"); + EXPECT_EQ("US", en_us_names.GetCountryCode(ASCIIToUTF16("United States"))); + + TestCountryNamesForLocale de_names("de"); + EXPECT_EQ("DE", de_names.GetCountryCode(ASCIIToUTF16("Deutschland"))); +} + +// Test that supplying an non-empty but invalid locale reverts back to 'en_US' +// localized names. +TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidLocale) { + TestCountryNamesForLocale not_a_locale_names("not_a_locale"); + + // The creation of an non-empty invalid locale reverts back to "en_US". + EXPECT_EQ("US", + not_a_locale_names.GetCountryCode(ASCIIToUTF16("United States"))); +} + +// The behavior depends on the platform. On Android the locale reverts back to +// the standard locale. +#if !defined(OS_ANDROID) +// Test that an empty string is returned for an empty locale. +TEST(CountryNamesForLocaleTest, EmptyCountryCodeForEmptyLocale) { + TestCountryNamesForLocale empty_locale_names(""); + EXPECT_EQ("", + empty_locale_names.GetCountryCode(ASCIIToUTF16("United States"))); +} +#endif + +// Test that an empty string is returned for an empty country name. +TEST(CountryNamesForLocaleTest, EmptyCountryCodeForEmptyCountryName) { + TestCountryNamesForLocale de_names("de"); + EXPECT_EQ("", de_names.GetCountryCode(ASCIIToUTF16(""))); +} + +// Test that an empty string is returned for an invalid country name. +TEST(CountryNamesForLocaleTest, EmptyCountryCodeForInvalidCountryName) { + TestCountryNamesForLocale de_names("de"); + EXPECT_EQ("", de_names.GetCountryCode(ASCIIToUTF16("ThisISNotACountry"))); +} + +// Test that an instance is correctly constructed using the move semantics. +TEST(CountryNamesForLocaleTest, MoveConstructior) { + // Construct a working |CountryNamesForLocale| instance. + TestCountryNamesForLocale de_names("de"); + EXPECT_EQ("DE", de_names.GetCountryCode(ASCIIToUTF16("Deutschland"))); + + // Construct another instance using the move semantics. + TestCountryNamesForLocale moved_names(std::move(de_names)); + + // Test that the new instance returns the correct values. + EXPECT_EQ("DE", moved_names.GetCountryCode(ASCIIToUTF16("Deutschland"))); +} +} // namespace autofill diff --git a/chromium/components/autofill/core/browser/geo/country_names_unittest.cc b/chromium/components/autofill/core/browser/geo/country_names_unittest.cc index c3e8b047bf9..46481c05e4b 100644 --- a/chromium/components/autofill/core/browser/geo/country_names_unittest.cc +++ b/chromium/components/autofill/core/browser/geo/country_names_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include <string> +#include <utility> #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" @@ -68,7 +69,31 @@ TEST(CountryNamesTest, GetCountryCode_EnUsFallback) { EXPECT_EQ("US", es_names.GetCountryCode(ASCIIToUTF16("USA"))); } -// Test mapping of empty country name to country code. +TEST(CountryNamesTest, GetCountryCodeForLocalizedCountryName) { + // Initialize with the default locale. + TestCountryNames names("en_US"); + EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName( + ASCIIToUTF16("Armenien"), "de")); + EXPECT_EQ("AZ", names.GetCountryCodeForLocalizedCountryName( + ASCIIToUTF16("Azerbeidzjan"), "nl")); +} + +TEST(CountryNamesTest, GetCachedCountryCodeForLocalizedCountryName) { + // Initialize with the default locale. + TestCountryNames names("en_US"); + + // Verify that the entry is not cached. + EXPECT_FALSE(names.IsCountryNamesForLocaleCachedForTesting("de")); + + // Make a lookup of the entry that should result in a cache write. + EXPECT_EQ("AM", names.GetCountryCodeForLocalizedCountryName( + ASCIIToUTF16("Armenien"), "de")); + + // Verify that the entry is cached. + EXPECT_TRUE(names.IsCountryNamesForLocaleCachedForTesting("de")); +} + +// Test mapping of an empty country name to an country code. TEST(CountryNamesTest, EmptyCountryNameHasEmptyCountryCode) { std::string country_code = TestCountryNames("en").GetCountryCode(base::string16()); diff --git a/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc b/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc index 3853bfe098e..0e1d01ee171 100644 --- a/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc +++ b/chromium/components/autofill/core/browser/geo/phone_number_i18n.cc @@ -6,7 +6,8 @@ #include <utility> -#include "base/logging.h" +#include "base/check_op.h" +#include "base/notreached.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" diff --git a/chromium/components/autofill/core/browser/geo/subkey_requester.h b/chromium/components/autofill/core/browser/geo/subkey_requester.h index 254e1c7199d..3a9200afcda 100644 --- a/chromium/components/autofill/core/browser/geo/subkey_requester.h +++ b/chromium/components/autofill/core/browser/geo/subkey_requester.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_SUBKEY_REQUESTER_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_GEO_SUBKEY_REQUESTER_H_ +#include "base/callback.h" #include "base/macros.h" #include "third_party/libaddressinput/chromium/chrome_address_validator.h" |