Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2247)

Unified Diff: chrome/browser/dom_ui/options/autofill_options_handler.cc

Issue 6484022: Autofill i18n: Set postal code and state field labels based on the selected country. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: I see you, ICU Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b72ecd00687592c0fab5dc97d5ad2272df7462bf 100644
--- a/chrome/browser/dom_ui/options/autofill_options_handler.cc
+++ b/chrome/browser/dom_ui/options/autofill_options_handler.cc
@@ -11,8 +11,10 @@
#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/browser_process.h"
#include "chrome/browser/dom_ui/web_ui_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/guid.h"
@@ -46,6 +48,26 @@ int CreditCardTypeToResourceID(const string16& type16) {
return 0;
}
+// Returns a dictionary that maps country codes to data for the country.
+DictionaryValue* GetCountryData() {
+ std::vector<AutoFillCountry> countries;
+ AutoFillCountry::GetAvailableCountries(&countries);
+
+ DictionaryValue* country_data = new DictionaryValue();
+ for (size_t i = 0; i < countries.size(); ++i) {
+ const AutoFillCountry& country = countries[i];
+
+ DictionaryValue* details = new DictionaryValue();
+ details->SetString("name", country.name());
+ details->SetString("postalCodeLabel", country.postal_code_label());
+ details->SetString("stateLabel", country.state_label());
+
+ country_data->Set(country.country_code(), details);
+ }
+
+ return country_data;
+}
+
} // namespace
AutoFillOptionsHandler::AutoFillOptionsHandler()
@@ -147,18 +169,23 @@ 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));
+
+ std::string app_locale = g_browser_process->GetApplicationLocale();
+ std::string default_country_code =
+ AutoFillCountry::CountryForLocale(app_locale).country_code();
+
+ localized_strings->SetString("defaultCountryCode", default_country_code);
+ localized_strings->Set("autofillCountryData", GetCountryData());
}
void AutoFillOptionsHandler::SetCreditCardOverlayStrings(
@@ -267,7 +294,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)));

Powered by Google App Engine
This is Rietveld 408576698