Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / input / touchscreen_tap_suppression_controller.h
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_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/renderer_host/input/gesture_event_queue.h"
10 #include "content/browser/renderer_host/input/tap_suppression_controller_client.h"
11
12 namespace content {
13
14 class GestureEventQueue;
15 class TapSuppressionController;
16
17 // Controls the suppression of touchscreen taps immediately following the
18 // dispatch of a GestureFlingCancel event.
19 class TouchscreenTapSuppressionController
20     : public TapSuppressionControllerClient {
21  public:
22   explicit TouchscreenTapSuppressionController(GestureEventQueue* geq);
23   virtual ~TouchscreenTapSuppressionController();
24
25   // Should be called on arrival of GestureFlingCancel events.
26   void GestureFlingCancel();
27
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);
31
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);
35
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);
39
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();
43
44  private:
45   // TapSuppressionControllerClient implementation.
46   virtual int MaxCancelToDownTimeInMs() OVERRIDE;
47   virtual int MaxTapGapTimeInMs() OVERRIDE;
48   virtual void DropStashedTapDown() OVERRIDE;
49   virtual void ForwardStashedTapDown() OVERRIDE;
50
51   GestureEventQueue* gesture_event_queue_;
52
53   typedef scoped_ptr<GestureEventWithLatencyInfo> ScopedGestureEvent;
54   ScopedGestureEvent stashed_tap_down_;
55   ScopedGestureEvent stashed_show_press_;
56
57   // The core controller of tap suppression.
58   scoped_ptr<TapSuppressionController> controller_;
59
60   DISALLOW_COPY_AND_ASSIGN(TouchscreenTapSuppressionController);
61 };
62
63 }  // namespace content
64
65 #endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_