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_UPDATE: | |
172 if (HitTestPoint(event->location())) | |
173 controller_->MouseHovered(event->x(), event->y()); | |
Rick Byers
2013/10/25 17:22:23
nit: would be nice to update these method names to
| |
174 else | |
175 controller_->MouseExitedPopup(); | |
176 break; | |
177 case ui::ET_GESTURE_TAP: | |
178 case ui::ET_GESTURE_SCROLL_END: | |
179 if (HitTestPoint(event->location())) | |
180 controller_->MouseClicked(event->x(), event->y()); | |
181 else | |
182 controller_->MouseExitedPopup(); | |
183 break; | |
184 case ui::ET_GESTURE_TAP_CANCEL: | |
185 case ui::ET_SCROLL_FLING_START: | |
186 controller_->MouseExitedPopup(); | |
187 default: | |
188 break; | |
189 } | |
190 event->SetHandled(); | |
Dan Beam
2013/10/25 18:38:23
don't you only want to set the event handled in so
mohsen
2013/10/25 21:36:41
I think it is not making any difference in this ca
| |
191 } | |
192 | |
165 void AutofillPopupViewViews::OnWidgetBoundsChanged( | 193 void AutofillPopupViewViews::OnWidgetBoundsChanged( |
166 views::Widget* widget, | 194 views::Widget* widget, |
167 const gfx::Rect& new_bounds) { | 195 const gfx::Rect& new_bounds) { |
168 DCHECK_EQ(widget, observing_widget_); | 196 DCHECK_EQ(widget, observing_widget_); |
169 controller_->Hide(); | 197 controller_->Hide(); |
170 } | 198 } |
171 | 199 |
172 void AutofillPopupViewViews::Show() { | 200 void AutofillPopupViewViews::Show() { |
173 if (!GetWidget()) { | 201 if (!GetWidget()) { |
174 observing_widget_->AddObserver(this); | 202 observing_widget_->AddObserver(this); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 301 |
274 // If the top level widget can't be found, cancel the popup since we can't | 302 // If the top level widget can't be found, cancel the popup since we can't |
275 // fully set it up. | 303 // fully set it up. |
276 if (!observing_widget) | 304 if (!observing_widget) |
277 return NULL; | 305 return NULL; |
278 | 306 |
279 return new AutofillPopupViewViews(controller, observing_widget); | 307 return new AutofillPopupViewViews(controller, observing_widget); |
280 } | 308 } |
281 | 309 |
282 } // namespace autofill | 310 } // namespace autofill |
OLD | NEW |