OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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/base/touch/touch_enabled.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/logging.h" | |
9 #include "ui/base/touch/touch_device.h" | |
10 #include "ui/base/ui_base_switches.h" | |
11 #include "ui/events/base_event_utils.h" | |
12 #include "ui/events/event_switches.h" | |
13 | |
14 namespace ui { | |
15 | |
16 namespace { | |
17 | |
18 bool ComputeTouchStatus() { | |
19 auto* command_line = base::CommandLine::ForCurrentProcess(); | |
20 const std::string touch_enabled_switch = | |
21 command_line->HasSwitch(switches::kTouchEvents) ? | |
22 command_line->GetSwitchValueASCII(switches::kTouchEvents) : | |
23 switches::kTouchEventsAuto; | |
24 | |
25 if (touch_enabled_switch.empty() || | |
26 touch_enabled_switch == switches::kTouchEventsEnabled) { | |
27 return true; | |
28 } | |
29 | |
30 if (touch_enabled_switch == switches::kTouchEventsAuto) | |
31 return IsTouchDevicePresent(); | |
32 | |
33 DLOG_IF(ERROR, touch_enabled_switch != switches::kTouchEventsDisabled) << | |
34 "Invalid --touch-events option: " << touch_enabled_switch; | |
35 return false; | |
36 } | |
37 | |
38 } // namespace | |
39 | |
40 bool AreTouchEventsEnabled() { | |
41 static bool touch_status = ComputeTouchStatus(); | |
42 | |
43 #if defined(OS_CHROMEOS) && defined(USE_X11) | |
44 return touch_status && GetTouchEventsCrOsX11MasterSwitch(); | |
sadrul
2015/11/18 20:58:46
On a chromeos device build (i.e. when USE_X11 is n
afakhry
2015/11/18 21:03:13
On non-X11 ChromeOS builds (i.e. Ozone builds) we
sadrul
2015/11/18 21:14:30
The various places that call AreTouchEventsEnabled
afakhry
2015/11/18 21:33:04
Valid point! Thanks. I now set the switch on ozone
| |
45 #else | |
46 return touch_status; | |
47 #endif // !defined(OS_CHROMEOS) && defined(USE_X11) | |
48 } | |
49 | |
50 } // namespace ui | |
51 | |
OLD | NEW |