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

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

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 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 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // access checks. 597 // access checks.
598 const GURL& current_url = web_contents()->GetLastCommittedURL(); 598 const GURL& current_url = web_contents()->GetLastCommittedURL();
599 invoked_from_same_origin_ = 599 invoked_from_same_origin_ =
600 current_url.GetOrigin() == source_url_.GetOrigin(); 600 current_url.GetOrigin() == source_url_.GetOrigin();
601 601
602 if (!invoked_from_same_origin_) { 602 if (!invoked_from_same_origin_) {
603 GetMetricLogger().LogDialogSecurityMetric( 603 GetMetricLogger().LogDialogSecurityMetric(
604 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME); 604 AutofillMetrics::SECURITY_METRIC_CROSS_ORIGIN_FRAME);
605 } 605 }
606 606
607 // TODO(dbeam): use GetManager()->GetDefaultCountryCodeForNewAddress() 607 account_chooser_model_.reset(
608 // instead when the country combobox is visible. http://crbug.com/331544 608 new AccountChooserModel(this,
609 std::string country_code = "US"; 609 profile_,
610 common::BuildInputsForSection(SECTION_CC, 610 !ShouldShowAccountChooser(),
611 country_code, 611 metric_logger_));
612 &requested_cc_fields_); 612
613 common::BuildInputsForSection(SECTION_BILLING, 613 // TODO(dbeam): does SECTION_CC need to be internationalized?
614 country_code, 614 common::BuildInputsForSection(SECTION_CC, "US", &requested_cc_fields_);
615 &requested_billing_fields_); 615 OnCountryComboboxModelChanged(shipping_country_combobox_model_);
616 common::BuildInputsForSection(SECTION_CC_BILLING, 616 OnCountryComboboxModelChanged(billing_country_combobox_model_);
617 country_code,
618 &requested_cc_billing_fields_);
619 common::BuildInputsForSection(SECTION_SHIPPING,
620 country_code,
621 &requested_shipping_fields_);
622 617
623 // Test whether we need to show the shipping section. If filling that section 618 // Test whether we need to show the shipping section. If filling that section
624 // would be a no-op, don't show it. 619 // would be a no-op, don't show it.
625 const DetailInputs& inputs = RequestedFieldsForSection(SECTION_SHIPPING); 620 const DetailInputs& inputs = RequestedFieldsForSection(SECTION_SHIPPING);
626 cares_about_shipping_ = EmptyDataModelWrapper().FillFormStructure( 621 cares_about_shipping_ = EmptyDataModelWrapper().FillFormStructure(
627 inputs, 622 inputs,
628 base::Bind(common::DetailInputMatchesField, SECTION_SHIPPING), 623 base::Bind(common::DetailInputMatchesField, SECTION_SHIPPING),
629 &form_structure_); 624 &form_structure_);
630 625
631 account_chooser_model_.reset(
632 new AccountChooserModel(this,
633 profile_,
634 !ShouldShowAccountChooser(),
635 metric_logger_));
636
637 if (account_chooser_model_->WalletIsSelected()) 626 if (account_chooser_model_->WalletIsSelected())
638 FetchWalletCookie(); 627 FetchWalletCookie();
639 628
640 // TODO(estade): don't show the dialog if the site didn't specify the right 629 // TODO(estade): don't show the dialog if the site didn't specify the right
641 // fields. First we must figure out what the "right" fields are. 630 // fields. First we must figure out what the "right" fields are.
642 SuggestionsUpdated(); 631 SuggestionsUpdated();
643 SubmitButtonDelayBegin(); 632 SubmitButtonDelayBegin();
644 view_.reset(CreateView()); 633 view_.reset(CreateView());
645 view_->Show(); 634 view_->Show();
646 GetManager()->AddObserver(this); 635 GetManager()->AddObserver(this);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 size_t link_start = offsets[i] + base_offset; 1083 size_t link_start = offsets[i] + base_offset;
1095 legal_document_link_ranges_.push_back(gfx::Range( 1084 legal_document_link_ranges_.push_back(gfx::Range(
1096 link_start, link_start + documents[i]->display_name().size())); 1085 link_start, link_start + documents[i]->display_name().size()));
1097 } 1086 }
1098 legal_documents_text_ = text; 1087 legal_documents_text_ = text;
1099 } 1088 }
1100 1089
1101 void AutofillDialogControllerImpl::ResetSectionInput(DialogSection section) { 1090 void AutofillDialogControllerImpl::ResetSectionInput(DialogSection section) {
1102 SetEditingExistingData(section, false); 1091 SetEditingExistingData(section, false);
1103 1092
1093 if (i18ninput::Enabled()) {
1094 if (section == SECTION_SHIPPING) {
1095 shipping_country_combobox_model_.SelectDefaultIndex();
1096 OnCountryComboboxModelChanged(shipping_country_combobox_model_);
1097 } else if (section == SECTION_BILLING || section == SECTION_CC_BILLING) {
1098 billing_country_combobox_model_.SelectDefaultIndex();
1099 OnCountryComboboxModelChanged(billing_country_combobox_model_);
1100 }
1101 }
1102
1104 DetailInputs* inputs = MutableRequestedFieldsForSection(section); 1103 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
1105 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) { 1104 for (DetailInputs::iterator it = inputs->begin(); it != inputs->end(); ++it) {
1106 it->initial_value = common::GetHardcodedValueForType(it->type); 1105 it->initial_value = common::GetHardcodedValueForType(it->type);
1107 } 1106 }
1108 } 1107 }
1109 1108
1110 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion( 1109 void AutofillDialogControllerImpl::ShowEditUiIfBadSuggestion(
1111 DialogSection section) { 1110 DialogSection section) {
1112 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so 1111 // |CreateWrapper()| returns an empty wrapper if |IsEditingExistingData()|, so
1113 // get the wrapper before this potentially happens below. 1112 // get the wrapper before this potentially happens below.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 1296
1298 ui::ComboboxModel* AutofillDialogControllerImpl::ComboboxModelForAutofillType( 1297 ui::ComboboxModel* AutofillDialogControllerImpl::ComboboxModelForAutofillType(
1299 ServerFieldType type) { 1298 ServerFieldType type) {
1300 switch (type) { 1299 switch (type) {
1301 case CREDIT_CARD_EXP_MONTH: 1300 case CREDIT_CARD_EXP_MONTH:
1302 return &cc_exp_month_combobox_model_; 1301 return &cc_exp_month_combobox_model_;
1303 1302
1304 case CREDIT_CARD_EXP_4_DIGIT_YEAR: 1303 case CREDIT_CARD_EXP_4_DIGIT_YEAR:
1305 return &cc_exp_year_combobox_model_; 1304 return &cc_exp_year_combobox_model_;
1306 1305
1306 case ADDRESS_BILLING_COUNTRY:
1307 return &billing_country_combobox_model_;
1308
1307 case ADDRESS_HOME_COUNTRY: 1309 case ADDRESS_HOME_COUNTRY:
1308 case ADDRESS_BILLING_COUNTRY: 1310 return &shipping_country_combobox_model_;
1309 return &country_combobox_model_;
1310 1311
1311 default: 1312 default:
1312 return NULL; 1313 return NULL;
1313 } 1314 }
1314 } 1315 }
1315 1316
1316 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection( 1317 ui::MenuModel* AutofillDialogControllerImpl::MenuModelForSection(
1317 DialogSection section) { 1318 DialogSection section) {
1318 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section); 1319 SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
1319 // The shipping section menu is special. It will always show because there is 1320 // The shipping section menu is special. It will always show because there is
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 } 1694 }
1694 break; 1695 break;
1695 1696
1696 case ADDRESS_HOME_LINE1: 1697 case ADDRESS_HOME_LINE1:
1697 break; 1698 break;
1698 1699
1699 case ADDRESS_HOME_LINE2: 1700 case ADDRESS_HOME_LINE2:
1700 return base::string16(); // Line 2 is optional - always valid. 1701 return base::string16(); // Line 2 is optional - always valid.
1701 1702
1702 case ADDRESS_HOME_CITY: 1703 case ADDRESS_HOME_CITY:
1704 case ADDRESS_HOME_DEPENDENT_LOCALITY:
1703 case ADDRESS_HOME_COUNTRY: 1705 case ADDRESS_HOME_COUNTRY:
1704 break; 1706 break;
1705 1707
1706 case ADDRESS_HOME_STATE: 1708 case ADDRESS_HOME_STATE:
1707 if (!value.empty() && !autofill::IsValidState(value)) { 1709 if (!value.empty() && !autofill::IsValidState(value) &&
1710 CountryCodeForSection(section) == "US") {
1708 return l10n_util::GetStringUTF16( 1711 return l10n_util::GetStringUTF16(
1709 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION); 1712 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_REGION);
1710 } 1713 }
1711 break; 1714 break;
1712 1715
1713 case ADDRESS_HOME_ZIP: 1716 case ADDRESS_HOME_ZIP:
1714 if (!value.empty() && !autofill::IsValidZip(value)) { 1717 if (!value.empty() && !autofill::IsValidZip(value) &&
1718 CountryCodeForSection(section) == "US") {
1715 return l10n_util::GetStringUTF16( 1719 return l10n_util::GetStringUTF16(
1716 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE); 1720 IDS_AUTOFILL_DIALOG_VALIDATION_INVALID_ZIP_CODE);
1717 } 1721 }
1718 break; 1722 break;
1719 1723
1724 case ADDRESS_HOME_SORTING_CODE:
1725 break;
1726
1720 case NAME_FULL: 1727 case NAME_FULL:
1721 // Wallet requires a first and last billing name. 1728 // Wallet requires a first and last billing name.
1722 if (section == SECTION_CC_BILLING && !value.empty() && 1729 if (section == SECTION_CC_BILLING && !value.empty() &&
1723 !IsCardHolderNameValidForWallet(value)) { 1730 !IsCardHolderNameValidForWallet(value)) {
1724 DCHECK(IsPayingWithWallet()); 1731 DCHECK(IsPayingWithWallet());
1725 return l10n_util::GetStringUTF16( 1732 return l10n_util::GetStringUTF16(
1726 IDS_AUTOFILL_DIALOG_VALIDATION_WALLET_REQUIRES_TWO_NAMES); 1733 IDS_AUTOFILL_DIALOG_VALIDATION_WALLET_REQUIRES_TWO_NAMES);
1727 } 1734 }
1728 break; 1735 break;
1729 1736
(...skipping 22 matching lines...) Expand all
1752 for (FieldValueMap::const_iterator iter = inputs.begin(); 1759 for (FieldValueMap::const_iterator iter = inputs.begin();
1753 iter != inputs.end(); ++iter) { 1760 iter != inputs.end(); ++iter) {
1754 const ServerFieldType type = iter->first; 1761 const ServerFieldType type = iter->first;
1755 1762
1756 base::string16 text = InputValidityMessage(section, type, iter->second); 1763 base::string16 text = InputValidityMessage(section, type, iter->second);
1757 1764
1758 // Skip empty/unchanged fields in edit mode. Ignore country code as it 1765 // Skip empty/unchanged fields in edit mode. Ignore country code as it
1759 // always has a value. If the individual field does not have validation 1766 // always has a value. If the individual field does not have validation
1760 // errors, assume it to be valid unless later proven otherwise. 1767 // errors, assume it to be valid unless later proven otherwise.
1761 bool sure = InputWasEdited(type, iter->second) || 1768 bool sure = InputWasEdited(type, iter->second) ||
1762 ComboboxModelForAutofillType(type) == &country_combobox_model_; 1769 IsCountryComboboxModel(ComboboxModelForAutofillType(type));
1763 1770
1764 // Consider only individually valid fields for inter-field validation. 1771 // Consider only individually valid fields for inter-field validation.
1765 if (text.empty()) { 1772 if (text.empty()) {
1766 field_values[type] = iter->second; 1773 field_values[type] = iter->second;
1767 // If the field is valid but can be invalidated by inter-field validation, 1774 // If the field is valid but can be invalidated by inter-field validation,
1768 // assume it to be unsure. 1775 // assume it to be unsure.
1769 if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR || 1776 if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
1770 type == CREDIT_CARD_EXP_MONTH || 1777 type == CREDIT_CARD_EXP_MONTH ||
1771 type == CREDIT_CARD_VERIFICATION_CODE || 1778 type == CREDIT_CARD_VERIFICATION_CODE ||
1772 type == PHONE_HOME_WHOLE_NUMBER || 1779 type == PHONE_HOME_WHOLE_NUMBER ||
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 content_bounds, 1922 content_bounds,
1916 base::i18n::IsRTL() ? 1923 base::i18n::IsRTL() ?
1917 base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT); 1924 base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT);
1918 popup_controller_->set_hide_on_outside_click(true); 1925 popup_controller_->set_hide_on_outside_click(true);
1919 popup_controller_->Show(popup_values, 1926 popup_controller_->Show(popup_values,
1920 popup_labels, 1927 popup_labels,
1921 popup_icons, 1928 popup_icons,
1922 popup_ids); 1929 popup_ids);
1923 } 1930 }
1924 1931
1932 void AutofillDialogControllerImpl::ComboboxItemSelected(ServerFieldType type,
1933 int index) {
1934 if (!IsCountryComboboxModel(ComboboxModelForAutofillType(type)))
1935 return;
1936
1937 ScopedViewUpdates updates(view_.get());
1938
1939 if (type == ADDRESS_BILLING_COUNTRY) {
1940 billing_country_combobox_model_.SelectIndex(index);
1941 OnCountryComboboxModelChanged(billing_country_combobox_model_);
1942 UpdateSection(IsPayingWithWallet() ? SECTION_CC_BILLING : SECTION_BILLING);
1943 } else if (type == ADDRESS_HOME_COUNTRY) {
1944 shipping_country_combobox_model_.SelectIndex(index);
1945 OnCountryComboboxModelChanged(shipping_country_combobox_model_);
1946 UpdateSection(SECTION_SHIPPING);
1947 }
1948 }
1949
1925 void AutofillDialogControllerImpl::FocusMoved() { 1950 void AutofillDialogControllerImpl::FocusMoved() {
1926 HidePopup(); 1951 HidePopup();
1927 } 1952 }
1928 1953
1929 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const { 1954 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const {
1930 return popup_input_type_ == UNKNOWN_TYPE; 1955 return popup_input_type_ == UNKNOWN_TYPE;
1931 } 1956 }
1932 1957
1933 void AutofillDialogControllerImpl::ViewClosed() { 1958 void AutofillDialogControllerImpl::ViewClosed() {
1934 GetManager()->RemoveObserver(this); 1959 GetManager()->RemoveObserver(this);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 GetManager()->GetCreditCardByGUID(pair.first))); 2179 GetManager()->GetCreditCardByGUID(pair.first)));
2155 } else { 2180 } else {
2156 wrapper.reset(new AutofillProfileWrapper( 2181 wrapper.reset(new AutofillProfileWrapper(
2157 GetManager()->GetProfileByGUID(pair.first), 2182 GetManager()->GetProfileByGUID(pair.first),
2158 AutofillType(popup_input_type_), 2183 AutofillType(popup_input_type_),
2159 pair.second)); 2184 pair.second));
2160 } 2185 }
2161 2186
2162 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { 2187 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
2163 DialogSection section = static_cast<DialogSection>(i); 2188 DialogSection section = static_cast<DialogSection>(i);
2189
2190 if (i18ninput::Enabled()) {
2191 if ((section == SECTION_BILLING || section == SECTION_CC_BILLING) &&
2192 billing_country_combobox_model_.IsDefaultIndexSelected()) {
2193 base::string16 country_name =
2194 wrapper->GetInfo(AutofillType(ADDRESS_BILLING_COUNTRY));
2195 if (!country_name.empty()) {
2196 billing_country_combobox_model_.SelectCountry(
2197 AutofillCountry::GetCountryCode(
2198 country_name, g_browser_process->GetApplicationLocale()));
2199 OnCountryComboboxModelChanged(billing_country_combobox_model_);
2200 UpdateSection(section);
2201 }
2202 } else if (section == SECTION_SHIPPING &&
2203 shipping_country_combobox_model_.IsDefaultIndexSelected()) {
2204 base::string16 country_name =
2205 wrapper->GetInfo(AutofillType(ADDRESS_HOME_COUNTRY));
2206 if (!country_name.empty()) {
2207 shipping_country_combobox_model_.SelectCountry(
2208 AutofillCountry::GetCountryCode(
2209 country_name, g_browser_process->GetApplicationLocale()));
2210 OnCountryComboboxModelChanged(shipping_country_combobox_model_);
2211 UpdateSection(section);
2212 }
2213 }
2214 }
2215
2164 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); 2216 wrapper->FillInputs(MutableRequestedFieldsForSection(section));
2165 view_->FillSection(section, popup_input_type_); 2217 view_->FillSection(section, popup_input_type_);
2166 } 2218 }
2167 2219
2168 GetMetricLogger().LogDialogPopupEvent( 2220 GetMetricLogger().LogDialogPopupEvent(
2169 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); 2221 AutofillMetrics::DIALOG_POPUP_FORM_FILLED);
2170 2222
2171 // TODO(estade): not sure why it's necessary to do this explicitly. 2223 // TODO(estade): not sure why it's necessary to do this explicitly.
2172 HidePopup(); 2224 HidePopup();
2173 } 2225 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 2567 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
2516 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 2568 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
2517 form_structure_(form_structure), 2569 form_structure_(form_structure),
2518 invoked_from_same_origin_(true), 2570 invoked_from_same_origin_(true),
2519 source_url_(source_url), 2571 source_url_(source_url),
2520 callback_(callback), 2572 callback_(callback),
2521 wallet_client_(profile_->GetRequestContext(), this, source_url), 2573 wallet_client_(profile_->GetRequestContext(), this, source_url),
2522 wallet_items_requested_(false), 2574 wallet_items_requested_(false),
2523 handling_use_wallet_link_click_(false), 2575 handling_use_wallet_link_click_(false),
2524 passive_failed_(false), 2576 passive_failed_(false),
2525 country_combobox_model_(*GetManager()), 2577 billing_country_combobox_model_(*GetManager()),
2578 shipping_country_combobox_model_(*GetManager()),
2526 suggested_cc_(this), 2579 suggested_cc_(this),
2527 suggested_billing_(this), 2580 suggested_billing_(this),
2528 suggested_cc_billing_(this), 2581 suggested_cc_billing_(this),
2529 suggested_shipping_(this), 2582 suggested_shipping_(this),
2530 cares_about_shipping_(true), 2583 cares_about_shipping_(true),
2531 popup_input_type_(UNKNOWN_TYPE), 2584 popup_input_type_(UNKNOWN_TYPE),
2532 weak_ptr_factory_(this), 2585 weak_ptr_factory_(this),
2533 waiting_for_explicit_sign_in_response_(false), 2586 waiting_for_explicit_sign_in_response_(false),
2534 has_accepted_legal_documents_(false), 2587 has_accepted_legal_documents_(false),
2535 is_submitting_(false), 2588 is_submitting_(false),
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 2891
2839 UpdateForErrors(); 2892 UpdateForErrors();
2840 } 2893 }
2841 2894
2842 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( 2895 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator(
2843 DialogSection section, 2896 DialogSection section,
2844 const InputFieldComparator& compare) { 2897 const InputFieldComparator& compare) {
2845 if (!SectionIsActive(section)) 2898 if (!SectionIsActive(section))
2846 return; 2899 return;
2847 2900
2848 const DetailInputs& inputs = RequestedFieldsForSection(section); 2901 DetailInputs inputs;
2902 std::string country_code = CountryCodeForSection(section);
2903 common::BuildInputsForSection(section, country_code, &inputs);
2904
2849 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); 2905 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
2850 if (wrapper) { 2906 if (wrapper) {
2851 // Only fill in data that is associated with this section. 2907 // Only fill in data that is associated with this section.
2852 const DetailInputs& inputs = RequestedFieldsForSection(section);
2853 wrapper->FillFormStructure(inputs, compare, &form_structure_); 2908 wrapper->FillFormStructure(inputs, compare, &form_structure_);
2854 2909
2855 // CVC needs special-casing because the CreditCard class doesn't store or 2910 // CVC needs special-casing because the CreditCard class doesn't store or
2856 // handle them. This isn't necessary when filling the combined CC and 2911 // handle them. This isn't necessary when filling the combined CC and
2857 // billing section as CVC comes from |full_wallet_| in this case. 2912 // billing section as CVC comes from |full_wallet_| in this case.
2858 if (section == SECTION_CC) 2913 if (section == SECTION_CC)
2859 SetOutputForFieldsOfType(CREDIT_CARD_VERIFICATION_CODE, view_->GetCvc()); 2914 SetOutputForFieldsOfType(CREDIT_CARD_VERIFICATION_CODE, view_->GetCvc());
2860 2915
2861 // When filling from Wallet data, use the email address associated with the 2916 // When filling from Wallet data, use the email address associated with the
2862 // account. There is no other email address stored as part of a Wallet 2917 // account. There is no other email address stored as part of a Wallet
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 3040
2986 DCHECK_EQ(&model, &suggested_shipping_); 3041 DCHECK_EQ(&model, &suggested_shipping_);
2987 return SECTION_SHIPPING; 3042 return SECTION_SHIPPING;
2988 } 3043 }
2989 3044
2990 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( 3045 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection(
2991 DialogSection section) { 3046 DialogSection section) {
2992 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); 3047 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section));
2993 } 3048 }
2994 3049
3050 bool AutofillDialogControllerImpl::IsCountryComboboxModel(
3051 const ui::ComboboxModel* model) const {
3052 return model == &billing_country_combobox_model_ ||
3053 model == &shipping_country_combobox_model_;
3054 }
3055
3056 void AutofillDialogControllerImpl::OnCountryComboboxModelChanged(
3057 const CountryComboboxModel& model) {
3058 const FieldValueMap snapshot = TakeUserInputSnapshot();
3059
3060 const bool is_shipping = &model == &shipping_country_combobox_model_;
3061 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) {
3062 DialogSection section = static_cast<DialogSection>(i);
3063
3064 if ((is_shipping && section != SECTION_SHIPPING) ||
3065 (!is_shipping && (section != SECTION_BILLING &&
3066 section != SECTION_CC_BILLING))) {
3067 continue;
3068 }
3069
3070 DetailInputs* inputs = MutableRequestedFieldsForSection(section);
3071 inputs->clear();
3072
3073 std::string country_code = CountryCodeForSection(section);
3074 common::BuildInputsForSection(section, country_code, inputs);
3075 }
3076
3077 RestoreUserInputFromSnapshot(snapshot);
3078 }
3079
3080 std::string AutofillDialogControllerImpl::CountryCodeForSection(
3081 DialogSection section) {
3082 if (section != SECTION_CC) {
3083 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section);
3084 if (wrapper) {
3085 return AutofillCountry::GetCountryCode(
3086 wrapper->GetInfo(AutofillType(section == SECTION_SHIPPING ?
3087 ADDRESS_HOME_COUNTRY : ADDRESS_BILLING_COUNTRY)),
3088 g_browser_process->GetApplicationLocale());
3089 }
3090 }
3091
3092 if (section == SECTION_BILLING || section == SECTION_CC_BILLING)
3093 return billing_country_combobox_model_.GetSelectedCountryCode();
3094
3095 if (section == SECTION_SHIPPING)
3096 return shipping_country_combobox_model_.GetSelectedCountryCode();
3097
3098 return "US";
3099 }
3100
2995 void AutofillDialogControllerImpl::HidePopup() { 3101 void AutofillDialogControllerImpl::HidePopup() {
2996 if (popup_controller_.get()) 3102 if (popup_controller_.get())
2997 popup_controller_->Hide(); 3103 popup_controller_->Hide();
2998 popup_input_type_ = UNKNOWN_TYPE; 3104 popup_input_type_ = UNKNOWN_TYPE;
2999 } 3105 }
3000 3106
3001 void AutofillDialogControllerImpl::SetEditingExistingData( 3107 void AutofillDialogControllerImpl::SetEditingExistingData(
3002 DialogSection section, bool editing) { 3108 DialogSection section, bool editing) {
3003 if (editing) 3109 if (editing)
3004 section_editing_state_.insert(section); 3110 section_editing_state_.insert(section);
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
3534 view_->UpdateButtonStrip(); 3640 view_->UpdateButtonStrip();
3535 } 3641 }
3536 3642
3537 void AutofillDialogControllerImpl::FetchWalletCookie() { 3643 void AutofillDialogControllerImpl::FetchWalletCookie() {
3538 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); 3644 net::URLRequestContextGetter* request_context = profile_->GetRequestContext();
3539 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); 3645 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context));
3540 signin_helper_->StartWalletCookieValueFetch(); 3646 signin_helper_->StartWalletCookieValueFetch();
3541 } 3647 }
3542 3648
3543 } // namespace autofill 3649 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698