| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/core/browser/autofill_country.h" | 5 #include "components/autofill/core/browser/autofill_country.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 AddressRequiredFields address_required_fields; | 38 AddressRequiredFields address_required_fields; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 struct StaticCountryData { | 41 struct StaticCountryData { |
| 42 char country_code[3]; | 42 char country_code[3]; |
| 43 CountryData country_data; | 43 CountryData country_data; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Maps country codes to localized label string identifiers. | 46 // Maps country codes to localized label string identifiers. |
| 47 const StaticCountryData kCountryData[] = { | 47 const StaticCountryData kCountryData[] = { |
| 48 { "AC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | |
| 49 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | |
| 50 ADDRESS_REQUIRES_CITY } }, | |
| 51 { "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 48 { "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 52 IDS_AUTOFILL_FIELD_LABEL_PARISH, | 49 IDS_AUTOFILL_FIELD_LABEL_PARISH, |
| 53 ADDRESS_REQUIRES_STATE } }, | 50 ADDRESS_REQUIRES_STATE } }, |
| 54 { "AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 51 { "AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 55 IDS_AUTOFILL_FIELD_LABEL_EMIRATE, | 52 IDS_AUTOFILL_FIELD_LABEL_EMIRATE, |
| 56 ADDRESS_REQUIRES_STATE } }, | 53 ADDRESS_REQUIRES_STATE } }, |
| 57 { "AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 54 { "AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 58 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 55 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 59 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 56 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 60 { "AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 57 { "AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 58 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 62 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, | 59 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, |
| 63 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 60 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 65 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 62 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 66 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 63 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 68 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 65 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 69 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 66 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 70 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 71 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 68 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 69 { "AN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 70 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 71 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 72 { "AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 72 { "AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 73 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 73 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 74 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 74 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 75 { "AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 75 { "AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 76 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 76 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 77 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 77 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 78 { "AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 78 { "AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 79 IDS_AUTOFILL_FIELD_LABEL_STATE, | 79 IDS_AUTOFILL_FIELD_LABEL_STATE, |
| 80 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 80 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 81 { "AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, | 81 { "AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 656 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 657 { "ST", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 657 { "ST", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 658 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 658 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 659 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 659 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 660 { "SV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 660 { "SV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 661 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 661 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 662 ADDRESS_REQUIRES_CITY_STATE } }, | 662 ADDRESS_REQUIRES_CITY_STATE } }, |
| 663 { "SZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 663 { "SZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 664 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 664 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 665 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 665 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 666 { "TA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | |
| 667 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | |
| 668 ADDRESS_REQUIRES_CITY } }, | |
| 669 { "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 666 { "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 670 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 667 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 671 ADDRESS_REQUIRES_CITY_ZIP } }, | 668 ADDRESS_REQUIRES_CITY_ZIP } }, |
| 672 { "TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 669 { "TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 673 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 670 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 674 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 671 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 675 { "TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 672 { "TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 676 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 673 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 677 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 674 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 678 { "TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 675 { "TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 CountryNames* CountryNames::GetInstance() { | 897 CountryNames* CountryNames::GetInstance() { |
| 901 return Singleton<CountryNames>::get(); | 898 return Singleton<CountryNames>::get(); |
| 902 } | 899 } |
| 903 | 900 |
| 904 CountryNames::CountryNames() { | 901 CountryNames::CountryNames() { |
| 905 // Add 2- and 3-letter ISO country codes. | 902 // Add 2- and 3-letter ISO country codes. |
| 906 for (CountryDataMap::Iterator it = CountryDataMap::Begin(); | 903 for (CountryDataMap::Iterator it = CountryDataMap::Begin(); |
| 907 it != CountryDataMap::End(); | 904 it != CountryDataMap::End(); |
| 908 ++it) { | 905 ++it) { |
| 909 const std::string& country_code = it->first; | 906 const std::string& country_code = it->first; |
| 910 common_names_.insert(std::make_pair(country_code, country_code)); | |
| 911 | |
| 912 std::string iso3_country_code = | 907 std::string iso3_country_code = |
| 913 icu::Locale(NULL, country_code.c_str()).getISO3Country(); | 908 icu::Locale(NULL, country_code.c_str()).getISO3Country(); |
| 914 | 909 |
| 915 // ICU list of countries can be out-of-date with CLDR. | 910 common_names_.insert(std::make_pair(country_code, country_code)); |
| 916 if (!iso3_country_code.empty()) | 911 common_names_.insert(std::make_pair(iso3_country_code, country_code)); |
| 917 common_names_.insert(std::make_pair(iso3_country_code, country_code)); | |
| 918 } | 912 } |
| 919 | 913 |
| 920 // Add a few other common synonyms. | 914 // Add a few other common synonyms. |
| 921 common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US")); | 915 common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US")); |
| 922 common_names_.insert(std::make_pair("U.S.A.", "US")); | 916 common_names_.insert(std::make_pair("U.S.A.", "US")); |
| 923 common_names_.insert(std::make_pair("GREAT BRITAIN", "GB")); | 917 common_names_.insert(std::make_pair("GREAT BRITAIN", "GB")); |
| 924 common_names_.insert(std::make_pair("UK", "GB")); | 918 common_names_.insert(std::make_pair("UK", "GB")); |
| 925 common_names_.insert(std::make_pair("BRASIL", "BR")); | 919 common_names_.insert(std::make_pair("BRASIL", "BR")); |
| 926 common_names_.insert(std::make_pair("DEUTSCHLAND", "DE")); | 920 common_names_.insert(std::make_pair("DEUTSCHLAND", "DE")); |
| 927 } | 921 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 const base::string16& name, | 1102 const base::string16& name, |
| 1109 const base::string16& postal_code_label, | 1103 const base::string16& postal_code_label, |
| 1110 const base::string16& state_label) | 1104 const base::string16& state_label) |
| 1111 : country_code_(country_code), | 1105 : country_code_(country_code), |
| 1112 name_(name), | 1106 name_(name), |
| 1113 postal_code_label_(postal_code_label), | 1107 postal_code_label_(postal_code_label), |
| 1114 state_label_(state_label) { | 1108 state_label_(state_label) { |
| 1115 } | 1109 } |
| 1116 | 1110 |
| 1117 } // namespace autofill | 1111 } // namespace autofill |
| OLD | NEW |