Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
index 188f72c2ed56d1f8e52fccd8a70cb138e15ff676..ddfde269f67f93f17371f305ab6e2ed0b99d5146 100644 |
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc |
@@ -697,7 +697,9 @@ void AutofillDialogControllerImpl::Show() { |
country_code = model->GetDefaultCountryCode(); |
DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
- common::BuildInputsForSection(section, country_code, inputs); |
+ common::BuildInputsForSection( |
+ section, country_code, inputs, |
+ MutableAddressLanguageCodeForSection(section)); |
} |
// Test whether we need to show the shipping section. If filling that section |
@@ -1851,6 +1853,7 @@ ValidityMessages AutofillDialogControllerImpl::InputsAreValid( |
AddressData address_data; |
i18ninput::CreateAddressData(base::Bind(&GetInfoFromProfile, profile), |
&address_data); |
+ address_data.language_code = AddressLanguageCodeForSection(section); |
AddressProblems problems; |
status = GetValidator()->ValidateAddress(address_data, |
@@ -3057,7 +3060,8 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
DetailInputs inputs; |
std::string country_code = CountryCodeForSection(section); |
- common::BuildInputsForSection(section, country_code, &inputs); |
+ common::BuildInputsForSection(section, country_code, &inputs, |
+ MutableAddressLanguageCodeForSection(section)); |
std::vector<ServerFieldType> types = common::TypesFromInputs(inputs); |
scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
@@ -3111,6 +3115,7 @@ void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
} else { |
AutofillProfile profile; |
FillFormGroupFromOutputs(output, &profile); |
+ profile.set_language_code(AddressLanguageCodeForSection(section)); |
if (ShouldSaveDetailsLocally()) { |
profile.set_origin(RulesAreLoaded(section) ? |
@@ -3259,6 +3264,7 @@ void AutofillDialogControllerImpl::GetI18nValidatorSuggestions( |
AddressData user_input; |
i18ninput::CreateAddressData( |
base::Bind(&GetInfoFromProfile, profile), &user_input); |
+ user_input.language_code = AddressLanguageCodeForSection(section); |
static const size_t kSuggestionsLimit = 10; |
AddressValidator::Status status = GetValidator()->GetSuggestions( |
@@ -3296,6 +3302,24 @@ DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( |
return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
} |
+std::string* AutofillDialogControllerImpl::MutableAddressLanguageCodeForSection( |
+ DialogSection section) { |
+ switch (section) { |
+ case SECTION_BILLING: |
+ return &billing_address_language_code_; |
+ case SECTION_SHIPPING: |
+ return &shipping_address_language_code_; |
+ default: |
Ilya Sherman
2014/03/29 01:24:42
please explicitly list all SECTION_'s rather than
please use gerrit instead
2014/04/02 21:54:52
Done.
|
+ return NULL; |
+ } |
+} |
+ |
+std::string AutofillDialogControllerImpl::AddressLanguageCodeForSection( |
+ DialogSection section) { |
+ std::string* language_code = MutableAddressLanguageCodeForSection(section); |
+ return language_code != NULL ? *language_code : std::string(); |
+} |
+ |
std::vector<ServerFieldType> AutofillDialogControllerImpl:: |
RequestedTypesForSection(DialogSection section) const { |
return common::TypesFromInputs(RequestedFieldsForSection(section)); |
@@ -3341,7 +3365,8 @@ bool AutofillDialogControllerImpl::RebuildInputsForCountry( |
DetailInputs* inputs = MutableRequestedFieldsForSection(section); |
inputs->clear(); |
- common::BuildInputsForSection(section, country_code, inputs); |
+ common::BuildInputsForSection(section, country_code, inputs, |
+ MutableAddressLanguageCodeForSection(section)); |
return true; |
} |
@@ -3599,6 +3624,8 @@ scoped_ptr<wallet::Address>AutofillDialogControllerImpl:: |
AutofillProfile profile; |
FillFormGroupFromOutputs(output, &profile); |
+ profile.set_language_code( |
+ AddressLanguageCodeForSection(SECTION_SHIPPING)); |
CanonicalizeState(validator_.get(), &profile); |
return scoped_ptr<wallet::Address>(new wallet::Address(profile)); |
@@ -3919,6 +3946,8 @@ void AutofillDialogControllerImpl::MaybeShowCreditCardBubble() { |
view_->GetUserInput(SECTION_BILLING, &outputs); |
billing_profile.reset(new AutofillProfile); |
FillFormGroupFromOutputs(outputs, billing_profile.get()); |
+ billing_profile->set_language_code( |
+ AddressLanguageCodeForSection(SECTION_BILLING)); |
} else { |
// Just snag the currently suggested profile. |
std::string item_key = SuggestionsMenuModelForSection(SECTION_BILLING)-> |