| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 CONTENT_BROWSER_RENDERER_HOST_INPUT_CONTENT_GESTURE_PROVIDER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_CONTENT_GESTURE_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "content/port/common/input_event_ack_state.h" | |
| 10 #include "ui/events/gesture_detection/gesture_event_data_packet.h" | |
| 11 #include "ui/events/gesture_detection/gesture_provider.h" | |
| 12 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 class WebGestureEvent; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 class ContentGestureProviderClient { | |
| 21 public: | |
| 22 virtual ~ContentGestureProviderClient() {} | |
| 23 virtual void OnGestureEvent(const blink::WebGestureEvent& event) = 0; | |
| 24 }; | |
| 25 | |
| 26 // Provides gesture detection and dispatch given a sequence of touch events | |
| 27 // and touch event acks. | |
| 28 class ContentGestureProvider : public ui::TouchDispositionGestureFilterClient, | |
| 29 public ui::GestureProviderClient { | |
| 30 public: | |
| 31 // TODO(jdduke): Move the scaling constant out of this class, instead hosting | |
| 32 // it on the generating MotionEvent. | |
| 33 ContentGestureProvider(ContentGestureProviderClient* client, | |
| 34 float touch_to_gesture_scale); | |
| 35 | |
| 36 // Returns true if |event| was both valid and successfully handled by the | |
| 37 // gesture detector. Otherwise, returns false, in which case the caller | |
| 38 // should drop |event|, not forwarding it to the renderer. | |
| 39 bool OnTouchEvent(const ui::MotionEvent& event); | |
| 40 | |
| 41 // To be called upon ack of an event that was forwarded after a successful | |
| 42 // call to |OnTouchEvent()|. | |
| 43 void OnTouchEventAck(InputEventAckState ack_state); | |
| 44 | |
| 45 // Methods delegated to |gesture_provider_|. | |
| 46 void ResetGestureDetectors(); | |
| 47 void SetMultiTouchSupportEnabled(bool enabled); | |
| 48 void SetDoubleTapSupportForPlatformEnabled(bool enabled); | |
| 49 void SetDoubleTapSupportForPageEnabled(bool enabled); | |
| 50 const ui::MotionEvent* GetCurrentDownEvent() const; | |
| 51 | |
| 52 private: | |
| 53 // ui::GestureProviderClient | |
| 54 virtual void OnGestureEvent(const ui::GestureEventData& event) OVERRIDE; | |
| 55 | |
| 56 // TouchDispositionGestureFilterClient | |
| 57 virtual void ForwardGestureEvent(const ui::GestureEventData& event) OVERRIDE; | |
| 58 | |
| 59 ContentGestureProviderClient* const client_; | |
| 60 float touch_to_gesture_scale_; | |
| 61 | |
| 62 ui::GestureProvider gesture_provider_; | |
| 63 ui::TouchDispositionGestureFilter gesture_filter_; | |
| 64 | |
| 65 bool handling_event_; | |
| 66 ui::GestureEventDataPacket pending_gesture_packet_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ContentGestureProvider); | |
| 69 }; | |
| 70 | |
| 71 } // namespace content | |
| 72 | |
| 73 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_CONTENT_GESTURE_PROVIDER_H_ | |
| OLD | NEW |