| 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 enum class TouchEventsStatus { |  | 
| 19   AUTO, |  | 
| 20   DISABLED, |  | 
| 21   ENABLED, |  | 
| 22 }; |  | 
| 23 |  | 
| 24 TouchEventsStatus ComputeTouchFlagStatus() { |  | 
| 25   auto* command_line = base::CommandLine::ForCurrentProcess(); |  | 
| 26   const std::string touch_enabled_switch = |  | 
| 27       command_line->HasSwitch(switches::kTouchEvents) ? |  | 
| 28           command_line->GetSwitchValueASCII(switches::kTouchEvents) : |  | 
| 29           switches::kTouchEventsAuto; |  | 
| 30 |  | 
| 31   if (touch_enabled_switch.empty() || |  | 
| 32       touch_enabled_switch == switches::kTouchEventsEnabled) { |  | 
| 33     return TouchEventsStatus::ENABLED; |  | 
| 34   } |  | 
| 35 |  | 
| 36   if (touch_enabled_switch == switches::kTouchEventsAuto) |  | 
| 37     return TouchEventsStatus::AUTO; |  | 
| 38 |  | 
| 39   DLOG_IF(ERROR, touch_enabled_switch != switches::kTouchEventsDisabled) << |  | 
| 40       "Invalid --touch-events option: " << touch_enabled_switch; |  | 
| 41   return TouchEventsStatus::DISABLED; |  | 
| 42 } |  | 
| 43 |  | 
| 44 }  // namespace |  | 
| 45 |  | 
| 46 bool AreTouchEventsEnabled() { |  | 
| 47   static TouchEventsStatus touch_flag_status = ComputeTouchFlagStatus(); |  | 
| 48 |  | 
| 49   // The #touch-events flag is used to force and simulate the presence or |  | 
| 50   // absence of touch devices. Only if the flag is set to AUTO, we need to check |  | 
| 51   // for the actual availability of touch devices. |  | 
| 52   if (touch_flag_status == TouchEventsStatus::AUTO) |  | 
| 53     return GetTouchScreensAvailability() == TouchScreensAvailability::ENABLED; |  | 
| 54 |  | 
| 55   return touch_flag_status == TouchEventsStatus::ENABLED; |  | 
| 56 } |  | 
| 57 |  | 
| 58 }  // namespace ui |  | 
| 59 |  | 
| OLD | NEW | 
|---|