| 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 // A const iterator over the wrapped map data. | 785 // A const iterator over the wrapped map data. |
| 786 typedef std::map<std::string, CountryData>::const_iterator Iterator; | 786 typedef std::map<std::string, CountryData>::const_iterator Iterator; |
| 787 | 787 |
| 788 static CountryDataMap* GetInstance(); | 788 static CountryDataMap* GetInstance(); |
| 789 static const Iterator Begin(); | 789 static const Iterator Begin(); |
| 790 static const Iterator End(); | 790 static const Iterator End(); |
| 791 static const Iterator Find(const std::string& country_code); | 791 static const Iterator Find(const std::string& country_code); |
| 792 | 792 |
| 793 private: | 793 private: |
| 794 CountryDataMap(); | 794 CountryDataMap(); |
| 795 friend struct DefaultSingletonTraits<CountryDataMap>; | 795 friend struct base::DefaultSingletonTraits<CountryDataMap>; |
| 796 | 796 |
| 797 std::map<std::string, CountryData> country_data_; | 797 std::map<std::string, CountryData> country_data_; |
| 798 | 798 |
| 799 DISALLOW_COPY_AND_ASSIGN(CountryDataMap); | 799 DISALLOW_COPY_AND_ASSIGN(CountryDataMap); |
| 800 }; | 800 }; |
| 801 | 801 |
| 802 // static | 802 // static |
| 803 CountryDataMap* CountryDataMap::GetInstance() { | 803 CountryDataMap* CountryDataMap::GetInstance() { |
| 804 return Singleton<CountryDataMap>::get(); | 804 return base::Singleton<CountryDataMap>::get(); |
| 805 } | 805 } |
| 806 | 806 |
| 807 CountryDataMap::CountryDataMap() { | 807 CountryDataMap::CountryDataMap() { |
| 808 // Add all the countries we have explicit data for. | 808 // Add all the countries we have explicit data for. |
| 809 for (size_t i = 0; i < arraysize(kCountryData); ++i) { | 809 for (size_t i = 0; i < arraysize(kCountryData); ++i) { |
| 810 const StaticCountryData& static_data = kCountryData[i]; | 810 const StaticCountryData& static_data = kCountryData[i]; |
| 811 country_data_.insert(std::make_pair(static_data.country_code, | 811 country_data_.insert(std::make_pair(static_data.country_code, |
| 812 static_data.country_data)); | 812 static_data.country_data)); |
| 813 } | 813 } |
| 814 | 814 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 static CountryNames* GetInstance(); | 848 static CountryNames* GetInstance(); |
| 849 | 849 |
| 850 // Returns the country code corresponding to |country|, which should be a | 850 // Returns the country code corresponding to |country|, which should be a |
| 851 // country code or country name localized to |locale|. | 851 // country code or country name localized to |locale|. |
| 852 const std::string GetCountryCode(const base::string16& country, | 852 const std::string GetCountryCode(const base::string16& country, |
| 853 const std::string& locale); | 853 const std::string& locale); |
| 854 | 854 |
| 855 private: | 855 private: |
| 856 CountryNames(); | 856 CountryNames(); |
| 857 ~CountryNames(); | 857 ~CountryNames(); |
| 858 friend struct DefaultSingletonTraits<CountryNames>; | 858 friend struct base::DefaultSingletonTraits<CountryNames>; |
| 859 | 859 |
| 860 // Populates |locales_to_localized_names_| with the mapping of country names | 860 // Populates |locales_to_localized_names_| with the mapping of country names |
| 861 // localized to |locale| to their corresponding country codes. | 861 // localized to |locale| to their corresponding country codes. |
| 862 void AddLocalizedNamesForLocale(const std::string& locale); | 862 void AddLocalizedNamesForLocale(const std::string& locale); |
| 863 | 863 |
| 864 // Interprets |country_name| as a full country name localized to the given | 864 // Interprets |country_name| as a full country name localized to the given |
| 865 // |locale| and returns the corresponding country code stored in | 865 // |locale| and returns the corresponding country code stored in |
| 866 // |locales_to_localized_names_|, or an empty string if there is none. | 866 // |locales_to_localized_names_|, or an empty string if there is none. |
| 867 const std::string GetCountryCodeForLocalizedName( | 867 const std::string GetCountryCodeForLocalizedName( |
| 868 const base::string16& country_name, | 868 const base::string16& country_name, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 894 locales_to_localized_names_; | 894 locales_to_localized_names_; |
| 895 | 895 |
| 896 // Maps ICU locale names to their corresponding collators. | 896 // Maps ICU locale names to their corresponding collators. |
| 897 std::map<std::string, icu::Collator*> collators_; | 897 std::map<std::string, icu::Collator*> collators_; |
| 898 | 898 |
| 899 DISALLOW_COPY_AND_ASSIGN(CountryNames); | 899 DISALLOW_COPY_AND_ASSIGN(CountryNames); |
| 900 }; | 900 }; |
| 901 | 901 |
| 902 // static | 902 // static |
| 903 CountryNames* CountryNames::GetInstance() { | 903 CountryNames* CountryNames::GetInstance() { |
| 904 return Singleton<CountryNames>::get(); | 904 return base::Singleton<CountryNames>::get(); |
| 905 } | 905 } |
| 906 | 906 |
| 907 CountryNames::CountryNames() { | 907 CountryNames::CountryNames() { |
| 908 // Add 2- and 3-letter ISO country codes. | 908 // Add 2- and 3-letter ISO country codes. |
| 909 for (CountryDataMap::Iterator it = CountryDataMap::Begin(); | 909 for (CountryDataMap::Iterator it = CountryDataMap::Begin(); |
| 910 it != CountryDataMap::End(); | 910 it != CountryDataMap::End(); |
| 911 ++it) { | 911 ++it) { |
| 912 const std::string& country_code = it->first; | 912 const std::string& country_code = it->first; |
| 913 common_names_.insert(std::make_pair(country_code, country_code)); | 913 common_names_.insert(std::make_pair(country_code, country_code)); |
| 914 | 914 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 const base::string16& name, | 1110 const base::string16& name, |
| 1111 const base::string16& postal_code_label, | 1111 const base::string16& postal_code_label, |
| 1112 const base::string16& state_label) | 1112 const base::string16& state_label) |
| 1113 : country_code_(country_code), | 1113 : country_code_(country_code), |
| 1114 name_(name), | 1114 name_(name), |
| 1115 postal_code_label_(postal_code_label), | 1115 postal_code_label_(postal_code_label), |
| 1116 state_label_(state_label) { | 1116 state_label_(state_label) { |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 } // namespace autofill | 1119 } // namespace autofill |
| OLD | NEW |