| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SERVICES_HTML_VIEWER_TOUCH_HANDLER_H_ | |
| 6 #define MOJO_SERVICES_HTML_VIEWER_TOUCH_HANDLER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 class WebView; | |
| 13 } | |
| 14 | |
| 15 namespace mojo { | |
| 16 class Event; | |
| 17 } | |
| 18 | |
| 19 namespace ui { | |
| 20 class MotionEventGeneric; | |
| 21 } | |
| 22 | |
| 23 namespace html_viewer { | |
| 24 | |
| 25 // TouchHandler is responsible for converting touch events into gesture events. | |
| 26 // It does this by converting mojo::Events into a MotionEventGeneric and using | |
| 27 // FilteredGestureProvider. | |
| 28 class TouchHandler : public ui::GestureProviderClient { | |
| 29 public: | |
| 30 explicit TouchHandler(blink::WebView* web_view); | |
| 31 ~TouchHandler() override; | |
| 32 | |
| 33 void OnTouchEvent(const mojo::Event& event); | |
| 34 | |
| 35 // ui::GestureProviderClient implementation. | |
| 36 void OnGestureEvent(const ui::GestureEventData& gesture) override; | |
| 37 | |
| 38 private: | |
| 39 // Updates |current_motion_event_| from |event|. Returns true on success. | |
| 40 bool UpdateMotionEvent(const mojo::Event& event); | |
| 41 | |
| 42 // Sends |current_motion_event_| to the GestureProvider and WebView. | |
| 43 void SendMotionEventToGestureProvider(); | |
| 44 | |
| 45 // Does post processing after sending |current_motion_event_| to the | |
| 46 // GestureProvider. | |
| 47 void PostProcessMotionEvent(const mojo::Event& event); | |
| 48 | |
| 49 blink::WebView* web_view_; | |
| 50 | |
| 51 ui::FilteredGestureProvider gesture_provider_; | |
| 52 | |
| 53 // As touch events are received they are converted to this event. If null no | |
| 54 // touch events are in progress. | |
| 55 scoped_ptr<ui::MotionEventGeneric> current_motion_event_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(TouchHandler); | |
| 58 }; | |
| 59 | |
| 60 } // namespace html_viewer | |
| 61 | |
| 62 #endif // MOJO_SERVICES_HTML_VIEWER_TOUCH_HANDLER_H_ | |
| OLD | NEW |