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 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h" 6 7 #include "content/browser/renderer_host/input/gesture_event_filter.h" 8 #include "content/browser/renderer_host/input/tap_suppression_controller.h" 9 #include "ui/base/gestures/gesture_configuration.h" 10 11 namespace content { 12 13 TouchscreenTapSuppressionController::TouchscreenTapSuppressionController( 14 GestureEventFilter* gef) 15 : gesture_event_filter_(gef), 16 controller_(new TapSuppressionController(this)) { 17 } 18 19 TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {} 20 21 void TouchscreenTapSuppressionController::GestureFlingCancel() { 22 controller_->GestureFlingCancel(); 23 } 24 25 void TouchscreenTapSuppressionController::GestureFlingCancelAck( 26 bool processed) { 27 controller_->GestureFlingCancelAck(processed); 28 } 29 30 bool TouchscreenTapSuppressionController::ShouldDeferGestureTapDown( 31 const GestureEventWithLatencyInfo& event) { 32 bool should_defer = controller_->ShouldDeferTapDown(); 33 if (should_defer) 34 stashed_tap_down_ = event; 35 return should_defer; 36 } 37 38 bool TouchscreenTapSuppressionController::ShouldSuppressGestureTap() { 39 return controller_->ShouldSuppressTapUp(); 40 } 41 42 bool TouchscreenTapSuppressionController::ShouldSuppressGestureTapCancel() { 43 return controller_->ShouldSuppressTapCancel(); 44 } 45 46 int TouchscreenTapSuppressionController::MaxCancelToDownTimeInMs() { 47 return ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms(); 48 } 49 50 int TouchscreenTapSuppressionController::MaxTapGapTimeInMs() { 51 return static_cast<int>( 52 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000); 53 } 54 55 void TouchscreenTapSuppressionController::DropStashedTapDown() { 56 } 57 58 void TouchscreenTapSuppressionController::ForwardStashedTapDownForDeferral() { 59 gesture_event_filter_->ForwardGestureEventForDeferral(stashed_tap_down_); 60 } 61 62 void TouchscreenTapSuppressionController::ForwardStashedTapDownSkipDeferral() { 63 gesture_event_filter_->ForwardGestureEventSkipDeferral(stashed_tap_down_); 64 } 65 66 } // namespace content 67