OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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/browser/renderer_host/input/gesture_event_packet.h" |
| 10 #include "content/browser/renderer_host/input/touch_disposition_gesture_filter.h
" |
| 11 #include "ui/events/gesture_detection/gesture_provider.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 class ContentGestureProviderClient { |
| 16 public: |
| 17 virtual ~ContentGestureProviderClient() {} |
| 18 virtual void OnGestureEvent(const blink::WebGestureEvent& event) = 0; |
| 19 }; |
| 20 |
| 21 // Provides gesture detection and dispatch given a sequence of touch events |
| 22 // and touch event acks. |
| 23 class ContentGestureProvider : public TouchDispositionGestureFilterClient, |
| 24 public ui::GestureProviderClient { |
| 25 public: |
| 26 ContentGestureProvider(ContentGestureProviderClient* client, |
| 27 float touch_to_gesture_scale); |
| 28 |
| 29 // Returns true if |event| was both valid and successfully handled by the |
| 30 // gesture detector. Otherwise, returns false, in which case the caller |
| 31 // should drop |event|, not forwarding it to the renderer. |
| 32 bool OnTouchEvent(const ui::MotionEvent& event); |
| 33 |
| 34 // To be called upon ack of an event that was forwarded after a successful |
| 35 // call to |OnTouchEvent()|. |
| 36 void OnTouchEventAck(InputEventAckState ack_state); |
| 37 |
| 38 // Methods delegated to |gesture_provider_|. |
| 39 void ResetGestureDetectors(); |
| 40 void CancelActiveTouchSequence(); |
| 41 void UpdateMultiTouchSupport(bool support_multi_touch_zoom); |
| 42 void UpdateDoubleTapSupportForPlatform(bool support_double_tap); |
| 43 void UpdateDoubleTapSupportForPage(bool support_double_tap); |
| 44 |
| 45 private: |
| 46 // ui::GestureProviderClient |
| 47 virtual void OnGestureEvent(const ui::GestureEventParams& params) OVERRIDE; |
| 48 |
| 49 // TouchDispositionGestureFilterClient |
| 50 virtual void ForwardGestureEvent(const blink::WebGestureEvent& event) |
| 51 OVERRIDE; |
| 52 |
| 53 ContentGestureProviderClient* const client_; |
| 54 float touch_to_gesture_scale_; |
| 55 |
| 56 ui::GestureProvider gesture_provider_; |
| 57 TouchDispositionGestureFilter gesture_filter_; |
| 58 |
| 59 bool handling_event_; |
| 60 GestureEventPacket pending_gesture_packet_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(ContentGestureProvider); |
| 63 }; |
| 64 |
| 65 } // namespace content |
| 66 |
| 67 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_CONTENT_GESTURE_PROVIDER_H_ |
OLD | NEW |