| 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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 &popup_labels, | 1892 &popup_labels, |
| 1893 &popup_icons, | 1893 &popup_icons, |
| 1894 &popup_guids_); | 1894 &popup_guids_); |
| 1895 } | 1895 } |
| 1896 | 1896 |
| 1897 if (popup_values.empty()) { | 1897 if (popup_values.empty()) { |
| 1898 HidePopup(); | 1898 HidePopup(); |
| 1899 return; | 1899 return; |
| 1900 } | 1900 } |
| 1901 | 1901 |
| 1902 // |input_showing_popup_| must be set before calling |Show()|. | 1902 // |popup_input_type_| must be set before calling |Show()|. |
| 1903 const DetailInputs& inputs = RequestedFieldsForSection(section); | 1903 popup_input_type_ = type; |
| 1904 for (DetailInputs::const_iterator iter = inputs.begin(); | |
| 1905 iter != inputs.end(); ++iter) { | |
| 1906 if (iter->type == type) { | |
| 1907 input_showing_popup_ = &(*iter); | |
| 1908 break; | |
| 1909 } | |
| 1910 } | |
| 1911 | |
| 1912 if (!input_showing_popup_) | |
| 1913 return; | |
| 1914 | 1904 |
| 1915 // TODO(estade): do we need separators and control rows like 'Clear | 1905 // TODO(estade): do we need separators and control rows like 'Clear |
| 1916 // Form'? | 1906 // Form'? |
| 1917 std::vector<int> popup_ids; | 1907 std::vector<int> popup_ids; |
| 1918 for (size_t i = 0; i < popup_guids_.size(); ++i) { | 1908 for (size_t i = 0; i < popup_guids_.size(); ++i) { |
| 1919 popup_ids.push_back(i); | 1909 popup_ids.push_back(i); |
| 1920 } | 1910 } |
| 1921 | 1911 |
| 1922 popup_controller_ = AutofillPopupControllerImpl::GetOrCreate( | 1912 popup_controller_ = AutofillPopupControllerImpl::GetOrCreate( |
| 1923 popup_controller_, | 1913 popup_controller_, |
| 1924 weak_ptr_factory_.GetWeakPtr(), | 1914 weak_ptr_factory_.GetWeakPtr(), |
| 1925 NULL, | 1915 NULL, |
| 1926 parent_view, | 1916 parent_view, |
| 1927 content_bounds, | 1917 content_bounds, |
| 1928 base::i18n::IsRTL() ? | 1918 base::i18n::IsRTL() ? |
| 1929 base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT); | 1919 base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT); |
| 1930 popup_controller_->set_hide_on_outside_click(true); | 1920 popup_controller_->set_hide_on_outside_click(true); |
| 1931 popup_controller_->Show(popup_values, | 1921 popup_controller_->Show(popup_values, |
| 1932 popup_labels, | 1922 popup_labels, |
| 1933 popup_icons, | 1923 popup_icons, |
| 1934 popup_ids); | 1924 popup_ids); |
| 1935 } | 1925 } |
| 1936 | 1926 |
| 1937 void AutofillDialogControllerImpl::FocusMoved() { | 1927 void AutofillDialogControllerImpl::FocusMoved() { |
| 1938 HidePopup(); | 1928 HidePopup(); |
| 1939 } | 1929 } |
| 1940 | 1930 |
| 1941 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const { | 1931 bool AutofillDialogControllerImpl::ShouldShowErrorBubble() const { |
| 1942 return !input_showing_popup_; | 1932 return popup_input_type_ == UNKNOWN_TYPE; |
| 1943 } | 1933 } |
| 1944 | 1934 |
| 1945 void AutofillDialogControllerImpl::ViewClosed() { | 1935 void AutofillDialogControllerImpl::ViewClosed() { |
| 1946 GetManager()->RemoveObserver(this); | 1936 GetManager()->RemoveObserver(this); |
| 1947 | 1937 |
| 1948 // Called from here rather than in ~AutofillDialogControllerImpl as this | 1938 // Called from here rather than in ~AutofillDialogControllerImpl as this |
| 1949 // relies on virtual methods that change to their base class in the dtor. | 1939 // relies on virtual methods that change to their base class in the dtor. |
| 1950 MaybeShowCreditCardBubble(); | 1940 MaybeShowCreditCardBubble(); |
| 1951 | 1941 |
| 1952 delete this; | 1942 delete this; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2136 ScopedViewUpdates update(view_.get()); | 2126 ScopedViewUpdates update(view_.get()); |
| 2137 view_->UpdateErrorBubble(); | 2127 view_->UpdateErrorBubble(); |
| 2138 | 2128 |
| 2139 GetMetricLogger().LogDialogPopupEvent(AutofillMetrics::DIALOG_POPUP_SHOWN); | 2129 GetMetricLogger().LogDialogPopupEvent(AutofillMetrics::DIALOG_POPUP_SHOWN); |
| 2140 } | 2130 } |
| 2141 | 2131 |
| 2142 void AutofillDialogControllerImpl::OnPopupHidden() {} | 2132 void AutofillDialogControllerImpl::OnPopupHidden() {} |
| 2143 | 2133 |
| 2144 bool AutofillDialogControllerImpl::ShouldRepostEvent( | 2134 bool AutofillDialogControllerImpl::ShouldRepostEvent( |
| 2145 const ui::MouseEvent& event) { | 2135 const ui::MouseEvent& event) { |
| 2146 // If the event would be reposted inside |input_showing_popup_|, just ignore. | 2136 DCHECK_NE(UNKNOWN_TYPE, popup_input_type_); |
| 2147 return !view_->HitTestInput(*input_showing_popup_, event.location()); | 2137 // If the event would be reposted inside the input showing an Autofill popup, |
| 2138 // just ignore. |
| 2139 return !view_->HitTestInput(popup_input_type_, event.location()); |
| 2148 } | 2140 } |
| 2149 | 2141 |
| 2150 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) { | 2142 void AutofillDialogControllerImpl::DidSelectSuggestion(int identifier) { |
| 2151 // TODO(estade): implement. | 2143 // TODO(estade): implement. |
| 2152 } | 2144 } |
| 2153 | 2145 |
| 2154 void AutofillDialogControllerImpl::DidAcceptSuggestion( | 2146 void AutofillDialogControllerImpl::DidAcceptSuggestion( |
| 2155 const base::string16& value, | 2147 const base::string16& value, |
| 2156 int identifier) { | 2148 int identifier) { |
| 2157 ScopedViewUpdates updates(view_.get()); | 2149 ScopedViewUpdates updates(view_.get()); |
| 2158 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier]; | 2150 const PersonalDataManager::GUIDPair& pair = popup_guids_[identifier]; |
| 2159 | 2151 |
| 2160 scoped_ptr<DataModelWrapper> wrapper; | 2152 scoped_ptr<DataModelWrapper> wrapper; |
| 2161 if (common::IsCreditCardType(input_showing_popup_->type)) { | 2153 if (common::IsCreditCardType(popup_input_type_)) { |
| 2162 wrapper.reset(new AutofillCreditCardWrapper( | 2154 wrapper.reset(new AutofillCreditCardWrapper( |
| 2163 GetManager()->GetCreditCardByGUID(pair.first))); | 2155 GetManager()->GetCreditCardByGUID(pair.first))); |
| 2164 } else { | 2156 } else { |
| 2165 wrapper.reset(new AutofillProfileWrapper( | 2157 wrapper.reset(new AutofillProfileWrapper( |
| 2166 GetManager()->GetProfileByGUID(pair.first), | 2158 GetManager()->GetProfileByGUID(pair.first), |
| 2167 AutofillType(input_showing_popup_->type), | 2159 AutofillType(popup_input_type_), |
| 2168 pair.second)); | 2160 pair.second)); |
| 2169 } | 2161 } |
| 2170 | 2162 |
| 2171 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { | 2163 for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { |
| 2172 DialogSection section = static_cast<DialogSection>(i); | 2164 DialogSection section = static_cast<DialogSection>(i); |
| 2173 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); | 2165 wrapper->FillInputs(MutableRequestedFieldsForSection(section)); |
| 2174 view_->FillSection(section, *input_showing_popup_); | 2166 view_->FillSection(section, popup_input_type_); |
| 2175 } | 2167 } |
| 2176 | 2168 |
| 2177 GetMetricLogger().LogDialogPopupEvent( | 2169 GetMetricLogger().LogDialogPopupEvent( |
| 2178 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); | 2170 AutofillMetrics::DIALOG_POPUP_FORM_FILLED); |
| 2179 | 2171 |
| 2180 // TODO(estade): not sure why it's necessary to do this explicitly. | 2172 // TODO(estade): not sure why it's necessary to do this explicitly. |
| 2181 HidePopup(); | 2173 HidePopup(); |
| 2182 } | 2174 } |
| 2183 | 2175 |
| 2184 void AutofillDialogControllerImpl::RemoveSuggestion( | 2176 void AutofillDialogControllerImpl::RemoveSuggestion( |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2530 wallet_client_(profile_->GetRequestContext(), this, source_url), | 2522 wallet_client_(profile_->GetRequestContext(), this, source_url), |
| 2531 wallet_items_requested_(false), | 2523 wallet_items_requested_(false), |
| 2532 handling_use_wallet_link_click_(false), | 2524 handling_use_wallet_link_click_(false), |
| 2533 passive_failed_(false), | 2525 passive_failed_(false), |
| 2534 country_combobox_model_(*GetManager()), | 2526 country_combobox_model_(*GetManager()), |
| 2535 suggested_cc_(this), | 2527 suggested_cc_(this), |
| 2536 suggested_billing_(this), | 2528 suggested_billing_(this), |
| 2537 suggested_cc_billing_(this), | 2529 suggested_cc_billing_(this), |
| 2538 suggested_shipping_(this), | 2530 suggested_shipping_(this), |
| 2539 cares_about_shipping_(true), | 2531 cares_about_shipping_(true), |
| 2540 input_showing_popup_(NULL), | 2532 popup_input_type_(UNKNOWN_TYPE), |
| 2541 weak_ptr_factory_(this), | 2533 weak_ptr_factory_(this), |
| 2542 waiting_for_explicit_sign_in_response_(false), | 2534 waiting_for_explicit_sign_in_response_(false), |
| 2543 has_accepted_legal_documents_(false), | 2535 has_accepted_legal_documents_(false), |
| 2544 is_submitting_(false), | 2536 is_submitting_(false), |
| 2545 choose_another_instrument_or_address_(false), | 2537 choose_another_instrument_or_address_(false), |
| 2546 wallet_server_validation_recoverable_(true), | 2538 wallet_server_validation_recoverable_(true), |
| 2547 data_was_passed_back_(false), | 2539 data_was_passed_back_(false), |
| 2548 was_ui_latency_logged_(false), | 2540 was_ui_latency_logged_(false), |
| 2549 card_generated_animation_(2000, 60, this) { | 2541 card_generated_animation_(2000, 60, this) { |
| 2550 // TODO(estade): remove duplicates from |form_structure|? | 2542 // TODO(estade): remove duplicates from |form_structure|? |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 } | 2989 } |
| 2998 | 2990 |
| 2999 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( | 2991 DetailInputs* AutofillDialogControllerImpl::MutableRequestedFieldsForSection( |
| 3000 DialogSection section) { | 2992 DialogSection section) { |
| 3001 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); | 2993 return const_cast<DetailInputs*>(&RequestedFieldsForSection(section)); |
| 3002 } | 2994 } |
| 3003 | 2995 |
| 3004 void AutofillDialogControllerImpl::HidePopup() { | 2996 void AutofillDialogControllerImpl::HidePopup() { |
| 3005 if (popup_controller_.get()) | 2997 if (popup_controller_.get()) |
| 3006 popup_controller_->Hide(); | 2998 popup_controller_->Hide(); |
| 3007 input_showing_popup_ = NULL; | 2999 popup_input_type_ = UNKNOWN_TYPE; |
| 3008 } | 3000 } |
| 3009 | 3001 |
| 3010 void AutofillDialogControllerImpl::SetEditingExistingData( | 3002 void AutofillDialogControllerImpl::SetEditingExistingData( |
| 3011 DialogSection section, bool editing) { | 3003 DialogSection section, bool editing) { |
| 3012 if (editing) | 3004 if (editing) |
| 3013 section_editing_state_.insert(section); | 3005 section_editing_state_.insert(section); |
| 3014 else | 3006 else |
| 3015 section_editing_state_.erase(section); | 3007 section_editing_state_.erase(section); |
| 3016 } | 3008 } |
| 3017 | 3009 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3543 view_->UpdateButtonStrip(); | 3535 view_->UpdateButtonStrip(); |
| 3544 } | 3536 } |
| 3545 | 3537 |
| 3546 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3538 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3547 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3539 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3548 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3540 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3549 signin_helper_->StartWalletCookieValueFetch(); | 3541 signin_helper_->StartWalletCookieValueFetch(); |
| 3550 } | 3542 } |
| 3551 | 3543 |
| 3552 } // namespace autofill | 3544 } // namespace autofill |
| OLD | NEW |