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 3 // found in the LICENSE file. 4 5 #include "ui/base/touch/touch_enabled.h" 6 #include "base/command_line.h" 7 #include "base/logging.h" 8 #include "ui/base/touch/touch_device.h" 9 #include "ui/base/ui_base_switches.h" 10 11 namespace ui { 12 13 bool AreTouchEventsEnabled() { 14 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 15 const std::string touch_enabled_switch = 16 command_line.HasSwitch(switches::kTouchEvents) ? 17 command_line.GetSwitchValueASCII(switches::kTouchEvents) : 18 switches::kTouchEventsAuto; 19 20 if (touch_enabled_switch.empty() || 21 touch_enabled_switch == switches::kTouchEventsEnabled) 22 return true; 23 if (touch_enabled_switch == switches::kTouchEventsAuto) 24 return IsTouchDevicePresent(); 25 if (touch_enabled_switch != switches::kTouchEventsDisabled) 26 LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch; 27 return false; 28 } 29 30 } // namespace ui 31