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

Unified Diff: ui/events/base_event_utils.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: Nits Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..c7d837798387a7290637b330a4c4f3a402b5894e 100644
--- a/ui/events/base_event_utils.cc
+++ b/ui/events/base_event_utils.cc
@@ -5,19 +5,54 @@
#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 {
+// Determines whether touch events are enabled or disabled.
+bool touch_events_enabled = true;
+
#if defined(OS_CHROMEOS)
const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN;
#else
const int kSystemKeyModifierMask = EF_ALT_DOWN;
-#endif // defined(OS_CHROMEOS)
+// Whether the status of the touch screen events has been retrieved and cached
+// from the command line on non-ChromeOS platforms.
+bool is_touch_events_status_cached = false;
+
+// Retrieves the status of the touch screen events from the command line on Non-
+// ChromeOS platforms.
+void UpdateAndCacheTouchStatus() {
+ if (is_touch_events_status_cached)
+ return;
+
+ 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;
+
+ if (touch_enabled_switch.empty() ||
+ touch_enabled_switch == switches::kTouchEventsEnabled ||
+ touch_enabled_switch == switches::kTouchEventsAuto) {
+ touch_events_enabled = true;
+ } else if (touch_enabled_switch == switches::kTouchEventsDisabled) {
+ touch_events_enabled = false;
+ } else {
+ LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch;
+ }
+
+ is_touch_events_status_cached = true;
+}
+
+#endif // defined(OS_CHROMEOS)
} // namespace
@@ -40,5 +75,21 @@ 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)
+ UpdateAndCacheTouchStatus();
sadrul 2015/11/09 21:38:53 You can get rid of is_touch_events_status_cached.
afakhry 2015/11/10 00:37:11 Done! Thanks for the useful suggestion! :)
+#endif // !defined(OS_CHROMEOS)
+
+ return touch_events_enabled;
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698