Index: chrome/browser/dom_ui/options/autofill_options_handler.cc |
diff --git a/chrome/browser/dom_ui/options/autofill_options_handler.cc b/chrome/browser/dom_ui/options/autofill_options_handler.cc |
index 946f77c4b6a10d62343039809da11c5254146d3d..f3f0fac431d0fa57fec8ade0d0aad683bd580c1b 100644 |
--- a/chrome/browser/dom_ui/options/autofill_options_handler.cc |
+++ b/chrome/browser/dom_ui/options/autofill_options_handler.cc |
@@ -11,6 +11,7 @@ |
#include "base/string_number_conversions.h" |
#include "base/utf_string_conversions.h" |
#include "base/values.h" |
+#include "chrome/browser/autofill/autofill_country.h" |
#include "chrome/browser/autofill/autofill_profile.h" |
#include "chrome/browser/autofill/credit_card.h" |
#include "chrome/browser/dom_ui/web_ui_util.h" |
@@ -20,6 +21,8 @@ |
#include "grit/webkit_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
+using autofill::AutoFillCountry; |
+ |
namespace { |
// Converts a credit card type to the appropriate resource ID of the CC icon. |
@@ -46,6 +49,31 @@ int CreditCardTypeToResourceID(const string16& type16) { |
return 0; |
} |
+DictionaryValue* GetCountryDetails(AutoFillCountry country) { |
+ DictionaryValue* details = new DictionaryValue(); |
+ details->SetString("name", autofill::GetCountryName(country)); |
+ details->SetString("postalCodeLabel", autofill::GetPostalCodeLabel(country)); |
+ details->SetString("stateLabel", autofill::GetStateLabel(country)); |
+ return details; |
+} |
+ |
+DictionaryValue* GetCountryList() { |
+ DictionaryValue* countries = new DictionaryValue(); |
+ |
+ DictionaryValue* default_country = |
+ GetCountryDetails(autofill::CountryCodeToCountry(std::string())); |
+ default_country->SetString("name", std::string()); |
+ countries->Set(std::string(), default_country); |
+ |
+ for (size_t i = autofill::FIRST_COUNTRY; i < autofill::NUM_COUNTRIES; ++i) { |
+ AutoFillCountry country = static_cast<AutoFillCountry>(i); |
+ countries->Set(autofill::GetCountryCode(country), |
+ GetCountryDetails(country)); |
+ } |
+ |
+ return countries; |
+} |
+ |
} // namespace |
AutoFillOptionsHandler::AutoFillOptionsHandler() |
@@ -147,18 +175,18 @@ void AutoFillOptionsHandler::SetAddressOverlayStrings( |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CITY)); |
localized_strings->SetString("stateLabel", |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_STATE)); |
- localized_strings->SetString("zipCodeLabel", |
+ localized_strings->SetString("postalCodeLabel", |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ZIP_CODE)); |
localized_strings->SetString("countryLabel", |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY)); |
- localized_strings->SetString("countryLabel", |
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY)); |
localized_strings->SetString("phoneLabel", |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PHONE)); |
localized_strings->SetString("faxLabel", |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FAX)); |
localized_strings->SetString("emailLabel", |
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EMAIL)); |
+ |
+ localized_strings->Set("autofillCountryData", GetCountryList()); |
} |
void AutoFillOptionsHandler::SetCreditCardOverlayStrings( |
@@ -267,7 +295,7 @@ void AutoFillOptionsHandler::LoadAddressEditor(const ListValue* args) { |
profile->GetFieldText(AutoFillType(ADDRESS_HOME_CITY))); |
address->SetString("state", |
profile->GetFieldText(AutoFillType(ADDRESS_HOME_STATE))); |
- address->SetString("zipCode", |
+ address->SetString("postalCode", |
profile->GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))); |
address->SetString("country", |
profile->GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY))); |