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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 212873003: Store the language code for the address in autofill profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Single line Created 6 years, 8 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/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..63e321343b490dae79571987225b6ea2e7bbee07 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,27 @@ DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
}
+std::string* AutofillDialogControllerImpl::MutableAddressLanguageCodeForSection(
+ DialogSection section) {
+ switch (section) {
+ case SECTION_BILLING:
+ case SECTION_CC_BILLING:
+ return &billing_address_language_code_;
+ case SECTION_SHIPPING:
+ return &shipping_address_language_code_;
+ case SECTION_CC:
+ return NULL;
+ }
+ NOTREACHED();
+ 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 +3368,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 +3627,8 @@ scoped_ptr<wallet::Address>AutofillDialogControllerImpl::
AutofillProfile profile;
FillFormGroupFromOutputs(output, &profile);
+ profile.set_language_code(
+ AddressLanguageCodeForSection(SECTION_SHIPPING));
Evan Stade 2014/04/10 00:58:49 use shipping_langauge_code_ directly
please use gerrit instead 2014/04/10 20:39:45 Good point.
CanonicalizeState(validator_.get(), &profile);
return scoped_ptr<wallet::Address>(new wallet::Address(profile));
@@ -3919,6 +3949,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));
Evan Stade 2014/04/10 00:58:49 ditto
please use gerrit instead 2014/04/10 20:39:45 Done.
} else {
// Just snag the currently suggested profile.
std::string item_key = SuggestionsMenuModelForSection(SECTION_BILLING)->

Powered by Google App Engine
This is Rietveld 408576698