handoff: Fix the origin so that it correctly reflects the sender.
[chromium-blink-merge.git] / content / browser / renderer_host / input / input_router_config_helper.cc
blob3ed530f9ecab13794479af5aa801e7e8c3b48640
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 return config;
76 TouchEventQueue::Config GetTouchEventQueueConfig() {
77 TouchEventQueue::Config config;
79 config.touch_ack_timeout_delay =
80 base::TimeDelta::FromMilliseconds(kTouchAckTimeoutDelayMs);
81 config.touch_ack_timeout_supported = true;
83 return config;
86 #else
88 GestureEventQueue::Config GetGestureEventQueueConfig() {
89 return GestureEventQueue::Config();
92 TouchEventQueue::Config GetTouchEventQueueConfig() {
93 return TouchEventQueue::Config();
96 #endif
98 } // namespace
100 InputRouterImpl::Config GetInputRouterConfigForPlatform() {
101 InputRouterImpl::Config config;
102 config.gesture_config = GetGestureEventQueueConfig();
103 config.touch_config = GetTouchEventQueueConfig();
104 return config;
107 } // namespace content