#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "grit/component_strings.h"
+#include "grit/components_strings.h"
#include "third_party/icu/source/common/unicode/locid.h"
#include "third_party/icu/source/common/unicode/uloc.h"
#include "third_party/icu/source/common/unicode/unistr.h"
// Maps country codes to localized label string identifiers.
const StaticCountryData kCountryData[] = {
+ { "AC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
+ IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
+ ADDRESS_REQUIRES_CITY } },
{ "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
IDS_AUTOFILL_FIELD_LABEL_PARISH,
ADDRESS_REQUIRES_STATE } },
{ "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
ADDRESS_REQUIREMENTS_UNKNOWN } },
- { "AN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
- IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
- ADDRESS_REQUIREMENTS_UNKNOWN } },
{ "AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
ADDRESS_REQUIREMENTS_UNKNOWN } },
{ "SZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
ADDRESS_REQUIREMENTS_UNKNOWN } },
+ { "TA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
+ IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
+ ADDRESS_REQUIRES_CITY } },
{ "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
ADDRESS_REQUIRES_CITY_ZIP } },
it != CountryDataMap::End();
++it) {
const std::string& country_code = it->first;
+ common_names_.insert(std::make_pair(country_code, country_code));
+
std::string iso3_country_code =
icu::Locale(NULL, country_code.c_str()).getISO3Country();
- common_names_.insert(std::make_pair(country_code, country_code));
- common_names_.insert(std::make_pair(iso3_country_code, country_code));
+ // ICU list of countries can be out-of-date with CLDR.
+ if (!iso3_country_code.empty())
+ common_names_.insert(std::make_pair(iso3_country_code, country_code));
}
// Add a few other common synonyms.
const std::string CountryNames::GetCountryCode(const base::string16& country,
const std::string& locale) {
// First, check common country names, including 2- and 3-letter country codes.
- std::string country_utf8 = UTF16ToUTF8(StringToUpperASCII(country));
+ std::string country_utf8 = base::UTF16ToUTF8(StringToUpperASCII(country));
std::map<std::string, std::string>::const_iterator result =
common_names_.find(country_utf8);
if (result != common_names_.end())