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

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: Still needs tests 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 4ab22e45ff13dc1f9d3c6d554c27ec3c4cbabdba..41f7e56aa14f21d141dd0c43d10dc112a9cee016 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"
@@ -46,6 +47,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()
@@ -137,6 +158,8 @@ void AutoFillOptionsHandler::SetAddressOverlayStrings(
l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION));
localized_strings->SetString("fullNameLabel",
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FULL_NAME));
+ localized_strings->SetString("country-label",
dhollowa 2011/02/17 00:55:28 As discussed... country should follow other addres
Ilya Sherman 2011/02/17 23:09:11 Done.
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY));
localized_strings->SetString("companyNameLabel",
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COMPANY_NAME));
localized_strings->SetString("addrLine1Label",
@@ -145,20 +168,16 @@ void AutoFillOptionsHandler::SetAddressOverlayStrings(
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2));
localized_strings->SetString("cityLabel",
l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CITY));
- localized_strings->SetString("stateLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_STATE));
- localized_strings->SetString("zipCodeLabel",
- 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 default_country_code = AutoFillCountry::DefaultCountryCode();
+ localized_strings->SetString("defaultCountryCode", default_country_code);
+ localized_strings->Set("autofillCountryData", GetCountryData());
}
void AutoFillOptionsHandler::SetCreditCardOverlayStrings(
@@ -254,6 +273,8 @@ void AutoFillOptionsHandler::LoadAddressEditor(const ListValue* args) {
address.SetString("guid", profile->guid());
address.SetString("fullName",
profile->GetFieldText(AutoFillType(NAME_FULL)));
+ address.SetString("country",
+ profile->CountryCode());
address.SetString("companyName",
profile->GetFieldText(AutoFillType(COMPANY_NAME)));
address.SetString("addrLine1",
@@ -264,10 +285,8 @@ 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("postal-code",
profile->GetFieldText(AutoFillType(ADDRESS_HOME_ZIP)));
- address.SetString("country",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY)));
address.SetString(
"phone",
profile->GetFieldText(AutoFillType(PHONE_HOME_WHOLE_NUMBER)));
@@ -332,23 +351,24 @@ void AutoFillOptionsHandler::SetAddress(const ListValue* args) {
AutoFillProfile profile(guid);
+ std::string country_code;
string16 value;
if (args->GetString(1, &value))
profile.SetInfo(AutoFillType(NAME_FULL), value);
- if (args->GetString(2, &value))
- profile.SetInfo(AutoFillType(COMPANY_NAME), value);
+ if (args->GetString(2, &country_code))
+ profile.SetCountryCode(country_code);
if (args->GetString(3, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), value);
+ profile.SetInfo(AutoFillType(COMPANY_NAME), value);
if (args->GetString(4, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), value);
+ profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), value);
if (args->GetString(5, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), value);
+ profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), value);
if (args->GetString(6, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), value);
+ profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), value);
if (args->GetString(7, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), value);
+ profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), value);
if (args->GetString(8, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), value);
+ profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), value);
if (args->GetString(9, &value))
profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), value);
if (args->GetString(10, &value))

Powered by Google App Engine
This is Rietveld 408576698