| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, | 59 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } }, |
| 60 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 60 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 62 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 62 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 63 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 63 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 65 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 65 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 66 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 66 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 68 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, | 69 { "AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 73 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 70 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 74 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 71 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 75 { "AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 72 { "AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 76 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 73 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 77 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 74 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 78 { "AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 75 { "AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 79 IDS_AUTOFILL_FIELD_LABEL_STATE, | 76 IDS_AUTOFILL_FIELD_LABEL_STATE, |
| 80 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 77 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 81 { "AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, | 78 { "AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE, |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 ADDRESS_REQUIRES_CITY } }, | 746 ADDRESS_REQUIRES_CITY } }, |
| 750 { "VU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 747 { "VU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 751 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 748 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 752 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 749 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 753 { "WF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 750 { "WF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 754 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 751 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 755 ADDRESS_REQUIRES_CITY_ZIP } }, | 752 ADDRESS_REQUIRES_CITY_ZIP } }, |
| 756 { "WS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 753 { "WS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 757 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 754 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 758 ADDRESS_REQUIREMENTS_UNKNOWN } }, | 755 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 756 { "XK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 757 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 758 ADDRESS_REQUIREMENTS_UNKNOWN } }, |
| 759 { "YE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 759 { "YE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 760 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 760 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 761 ADDRESS_REQUIRES_CITY } }, | 761 ADDRESS_REQUIRES_CITY } }, |
| 762 { "YT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 762 { "YT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 763 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 763 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 764 ADDRESS_REQUIRES_CITY_ZIP } }, | 764 ADDRESS_REQUIRES_CITY_ZIP } }, |
| 765 { "ZA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 765 { "ZA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| 766 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, | 766 IDS_AUTOFILL_FIELD_LABEL_PROVINCE, |
| 767 ADDRESS_REQUIRES_CITY_ZIP } }, | 767 ADDRESS_REQUIRES_CITY_ZIP } }, |
| 768 { "ZM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, | 768 { "ZM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 DCHECK_EQ(*buffer_size, expected_size); | 1037 DCHECK_EQ(*buffer_size, expected_size); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 return std::string(reinterpret_cast<const char*>(buffer->get())); | 1040 return std::string(reinterpret_cast<const char*>(buffer->get())); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 } // namespace | 1043 } // namespace |
| 1044 | 1044 |
| 1045 AutofillCountry::AutofillCountry(const std::string& country_code, | 1045 AutofillCountry::AutofillCountry(const std::string& country_code, |
| 1046 const std::string& locale) { | 1046 const std::string& locale) { |
| 1047 const CountryDataMap::Iterator result = CountryDataMap::Find(country_code); | |
| 1048 DCHECK(result != CountryDataMap::End()); | |
| 1049 const CountryData& data = result->second; | |
| 1050 | |
| 1051 country_code_ = country_code; | 1047 country_code_ = country_code; |
| 1052 name_ = l10n_util::GetDisplayNameForCountry(country_code, locale); | 1048 name_ = l10n_util::GetDisplayNameForCountry(country_code, locale); |
| 1053 postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id); | 1049 |
| 1054 state_label_ = l10n_util::GetStringUTF16(data.state_label_id); | 1050 const CountryDataMap::Iterator result = CountryDataMap::Find(country_code); |
| 1055 address_required_fields_ = data.address_required_fields; | 1051 if (result != CountryDataMap::End()) { |
| 1052 const CountryData& data = result->second; |
| 1053 postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id); |
| 1054 state_label_ = l10n_util::GetStringUTF16(data.state_label_id); |
| 1055 address_required_fields_ = data.address_required_fields; |
| 1056 } else { |
| 1057 postal_code_label_ = state_label_ = base::ASCIIToUTF16("[UNKNOWN]"); |
| 1058 } |
| 1056 } | 1059 } |
| 1057 | 1060 |
| 1058 AutofillCountry::~AutofillCountry() { | 1061 AutofillCountry::~AutofillCountry() { |
| 1059 } | 1062 } |
| 1060 | 1063 |
| 1061 // static | 1064 // static |
| 1062 void AutofillCountry::GetAvailableCountries( | 1065 void AutofillCountry::GetAvailableCountries( |
| 1063 std::vector<std::string>* country_codes) { | 1066 std::vector<std::string>* country_codes) { |
| 1064 DCHECK(country_codes); | 1067 DCHECK(country_codes); |
| 1065 | 1068 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 const base::string16& name, | 1105 const base::string16& name, |
| 1103 const base::string16& postal_code_label, | 1106 const base::string16& postal_code_label, |
| 1104 const base::string16& state_label) | 1107 const base::string16& state_label) |
| 1105 : country_code_(country_code), | 1108 : country_code_(country_code), |
| 1106 name_(name), | 1109 name_(name), |
| 1107 postal_code_label_(postal_code_label), | 1110 postal_code_label_(postal_code_label), |
| 1108 state_label_(state_label) { | 1111 state_label_(state_label) { |
| 1109 } | 1112 } |
| 1110 | 1113 |
| 1111 } // namespace autofill | 1114 } // namespace autofill |
| OLD | NEW |