Index: chrome/browser/ui/autofill/autofill_dialog_models.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_models.cc b/chrome/browser/ui/autofill/autofill_dialog_models.cc |
index 10aa69b6735247e3fa83148e32cc5b2126423d26..ca09e3140ed1d806104d075a0a8853f28c99a4ac 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_models.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_models.cc |
@@ -9,6 +9,7 @@ |
#include "base/time.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/autofill/autofill_country.h" |
+#include "ui/base/l10n/l10n_util_collator.h" |
namespace autofill { |
@@ -104,19 +105,40 @@ string16 YearComboboxModel::GetItemAt(int index) { |
// CountryComboboxModel -------------------------------------------------------- |
CountryComboboxModel::CountryComboboxModel() { |
- AutofillCountry::GetAvailableCountries(&country_codes_); |
+ std::vector<std::string> country_codes; |
+ AutofillCountry::GetAvailableCountries(&country_codes); |
+ std::string app_locale = AutofillCountry::ApplicationLocale(); |
+ |
+ for (std::vector<std::string>::iterator iter = country_codes.begin(); |
+ iter != country_codes.end(); ++iter) { |
+ countries_.push_back(new AutofillCountry(*iter, app_locale)); |
+ } |
+ |
+ l10n_util::SortStringsUsingMethod(app_locale, |
+ &countries_.get(), |
+ &AutofillCountry::name); |
} |
CountryComboboxModel::~CountryComboboxModel() {} |
int CountryComboboxModel::GetItemCount() const { |
- return country_codes_.size(); |
+ return countries_.size(); |
} |
string16 CountryComboboxModel::GetItemAt(int index) { |
+ return countries_[index]->name(); |
+} |
+ |
+int CountryComboboxModel::GetDefaultIndex() const { |
std::string app_locale = AutofillCountry::ApplicationLocale(); |
- const AutofillCountry country(country_codes_[index], app_locale); |
- return country.name(); |
+ std::string country_code = |
+ AutofillCountry::CountryCodeForLocale(app_locale); |
+ for (size_t i = 0; i < countries_.size(); ++i) { |
+ if (countries_[i]->country_code() == country_code) |
+ return i; |
+ } |
+ NOTREACHED(); |
+ return 0; |
} |
} // autofill |