Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / input / touchpad_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_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
7
8 #include "content/browser/renderer_host/event_with_latency_info.h"
9 #include "content/browser/renderer_host/input/tap_suppression_controller.h"
10 #include "content/browser/renderer_host/input/tap_suppression_controller_client.h"
11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h"
13
14 namespace content {
15
16 class TapSuppressionController;
17
18 class CONTENT_EXPORT TouchpadTapSuppressionControllerClient {
19  public:
20   virtual ~TouchpadTapSuppressionControllerClient() {}
21   virtual void SendMouseEventImmediately(
22       const MouseEventWithLatencyInfo& event) = 0;
23 };
24
25 // Controls the suppression of touchpad taps immediately following the dispatch
26 // of a GestureFlingCancel event.
27 class TouchpadTapSuppressionController : public TapSuppressionControllerClient {
28  public:
29   // The |client| must outlive the TouchpadTapSupressionController.
30   TouchpadTapSuppressionController(
31       TouchpadTapSuppressionControllerClient* client,
32       const TapSuppressionController::Config& config);
33   virtual ~TouchpadTapSuppressionController();
34
35   // Should be called on arrival of GestureFlingCancel events.
36   void GestureFlingCancel();
37
38   // Should be called on arrival of ACK for a GestureFlingCancel event.
39   // |processed| is true if the GestureFlingCancel successfully stopped a fling.
40   void GestureFlingCancelAck(bool processed);
41
42   // Should be called on arrival of MouseDown events. Returns true if the caller
43   // should stop normal handling of the MouseDown. In this case, the caller is
44   // responsible for saving the event for later use, if needed.
45   bool ShouldDeferMouseDown(const MouseEventWithLatencyInfo& event);
46
47   // Should be called on arrival of MouseUp events. Returns true if the caller
48   // should stop normal handling of the MouseUp.
49   bool ShouldSuppressMouseUp();
50
51  private:
52   friend class MockRenderWidgetHost;
53
54   // TapSuppressionControllerClient implementation.
55   virtual void DropStashedTapDown() OVERRIDE;
56   virtual void ForwardStashedTapDown() OVERRIDE;
57
58   TouchpadTapSuppressionControllerClient* client_;
59   MouseEventWithLatencyInfo stashed_mouse_down_;
60
61   // The core controller of tap suppression.
62   TapSuppressionController controller_;
63
64   DISALLOW_COPY_AND_ASSIGN(TouchpadTapSuppressionController);
65 };
66
67 }  // namespace content
68
69 #endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_