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 UI_EVENTS_GESTURE_DETECTION_FILTERED_GESTURE_PROVIDER_H_ 6 #define UI_EVENTS_GESTURE_DETECTION_FILTERED_GESTURE_PROVIDER_H_ 7 8 #include "base/basictypes.h" 9 #include "ui/events/gesture_detection/gesture_event_data_packet.h" 10 #include "ui/events/gesture_detection/gesture_provider.h" 11 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" 12 13 namespace ui { 14 15 // Provides filtered gesture detection and dispatch given a sequence of touch 16 // events and touch event acks. 17 class GESTURE_DETECTION_EXPORT FilteredGestureProvider 18 : public ui::TouchDispositionGestureFilterClient, 19 public ui::GestureProviderClient { 20 public: 21 // |client| will be offered all gestures detected by the |gesture_provider_| 22 // and allowed by the |gesture_filter_|. 23 FilteredGestureProvider(const GestureProvider::Config& config, 24 GestureProviderClient* client); 25 26 // Returns true if |event| was both valid and successfully handled by the 27 // gesture provider. Otherwise, returns false, in which case the caller 28 // should drop |event|, not forwarding it to the renderer. 29 bool OnTouchEvent(const MotionEvent& event); 30 31 // To be called upon ack of an event that was forwarded after a successful 32 // call to |OnTouchEvent()|. 33 void OnTouchEventAck(bool event_consumed); 34 35 // Methods delegated to |gesture_provider_|. 36 void SetMultiTouchZoomSupportEnabled(bool enabled); 37 void SetDoubleTapSupportForPlatformEnabled(bool enabled); 38 void SetDoubleTapSupportForPageEnabled(bool enabled); 39 const ui::MotionEvent* GetCurrentDownEvent() const; 40 41 private: 42 // GestureProviderClient implementation. 43 virtual void OnGestureEvent(const ui::GestureEventData& event) OVERRIDE; 44 45 // TouchDispositionGestureFilterClient implementation. 46 virtual void ForwardGestureEvent(const ui::GestureEventData& event) OVERRIDE; 47 48 GestureProviderClient* const client_; 49 50 ui::GestureProvider gesture_provider_; 51 ui::TouchDispositionGestureFilter gesture_filter_; 52 53 bool handling_event_; 54 ui::GestureEventDataPacket pending_gesture_packet_; 55 56 DISALLOW_COPY_AND_ASSIGN(FilteredGestureProvider); 57 }; 58 59 } // namespace ui 60 61 #endif // UI_EVENTS_GESTURE_DETECTION_FILTERED_GESTURE_PROVIDER_H_ 62