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