Chromium Code Reviews| Index: chrome/browser/autofill/autofill_country.cc |
| diff --git a/chrome/browser/autofill/autofill_country.cc b/chrome/browser/autofill/autofill_country.cc |
| index 4a83bd0f4f1fdd4f9114d92bbee1641d7ce9d5ef..b36f5f8b591bbc1d365d2833b568e5fb6ba1ffac 100644 |
| --- a/chrome/browser/autofill/autofill_country.cc |
| +++ b/chrome/browser/autofill/autofill_country.cc |
| @@ -390,7 +390,7 @@ class CountryNames { |
| // effect. |buffer_size| should specify the |buffer|'s size, and is updated if |
| // the |buffer| is resized. |
| const std::string GetSortKey(const icu::Collator& collator, |
| - const icu::UnicodeString& str, |
| + const string16& str, |
| scoped_array<uint8_t>* buffer, |
| int32_t* buffer_size) const; |
| @@ -493,10 +493,8 @@ void CountryNames::AddLocalizedNamesForLocale(const std::string& locale) { |
| it != CountryDataMap::End(); |
| ++it) { |
| const std::string& country_code = it->first; |
| - |
| - icu::Locale country_locale(NULL, country_code.c_str()); |
| - icu::UnicodeString country_name; |
| - country_locale.getDisplayName(icu_locale, country_name); |
| + string16 country_name = l10n_util::GetDisplayNameForCountry(country_code, |
| + locale, false); |
|
Ilya Sherman
2012/04/25 20:10:36
nit: I don't fully follow the significance of the
Xianzhu
2012/04/25 22:31:46
I'm also not sure about this. I included the param
Xianzhu
2012/04/25 22:49:27
Just noticed that the is_for_ui parameter of the o
|
| std::string sort_key = GetSortKey(*collator, |
| country_name, |
| &buffer, |
| @@ -521,7 +519,7 @@ const std::string CountryNames::GetCountryCodeForLocalizedName( |
| int32_t buffer_size = country_name.size() * 4; |
| scoped_array<uint8_t> buffer(new uint8_t[buffer_size]); |
| std::string sort_key = GetSortKey(*collator, |
| - country_name.c_str(), |
| + country_name, |
| &buffer, |
| &buffer_size); |
| @@ -555,38 +553,28 @@ icu::Collator* CountryNames::GetCollatorForLocale(const std::string& locale) { |
| } |
| const std::string CountryNames::GetSortKey(const icu::Collator& collator, |
| - const icu::UnicodeString& str, |
| + const string16& str, |
| scoped_array<uint8_t>* buffer, |
| int32_t* buffer_size) const { |
| DCHECK(buffer); |
| DCHECK(buffer_size); |
| - int32_t expected_size = collator.getSortKey(str, buffer->get(), *buffer_size); |
| + icu::UnicodeString icu_str(str.c_str(), str.length()); |
| + int32_t expected_size = collator.getSortKey(icu_str, buffer->get(), |
| + *buffer_size); |
| if (expected_size > *buffer_size) { |
| // If there wasn't enough space, grow the buffer and try again. |
| *buffer_size = expected_size; |
| buffer->reset(new uint8_t[*buffer_size]); |
| DCHECK(buffer->get()); |
| - expected_size = collator.getSortKey(str, buffer->get(), *buffer_size); |
| + expected_size = collator.getSortKey(icu_str, buffer->get(), *buffer_size); |
| DCHECK_EQ(*buffer_size, expected_size); |
| } |
| return std::string(reinterpret_cast<const char*>(buffer->get())); |
| } |
| -// Returns the country name corresponding to |country_code|, localized to the |
| -// |display_locale|. |
| -string16 GetDisplayName(const std::string& country_code, |
| - const icu::Locale& display_locale) { |
| - icu::Locale country_locale(NULL, country_code.c_str()); |
| - icu::UnicodeString name; |
| - country_locale.getDisplayName(display_locale, name); |
| - |
| - DCHECK_GT(name.length(), 0); |
| - return string16(name.getBuffer(), name.length()); |
| -} |
| - |
| } // namespace |
| AutofillCountry::AutofillCountry(const std::string& country_code, |
| @@ -596,7 +584,7 @@ AutofillCountry::AutofillCountry(const std::string& country_code, |
| const CountryData& data = result->second; |
| country_code_ = country_code; |
| - name_ = GetDisplayName(country_code, icu::Locale(locale.c_str())); |
| + name_ = l10n_util::GetDisplayNameForCountry(country_code, locale, false); |
| postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id); |
| state_label_ = l10n_util::GetStringUTF16(data.state_label_id); |
| } |