Chromium Code Reviews| Index: chrome/browser/autofill/autofill_country.cc |
| diff --git a/chrome/browser/autofill/autofill_country.cc b/chrome/browser/autofill/autofill_country.cc |
| index 99664966e8b8b26060f7df6a32f95d060ec32839..55c71a7da8c3ea9dda867c0d323c1595cbb63023 100644 |
| --- a/chrome/browser/autofill/autofill_country.cc |
| +++ b/chrome/browser/autofill/autofill_country.cc |
| @@ -29,7 +29,6 @@ |
| namespace { |
| struct CountryData { |
| - std::string country_code; |
| int postal_code_label_id; |
| int state_label_id; |
| }; |
| @@ -38,8 +37,14 @@ struct CountryData { |
| const size_t kLocaleCapacity = |
| ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY + 1; |
| +struct StaticCountryData { |
| + char country_code[3]; |
| + int postal_code_label_id; |
|
Peter Kasting
2011/08/30 22:55:52
Nit: If we nested the structs:
struct CountryData
tony
2011/08/30 23:11:28
Good idea! Done.
|
| + int state_label_id; |
| +}; |
| + |
| // Maps country codes to localized label string identifiers. |
| -const CountryData kCountryData[] = { |
| +const StaticCountryData kCountryData[] = { |
| {"AD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PARISH}, |
| {"AE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_EMIRATE}, |
| {"AF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, |
| @@ -311,8 +316,12 @@ CountryDataMap* CountryDataMap::GetInstance() { |
| CountryDataMap::CountryDataMap() { |
| // Add all the countries we have explicit data for. |
| for (size_t i = 0; i < arraysize(kCountryData); ++i) { |
| - const CountryData& data = kCountryData[i]; |
| - country_data_.insert(std::make_pair(data.country_code, data)); |
| + const StaticCountryData& static_data = kCountryData[i]; |
| + CountryData data = { |
| + static_data.postal_code_label_id, |
| + static_data.state_label_id |
| + }; |
| + country_data_.insert(std::make_pair(static_data.country_code, data)); |
| } |
| // Add any other countries that ICU knows about, falling back to default data |
| @@ -323,7 +332,6 @@ CountryDataMap::CountryDataMap() { |
| std::string country_code = *country_pointer; |
| if (!country_data_.count(country_code)) { |
| CountryData data = { |
| - country_code, |
| IDS_AUTOFILL_DIALOG_POSTAL_CODE, |
| IDS_AUTOFILL_DIALOG_PROVINCE |
| }; |
| @@ -415,7 +423,7 @@ CountryNames::CountryNames() { |
| ++it) { |
| const std::string& country_code = it->first; |
| std::string iso3_country_code = |
| - icu::Locale(NULL, country_code.c_str()).getISO3Country(); |
| + 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)); |