| Index: chrome/browser/ui/webui/options/autofill_options_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc
|
| index 4b83a007a168bb62de30a8621ba06faa83888676..0f5f76011e5c318748122db90db976e1f5ea96b2 100644
|
| --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc
|
| @@ -21,6 +21,7 @@
|
| #include "chrome/browser/autofill/personal_data_manager_factory.h"
|
| #include "chrome/browser/autofill/phone_number_i18n.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/autofill/country_combobox_model.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/web_ui.h"
|
| #include "grit/generated_resources.h"
|
| @@ -29,25 +30,39 @@
|
|
|
| namespace {
|
|
|
| -// Returns a dictionary that maps country codes to data for the country.
|
| -DictionaryValue* GetCountryData() {
|
| +// Sets data related to the country <select>.
|
| +void SetCountryData(DictionaryValue* localized_strings) {
|
| std::string app_locale = AutofillCountry::ApplicationLocale();
|
| - std::vector<std::string> country_codes;
|
| - AutofillCountry::GetAvailableCountries(&country_codes);
|
| + std::string default_country_code =
|
| + AutofillCountry::CountryCodeForLocale(app_locale);
|
| + localized_strings->SetString("defaultCountryCode", default_country_code);
|
|
|
| - DictionaryValue* country_data = new DictionaryValue();
|
| - for (size_t i = 0; i < country_codes.size(); ++i) {
|
| - const AutofillCountry country(country_codes[i], app_locale);
|
| + autofill::CountryComboboxModel model;
|
| + const std::vector<AutofillCountry*>& countries = model.countries();
|
| +
|
| + // An ordered list of options to show in the <select>.
|
| + scoped_ptr<ListValue> country_list(new ListValue());
|
| + // A dictionary of postal code and state info, keyed on country code.
|
| + scoped_ptr<DictionaryValue> country_data(new DictionaryValue());
|
| + for (size_t i = 0; i < countries.size(); ++i) {
|
| + scoped_ptr<DictionaryValue> option_details(new DictionaryValue());
|
| + option_details->SetString("name", model.GetItemAt(i));
|
| + option_details->SetString(
|
| + "value",
|
| + countries[i] ? countries[i]->country_code() : "separator");
|
| + country_list->Append(option_details.release());
|
| +
|
| + if (!countries[i])
|
| + continue;
|
|
|
| - DictionaryValue* details = new DictionaryValue();
|
| - details->SetString("name", country.name());
|
| - details->SetString("postalCodeLabel", country.postal_code_label());
|
| - details->SetString("stateLabel", country.state_label());
|
| + scoped_ptr<DictionaryValue> details(new DictionaryValue());
|
| + details->SetString("postalCodeLabel", countries[i]->postal_code_label());
|
| + details->SetString("stateLabel", countries[i]->state_label());
|
| + country_data->Set(countries[i]->country_code(), details.release());
|
|
|
| - country_data->Set(country.country_code(), details);
|
| }
|
| -
|
| - return country_data;
|
| + localized_strings->Set("autofillCountrySelectList", country_list.release());
|
| + localized_strings->Set("autofillCountryData", country_data.release());
|
| }
|
|
|
| // Get the multi-valued element for |type| and return it in |ListValue| form.
|
| @@ -335,12 +350,7 @@ void AutofillOptionsHandler::SetAddressOverlayStrings(
|
| l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_ADD_PHONE));
|
| localized_strings->SetString("autofillAddEmailPlaceholder",
|
| l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_ADD_EMAIL));
|
| -
|
| - std::string app_locale = AutofillCountry::ApplicationLocale();
|
| - std::string default_country_code =
|
| - AutofillCountry::CountryCodeForLocale(app_locale);
|
| - localized_strings->SetString("defaultCountryCode", default_country_code);
|
| - localized_strings->Set("autofillCountryData", GetCountryData());
|
| + SetCountryData(localized_strings);
|
| }
|
|
|
| void AutofillOptionsHandler::SetCreditCardOverlayStrings(
|
|
|