Add ICU message format support
[chromium-blink-merge.git] / content / browser / renderer_host / input / input_router_config_helper.cc
blob24a4354a60f2a2cc1208e448f63433e964c6e6d7
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_configuration.h"
10 #include "ui/events/gesture_detection/gesture_detector.h"
12 namespace content {
13 namespace {
15 // Default time allowance for the touch ack delay before the touch sequence is
16 // cancelled, depending on whether the site has a mobile-friendly viewport.
17 // Note that these constants are effective only when the timeout is supported.
18 const int kDesktopTouchAckTimeoutDelayMs = 200;
19 const int kMobileTouchAckTimeoutDelayMs = 1000;
21 TouchEventQueue::Config GetTouchEventQueueConfig() {
22 TouchEventQueue::Config config;
24 config.desktop_touch_ack_timeout_delay =
25 base::TimeDelta::FromMilliseconds(kDesktopTouchAckTimeoutDelayMs);
26 config.mobile_touch_ack_timeout_delay =
27 base::TimeDelta::FromMilliseconds(kMobileTouchAckTimeoutDelayMs);
29 #if defined(OS_ANDROID)
30 // For historical reasons only Android enables the touch ack timeout.
31 config.touch_ack_timeout_supported = true;
32 #else
33 config.touch_ack_timeout_supported = false;
34 #endif
36 return config;
39 GestureEventQueue::Config GetGestureEventQueueConfig() {
40 GestureEventQueue::Config config;
41 ui::GestureConfiguration* gesture_config =
42 ui::GestureConfiguration::GetInstance();
43 config.debounce_interval = base::TimeDelta::FromMilliseconds(
44 gesture_config->scroll_debounce_interval_in_ms());
46 config.touchscreen_tap_suppression_config.enabled =
47 gesture_config->fling_touchscreen_tap_suppression_enabled();
48 config.touchscreen_tap_suppression_config.max_cancel_to_down_time =
49 base::TimeDelta::FromMilliseconds(
50 gesture_config->fling_max_cancel_to_down_time_in_ms());
51 config.touchscreen_tap_suppression_config.max_tap_gap_time =
52 base::TimeDelta::FromMilliseconds(
53 gesture_config->long_press_time_in_ms());
55 config.touchpad_tap_suppression_config.enabled =
56 gesture_config->fling_touchpad_tap_suppression_enabled();
57 config.touchpad_tap_suppression_config.max_cancel_to_down_time =
58 base::TimeDelta::FromMilliseconds(
59 gesture_config->fling_max_cancel_to_down_time_in_ms());
60 config.touchpad_tap_suppression_config.max_tap_gap_time =
61 base::TimeDelta::FromMilliseconds(
62 gesture_config->fling_max_tap_gap_time_in_ms());
64 return config;
67 } // namespace
69 InputRouterImpl::Config GetInputRouterConfigForPlatform() {
70 InputRouterImpl::Config config;
71 config.gesture_config = GetGestureEventQueueConfig();
72 config.touch_config = GetTouchEventQueueConfig();
73 return config;
76 } // namespace content