Index: chrome/browser/ui/autofill/autofill_dialog_common.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_common.cc b/chrome/browser/ui/autofill/autofill_dialog_common.cc |
index 4391a6b0d18d94711069617aaa590d3ce8457c76..4eea691a4efc6da5bac580f8346470f944817212 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_common.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_common.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/ui/autofill/autofill_dialog_common.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
#include "components/autofill/core/browser/autofill_country.h" |
#include "components/autofill/core/browser/autofill_field.h" |
#include "components/autofill/core/browser/autofill_type.h" |
@@ -13,6 +14,7 @@ |
#include "grit/generated_resources.h" |
#include "grit/theme_resources.h" |
#include "grit/webkit_resources.h" |
+#include "ui/base/l10n/l10n_util.h" |
namespace autofill { |
namespace common { |
@@ -73,48 +75,69 @@ void BuildInputs(const DetailInput* input_template, |
// Constructs |inputs| from template data for a given |dialog_section|. |
void BuildInputsForSection(DialogSection dialog_section, |
- DetailInputs* inputs) { |
+ DetailInputs* inputs, |
+ const std::string& country_region) { |
+ using l10n_util::GetStringUTF16; |
+ |
const DetailInput kCCInputs[] = { |
- { 1, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, |
- { 2, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH }, |
+ { 1, CREDIT_CARD_NUMBER, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER) }, |
+ { 2, CREDIT_CARD_EXP_MONTH, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH) }, |
{ 2, CREDIT_CARD_EXP_4_DIGIT_YEAR, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR }, |
- { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR) }, |
+ { 2, CREDIT_CARD_VERIFICATION_CODE, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC), |
1.5 }, |
}; |
+ const int kBillingInputsStartRow = 3; |
const DetailInput kBillingInputs[] = { |
- { 3, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME }, |
+ { 3, NAME_BILLING_FULL, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME) }, |
{ 4, ADDRESS_BILLING_LINE1, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1) }, |
{ 5, ADDRESS_BILLING_LINE2, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2) }, |
{ 6, ADDRESS_BILLING_CITY, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, |
- // TODO(estade): state placeholder should depend on locale. |
- { 7, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY) }, |
+ { 7, ADDRESS_BILLING_STATE, |
+ GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_STATE) }, |
{ 7, ADDRESS_BILLING_ZIP, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, |
- // We don't allow the user to change the country: http://crbug.com/247518 |
Evan Stade
2013/12/02 17:57:33
leave this comment
Dan Beam
2013/12/02 22:37:54
Done.
|
- { -1, ADDRESS_BILLING_COUNTRY, 0 }, |
- { 9, PHONE_BILLING_WHOLE_NUMBER, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE) }, |
+ { -1, ADDRESS_BILLING_COUNTRY, base::string16() }, |
+ }; |
+ |
+ const DetailInput kBillingPhoneInputs[] = { |
+ { 19, PHONE_BILLING_WHOLE_NUMBER, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER) }, |
}; |
const DetailInput kEmailInputs[] = { |
- { 10, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, |
+ { 20, EMAIL_ADDRESS, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL) }, |
}; |
+ const int kShippingInputsStartRow = 21; |
const DetailInput kShippingInputs[] = { |
- { 11, NAME_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME }, |
- { 12, ADDRESS_HOME_LINE1, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, |
- { 13, ADDRESS_HOME_LINE2, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, |
- { 14, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, |
- { 15, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, |
- { 15, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, |
- { -1, ADDRESS_HOME_COUNTRY, 0 }, |
- { 17, PHONE_HOME_WHOLE_NUMBER, |
- IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, |
+ { 21, NAME_FULL, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME) }, |
+ { 22, ADDRESS_HOME_LINE1, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1) }, |
+ { 23, ADDRESS_HOME_LINE2, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2) }, |
+ { 24, ADDRESS_HOME_CITY, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY) }, |
+ { 25, ADDRESS_HOME_STATE, |
+ GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_STATE) }, |
+ { 25, ADDRESS_HOME_ZIP, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE) }, |
+ { -1, ADDRESS_HOME_COUNTRY, base::string16() }, |
+ }; |
+ |
+ const DetailInput kShippingPhoneInputs[] = { |
Evan Stade
2013/12/02 17:57:33
Might as well just have one phone input struct arr
Dan Beam
2013/12/02 22:37:54
the ServerFieldType differs
|
+ { 37, PHONE_HOME_WHOLE_NUMBER, |
+ GetStringUTF16(IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER) }, |
}; |
switch (dialog_section) { |
@@ -123,17 +146,42 @@ void BuildInputsForSection(DialogSection dialog_section, |
break; |
case SECTION_BILLING: |
- BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); |
+ if (i18ninput::IsI18nAddressInputEnabled()) { |
+ i18ninput::BuildI18nInputs(i18ninput::ADDRESS_TYPE_BILLING, |
+ country_region, |
+ kBillingInputsStartRow, |
+ inputs); |
+ } else { |
+ BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); |
+ } |
+ BuildInputs(kBillingPhoneInputs, arraysize(kBillingPhoneInputs), inputs); |
BuildInputs(kEmailInputs, arraysize(kEmailInputs), inputs); |
break; |
case SECTION_CC_BILLING: |
BuildInputs(kCCInputs, arraysize(kCCInputs), inputs); |
- BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); |
+ if (i18ninput::IsI18nAddressInputEnabled()) { |
+ i18ninput::BuildI18nInputs(i18ninput::ADDRESS_TYPE_BILLING, |
+ country_region, |
+ kBillingInputsStartRow, |
+ inputs); |
+ } else { |
+ BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); |
+ } |
+ BuildInputs(kBillingPhoneInputs, arraysize(kBillingPhoneInputs), inputs); |
break; |
case SECTION_SHIPPING: |
- BuildInputs(kShippingInputs, arraysize(kShippingInputs), inputs); |
+ if (i18ninput::IsI18nAddressInputEnabled()) { |
+ i18ninput::BuildI18nInputs(i18ninput::ADDRESS_TYPE_SHIPPING, |
+ country_region, |
+ kShippingInputsStartRow, |
+ inputs); |
+ } else { |
+ BuildInputs(kShippingInputs, arraysize(kShippingInputs), inputs); |
+ } |
+ BuildInputs( |
+ kShippingPhoneInputs, arraysize(kShippingPhoneInputs), inputs); |
break; |
} |
} |
@@ -178,13 +226,13 @@ AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( |
return AutofillMetrics::NUM_DIALOG_UI_EVENTS; |
} |
-string16 GetHardcodedValueForType(ServerFieldType type) { |
+base::string16 GetInitialValueForType(ServerFieldType type, |
+ const std::string& country_code) { |
if (AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY) { |
- AutofillCountry country("US", g_browser_process->GetApplicationLocale()); |
- return country.name(); |
+ const std::string& ui_locale = g_browser_process->GetApplicationLocale(); |
+ return AutofillCountry(country_code, ui_locale).name(); |
} |
- |
- return string16(); |
+ return base::string16(); |
} |
} // namespace common |