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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/rand_util.h" 22 #include "base/rand_util.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "chrome/browser/autofill/personal_data_manager_factory.h" 28 #include "chrome/browser/autofill/personal_data_manager_factory.h"
29 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" 31 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
32 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
32 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 33 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
33 #include "chrome/browser/ui/autofill/data_model_wrapper.h" 34 #include "chrome/browser/ui/autofill/data_model_wrapper.h"
34 #if !defined(OS_ANDROID) 35 #if !defined(OS_ANDROID)
35 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" 36 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
36 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h" 37 #include "chrome/browser/ui/autofill/new_credit_card_bubble_controller.h"
37 #endif 38 #endif
38 #include "chrome/browser/ui/browser.h" 39 #include "chrome/browser/ui/browser.h"
39 #include "chrome/browser/ui/browser_finder.h" 40 #include "chrome/browser/ui/browser_finder.h"
40 #include "chrome/browser/ui/browser_navigator.h" 41 #include "chrome/browser/ui/browser_navigator.h"
41 #include "chrome/browser/ui/browser_window.h" 42 #include "chrome/browser/ui/browser_window.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); 597 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME);
597 } 598 }
598 599
599 // Fail if the author didn't specify autocomplete types. 600 // Fail if the author didn't specify autocomplete types.
600 if (!has_types) { 601 if (!has_types) {
601 callback_.Run(NULL); 602 callback_.Run(NULL);
602 delete this; 603 delete this;
603 return; 604 return;
604 } 605 }
605 606
606 common::BuildInputsForSection(SECTION_CC, 607 const std::string& country_code =
607 &requested_cc_fields_); 608 GetManager()->GetDefaultCountryCodeForNewAddress();
608 common::BuildInputsForSection(SECTION_BILLING, 609 for (size_t section = SECTION_MIN; section <= SECTION_MAX; ++section) {
609 &requested_billing_fields_); 610 SetCountryCodeForSection(static_cast<DialogSection>(section), country_code);
610 common::BuildInputsForSection(SECTION_CC_BILLING, 611 }
611 &requested_cc_billing_fields_);
612 common::BuildInputsForSection(SECTION_SHIPPING,
613 &requested_shipping_fields_);
614 612
615 // Test whether we need to show the shipping section. If filling that section 613 // Test whether we need to show the shipping section. If filling that section
616 // would be a no-op, don't show it. 614 // would be a no-op, don't show it.
617 const DetailInputs& inputs = RequestedFieldsForSection(SECTION_SHIPPING); 615 const DetailInputs& inputs = RequestedFieldsForSection(SECTION_SHIPPING);
618 EmptyDataModelWrapper empty_wrapper; 616 EmptyDataModelWrapper empty_wrapper;
619 cares_about_shipping_ = empty_wrapper.FillFormStructure( 617 cares_about_shipping_ = empty_wrapper.FillFormStructure(
620 inputs, 618 inputs,
621 base::Bind(common::DetailInputMatchesField, SECTION_SHIPPING), 619 base::Bind(common::DetailInputMatchesField, SECTION_SHIPPING),
622 &form_structure_); 620 &form_structure_);
623 621
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 legal_document_link_ranges_.push_back(gfx::Range( 1084 legal_document_link_ranges_.push_back(gfx::Range(
1087 link_start, link_start + documents[i]->display_name().size())); 1085 link_start, link_start + documents[i]->display_name().size()));
1088 } 1086 }
1089 legal_documents_text_ = text; 1087 legal_documents_text_ = text;
1090 } 1088 }
1091 1089
1092 void AutofillDialogControllerImpl::ResetSectionInput(DialogSection section) { 1090 void AutofillDialogControllerImpl::ResetSectionInput(DialogSection section) {
1093 SetEditingExistingData(section, false); 1091 SetEditingExistingData(section, false);
1094 1092
1095 DetailInputs* inputs = MutableRequestedFieldsForSection(section); 1093 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
1094 std::string country_code = GetCountryCodeForSection(section);
1096 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) { 1095 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
1097 it->initial_value = common::GetHardcodedValueForType(it->type); 1096 it->initial_value = common::GetInitialValueForType(it->type, country_code);
Evan Stade 2013/12/05 03:09:18 I think it's simpler if you leave this code alone
1098 } 1097 }
1099 } 1098 }
1100 1099
1101 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion( 1100 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion(
1102 DialogSection section) { 1101 DialogSection section) {
1103 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so 1102 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so
1104 // get the wrapper before this potentially happens below. 1103 // get the wrapper before this potentially happens below.
1105 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); 1104 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
1106 1105
1107 // If the chosen item in |model| yields an empty suggestion text, it is 1106 // If the chosen item in |model| yields an empty suggestion text, it is
1108 // invalid. In this case, show the edit UI and highlight invalid fields. 1107 // invalid. In this case, show the edit UI and highlight invalid fields.
1109 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); 1108 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
1110 string16 unused, unused2; 1109 string16 unused, unused2;
1111 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) && 1110 if (IsASuggestionItemKey(model->GetItemKeyForCheckedItem()) &&
1112 !SuggestionTextForSection(section, &unused, &unused2)) { 1111 !SuggestionTextForSection(section, &unused, &unused2)) {
1113 SetEditingExistingData(section, true); 1112 SetEditingExistingData(section, true);
1114 } 1113 }
1115 1114
1116 DetailInputs* inputs = MutableRequestedFieldsForSection(section); 1115 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
1117 if (wrapper && IsEditingExistingData(section)) 1116 if (wrapper && IsEditingExistingData(section))
1118 wrapper->FillInputs(inputs); 1117 wrapper->FillInputs(inputs, GetCountryCodeForSection(section));
1119 } 1118 }
1120 1119
1121 bool AutofillDialogControllerImpl::InputWasEdited(ServerFieldType type, 1120 bool AutofillDialogControllerImpl::InputWasEdited(ServerFieldType type,
1122 const base::string16& value) { 1121 const base::string16& value) {
1123 if (value.empty()) 1122 if (value.empty())
1124 return false; 1123 return false;
1125 1124
1126 // If this is a combobox at the default value, don't preserve it. 1125 // If this is a combobox at the default value, don't preserve it.
1127 ui::ComboboxModel* model = ComboboxModelForAutofillType(type); 1126 ui::ComboboxModel* model = ComboboxModelForAutofillType(type);
1128 if (model && model->GetItemAt(model->GetDefaultIndex()) == value) 1127 if (model && model->GetItemAt(model->GetDefaultIndex()) == value)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 if (snapshot.empty()) 1161 if (snapshot.empty())
1163 return; 1162 return;
1164 1163
1165 FieldMapWrapper wrapper(snapshot); 1164 FieldMapWrapper wrapper(snapshot);
1166 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { 1165 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
1167 DialogSection section = static_cast<DialogSection>(i); 1166 DialogSection section = static_cast<DialogSection>(i);
1168 if (!SectionIsActive(section)) 1167 if (!SectionIsActive(section))
1169 continue; 1168 continue;
1170 1169
1171 DetailInputs* inputs = MutableRequestedFieldsForSection(section); 1170 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
1172 wrapper.FillInputs(inputs); 1171 wrapper.FillInputs(inputs, GetCountryCodeForSection(section));
1173 1172
1174 for (size_t i = 0; i < inputs->size(); ++i) { 1173 for (size_t i = 0; i < inputs->size(); ++i) {
1175 if (InputWasEdited((*inputs)[i].type, (*inputs)[i].initial_value)) { 1174 if (InputWasEdited((*inputs)[i].type, (*inputs)[i].initial_value)) {
1176 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey); 1175 SuggestionsMenuModelForSection(section)->SetCheckedItem(kAddNewItemKey);
1177 break; 1176 break;
1178 } 1177 }
1179 } 1178 }
1180 } 1179 }
1181 } 1180 }
1182 1181
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 } 1683 }
1685 break; 1684 break;
1686 1685
1687 case ADDRESS_HOME_LINE1: 1686 case ADDRESS_HOME_LINE1:
1688 break; 1687 break;
1689 1688
1690 case ADDRESS_HOME_LINE2: 1689 case ADDRESS_HOME_LINE2:
1691 return base::string16(); // Line 2 is optional - always valid. 1690 return base::string16(); // Line 2 is optional - always valid.
1692 1691
1693 case ADDRESS_HOME_CITY: 1692 case ADDRESS_HOME_CITY:
1693 case ADDRESS_HOME_DEPENDENT_LOCALITY:
1694 case ADDRESS_HOME_COUNTRY: 1694 case ADDRESS_HOME_COUNTRY:
1695 break; 1695 break;
1696 1696
1697 case ADDRESS_HOME_STATE: 1697 case ADDRESS_HOME_STATE:
1698 if (!value.empty() && !autofill::IsValidState(value)) { 1698 if (!value.empty() && !autofill::IsValidState(value)) {
1699 return l10n_util::GetStringUTF16( 1699 return l10n_util::GetStringUTF16(
1700 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION); 1700 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION);
1701 } 1701 }
1702 break; 1702 break;
1703 1703
1704 case ADDRESS_HOME_ZIP: 1704 case ADDRESS_HOME_ZIP:
1705 if (!value.empty() && !autofill::IsValidZip(value)) { 1705 if (!value.empty() && !autofill::IsValidZip(value)) {
1706 return l10n_util::GetStringUTF16( 1706 return l10n_util::GetStringUTF16(
1707 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE); 1707 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE);
1708 } 1708 }
1709 break; 1709 break;
1710 1710
1711 case ADDRESS_HOME_SORTING_CODE:
1712 break;
1713
1711 case NAME_FULL: 1714 case NAME_FULL:
1712 // Wallet requires a first and last billing name. 1715 // Wallet requires a first and last billing name.
1713 if (section == SECTION_CC_BILLING && !value.empty() && 1716 if (section == SECTION_CC_BILLING && !value.empty() &&
1714 !IsCardHolderNameValidForWallet(value)) { 1717 !IsCardHolderNameValidForWallet(value)) {
1715 DCHECK(IsPayingWithWallet()); 1718 DCHECK(IsPayingWithWallet());
1716 return l10n_util::GetStringUTF16( 1719 return l10n_util::GetStringUTF16(
1717 IDS_AUTOFILL_DIALOG_VALIDATION_WALLET_REQUIRES_TWO_NAMES); 1720 IDS_AUTOFILL_DIALOG_VALIDATION_WALLET_REQUIRES_TWO_NAMES);
1718 } 1721 }
1719 break; 1722 break;
1720 1723
1724 case COMPANY_NAME:
1725 break;
1726
1721 case PHONE_HOME_WHOLE_NUMBER: // Used in shipping section. 1727 case PHONE_HOME_WHOLE_NUMBER: // Used in shipping section.
1722 break; 1728 break;
1723 1729
1724 case PHONE_BILLING_WHOLE_NUMBER: // Used in billing section. 1730 case PHONE_BILLING_WHOLE_NUMBER: // Used in billing section.
1725 break; 1731 break;
1726 1732
1727 default: 1733 default:
1728 NOTREACHED(); // Trying to validate unknown field. 1734 NOTREACHED(); // Trying to validate unknown field.
1729 break; 1735 break;
1730 } 1736 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 content_bounds, 1922 content_bounds,
1917 base::i18n::IsRTL() ? 1923 base::i18n::IsRTL() ?
1918 base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT); 1924 base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT);
1919 popup_controller_->set_hide_on_outside_click(true); 1925 popup_controller_->set_hide_on_outside_click(true);
1920 popup_controller_->Show(popup_values, 1926 popup_controller_->Show(popup_values,
1921 popup_labels, 1927 popup_labels,
1922 popup_icons, 1928 popup_icons,
1923 popup_ids); 1929 popup_ids);
1924 } 1930 }
1925 1931
1932 void AutofillDialogControllerImpl::ComboboxItemSelected(ServerFieldType type,
1933 int index) {
1934 ui::ComboboxModel* model = ComboboxModelForAutofillType(type);
1935 if (model != &country_combobox_model_ || model->IsItemSeparatorAt(index))
Evan Stade 2013/12/05 03:09:18 are you sure the isitemseparatorat is necessary? s
1936 return;
1937
1938 std::string country_code =
1939 country_combobox_model_.countries()[index]->country_code();
1940 DialogSection section = AutofillType(type).group() == ADDRESS_BILLING ?
1941 IsPayingWithWallet() ? SECTION_CC_BILLING : SECTION_BILLING :
1942 SECTION_SHIPPING;
1943 if (country_code == GetCountryCodeForSection(section))
1944 return;
1945
1946 ScopedViewUpdates updates(view_.get());
1947 const FieldValueMap snapshot = TakeUserInputSnapshot();
1948
1949 SetCountryCodeForSection(section, country_code);
1950
1951 ResetSectionInput(section);
1952 RestoreUserInputFromSnapshot(snapshot);
1953 UpdateSection(section);
1954 }
1955
1926 void AutofillDialogControllerImpl::FocusMoved() { 1956 void AutofillDialogControllerImpl::FocusMoved() {
1927 HidePopup(); 1957 HidePopup();
1928 } 1958 }
1929 1959
1930 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const { 1960 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const {
1931 return !input_showing_popup_; 1961 return !input_showing_popup_;
1932 } 1962 }
1933 1963
1934 void AutofillDialogControllerImpl::ViewClosed() { 1964 void AutofillDialogControllerImpl::ViewClosed() {
1935 GetManager()->RemoveObserver(this); 1965 GetManager()->RemoveObserver(this);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 GetManager()->GetCreditCardByGUID(pair.first))); 2187 GetManager()->GetCreditCardByGUID(pair.first)));
2158 } else { 2188 } else {
2159 wrapper.reset(new AutofillProfileWrapper( 2189 wrapper.reset(new AutofillProfileWrapper(
2160 GetManager()->GetProfileByGUID(pair.first), 2190 GetManager()->GetProfileByGUID(pair.first),
2161 AutofillType(input_showing_popup_->type), 2191 AutofillType(input_showing_popup_->type),
2162 pair.second)); 2192 pair.second));
2163 } 2193 }
2164 2194
2165 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { 2195 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
2166 DialogSection section = static_cast<DialogSection>(i); 2196 DialogSection section = static_cast<DialogSection>(i);
2167 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); 2197 wrapper->FillInputs(MutableRequestedFieldsForSection(section),
2198 GetCountryCodeForSection(section));
2168 view_->FillSection(section, *input_showing_popup_); 2199 view_->FillSection(section, *input_showing_popup_);
2169 } 2200 }
2170 2201
2171 GetMetricLogger().LogDialogPopupEvent( 2202 GetMetricLogger().LogDialogPopupEvent(
2172 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); 2203 AutofillMetrics::DIALOG_POPUP_FORM_FILLED);
2173 2204
2174 // TODO(estade): not sure why it's necessary to do this explicitly. 2205 // TODO(estade): not sure why it's necessary to do this explicitly.
2175 HidePopup(); 2206 HidePopup();
2176 } 2207 }
2177 2208
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 suggested_cc_.AddKeyedItemWithIcon( 2787 suggested_cc_.AddKeyedItemWithIcon(
2757 cards[i]->guid(), 2788 cards[i]->guid(),
2758 cards[i]->Label(), 2789 cards[i]->Label(),
2759 rb.GetImageNamed(CreditCard::IconResourceId(cards[i]->type()))); 2790 rb.GetImageNamed(CreditCard::IconResourceId(cards[i]->type())));
2760 } 2791 }
2761 2792
2762 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); 2793 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles();
2763 std::vector<base::string16> labels; 2794 std::vector<base::string16> labels;
2764 AutofillProfile::CreateDifferentiatingLabels(profiles, &labels); 2795 AutofillProfile::CreateDifferentiatingLabels(profiles, &labels);
2765 DCHECK_EQ(labels.size(), profiles.size()); 2796 DCHECK_EQ(labels.size(), profiles.size());
2766 const std::string app_locale = g_browser_process->GetApplicationLocale();
2767 for (size_t i = 0; i < profiles.size(); ++i) { 2797 for (size_t i = 0; i < profiles.size(); ++i) {
2768 const AutofillProfile& profile = *profiles[i]; 2798 const AutofillProfile& profile = *profiles[i];
2769 if (!HasCompleteAndVerifiedData(profile, requested_shipping_fields_) || 2799 if (!HasCompleteAndVerifiedData(profile, requested_shipping_fields_) ||
2770 HasInvalidAddress(*profiles[i])) { 2800 HasInvalidAddress(*profiles[i])) {
2771 continue; 2801 continue;
2772 } 2802 }
2773 2803
2774 // Don't add variants for addresses: name is part of credit card and we'll 2804 // Don't add variants for addresses: name is part of credit card and we'll
2775 // just ignore email and phone number variants. 2805 // just ignore email and phone number variants.
2776 suggested_shipping_.AddKeyedItem(profile.guid(), labels[i]); 2806 suggested_shipping_.AddKeyedItem(profile.guid(), labels[i]);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 ShowEditUiIfBadSuggestion(section); 2872 ShowEditUiIfBadSuggestion(section);
2843 UpdateSection(section); 2873 UpdateSection(section);
2844 } 2874 }
2845 2875
2846 UpdateForErrors(); 2876 UpdateForErrors();
2847 } 2877 }
2848 2878
2849 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( 2879 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator(
2850 DialogSection section, 2880 DialogSection section,
2851 const InputFieldComparator& compare) { 2881 const InputFieldComparator& compare) {
2852 const DetailInputs& inputs = RequestedFieldsForSection(section);
2853
2854 if (!SectionIsActive(section)) 2882 if (!SectionIsActive(section))
2855 return; 2883 return;
2856 2884
2885 const DetailInputs& inputs = RequestedFieldsForSection(section);
2857 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); 2886 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
2858 if (wrapper) { 2887 if (wrapper) {
2859 // Only fill in data that is associated with this section. 2888 // Only fill in data that is associated with this section.
2860 const DetailInputs& inputs = RequestedFieldsForSection(section); 2889 const DetailInputs& inputs = RequestedFieldsForSection(section);
2861 wrapper->FillFormStructure(inputs, compare, &form_structure_); 2890 wrapper->FillFormStructure(inputs, compare, &form_structure_);
2862 2891
2863 // CVC needs special-casing because the CreditCard class doesn't store or 2892 // CVC needs special-casing because the CreditCard class doesn't store or
2864 // handle them. This isn't necessary when filling the combined CC and 2893 // handle them. This isn't necessary when filling the combined CC and
2865 // billing section as CVC comes from |full_wallet_| in this case. 2894 // billing section as CVC comes from |full_wallet_| in this case.
2866 if (section == SECTION_CC) 2895 if (section == SECTION_CC)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 3022
2994 DCHECK_EQ(&model, &suggested_shipping_); 3023 DCHECK_EQ(&model, &suggested_shipping_);
2995 return SECTION_SHIPPING; 3024 return SECTION_SHIPPING;
2996 } 3025 }
2997 3026
2998 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( 3027 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
2999 DialogSection section) { 3028 DialogSection section) {
3000 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); 3029 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
3001 } 3030 }
3002 3031
3032 std::string AutofillDialogControllerImpl::GetCountryCodeForSection(
3033 DialogSection section) const {
3034 if (section == SECTION_BILLING || section == SECTION_CC_BILLING)
3035 return billing_country_code_;
3036 if (section == SECTION_SHIPPING)
3037 return shipping_country_code_;
3038 return "US";
3039 }
3040
3041 void AutofillDialogControllerImpl::SetCountryCodeForSection(
3042 DialogSection section,
3043 const std::string& country_code) {
3044 if (section == SECTION_BILLING || section == SECTION_CC_BILLING)
3045 billing_country_code_ = country_code;
3046 else if (section == SECTION_SHIPPING)
3047 shipping_country_code_ = country_code;
3048
3049 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
3050 inputs->clear();
3051
3052 common::BuildInputsForSection(section, inputs, country_code);
3053
3054 const std::string& ui_locale = g_browser_process->GetApplicationLocale();
3055 base::string16 country_name = AutofillCountry(country_code, ui_locale).name();
3056 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
3057 if (AutofillType(it->type).GetStorableType() == ADDRESS_HOME_COUNTRY)
3058 it->initial_value = country_name;
3059 }
3060 }
3061
3003 void AutofillDialogControllerImpl::HidePopup() { 3062 void AutofillDialogControllerImpl::HidePopup() {
3004 if (popup_controller_.get()) 3063 if (popup_controller_.get())
3005 popup_controller_->Hide(); 3064 popup_controller_->Hide();
3006 input_showing_popup_ = NULL; 3065 input_showing_popup_ = NULL;
3007 } 3066 }
3008 3067
3009 void AutofillDialogControllerImpl::SetEditingExistingData( 3068 void AutofillDialogControllerImpl::SetEditingExistingData(
3010 DialogSection section, bool editing) { 3069 DialogSection section, bool editing) {
3011 if (editing) 3070 if (editing)
3012 section_editing_state_.insert(section); 3071 section_editing_state_.insert(section);
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 view_->UpdateButtonStrip(); 3600 view_->UpdateButtonStrip();
3542 } 3601 }
3543 3602
3544 void AutofillDialogControllerImpl::FetchWalletCookie() { 3603 void AutofillDialogControllerImpl::FetchWalletCookie() {
3545 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 3604 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
3546 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 3605 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
3547 signin_helper_->StartWalletCookieValueFetch(); 3606 signin_helper_->StartWalletCookieValueFetch();
3548 } 3607 }
3549 3608
3550 } // namespace autofill 3609 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698