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 1026 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 |