1 // Copyright 2014 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 #include "content/browser/renderer_host/input/input_router_config_helper.h"
7 #include "base/command_line.h"
8 #include "content/public/common/content_switches.h"
9 #include "ui/events/gesture_detection/gesture_detector.h"
12 #include "ui/events/gesture_detection/gesture_configuration.h"
13 #elif defined(OS_ANDROID)
14 #include "ui/gfx/android/view_configuration.h"
15 #include "ui/gfx/screen.h"
22 // TODO(jdduke): Consolidate router configuration paths using
23 // ui::GestureConfiguration.
24 GestureEventQueue::Config
GetGestureEventQueueConfig() {
25 GestureEventQueue::Config config
;
26 ui::GestureConfiguration
* gesture_config
=
27 ui::GestureConfiguration::GetInstance();
28 config
.debounce_interval
= base::TimeDelta::FromMilliseconds(
29 gesture_config
->scroll_debounce_interval_in_ms());
31 config
.touchscreen_tap_suppression_config
.enabled
= true;
32 config
.touchscreen_tap_suppression_config
.max_cancel_to_down_time
=
33 base::TimeDelta::FromMilliseconds(
34 gesture_config
->fling_max_cancel_to_down_time_in_ms());
36 config
.touchscreen_tap_suppression_config
.max_tap_gap_time
=
37 base::TimeDelta::FromMilliseconds(
38 gesture_config
->semi_long_press_time_in_ms());
40 config
.touchpad_tap_suppression_config
.enabled
= true;
41 config
.touchpad_tap_suppression_config
.max_cancel_to_down_time
=
42 base::TimeDelta::FromMilliseconds(
43 gesture_config
->fling_max_cancel_to_down_time_in_ms());
45 config
.touchpad_tap_suppression_config
.max_tap_gap_time
=
46 base::TimeDelta::FromMilliseconds(
47 gesture_config
->fling_max_tap_gap_time_in_ms());
52 TouchEventQueue::Config
GetTouchEventQueueConfig() {
53 return TouchEventQueue::Config();
56 #elif defined(OS_ANDROID)
58 // Default time allowance for the touch ack delay before the touch sequence is
59 // cancelled, depending on whether the site has a mobile-friendly viewport.
60 const int kDesktopTouchAckTimeoutDelayMs
= 200;
61 const int kMobileTouchAckTimeoutDelayMs
= 1000;
63 GestureEventQueue::Config
GetGestureEventQueueConfig() {
64 GestureEventQueue::Config config
;
66 config
.touchscreen_tap_suppression_config
.enabled
= true;
67 config
.touchscreen_tap_suppression_config
.max_cancel_to_down_time
=
68 base::TimeDelta::FromMilliseconds(
69 gfx::ViewConfiguration::GetTapTimeoutInMs());
70 config
.touchscreen_tap_suppression_config
.max_tap_gap_time
=
71 base::TimeDelta::FromMilliseconds(
72 gfx::ViewConfiguration::GetLongPressTimeoutInMs());
77 TouchEventQueue::Config
GetTouchEventQueueConfig() {
78 TouchEventQueue::Config config
;
80 config
.desktop_touch_ack_timeout_delay
=
81 base::TimeDelta::FromMilliseconds(kDesktopTouchAckTimeoutDelayMs
);
82 config
.mobile_touch_ack_timeout_delay
=
83 base::TimeDelta::FromMilliseconds(kMobileTouchAckTimeoutDelayMs
);
84 config
.touch_ack_timeout_supported
= true;
91 GestureEventQueue::Config
GetGestureEventQueueConfig() {
92 return GestureEventQueue::Config();
95 TouchEventQueue::Config
GetTouchEventQueueConfig() {
96 return TouchEventQueue::Config();
103 InputRouterImpl::Config
GetInputRouterConfigForPlatform() {
104 InputRouterImpl::Config config
;
105 config
.gesture_config
= GetGestureEventQueueConfig();
106 config
.touch_config
= GetTouchEventQueueConfig();
110 } // namespace content