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 ffff0f1da12e42f4475ba7fcd36d22c80f50b82f..622d2f206179bf0886a1ffc7110366ab16e4abbc 100644 |
| --- a/ui/events/base_event_utils.cc |
| +++ b/ui/events/base_event_utils.cc |
| @@ -5,19 +5,47 @@ |
| #include "ui/events/base_event_utils.h" |
| #include "base/atomic_sequence_num.h" |
| +#include "base/command_line.h" |
| #include "base/logging.h" |
| #include "ui/events/event_constants.h" |
| +#include "ui/events/event_switches.h" |
| namespace ui { |
| namespace { |
| #if defined(OS_CHROMEOS) |
| +// Determines whether touch events are enabled or disabled on ChromeOS only. |
| +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. |
| +bool ComputeTouchStatus() { |
| + const base::CommandLine& command_line = |
| + *base::CommandLine::ForCurrentProcess(); |
| + const std::string touch_enabled_switch = |
| + command_line.HasSwitch(switches::kTouchEvents) ? |
| + command_line.GetSwitchValueASCII(switches::kTouchEvents) : |
| + switches::kTouchEventsAuto; |
|
dtapuska
2015/11/18 04:00:55
If no command switch is set; auto mode is enable a
|
| + |
| + if (touch_enabled_switch.empty() || |
| + touch_enabled_switch == switches::kTouchEventsEnabled || |
| + touch_enabled_switch == switches::kTouchEventsAuto) { |
| + return true; |
| + } |
| + |
| + if (touch_enabled_switch == switches::kTouchEventsDisabled) |
| + return false; |
| + |
| + LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch; |
| + return false; |
| +} |
| + |
| +#endif // defined(OS_CHROMEOS) |
| } // namespace |
| @@ -40,5 +68,22 @@ bool IsSystemKeyModifier(int flags) { |
| (EF_ALTGR_DOWN & flags) == 0; |
| } |
| +#if defined(OS_CHROMEOS) |
| + |
| +void SetTouchEventsEnabled(bool enabled) { |
| + touch_events_enabled = enabled; |
| +} |
| + |
| +#endif // defined(OS_CHROMEOS) |
| + |
| +bool AreTouchEventsEnabled() { |
| +#if defined(OS_CHROMEOS) |
| + return touch_events_enabled; |
| +#else |
| + static bool touch_events_enabled = ComputeTouchStatus(); |
| + return touch_events_enabled; |
| +#endif // !defined(OS_CHROMEOS) |
| +} |
| + |
| } // namespace ui |