| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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_TAP_SUPPRESSION_CONTROLLER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_TAP_SUPPRESSION_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/time/time.h" | |
| 9 #include "base/timer/timer.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 class TapSuppressionControllerClient; | |
| 15 | |
| 16 // The core controller for suppression of taps (touchpad or touchscreen) | |
| 17 // immediately following a GestureFlingCancel event (caused by the same tap). | |
| 18 // Only taps of sufficient speed and within a specified time window after a | |
| 19 // GestureFlingCancel are suppressed. | |
| 20 class CONTENT_EXPORT TapSuppressionController { | |
| 21 public: | |
| 22 explicit TapSuppressionController(TapSuppressionControllerClient* client); | |
| 23 virtual ~TapSuppressionController(); | |
| 24 | |
| 25 // Should be called whenever a GestureFlingCancel event is received. | |
| 26 void GestureFlingCancel(); | |
| 27 | |
| 28 // Should be called whenever an ACK for a GestureFlingCancel event is | |
| 29 // received. |processed| is true when the GestureFlingCancel actually stopped | |
| 30 // a fling and therefore should suppress the forwarding of the following tap. | |
| 31 void GestureFlingCancelAck(bool processed); | |
| 32 | |
| 33 // Should be called whenever a tap down (touchpad or touchscreen) is received. | |
| 34 // Returns true if the tap down should be deferred. The caller is responsible | |
| 35 // for keeping the event for later release, if needed. | |
| 36 bool ShouldDeferTapDown(); | |
| 37 | |
| 38 // Should be called whenever a tap up (touchpad or touchscreen) is received. | |
| 39 // Returns true if the tap up should be suppressed. | |
| 40 bool ShouldSuppressTapUp(); | |
| 41 | |
| 42 // Should be called whenever a tap cancel is received. Returns true if the tap | |
| 43 // cancel should be suppressed. | |
| 44 bool ShouldSuppressTapCancel(); | |
| 45 | |
| 46 protected: | |
| 47 virtual base::TimeTicks Now(); | |
| 48 virtual void StartTapDownTimer(const base::TimeDelta& delay); | |
| 49 virtual void StopTapDownTimer(); | |
| 50 void TapDownTimerExpired(); | |
| 51 | |
| 52 private: | |
| 53 friend class MockTapSuppressionController; | |
| 54 | |
| 55 enum State { | |
| 56 NOTHING, | |
| 57 GFC_IN_PROGRESS, | |
| 58 TAP_DOWN_STASHED, | |
| 59 LAST_CANCEL_STOPPED_FLING, | |
| 60 }; | |
| 61 | |
| 62 | |
| 63 TapSuppressionControllerClient* client_; | |
| 64 base::OneShotTimer<TapSuppressionController> tap_down_timer_; | |
| 65 State state_; | |
| 66 | |
| 67 // TODO(rjkroege): During debugging, the event times did not prove reliable. | |
| 68 // Replace the use of base::TimeTicks with an accurate event time when they | |
| 69 // become available post http://crbug.com/119556. | |
| 70 base::TimeTicks fling_cancel_time_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(TapSuppressionController); | |
| 73 }; | |
| 74 | |
| 75 } // namespace content | |
| 76 | |
| 77 #endif // CONTENT_BROWSER_RENDERER_HOST_TAP_SUPPRESSION_CONTROLLER_H_ | |
| OLD | NEW |