OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/autofill/autofill_popup_view_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" |
6 | 6 |
7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 9 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 // receive an OnMouseReleased event just after showing. This breaks the mouse | 155 // receive an OnMouseReleased event just after showing. This breaks the mouse |
156 // capture, so restart capturing here. | 156 // capture, so restart capturing here. |
157 if (controller_->hide_on_outside_click() && GetWidget()) | 157 if (controller_->hide_on_outside_click() && GetWidget()) |
158 GetWidget()->SetCapture(this); | 158 GetWidget()->SetCapture(this); |
159 | 159 |
160 // We only care about the left click. | 160 // We only care about the left click. |
161 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) | 161 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) |
162 controller_->MouseClicked(event.x(), event.y()); | 162 controller_->MouseClicked(event.x(), event.y()); |
163 } | 163 } |
164 | 164 |
165 void AutofillPopupViewViews::OnGestureEvent(ui::GestureEvent* event) { | |
166 if (!controller_) | |
167 return; | |
168 | |
169 switch (event->type()) { | |
170 case ui::ET_GESTURE_TAP_DOWN: | |
171 case ui::ET_GESTURE_SCROLL_BEGIN: | |
172 case ui::ET_GESTURE_SCROLL_UPDATE: | |
173 if (HitTestPoint(event->location())) | |
174 controller_->MouseHovered(event->x(), event->y()); | |
175 else | |
176 controller_->MouseExitedPopup(); | |
177 break; | |
178 case ui::ET_GESTURE_TAP: | |
179 case ui::ET_GESTURE_SCROLL_END: | |
180 if (HitTestPoint(event->location())) | |
181 controller_->MouseClicked(event->x(), event->y()); | |
182 else | |
183 controller_->MouseExitedPopup(); | |
184 break; | |
185 case ui::ET_GESTURE_TAP_CANCEL: | |
186 case ui::ET_SCROLL_FLING_START: | |
187 controller_->MouseExitedPopup(); | |
188 break; | |
189 default: | |
190 return; | |
191 } | |
192 event->SetHandled(); | |
Dan Beam
2013/10/26 01:56:09
^ this doesn't seem done
mohsen
2013/10/26 03:30:00
non-handled events return from the function before
Dan Beam
2013/10/28 19:31:18
ah, i see
| |
193 } | |
194 | |
165 void AutofillPopupViewViews::OnWidgetBoundsChanged( | 195 void AutofillPopupViewViews::OnWidgetBoundsChanged( |
166 views::Widget* widget, | 196 views::Widget* widget, |
167 const gfx::Rect& new_bounds) { | 197 const gfx::Rect& new_bounds) { |
168 DCHECK_EQ(widget, observing_widget_); | 198 DCHECK_EQ(widget, observing_widget_); |
169 controller_->Hide(); | 199 controller_->Hide(); |
170 } | 200 } |
171 | 201 |
172 void AutofillPopupViewViews::Show() { | 202 void AutofillPopupViewViews::Show() { |
173 if (!GetWidget()) { | 203 if (!GetWidget()) { |
174 observing_widget_->AddObserver(this); | 204 observing_widget_->AddObserver(this); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 303 |
274 // If the top level widget can't be found, cancel the popup since we can't | 304 // If the top level widget can't be found, cancel the popup since we can't |
275 // fully set it up. | 305 // fully set it up. |
276 if (!observing_widget) | 306 if (!observing_widget) |
277 return NULL; | 307 return NULL; |
278 | 308 |
279 return new AutofillPopupViewViews(controller, observing_widget); | 309 return new AutofillPopupViewViews(controller, observing_widget); |
280 } | 310 } |
281 | 311 |
282 } // namespace autofill | 312 } // namespace autofill |
OLD | NEW |