[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / content / browser / renderer_host / input / input_router_config_helper.cc
blob34c2a19218d79f3ad144e6b61751881e0f3f60b1
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"
11 #if defined(USE_AURA)
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"
16 #endif
18 namespace content {
19 namespace {
21 #if defined(USE_AURA)
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());
49 return config;
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.
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;
79 return config;
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;
89 return config;
92 #else
94 GestureEventQueue::Config GetGestureEventQueueConfig() {
95 return GestureEventQueue::Config();
98 TouchEventQueue::Config GetTouchEventQueueConfig() {
99 return TouchEventQueue::Config();
102 #endif
104 } // namespace
106 InputRouterImpl::Config GetInputRouterConfigForPlatform() {
107 InputRouterImpl::Config config;
108 config.gesture_config = GetGestureEventQueueConfig();
109 config.touch_config = GetTouchEventQueueConfig();
110 return config;
113 } // namespace content