OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 } | |
Dan Beam
2014/01/11 04:16:58
note for myself:
SuggestionsUpdated is taking a sn
| |
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 Loading... | |
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 Loading... | |
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 18 matching lines...) Expand all Loading... | |
1748 DialogSection section, | 1755 DialogSection section, |
1749 const FieldValueMap& inputs) { | 1756 const FieldValueMap& inputs) { |
1750 ValidityMessages messages; | 1757 ValidityMessages messages; |
1751 std::map<ServerFieldType, base::string16> field_values; | 1758 std::map<ServerFieldType, base::string16> field_values; |
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 as it always has |
1759 // always has a value. If the individual field does not have validation | 1766 // a value. If the individual field does not have validation errors, assume |
1760 // errors, assume it to be valid unless later proven otherwise. | 1767 // 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 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY; |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1847 return messages; | 1854 return messages; |
1848 } | 1855 } |
1849 | 1856 |
1850 void AutofillDialogControllerImpl::UserEditedOrActivatedInput( | 1857 void AutofillDialogControllerImpl::UserEditedOrActivatedInput( |
1851 DialogSection section, | 1858 DialogSection section, |
1852 ServerFieldType type, | 1859 ServerFieldType type, |
1853 gfx::NativeView parent_view, | 1860 gfx::NativeView parent_view, |
1854 const gfx::Rect& content_bounds, | 1861 const gfx::Rect& content_bounds, |
1855 const base::string16& field_contents, | 1862 const base::string16& field_contents, |
1856 bool was_edit) { | 1863 bool was_edit) { |
1864 ScopedViewUpdates updates(view_.get()); | |
1865 | |
1866 if (type == ADDRESS_BILLING_COUNTRY) { | |
1867 billing_country_combobox_model_.SelectCountry( | |
1868 AutofillCountry::GetCountryCode( | |
1869 field_contents, g_browser_process->GetApplicationLocale())); | |
1870 OnCountryComboboxModelChanged(billing_country_combobox_model_); | |
1871 UpdateSection(IsPayingWithWallet() ? SECTION_CC_BILLING : SECTION_BILLING); | |
1872 } else if (type == ADDRESS_HOME_COUNTRY) { | |
1873 shipping_country_combobox_model_.SelectCountry( | |
1874 AutofillCountry::GetCountryCode( | |
1875 field_contents, g_browser_process->GetApplicationLocale())); | |
1876 OnCountryComboboxModelChanged(shipping_country_combobox_model_); | |
1877 UpdateSection(SECTION_SHIPPING); | |
1878 } | |
1879 | |
1880 // The rest of this method applies only to textfields. If a combobox, bail. | |
1881 if (ComboboxModelForAutofillType(type)) | |
1882 return; | |
1883 | |
1857 // If the field is edited down to empty, don't show a popup. | 1884 // If the field is edited down to empty, don't show a popup. |
1858 if (was_edit && field_contents.empty()) { | 1885 if (was_edit && field_contents.empty()) { |
1859 HidePopup(); | 1886 HidePopup(); |
1860 return; | 1887 return; |
1861 } | 1888 } |
1862 | 1889 |
1863 // If the user clicks while the popup is already showing, be sure to hide | 1890 // If the user clicks while the popup is already showing, be sure to hide |
1864 // it. | 1891 // it. |
1865 if (!was_edit && popup_controller_.get()) { | 1892 if (!was_edit && popup_controller_.get()) { |
1866 HidePopup(); | 1893 HidePopup(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2154 GetManager()->GetCreditCardByGUID(pair.first))); | 2181 GetManager()->GetCreditCardByGUID(pair.first))); |
2155 } else { | 2182 } else { |
2156 wrapper.reset(new AutofillProfileWrapper( | 2183 wrapper.reset(new AutofillProfileWrapper( |
2157 GetManager()->GetProfileByGUID(pair.first), | 2184 GetManager()->GetProfileByGUID(pair.first), |
2158 AutofillType(popup_input_type_), | 2185 AutofillType(popup_input_type_), |
2159 pair.second)); | 2186 pair.second)); |
2160 } | 2187 } |
2161 | 2188 |
2162 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 2189 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
2163 DialogSection section = static_cast<DialogSection>(i); | 2190 DialogSection section = static_cast<DialogSection>(i); |
2191 | |
2192 if (i18ninput::Enabled()) { | |
2193 if ((section == SECTION_BILLING || section == SECTION_CC_BILLING) && | |
2194 billing_country_combobox_model_.IsDefaultIndexSelected()) { | |
2195 base::string16 country_name = | |
2196 wrapper->GetInfo(AutofillType(ADDRESS_BILLING_COUNTRY)); | |
2197 if (!country_name.empty()) { | |
2198 billing_country_combobox_model_.SelectCountry( | |
2199 AutofillCountry::GetCountryCode( | |
2200 country_name, g_browser_process->GetApplicationLocale())); | |
2201 OnCountryComboboxModelChanged(billing_country_combobox_model_); | |
2202 UpdateSection(section); | |
2203 } | |
2204 } else if (section == SECTION_SHIPPING && | |
2205 shipping_country_combobox_model_.IsDefaultIndexSelected()) { | |
2206 base::string16 country_name = | |
2207 wrapper->GetInfo(AutofillType(ADDRESS_HOME_COUNTRY)); | |
2208 if (!country_name.empty()) { | |
2209 shipping_country_combobox_model_.SelectCountry( | |
2210 AutofillCountry::GetCountryCode( | |
2211 country_name, g_browser_process->GetApplicationLocale())); | |
2212 OnCountryComboboxModelChanged(shipping_country_combobox_model_); | |
2213 UpdateSection(section); | |
2214 } | |
2215 } | |
2216 } | |
2217 | |
2164 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); | 2218 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); |
2165 view_->FillSection(section, popup_input_type_); | 2219 view_->FillSection(section, popup_input_type_); |
2166 } | 2220 } |
2167 | 2221 |
2168 GetMetricLogger().LogDialogPopupEvent( | 2222 GetMetricLogger().LogDialogPopupEvent( |
2169 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); | 2223 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); |
2170 | 2224 |
2171 // TODO(estade): not sure why it's necessary to do this explicitly. | 2225 // TODO(estade): not sure why it's necessary to do this explicitly. |
2172 HidePopup(); | 2226 HidePopup(); |
2173 } | 2227 } |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2515 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), | 2569 profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), |
2516 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), | 2570 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), |
2517 form_structure_(form_structure), | 2571 form_structure_(form_structure), |
2518 invoked_from_same_origin_(true), | 2572 invoked_from_same_origin_(true), |
2519 source_url_(source_url), | 2573 source_url_(source_url), |
2520 callback_(callback), | 2574 callback_(callback), |
2521 wallet_client_(profile_->GetRequestContext(), this, source_url), | 2575 wallet_client_(profile_->GetRequestContext(), this, source_url), |
2522 wallet_items_requested_(false), | 2576 wallet_items_requested_(false), |
2523 handling_use_wallet_link_click_(false), | 2577 handling_use_wallet_link_click_(false), |
2524 passive_failed_(false), | 2578 passive_failed_(false), |
2525 country_combobox_model_(*GetManager()), | 2579 billing_country_combobox_model_(*GetManager()), |
2580 shipping_country_combobox_model_(*GetManager()), | |
2526 suggested_cc_(this), | 2581 suggested_cc_(this), |
2527 suggested_billing_(this), | 2582 suggested_billing_(this), |
2528 suggested_cc_billing_(this), | 2583 suggested_cc_billing_(this), |
2529 suggested_shipping_(this), | 2584 suggested_shipping_(this), |
2530 cares_about_shipping_(true), | 2585 cares_about_shipping_(true), |
2531 popup_input_type_(UNKNOWN_TYPE), | 2586 popup_input_type_(UNKNOWN_TYPE), |
2532 weak_ptr_factory_(this), | 2587 weak_ptr_factory_(this), |
2533 waiting_for_explicit_sign_in_response_(false), | 2588 waiting_for_explicit_sign_in_response_(false), |
2534 has_accepted_legal_documents_(false), | 2589 has_accepted_legal_documents_(false), |
2535 is_submitting_(false), | 2590 is_submitting_(false), |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2838 | 2893 |
2839 UpdateForErrors(); | 2894 UpdateForErrors(); |
2840 } | 2895 } |
2841 | 2896 |
2842 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( | 2897 void AutofillDialogControllerImpl::FillOutputForSectionWithComparator( |
2843 DialogSection section, | 2898 DialogSection section, |
2844 const InputFieldComparator& compare) { | 2899 const InputFieldComparator& compare) { |
2845 if (!SectionIsActive(section)) | 2900 if (!SectionIsActive(section)) |
2846 return; | 2901 return; |
2847 | 2902 |
2848 const DetailInputs& inputs = RequestedFieldsForSection(section); | 2903 DetailInputs inputs; |
2904 std::string country_code = CountryCodeForSection(section); | |
2905 common::BuildInputsForSection(section, country_code, &inputs); | |
2906 | |
2849 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | 2907 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); |
2850 if (wrapper) { | 2908 if (wrapper) { |
2851 // Only fill in data that is associated with this section. | 2909 // Only fill in data that is associated with this section. |
2852 const DetailInputs& inputs = RequestedFieldsForSection(section); | |
2853 wrapper->FillFormStructure(inputs, compare, &form_structure_); | 2910 wrapper->FillFormStructure(inputs, compare, &form_structure_); |
2854 | 2911 |
2855 // CVC needs special-casing because the CreditCard class doesn't store or | 2912 // 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 | 2913 // handle them. This isn't necessary when filling the combined CC and |
2857 // billing section as CVC comes from |full_wallet_| in this case. | 2914 // billing section as CVC comes from |full_wallet_| in this case. |
2858 if (section == SECTION_CC) | 2915 if (section == SECTION_CC) |
2859 SetOutputForFieldsOfType(CREDIT_CARD_VERIFICATION_CODE, view_->GetCvc()); | 2916 SetOutputForFieldsOfType(CREDIT_CARD_VERIFICATION_CODE, view_->GetCvc()); |
2860 | 2917 |
2861 // When filling from Wallet data, use the email address associated with the | 2918 // 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 | 2919 // 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 Loading... | |
2985 | 3042 |
2986 DCHECK_EQ(&model, &suggested_shipping_); | 3043 DCHECK_EQ(&model, &suggested_shipping_); |
2987 return SECTION_SHIPPING; | 3044 return SECTION_SHIPPING; |
2988 } | 3045 } |
2989 | 3046 |
2990 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( | 3047 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( |
2991 DialogSection section) { | 3048 DialogSection section) { |
2992 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 3049 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
2993 } | 3050 } |
2994 | 3051 |
3052 void AutofillDialogControllerImpl::OnCountryComboboxModelChanged( | |
3053 const CountryComboboxModel& model) { | |
3054 const FieldValueMap snapshot = TakeUserInputSnapshot(); | |
3055 | |
3056 const bool is_shipping = &model == &shipping_country_combobox_model_; | |
3057 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | |
3058 DialogSection section = static_cast<DialogSection>(i); | |
3059 | |
3060 if ((is_shipping && section != SECTION_SHIPPING) || | |
3061 (!is_shipping && (section != SECTION_BILLING && | |
3062 section != SECTION_CC_BILLING))) { | |
3063 continue; | |
3064 } | |
3065 | |
3066 DetailInputs* inputs = MutableRequestedFieldsForSection(section); | |
3067 inputs->clear(); | |
3068 | |
3069 std::string country_code = CountryCodeForSection(section); | |
3070 common::BuildInputsForSection(section, country_code, inputs); | |
3071 } | |
3072 | |
3073 RestoreUserInputFromSnapshot(snapshot); | |
3074 } | |
3075 | |
3076 std::string AutofillDialogControllerImpl::CountryCodeForSection( | |
3077 DialogSection section) { | |
3078 if (section != SECTION_CC) { | |
3079 scoped_ptr<DataModelWrapper> wrapper = CreateWrapper(section); | |
3080 if (wrapper) { | |
3081 return AutofillCountry::GetCountryCode( | |
3082 wrapper->GetInfo(AutofillType(section == SECTION_SHIPPING ? | |
3083 ADDRESS_HOME_COUNTRY : ADDRESS_BILLING_COUNTRY)), | |
3084 g_browser_process->GetApplicationLocale()); | |
3085 } | |
3086 } | |
3087 | |
3088 if (section == SECTION_BILLING || section == SECTION_CC_BILLING) | |
3089 return billing_country_combobox_model_.GetSelectedCountryCode(); | |
3090 | |
3091 if (section == SECTION_SHIPPING) | |
3092 return shipping_country_combobox_model_.GetSelectedCountryCode(); | |
3093 | |
3094 return "US"; | |
3095 } | |
3096 | |
2995 void AutofillDialogControllerImpl::HidePopup() { | 3097 void AutofillDialogControllerImpl::HidePopup() { |
2996 if (popup_controller_.get()) | 3098 if (popup_controller_.get()) |
2997 popup_controller_->Hide(); | 3099 popup_controller_->Hide(); |
2998 popup_input_type_ = UNKNOWN_TYPE; | 3100 popup_input_type_ = UNKNOWN_TYPE; |
2999 } | 3101 } |
3000 | 3102 |
3001 void AutofillDialogControllerImpl::SetEditingExistingData( | 3103 void AutofillDialogControllerImpl::SetEditingExistingData( |
3002 DialogSection section, bool editing) { | 3104 DialogSection section, bool editing) { |
3003 if (editing) | 3105 if (editing) |
3004 section_editing_state_.insert(section); | 3106 section_editing_state_.insert(section); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3534 view_->UpdateButtonStrip(); | 3636 view_->UpdateButtonStrip(); |
3535 } | 3637 } |
3536 | 3638 |
3537 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3639 void AutofillDialogControllerImpl::FetchWalletCookie() { |
3538 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3640 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
3539 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3641 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
3540 signin_helper_->StartWalletCookieValueFetch(); | 3642 signin_helper_->StartWalletCookieValueFetch(); |
3541 } | 3643 } |
3542 | 3644 |
3543 } // namespace autofill | 3645 } // namespace autofill |
OLD | NEW |