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

Side by Side Diff: ui/events/base_event_utils.cc

Issue 1453813003: Fix a regression in checking the status of the touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ui/events/base_event_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/base_event_utils.h" 5 #include "ui/events/base_event_utils.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #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
10 #include "ui/events/event_constants.h" 11 #include "ui/events/event_constants.h"
11 #include "ui/events/event_switches.h" 12 #include "ui/events/event_switches.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 namespace { 16 namespace {
16 17
17 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
18 // Determines whether touch events are enabled or disabled on ChromeOS only. 19 // Determines whether touch events are enabled or disabled on ChromeOS only.
19 bool touch_events_enabled = true; 20 bool touch_events_enabled = true;
20 21
21 const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN; 22 const int kSystemKeyModifierMask = EF_ALT_DOWN | EF_COMMAND_DOWN;
22 #else 23 #else
23 const int kSystemKeyModifierMask = EF_ALT_DOWN; 24 const int kSystemKeyModifierMask = EF_ALT_DOWN;
25 #endif // defined(OS_CHROMEOS)
24 26
25 // Retrieves the status of the touch screen events from the command line on Non- 27 // Retrieves the status of the touch screen events from the command line.
26 // ChromeOS platforms.
27 bool ComputeTouchStatus() { 28 bool ComputeTouchStatus() {
28 const base::CommandLine& command_line = 29 const base::CommandLine& command_line =
29 *base::CommandLine::ForCurrentProcess(); 30 *base::CommandLine::ForCurrentProcess();
30 const std::string touch_enabled_switch = 31 const std::string touch_enabled_switch =
31 command_line.HasSwitch(switches::kTouchEvents) ? 32 command_line.HasSwitch(switches::kTouchEvents) ?
32 command_line.GetSwitchValueASCII(switches::kTouchEvents) : 33 command_line.GetSwitchValueASCII(switches::kTouchEvents) :
33 switches::kTouchEventsAuto; 34 switches::kTouchEventsAuto;
34 35
35 if (touch_enabled_switch.empty() || 36 if (touch_enabled_switch.empty() ||
36 touch_enabled_switch == switches::kTouchEventsEnabled || 37 touch_enabled_switch == switches::kTouchEventsEnabled) {
37 touch_enabled_switch == switches::kTouchEventsAuto) {
38 return true; 38 return true;
39 } 39 }
40 40
41 if (touch_enabled_switch == switches::kTouchEventsDisabled) 41 if (touch_enabled_switch == switches::kTouchEventsAuto)
42 return false; 42 return IsTouchDevicePresent();
43 43
44 LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch; 44 if (touch_enabled_switch != switches::kTouchEventsDisabled)
45 LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch;
45 return false; 46 return false;
46 } 47 }
47 48
48 #endif // defined(OS_CHROMEOS)
49
50 } // namespace 49 } // namespace
51 50
52 base::StaticAtomicSequenceNumber g_next_event_id; 51 base::StaticAtomicSequenceNumber g_next_event_id;
53 52
54 uint32 GetNextTouchEventId() { 53 uint32 GetNextTouchEventId() {
55 // Set the first touch event ID to 1 because we set id to 0 for other types 54 // Set the first touch event ID to 1 because we set id to 0 for other types
56 // of events. 55 // of events.
57 uint32 id = g_next_event_id.GetNext(); 56 uint32 id = g_next_event_id.GetNext();
58 if (id == 0) 57 if (id == 0)
59 id = g_next_event_id.GetNext(); 58 id = g_next_event_id.GetNext();
(...skipping 10 matching lines...) Expand all
70 69
71 #if defined(OS_CHROMEOS) 70 #if defined(OS_CHROMEOS)
72 71
73 void SetTouchEventsEnabled(bool enabled) { 72 void SetTouchEventsEnabled(bool enabled) {
74 touch_events_enabled = enabled; 73 touch_events_enabled = enabled;
75 } 74 }
76 75
77 #endif // defined(OS_CHROMEOS) 76 #endif // defined(OS_CHROMEOS)
78 77
79 bool AreTouchEventsEnabled() { 78 bool AreTouchEventsEnabled() {
79 static bool touch_status = ComputeTouchStatus();
80
80 #if defined(OS_CHROMEOS) 81 #if defined(OS_CHROMEOS)
81 return touch_events_enabled; 82 return touch_events_enabled && touch_status;
82 #else 83 #else
83 static bool touch_events_enabled = ComputeTouchStatus(); 84 return touch_status;
84 return touch_events_enabled;
85 #endif // !defined(OS_CHROMEOS) 85 #endif // !defined(OS_CHROMEOS)
86 } 86 }
87 87
88 } // namespace ui 88 } // namespace ui
89 89
OLDNEW
« no previous file with comments | « ui/events/base_event_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698