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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 } | 930 } |
931 | 931 |
932 CountryNames::~CountryNames() { | 932 CountryNames::~CountryNames() { |
933 STLDeleteContainerPairSecondPointers(collators_.begin(), | 933 STLDeleteContainerPairSecondPointers(collators_.begin(), |
934 collators_.end()); | 934 collators_.end()); |
935 } | 935 } |
936 | 936 |
937 const std::string CountryNames::GetCountryCode(const base::string16& country, | 937 const std::string CountryNames::GetCountryCode(const base::string16& country, |
938 const std::string& locale) { | 938 const std::string& locale) { |
939 // First, check common country names, including 2- and 3-letter country codes. | 939 // First, check common country names, including 2- and 3-letter country codes. |
940 std::string country_utf8 = base::UTF16ToUTF8( | 940 std::string country_utf8 = base::UTF16ToUTF8(base::ToUpperASCII(country)); |
941 base::StringToUpperASCII(country)); | 941 const auto result = common_names_.find(country_utf8); |
942 std::map<std::string, std::string>::const_iterator result = | |
943 common_names_.find(country_utf8); | |
944 if (result != common_names_.end()) | 942 if (result != common_names_.end()) |
945 return result->second; | 943 return result->second; |
946 | 944 |
947 // Next, check country names localized to |locale|. | 945 // Next, check country names localized to |locale|. |
948 std::string country_code = GetCountryCodeForLocalizedName(country, locale); | 946 std::string country_code = GetCountryCodeForLocalizedName(country, locale); |
949 if (!country_code.empty()) | 947 if (!country_code.empty()) |
950 return country_code; | 948 return country_code; |
951 | 949 |
952 // Finally, check country names localized to US English. | 950 // Finally, check country names localized to US English. |
953 return GetCountryCodeForLocalizedName(country, "en_US"); | 951 return GetCountryCodeForLocalizedName(country, "en_US"); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 const base::string16& name, | 1110 const base::string16& name, |
1113 const base::string16& postal_code_label, | 1111 const base::string16& postal_code_label, |
1114 const base::string16& state_label) | 1112 const base::string16& state_label) |
1115 : country_code_(country_code), | 1113 : country_code_(country_code), |
1116 name_(name), | 1114 name_(name), |
1117 postal_code_label_(postal_code_label), | 1115 postal_code_label_(postal_code_label), |
1118 state_label_(state_label) { | 1116 state_label_(state_label) { |
1119 } | 1117 } |
1120 | 1118 |
1121 } // namespace autofill | 1119 } // namespace autofill |
OLD | NEW |