summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/touchscreen_tap_suppression_controller.cc
blob: 001ef1181d52394362133d824ead506066f28470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/renderer_host/touchscreen_tap_suppression_controller.h"

#include "content/browser/renderer_host/gesture_event_filter.h"
#include "content/browser/renderer_host/tap_suppression_controller.h"
#include "ui/base/gestures/gesture_configuration.h"

namespace content {

TouchscreenTapSuppressionController::TouchscreenTapSuppressionController(
    GestureEventFilter* gef)
    : gesture_event_filter_(gef),
      controller_(new TapSuppressionController(this)) {
}

TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {}

void TouchscreenTapSuppressionController::GestureFlingCancel() {
  controller_->GestureFlingCancel();
}

void TouchscreenTapSuppressionController::GestureFlingCancelAck(
    bool processed) {
  controller_->GestureFlingCancelAck(processed);
}

bool TouchscreenTapSuppressionController::ShouldDeferGestureTapDown(
    const GestureEventWithLatencyInfo& event) {
  bool should_defer = controller_->ShouldDeferTapDown();
  if (should_defer)
    stashed_tap_down_ = event;
  return should_defer;
}

bool TouchscreenTapSuppressionController::ShouldSuppressGestureTap() {
  return controller_->ShouldSuppressTapUp();
}

bool TouchscreenTapSuppressionController::ShouldSuppressGestureTapCancel() {
  return controller_->ShouldSuppressTapCancel();
}

int TouchscreenTapSuppressionController::MaxCancelToDownTimeInMs() {
  return ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms();
}

int TouchscreenTapSuppressionController::MaxTapGapTimeInMs() {
  return static_cast<int>(
      ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000);
}

void TouchscreenTapSuppressionController::DropStashedTapDown() {
}

void TouchscreenTapSuppressionController::ForwardStashedTapDownForDeferral() {
  gesture_event_filter_->ForwardGestureEventForDeferral(stashed_tap_down_);
}

void TouchscreenTapSuppressionController::ForwardStashedTapDownSkipDeferral() {
  gesture_event_filter_->ForwardGestureEventSkipDeferral(stashed_tap_down_);
}

}  // namespace content