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
60 const int kTouchAckTimeoutDelayMs
= 200;
62 GestureEventQueue::Config
GetGestureEventQueueConfig() {
63 GestureEventQueue::Config config
;
65 config
.touchscreen_tap_suppression_config
.enabled
= true;
66 config
.touchscreen_tap_suppression_config
.max_cancel_to_down_time
=
67 base::TimeDelta::FromMilliseconds(
68 gfx::ViewConfiguration::GetTapTimeoutInMs());
69 config
.touchscreen_tap_suppression_config
.max_tap_gap_time
=
70 base::TimeDelta::FromMilliseconds(
71 gfx::ViewConfiguration::GetLongPressTimeoutInMs());
73 // Android WebView may handle root layer flings itself, which prevents
74 // accurate fling cancel filtering (see |RenderWidgetCompositor::Initialize|).
75 // TODO(jdduke): Remove this exception when the WebView fling architecture
76 // is unified with the rest of Chrome, crbug.com/378984.
77 config
.enable_fling_cancel_filtering
= false;
82 TouchEventQueue::Config
GetTouchEventQueueConfig() {
83 TouchEventQueue::Config config
;
85 config
.touch_ack_timeout_delay
=
86 base::TimeDelta::FromMilliseconds(kTouchAckTimeoutDelayMs
);
87 config
.touch_ack_timeout_supported
= true;
94 GestureEventQueue::Config
GetGestureEventQueueConfig() {
95 return GestureEventQueue::Config();
98 TouchEventQueue::Config
GetTouchEventQueueConfig() {
99 return TouchEventQueue::Config();
106 InputRouterImpl::Config
GetInputRouterConfigForPlatform() {
107 InputRouterImpl::Config config
;
108 config
.gesture_config
= GetGestureEventQueueConfig();
109 config
.touch_config
= GetTouchEventQueueConfig();
113 } // namespace content