Chromium Code Reviews| Index: ui/events/base_event_utils.cc |
| diff --git a/ui/events/base_event_utils.cc b/ui/events/base_event_utils.cc |
| index 622d2f206179bf0886a1ffc7110366ab16e4abbc..f81c21dcbe90a4acf442e6a9acc89b319e9b71fe 100644 |
| --- a/ui/events/base_event_utils.cc |
| +++ b/ui/events/base_event_utils.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/atomic_sequence_num.h" |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| +#include "ui/base/touch/touch_device.h" |
|
sadrul
2015/11/17 22:32:05
This is in the ui_base target, which depends on th
|
| #include "ui/events/event_constants.h" |
| #include "ui/events/event_switches.h" |
| @@ -21,9 +22,9 @@ bool touch_events_enabled = true; |
| const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN; |
| #else |
| const int kSystemKeyModifierMask = EF_ALT_DOWN; |
| +#endif // defined(OS_CHROMEOS) |
| -// Retrieves the status of the touch screen events from the command line on Non- |
| -// ChromeOS platforms. |
| +// Retrieves the status of the touch screen events from the command line. |
| bool ComputeTouchStatus() { |
| const base::CommandLine& command_line = |
| *base::CommandLine::ForCurrentProcess(); |
| @@ -33,20 +34,18 @@ bool ComputeTouchStatus() { |
| switches::kTouchEventsAuto; |
| if (touch_enabled_switch.empty() || |
| - touch_enabled_switch == switches::kTouchEventsEnabled || |
| - touch_enabled_switch == switches::kTouchEventsAuto) { |
| + touch_enabled_switch == switches::kTouchEventsEnabled) { |
| return true; |
| } |
| - if (touch_enabled_switch == switches::kTouchEventsDisabled) |
| - return false; |
| + if (touch_enabled_switch == switches::kTouchEventsAuto) |
| + return IsTouchDevicePresent(); |
| - LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch; |
| + if (touch_enabled_switch != switches::kTouchEventsDisabled) |
| + LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch; |
| return false; |
| } |
| -#endif // defined(OS_CHROMEOS) |
| - |
| } // namespace |
| base::StaticAtomicSequenceNumber g_next_event_id; |
| @@ -77,11 +76,12 @@ void SetTouchEventsEnabled(bool enabled) { |
| #endif // defined(OS_CHROMEOS) |
| bool AreTouchEventsEnabled() { |
| + static bool touch_status = ComputeTouchStatus(); |
| + |
| #if defined(OS_CHROMEOS) |
| - return touch_events_enabled; |
| + return touch_events_enabled && touch_status; |
| #else |
| - static bool touch_events_enabled = ComputeTouchStatus(); |
| - return touch_events_enabled; |
| + return touch_status; |
| #endif // !defined(OS_CHROMEOS) |
| } |