Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / ui / events / gesture_detection / gesture_provider_config_helper.cc
blob6b1dad0932b2ba91144d13da529a165cba86941e
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 "ui/events/gesture_detection/gesture_provider_config_helper.h"
7 #include "ui/events/gesture_detection/gesture_configuration.h"
8 #include "ui/gfx/screen.h"
10 namespace ui {
11 namespace {
13 class GenericDesktopGestureConfiguration : public GestureConfiguration {
14 public:
15 // The default GestureConfiguration parameters are already tailored for a
16 // desktop environment (Aura).
17 GenericDesktopGestureConfiguration() {}
18 ~GenericDesktopGestureConfiguration() override {}
21 GestureDetector::Config BuildGestureDetectorConfig(
22 const GestureConfiguration& gesture_config) {
23 GestureDetector::Config config;
24 config.longpress_timeout =
25 base::TimeDelta::FromMilliseconds(gesture_config.long_press_time_in_ms());
26 config.showpress_timeout = base::TimeDelta::FromMilliseconds(
27 gesture_config.show_press_delay_in_ms());
28 config.double_tap_timeout = base::TimeDelta::FromMilliseconds(
29 gesture_config.double_tap_timeout_in_ms());
30 config.touch_slop = gesture_config.max_touch_move_in_pixels_for_click();
31 config.double_tap_slop =
32 gesture_config.max_distance_between_taps_for_double_tap();
33 config.minimum_fling_velocity = gesture_config.min_fling_velocity();
34 config.maximum_fling_velocity = gesture_config.max_fling_velocity();
35 config.swipe_enabled = gesture_config.swipe_enabled();
36 config.minimum_swipe_velocity = gesture_config.min_swipe_velocity();
37 config.maximum_swipe_deviation_angle =
38 gesture_config.max_swipe_deviation_angle();
39 config.two_finger_tap_enabled = gesture_config.two_finger_tap_enabled();
40 config.two_finger_tap_max_separation =
41 gesture_config.max_distance_for_two_finger_tap_in_pixels();
42 config.two_finger_tap_timeout = base::TimeDelta::FromMilliseconds(
43 gesture_config.max_touch_down_duration_for_click_in_ms());
44 config.velocity_tracker_strategy = gesture_config.velocity_tracker_strategy();
45 return config;
48 ScaleGestureDetector::Config BuildScaleGestureDetectorConfig(
49 const GestureConfiguration& gesture_config) {
50 ScaleGestureDetector::Config config;
51 config.span_slop = gesture_config.span_slop();
52 config.min_scaling_touch_major = gesture_config.min_scaling_touch_major();
53 config.min_scaling_span = gesture_config.min_scaling_span_in_pixels();
54 config.min_pinch_update_span_delta =
55 gesture_config.min_pinch_update_span_delta();
56 return config;
59 GestureProvider::Config BuildGestureProviderConfig(
60 const GestureConfiguration& gesture_config) {
61 GestureProvider::Config config;
62 config.gesture_detector_config = BuildGestureDetectorConfig(gesture_config);
63 config.scale_gesture_detector_config =
64 BuildScaleGestureDetectorConfig(gesture_config);
65 config.double_tap_support_for_platform_enabled =
66 gesture_config.double_tap_enabled();
67 config.gesture_begin_end_types_enabled =
68 gesture_config.gesture_begin_end_types_enabled();
69 config.min_gesture_bounds_length = gesture_config.min_gesture_bounds_length();
70 config.max_gesture_bounds_length = gesture_config.max_gesture_bounds_length();
71 return config;
74 } // namespace
76 GestureProvider::Config GetGestureProviderConfig(
77 GestureProviderConfigType type) {
78 GestureProvider::Config config;
79 switch (type) {
80 case GestureProviderConfigType::CURRENT_PLATFORM:
81 config = BuildGestureProviderConfig(*GestureConfiguration::GetInstance());
82 break;
83 case GestureProviderConfigType::GENERIC_DESKTOP:
84 config = BuildGestureProviderConfig(GenericDesktopGestureConfiguration());
85 break;
86 case GestureProviderConfigType::GENERIC_MOBILE:
87 // The default GestureProvider::Config embeds a mobile configuration.
88 break;
91 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
92 // |screen| is sometimes NULL during tests.
93 if (screen)
94 config.display = screen->GetPrimaryDisplay();
96 return config;
99 } // namespace ui