Home | History | Annotate | Download | only in input
      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/touchpad_tap_suppression_controller.h"
      6 
      7 #include "content/browser/renderer_host/input/input_router.h"
      8 #include "content/browser/renderer_host/input/tap_suppression_controller.h"
      9 #include "content/browser/renderer_host/input/tap_suppression_controller_client.h"
     10 #include "ui/base/gestures/gesture_configuration.h"
     11 
     12 namespace content {
     13 
     14 TouchpadTapSuppressionController::TouchpadTapSuppressionController(
     15     InputRouter* input_router)
     16     : input_router_(input_router),
     17       controller_(new TapSuppressionController(this)) {
     18 }
     19 
     20 TouchpadTapSuppressionController::~TouchpadTapSuppressionController() {}
     21 
     22 void TouchpadTapSuppressionController::GestureFlingCancel() {
     23   controller_->GestureFlingCancel();
     24 }
     25 
     26 void TouchpadTapSuppressionController::GestureFlingCancelAck(bool processed) {
     27   controller_->GestureFlingCancelAck(processed);
     28 }
     29 
     30 bool TouchpadTapSuppressionController::ShouldDeferMouseDown(
     31     const MouseEventWithLatencyInfo& event) {
     32   bool should_defer = controller_->ShouldDeferTapDown();
     33   if (should_defer)
     34     stashed_mouse_down_ = event;
     35   return should_defer;
     36 }
     37 
     38 bool TouchpadTapSuppressionController::ShouldSuppressMouseUp() {
     39   return controller_->ShouldSuppressTapUp();
     40 }
     41 
     42 int TouchpadTapSuppressionController::MaxCancelToDownTimeInMs() {
     43   return ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms();
     44 }
     45 
     46 int TouchpadTapSuppressionController::MaxTapGapTimeInMs() {
     47   return ui::GestureConfiguration::fling_max_tap_gap_time_in_ms();
     48 }
     49 
     50 void TouchpadTapSuppressionController::DropStashedTapDown() {
     51 }
     52 
     53 void TouchpadTapSuppressionController::ForwardStashedTapDownForDeferral() {
     54   // Mouse downs are not handled by gesture event filter; so, they are
     55   // immediately forwarded to the renderer.
     56   input_router_->SendMouseEventImmediately(stashed_mouse_down_);
     57 }
     58 
     59 void TouchpadTapSuppressionController::ForwardStashedTapDownSkipDeferral() {
     60   // Mouse downs are not handled by gesture event filter; so, they are
     61   // immediately forwarded to the renderer.
     62   input_router_->SendMouseEventImmediately(stashed_mouse_down_);
     63 }
     64 
     65 }  // namespace content
     66