Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: ui/base/touch/touch_enabled.cc

Issue 1412623006: Developer Feature: Add Debug Accelerators to Toggle Touchscreen/Touchpad On or Off (CrOS) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix actions.xml. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/touch/touch_enabled.h" 5 #include "ui/base/touch/touch_enabled.h"
6
6 #include "base/command_line.h" 7 #include "base/command_line.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "ui/base/touch/touch_device.h" 9 #include "ui/base/touch/touch_device.h"
9 #include "ui/base/ui_base_switches.h" 10 #include "ui/base/ui_base_switches.h"
10 #include "ui/events/event_switches.h" 11 #include "ui/events/event_switches.h"
11 12
12 namespace ui { 13 namespace ui {
13 14
15 #if defined(OS_CHROMEOS)
16
17 namespace {
18
19 bool g_touch_events_enabled = true;
oshima 2015/10/29 23:38:43 i'll leave this for owner, but I'd avoid using g_
afakhry 2015/10/30 05:18:03 Yes it can be arguable. I meant it's global to thi
oshima 2015/10/31 00:27:49 global and file scoped variable have well defined
afakhry 2015/11/03 18:02:55 Removed the g_ and moved these two functions to ba
20
21 } // namespace
22
23 void SetTouchEventsEnabled(bool enabled) {
24 g_touch_events_enabled = enabled;
25 }
26
27 #endif // defined(OS_CHROMEOS)
28
14 bool AreTouchEventsEnabled() { 29 bool AreTouchEventsEnabled() {
30 #if defined(OS_CHROMEOS)
31 return g_touch_events_enabled;
32 #else
15 const base::CommandLine& command_line = 33 const base::CommandLine& command_line =
16 *base::CommandLine::ForCurrentProcess(); 34 *base::CommandLine::ForCurrentProcess();
17 const std::string touch_enabled_switch = 35 const std::string touch_enabled_switch =
18 command_line.HasSwitch(switches::kTouchEvents) ? 36 command_line.HasSwitch(switches::kTouchEvents) ?
19 command_line.GetSwitchValueASCII(switches::kTouchEvents) : 37 command_line.GetSwitchValueASCII(switches::kTouchEvents) :
20 switches::kTouchEventsAuto; 38 switches::kTouchEventsAuto;
21 39
22 if (touch_enabled_switch.empty() || 40 if (touch_enabled_switch.empty() ||
23 touch_enabled_switch == switches::kTouchEventsEnabled) 41 touch_enabled_switch == switches::kTouchEventsEnabled)
24 return true; 42 return true;
25 if (touch_enabled_switch == switches::kTouchEventsAuto) 43 if (touch_enabled_switch == switches::kTouchEventsAuto)
26 return IsTouchDevicePresent(); 44 return IsTouchDevicePresent();
27 if (touch_enabled_switch != switches::kTouchEventsDisabled) 45 if (touch_enabled_switch != switches::kTouchEventsDisabled)
28 LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch; 46 LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch;
29 return false; 47 return false;
48 #endif // defined(OS_CHROMEOS)
30 } 49 }
31 50
32 } // namespace ui 51 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698