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_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/renderer_host/input/tap_suppression_controller_client.h"
10 #include "content/common/content_export.h"
11 #include "content/port/browser/event_with_latency_info.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h"
16 class TapSuppressionController;
18 class CONTENT_EXPORT TouchpadTapSuppressionControllerClient {
20 virtual ~TouchpadTapSuppressionControllerClient() {}
21 virtual void SendMouseEventImmediately(
22 const MouseEventWithLatencyInfo& event) = 0;
25 // Controls the suppression of touchpad taps immediately following the dispatch
26 // of a GestureFlingCancel event.
27 class TouchpadTapSuppressionController : public TapSuppressionControllerClient {
29 // The |client| must outlive the TouchpadTapSupressionController.
30 explicit TouchpadTapSuppressionController(
31 TouchpadTapSuppressionControllerClient* client);
32 virtual ~TouchpadTapSuppressionController();
34 // Should be called on arrival of GestureFlingCancel events.
35 void GestureFlingCancel();
37 // Should be called on arrival of ACK for a GestureFlingCancel event.
38 // |processed| is true if the GestureFlingCancel successfully stopped a fling.
39 void GestureFlingCancelAck(bool processed);
41 // Should be called on arrival of MouseDown events. Returns true if the caller
42 // should stop normal handling of the MouseDown. In this case, the caller is
43 // responsible for saving the event for later use, if needed.
44 bool ShouldDeferMouseDown(const MouseEventWithLatencyInfo& event);
46 // Should be called on arrival of MouseUp events. Returns true if the caller
47 // should stop normal handling of the MouseUp.
48 bool ShouldSuppressMouseUp();
51 friend class MockRenderWidgetHost;
53 // TapSuppressionControllerClient implementation.
54 virtual int MaxCancelToDownTimeInMs() OVERRIDE;
55 virtual int MaxTapGapTimeInMs() OVERRIDE;
56 virtual void DropStashedTapDown() OVERRIDE;
57 virtual void ForwardStashedTapDown() OVERRIDE;
59 TouchpadTapSuppressionControllerClient* client_;
60 MouseEventWithLatencyInfo stashed_mouse_down_;
62 // The core controller of tap suppression.
63 scoped_ptr<TapSuppressionController> controller_;
65 DISALLOW_COPY_AND_ASSIGN(TouchpadTapSuppressionController);
68 } // namespace content
70 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_