| 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 COMPONENTS_HTML_VIEWER_TOUCH_HANDLER_H_ | |
| 6 #define COMPONENTS_HTML_VIEWER_TOUCH_HANDLER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "components/mus/public/interfaces/input_events.mojom.h" | |
| 10 #include "ui/events/gesture_detection/filtered_gesture_provider.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 class WebWidget; | |
| 14 } | |
| 15 | |
| 16 namespace ui { | |
| 17 class MotionEventGeneric; | |
| 18 } | |
| 19 | |
| 20 namespace html_viewer { | |
| 21 | |
| 22 // TouchHandler is responsible for converting touch events into gesture events. | |
| 23 // It does this by converting mus::mojom::Events into a MotionEventGeneric and | |
| 24 // using | |
| 25 // FilteredGestureProvider. | |
| 26 class TouchHandler : public ui::GestureProviderClient { | |
| 27 public: | |
| 28 explicit TouchHandler(blink::WebWidget* web_widget); | |
| 29 ~TouchHandler() override; | |
| 30 | |
| 31 void OnTouchEvent(const mus::mojom::Event& event); | |
| 32 | |
| 33 // ui::GestureProviderClient implementation. | |
| 34 void OnGestureEvent(const ui::GestureEventData& gesture) override; | |
| 35 | |
| 36 private: | |
| 37 // Updates |current_motion_event_| from |event|. Returns true on success. | |
| 38 bool UpdateMotionEvent(const mus::mojom::Event& event); | |
| 39 | |
| 40 // Sends |current_motion_event_| to the GestureProvider and WebView. | |
| 41 void SendMotionEventToGestureProvider(); | |
| 42 | |
| 43 // Does post processing after sending |current_motion_event_| to the | |
| 44 // GestureProvider. | |
| 45 void PostProcessMotionEvent(const mus::mojom::Event& event); | |
| 46 | |
| 47 blink::WebWidget* web_widget_; | |
| 48 | |
| 49 ui::FilteredGestureProvider gesture_provider_; | |
| 50 | |
| 51 // As touch events are received they are converted to this event. If null no | |
| 52 // touch events are in progress. | |
| 53 scoped_ptr<ui::MotionEventGeneric> current_motion_event_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(TouchHandler); | |
| 56 }; | |
| 57 | |
| 58 } // namespace html_viewer | |
| 59 | |
| 60 #endif // COMPONENTS_HTML_VIEWER_TOUCH_HANDLER_H_ | |
| OLD | NEW |