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 } }, |
48 { "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 51 { "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
49 IDS_AUTOFILL_FIELD_LABEL_PARISH, | 52 IDS_AUTOFILL_FIELD_LABEL_PARISH, |
50 ADDRESS_REQUIRES_STATE } }, | 53 ADDRESS_REQUIRES_STATE } }, |
51 { "AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 54 { "AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
52 IDS_AUTOFILL_FIELD_LABEL_EMIRATE, | 55 IDS_AUTOFILL_FIELD_LABEL_EMIRATE, |
53 ADDRESS_REQUIRES_STATE } }, | 56 ADDRESS_REQUIRES_STATE } }, |
54 { "AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 57 { "AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
55 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 58 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
56 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 59 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
57 { "AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 60 { "AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
58 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
59 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, | 62 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, |
60 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 63 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
62 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 65 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
63 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 66 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
65 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 68 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
66 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 69 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 70 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
68 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 71 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 } }, |
666 { "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 669 { "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
667 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 670 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
668 ADDRESS_REQUIRES_CITY_ZIP } }, | 671 ADDRESS_REQUIRES_CITY_ZIP } }, |
669 { "TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 672 { "TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
670 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 673 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
671 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 674 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
672 { "TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 675 { "TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
673 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 676 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
674 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 677 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
675 { "TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 678 { "TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 CountryNames* CountryNames::GetInstance() { | 900 CountryNames* CountryNames::GetInstance() { |
898 return Singleton<CountryNames>::get(); | 901 return Singleton<CountryNames>::get(); |
899 } | 902 } |
900 | 903 |
901 CountryNames::CountryNames() { | 904 CountryNames::CountryNames() { |
902 // Add 2- and 3-letter ISO country codes. | 905 // Add 2- and 3-letter ISO country codes. |
903 for (CountryDataMap::Iterator it = CountryDataMap::Begin(); | 906 for (CountryDataMap::Iterator it = CountryDataMap::Begin(); |
904 it != CountryDataMap::End(); | 907 it != CountryDataMap::End(); |
905 ++it) { | 908 ++it) { |
906 const std::string& country_code = it->first; | 909 const std::string& country_code = it->first; |
| 910 common_names_.insert(std::make_pair(country_code, country_code)); |
| 911 |
907 std::string iso3_country_code = | 912 std::string iso3_country_code = |
908 icu::Locale(NULL, country_code.c_str()).getISO3Country(); | 913 icu::Locale(NULL, country_code.c_str()).getISO3Country(); |
909 | 914 |
910 common_names_.insert(std::make_pair(country_code, country_code)); | 915 // ICU list of countries can be out-of-date with CLDR. |
911 common_names_.insert(std::make_pair(iso3_country_code, country_code)); | 916 if (!iso3_country_code.empty()) |
| 917 common_names_.insert(std::make_pair(iso3_country_code, country_code)); |
912 } | 918 } |
913 | 919 |
914 // Add a few other common synonyms. | 920 // Add a few other common synonyms. |
915 common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US")); | 921 common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US")); |
916 common_names_.insert(std::make_pair("U.S.A.", "US")); | 922 common_names_.insert(std::make_pair("U.S.A.", "US")); |
917 common_names_.insert(std::make_pair("GREAT BRITAIN", "GB")); | 923 common_names_.insert(std::make_pair("GREAT BRITAIN", "GB")); |
918 common_names_.insert(std::make_pair("UK", "GB")); | 924 common_names_.insert(std::make_pair("UK", "GB")); |
919 common_names_.insert(std::make_pair("BRASIL", "BR")); | 925 common_names_.insert(std::make_pair("BRASIL", "BR")); |
920 common_names_.insert(std::make_pair("DEUTSCHLAND", "DE")); | 926 common_names_.insert(std::make_pair("DEUTSCHLAND", "DE")); |
921 } | 927 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 const base::string16& name, | 1108 const base::string16& name, |
1103 const base::string16& postal_code_label, | 1109 const base::string16& postal_code_label, |
1104 const base::string16& state_label) | 1110 const base::string16& state_label) |
1105 : country_code_(country_code), | 1111 : country_code_(country_code), |
1106 name_(name), | 1112 name_(name), |
1107 postal_code_label_(postal_code_label), | 1113 postal_code_label_(postal_code_label), |
1108 state_label_(state_label) { | 1114 state_label_(state_label) { |
1109 } | 1115 } |
1110 | 1116 |
1111 } // namespace autofill | 1117 } // namespace autofill |
OLD | NEW |