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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/renderer_host/input/gesture_event_filter.h"
10 #include "content/browser/renderer_host/input/tap_suppression_controller_client.h"
14 class GestureEventFilter
;
15 class TapSuppressionController
;
17 // Controls the suppression of touchscreen taps immediately following the
18 // dispatch of a GestureFlingCancel event.
19 class TouchscreenTapSuppressionController
20 : public TapSuppressionControllerClient
{
22 explicit TouchscreenTapSuppressionController(GestureEventFilter
* gef
);
23 virtual ~TouchscreenTapSuppressionController();
25 // Should be called on arrival of GestureFlingCancel events.
26 void GestureFlingCancel();
28 // Should be called on arrival of ACK for a GestureFlingCancel event.
29 // |processed| is true if the GestureFlingCancel successfully stopped a fling.
30 void GestureFlingCancelAck(bool processed
);
32 // Should be called on arrival of GestureTapDown events. Returns true if the
33 // caller should stop normal handling of the GestureTapDown.
34 bool ShouldDeferGestureTapDown(const GestureEventWithLatencyInfo
& event
);
36 // Should be called on arrival of GestureShowPress events. Returns true if the
37 // caller should stop normal handling of the GestureShowPress.
38 bool ShouldDeferGestureShowPress(const GestureEventWithLatencyInfo
& event
);
40 // Should be called on arrival of tap-ending gesture events. Returns true if
41 // the caller should stop normal handling of the GestureTap.
42 bool ShouldSuppressGestureTapEnd();
45 // TapSuppressionControllerClient implementation.
46 virtual int MaxCancelToDownTimeInMs() OVERRIDE
;
47 virtual int MaxTapGapTimeInMs() OVERRIDE
;
48 virtual void DropStashedTapDown() OVERRIDE
;
49 virtual void ForwardStashedTapDown() OVERRIDE
;
51 GestureEventFilter
* gesture_event_filter_
;
53 typedef scoped_ptr
<GestureEventWithLatencyInfo
> ScopedGestureEvent
;
54 ScopedGestureEvent stashed_tap_down_
;
55 ScopedGestureEvent stashed_show_press_
;
57 // The core controller of tap suppression.
58 scoped_ptr
<TapSuppressionController
> controller_
;
60 DISALLOW_COPY_AND_ASSIGN(TouchscreenTapSuppressionController
);
63 } // namespace content
65 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_