| 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..f1fb27dc79182b2cd65f1037bcddf269c2c9b79b 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;
|
|
|
| @@ -482,10 +482,7 @@ void CountryNames::AddLocalizedNamesForLocale(const std::string& locale) {
|
| return;
|
|
|
| std::map<std::string, std::string> localized_names;
|
| -
|
| - icu::Locale icu_locale(locale.c_str());
|
| const icu::Collator* collator = GetCollatorForLocale(locale);
|
| -
|
| int32_t buffer_size = 1000;
|
| scoped_array<uint8_t> buffer(new uint8_t[buffer_size]);
|
|
|
| @@ -493,10 +490,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);
|
| std::string sort_key = GetSortKey(*collator,
|
| country_name,
|
| &buffer,
|
| @@ -521,7 +516,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 +550,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 +581,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);
|
| postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id);
|
| state_label_ = l10n_util::GetStringUTF16(data.state_label_id);
|
| }
|
|
|