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.
5 #ifndef COMPONENTS_HTML_VIEWER_TOUCH_HANDLER_H_
6 #define COMPONENTS_HTML_VIEWER_TOUCH_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "ui/events/gesture_detection/filtered_gesture_provider.h"
20 class MotionEventGeneric
;
23 namespace html_viewer
{
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
{
30 explicit TouchHandler(blink::WebWidget
* web_widget
);
31 ~TouchHandler() override
;
33 void OnTouchEvent(const mojo::Event
& event
);
35 // ui::GestureProviderClient implementation.
36 void OnGestureEvent(const ui::GestureEventData
& gesture
) override
;
39 // Updates |current_motion_event_| from |event|. Returns true on success.
40 bool UpdateMotionEvent(const mojo::Event
& event
);
42 // Sends |current_motion_event_| to the GestureProvider and WebView.
43 void SendMotionEventToGestureProvider();
45 // Does post processing after sending |current_motion_event_| to the
47 void PostProcessMotionEvent(const mojo::Event
& event
);
49 blink::WebWidget
* web_widget_
;
51 ui::FilteredGestureProvider gesture_provider_
;
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_
;
57 DISALLOW_COPY_AND_ASSIGN(TouchHandler
);
60 } // namespace html_viewer
62 #endif // COMPONENTS_HTML_VIEWER_TOUCH_HANDLER_H_