1 // Copyright 2018 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.
4 
5 #include "ui/events/gesture_detection/gesture_configuration.h"
6 
7 #include "base/command_line.h"
8 #include "base/macros.h"
9 #include "base/memory/singleton.h"
10 #include "ui/events/event_switches.h"
11 
12 namespace ui {
13 namespace {
14 
15 class GestureConfigurationCast : public GestureConfiguration {
16  public:
~GestureConfigurationCast()17   ~GestureConfigurationCast() override {
18   }
19 
GetInstance()20   static GestureConfigurationCast* GetInstance() {
21     return base::Singleton<GestureConfigurationCast>::get();
22   }
23 
24  private:
GestureConfigurationCast()25   GestureConfigurationCast() : GestureConfiguration() {
26     set_double_tap_enabled(false);
27     set_double_tap_timeout_in_ms(semi_long_press_time_in_ms());
28     set_gesture_begin_end_types_enabled(true);
29     set_min_gesture_bounds_length(default_radius());
30     set_min_pinch_update_span_delta(
31         base::CommandLine::ForCurrentProcess()->HasSwitch(
32             switches::kCompensateForUnstablePinchZoom)
33             ? 5
34             : 0);
35     set_velocity_tracker_strategy(VelocityTracker::Strategy::LSQ2_RESTRICTED);
36     set_span_slop(max_touch_move_in_pixels_for_click() * 2);
37     set_swipe_enabled(true);
38     set_two_finger_tap_enabled(true);
39     set_fling_touchpad_tap_suppression_enabled(true);
40     set_fling_touchscreen_tap_suppression_enabled(true);
41     set_max_fling_velocity(5000.0f);
42   }
43 
44   friend struct base::DefaultSingletonTraits<GestureConfigurationCast>;
45   DISALLOW_COPY_AND_ASSIGN(GestureConfigurationCast);
46 };
47 
48 }  // namespace
49 
50 // Create a GestureConfigurationCast singleton instance when using Chromecast.
GetPlatformSpecificInstance()51 GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() {
52   return GestureConfigurationCast::GetInstance();
53 }
54 
55 }  // namespace ui
56