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

Side by Side Diff: ui/chromeos/events/event_rewriter.cc

Issue 2724913002: Move chromeos::EventRewriter to //ui/chromeos/events (Closed)
Patch Set: Fix build issue Created 3 years, 9 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/events/event_rewriter.h" 5 #include "ui/chromeos/events/event_rewriter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/sys_info.h" 17 #include "base/sys_info.h"
17 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
18 #include "chrome/browser/extensions/extension_commands_global_registry.h"
19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
22 #include "chrome/common/pref_names.h"
23 #include "chromeos/chromeos_switches.h" 18 #include "chromeos/chromeos_switches.h"
24 #include "components/prefs/pref_service.h"
25 #include "components/user_manager/user_manager.h"
26 #include "ui/base/ime/chromeos/ime_keyboard.h" 19 #include "ui/base/ime/chromeos/ime_keyboard.h"
27 #include "ui/base/ime/chromeos/input_method_manager.h" 20 #include "ui/base/ime/chromeos/input_method_manager.h"
21 #include "ui/chromeos/events/pref_names.h"
28 #include "ui/events/devices/input_device_manager.h" 22 #include "ui/events/devices/input_device_manager.h"
29 #include "ui/events/event.h" 23 #include "ui/events/event.h"
30 #include "ui/events/event_utils.h" 24 #include "ui/events/event_utils.h"
31 #include "ui/events/keycodes/dom/dom_code.h" 25 #include "ui/events/keycodes/dom/dom_code.h"
32 #include "ui/events/keycodes/dom/dom_key.h" 26 #include "ui/events/keycodes/dom/dom_key.h"
33 #include "ui/events/keycodes/dom/keycode_converter.h" 27 #include "ui/events/keycodes/dom/keycode_converter.h"
34 #include "ui/events/keycodes/keyboard_code_conversion.h" 28 #include "ui/events/keycodes/keyboard_code_conversion.h"
35 29
36 #if defined(USE_X11) 30 #if defined(USE_X11)
31 #include <X11/Xlib.h>
37 #include <X11/extensions/XInput2.h> 32 #include <X11/extensions/XInput2.h>
38 #include <X11/Xlib.h>
39 33
40 // Get rid of macros from Xlib.h that conflicts with other parts of the code. 34 // Get rid of macros from Xlib.h that conflicts with other parts of the code.
41 #undef RootWindow 35 #undef RootWindow
42 #undef Status 36 #undef Status
43 37
44 #include "ui/base/x/x11_util.h" 38 #include "ui/base/x/x11_util.h"
45 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 39 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
46 #endif 40 #endif
47 41
42 namespace ui {
48 namespace chromeos { 43 namespace chromeos {
49 44
50 namespace { 45 namespace {
51 46
52 // Hotrod controller vendor/product ids. 47 // Hotrod controller vendor/product ids.
53 const int kHotrodRemoteVendorId = 0x0471; 48 const int kHotrodRemoteVendorId = 0x0471;
54 const int kHotrodRemoteProductId = 0x21cc; 49 const int kHotrodRemoteProductId = 0x21cc;
55 const int kUnknownVendorId = -1; 50 const int kUnknownVendorId = -1;
56 const int kUnknownProductId = -1; 51 const int kUnknownProductId = -1;
57 52
(...skipping 15 matching lines...) Expand all
73 // it likewise uses |GetRemappedKey()| to find the properties of the 68 // it likewise uses |GetRemappedKey()| to find the properties of the
74 // user preference target key, and replaces the flag accordingly. 69 // user preference target key, and replaces the flag accordingly.
75 const struct ModifierRemapping { 70 const struct ModifierRemapping {
76 int flag; 71 int flag;
77 int remap_to; 72 int remap_to;
78 const char* pref_name; 73 const char* pref_name;
79 EventRewriter::MutableKeyState result; 74 EventRewriter::MutableKeyState result;
80 } kModifierRemappings[] = { 75 } kModifierRemappings[] = {
81 {// kModifierRemappingCtrl references this entry by index. 76 {// kModifierRemappingCtrl references this entry by index.
82 ui::EF_CONTROL_DOWN, 77 ui::EF_CONTROL_DOWN,
83 input_method::kControlKey, 78 ::chromeos::input_method::kControlKey,
84 prefs::kLanguageRemapControlKeyTo, 79 prefs::kLanguageRemapControlKeyTo,
85 {ui::EF_CONTROL_DOWN, ui::DomCode::CONTROL_LEFT, ui::DomKey::CONTROL, 80 {ui::EF_CONTROL_DOWN, ui::DomCode::CONTROL_LEFT, ui::DomKey::CONTROL,
86 ui::VKEY_CONTROL}}, 81 ui::VKEY_CONTROL}},
87 {// kModifierRemappingNeoMod3 references this entry by index. 82 {// kModifierRemappingNeoMod3 references this entry by index.
88 ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, 83 ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN,
89 input_method::kNumModifierKeys, 84 ::chromeos::input_method::kNumModifierKeys,
90 nullptr, 85 nullptr,
91 {ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, ui::DomCode::CAPS_LOCK, 86 {ui::EF_MOD3_DOWN | ui::EF_ALTGR_DOWN, ui::DomCode::CAPS_LOCK,
92 ui::DomKey::ALT_GRAPH, ui::VKEY_ALTGR}}, 87 ui::DomKey::ALT_GRAPH, ui::VKEY_ALTGR}},
93 {ui::EF_COMMAND_DOWN, 88 {ui::EF_COMMAND_DOWN,
94 input_method::kSearchKey, 89 ::chromeos::input_method::kSearchKey,
95 prefs::kLanguageRemapSearchKeyTo, 90 prefs::kLanguageRemapSearchKeyTo,
96 {ui::EF_COMMAND_DOWN, ui::DomCode::META_LEFT, ui::DomKey::META, 91 {ui::EF_COMMAND_DOWN, ui::DomCode::META_LEFT, ui::DomKey::META,
97 ui::VKEY_LWIN}}, 92 ui::VKEY_LWIN}},
98 {ui::EF_ALT_DOWN, 93 {ui::EF_ALT_DOWN,
99 input_method::kAltKey, 94 ::chromeos::input_method::kAltKey,
100 prefs::kLanguageRemapAltKeyTo, 95 prefs::kLanguageRemapAltKeyTo,
101 {ui::EF_ALT_DOWN, ui::DomCode::ALT_LEFT, ui::DomKey::ALT, ui::VKEY_MENU}}, 96 {ui::EF_ALT_DOWN, ui::DomCode::ALT_LEFT, ui::DomKey::ALT, ui::VKEY_MENU}},
102 {ui::EF_NONE, 97 {ui::EF_NONE,
103 input_method::kVoidKey, 98 ::chromeos::input_method::kVoidKey,
104 nullptr, 99 nullptr,
105 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::NONE, ui::VKEY_UNKNOWN}}, 100 {ui::EF_NONE, ui::DomCode::NONE, ui::DomKey::NONE, ui::VKEY_UNKNOWN}},
106 {ui::EF_MOD3_DOWN, 101 {ui::EF_MOD3_DOWN,
107 input_method::kCapsLockKey, 102 ::chromeos::input_method::kCapsLockKey,
108 prefs::kLanguageRemapCapsLockKeyTo, 103 prefs::kLanguageRemapCapsLockKeyTo,
109 {ui::EF_MOD3_DOWN, ui::DomCode::CAPS_LOCK, ui::DomKey::CAPS_LOCK, 104 {ui::EF_MOD3_DOWN, ui::DomCode::CAPS_LOCK, ui::DomKey::CAPS_LOCK,
110 ui::VKEY_CAPITAL}}, 105 ui::VKEY_CAPITAL}},
111 {ui::EF_NONE, 106 {ui::EF_NONE,
112 input_method::kEscapeKey, 107 ::chromeos::input_method::kEscapeKey,
113 prefs::kLanguageRemapEscapeKeyTo, 108 prefs::kLanguageRemapEscapeKeyTo,
114 {ui::EF_NONE, ui::DomCode::ESCAPE, ui::DomKey::ESCAPE, ui::VKEY_ESCAPE}}, 109 {ui::EF_NONE, ui::DomCode::ESCAPE, ui::DomKey::ESCAPE, ui::VKEY_ESCAPE}},
115 {ui::EF_NONE, 110 {ui::EF_NONE,
116 input_method::kBackspaceKey, 111 ::chromeos::input_method::kBackspaceKey,
117 prefs::kLanguageRemapBackspaceKeyTo, 112 prefs::kLanguageRemapBackspaceKeyTo,
118 {ui::EF_NONE, ui::DomCode::BACKSPACE, ui::DomKey::BACKSPACE, 113 {ui::EF_NONE, ui::DomCode::BACKSPACE, ui::DomKey::BACKSPACE,
119 ui::VKEY_BACK}}, 114 ui::VKEY_BACK}},
120 {ui::EF_NONE, 115 {ui::EF_NONE,
121 input_method::kNumModifierKeys, 116 ::chromeos::input_method::kNumModifierKeys,
122 prefs::kLanguageRemapDiamondKeyTo, 117 prefs::kLanguageRemapDiamondKeyTo,
123 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}}; 118 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}};
124 119
125 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0]; 120 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0];
126 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1]; 121 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1];
127 122
128 // Gets a remapped key for |pref_name| key. For example, to find out which 123 // Gets a remapped key for |pref_name| key. For example, to find out which
129 // key Search is currently remapped to, call the function with 124 // key Search is currently remapped to, call the function with
130 // prefs::kLanguageRemapSearchKeyTo. 125 // prefs::kLanguageRemapSearchKeyTo.
131 const ModifierRemapping* GetRemappedKey(const std::string& pref_name, 126 const ModifierRemapping* GetRemappedKey(const std::string& pref_name,
132 const PrefService& pref_service) { 127 EventRewriter::Delegate* delegate) {
128 if (!delegate)
129 return nullptr;
130
133 int value = -1; 131 int value = -1;
134 // If we're at the login screen, try to get the pref from the global prefs 132 if (!delegate->GetKeyboardRemappedPrefValue(pref_name, &value))
135 // dictionary. 133 return nullptr;
136 if (!LoginDisplayHost::default_host() ||
137 !LoginDisplayHost::default_host()
138 ->GetOobeUI()
139 ->signin_screen_handler()
140 ->GetKeyboardRemappedPrefValue(pref_name, &value)) {
141 if (!pref_service.FindPreference(pref_name))
142 return nullptr;
143 value = pref_service.GetInteger(pref_name);
144 }
145 134
146 for (size_t i = 0; i < arraysize(kModifierRemappings); ++i) { 135 for (size_t i = 0; i < arraysize(kModifierRemappings); ++i) {
147 if (value == kModifierRemappings[i].remap_to) 136 if (value == kModifierRemappings[i].remap_to)
148 return &kModifierRemappings[i]; 137 return &kModifierRemappings[i];
149 } 138 }
150 return nullptr; 139 return nullptr;
151 } 140 }
152 141
153 bool HasDiamondKey() { 142 bool HasDiamondKey() {
154 return base::CommandLine::ForCurrentProcess()->HasSwitch( 143 return base::CommandLine::ForCurrentProcess()->HasSwitch(
155 chromeos::switches::kHasChromeOSDiamondKey); 144 ::chromeos::switches::kHasChromeOSDiamondKey);
156 } 145 }
157 146
158 bool IsISOLevel5ShiftUsedByCurrentInputMethod() { 147 bool IsISOLevel5ShiftUsedByCurrentInputMethod() {
159 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, 148 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask,
160 // it's not possible to make both features work. For now, we don't remap 149 // it's not possible to make both features work. For now, we don't remap
161 // Mod3Mask when Neo2 is in use. 150 // Mod3Mask when Neo2 is in use.
162 // TODO(yusukes): Remove the restriction. 151 // TODO(yusukes): Remove the restriction.
163 input_method::InputMethodManager* manager = 152 ::chromeos::input_method::InputMethodManager* manager =
164 input_method::InputMethodManager::Get(); 153 ::chromeos::input_method::InputMethodManager::Get();
165 return manager->IsISOLevel5ShiftUsedByCurrentInputMethod(); 154 return manager->IsISOLevel5ShiftUsedByCurrentInputMethod();
166 } 155 }
167 156
168 bool IsExtensionCommandRegistered(ui::KeyboardCode key_code, int flags) {
169 // Some keyboard events for ChromeOS get rewritten, such as:
170 // Search+Shift+Left gets converted to Shift+Home (BeginDocument).
171 // This doesn't make sense if the user has assigned that shortcut
172 // to an extension. Because:
173 // 1) The extension would, upon seeing a request for Ctrl+Shift+Home have
174 // to register for Shift+Home, instead.
175 // 2) The conversion is unnecessary, because Shift+Home (BeginDocument) isn't
176 // going to be executed.
177 // Therefore, we skip converting the accelerator if an extension has
178 // registered for this shortcut.
179 Profile* profile = ProfileManager::GetActiveUserProfile();
180 if (!profile || !extensions::ExtensionCommandsGlobalRegistry::Get(profile))
181 return false;
182
183 int modifiers = flags & (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN |
184 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN);
185 ui::Accelerator accelerator(key_code, modifiers);
186 return extensions::ExtensionCommandsGlobalRegistry::Get(profile)
187 ->IsRegistered(accelerator);
188 }
189
190 EventRewriter::DeviceType GetDeviceType(const std::string& device_name, 157 EventRewriter::DeviceType GetDeviceType(const std::string& device_name,
191 int vendor_id, 158 int vendor_id,
192 int product_id) { 159 int product_id) {
193 if (vendor_id == kHotrodRemoteVendorId && 160 if (vendor_id == kHotrodRemoteVendorId &&
194 product_id == kHotrodRemoteProductId) { 161 product_id == kHotrodRemoteProductId) {
195 return EventRewriter::kDeviceHotrodRemote; 162 return EventRewriter::kDeviceHotrodRemote;
196 } 163 }
197 164
198 if (base::LowerCaseEqualsASCII(device_name, "virtual core keyboard")) 165 if (base::LowerCaseEqualsASCII(device_name, "virtual core keyboard"))
199 return EventRewriter::kDeviceVirtualCoreKeyboard; 166 return EventRewriter::kDeviceVirtualCoreKeyboard;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 case ui::DomCode::META_RIGHT: 262 case ui::DomCode::META_RIGHT:
296 return right ? ui::DomCode::META_RIGHT : ui::DomCode::META_LEFT; 263 return right ? ui::DomCode::META_RIGHT : ui::DomCode::META_LEFT;
297 default: 264 default:
298 break; 265 break;
299 } 266 }
300 return code; 267 return code;
301 } 268 }
302 269
303 } // namespace 270 } // namespace
304 271
305 EventRewriter::EventRewriter(ui::EventRewriter* sticky_keys_controller) 272 EventRewriter::EventRewriter(Delegate* delegate,
273 ui::EventRewriter* sticky_keys_controller)
306 : last_keyboard_device_id_(ui::ED_UNKNOWN_DEVICE), 274 : last_keyboard_device_id_(ui::ED_UNKNOWN_DEVICE),
307 ime_keyboard_for_testing_(NULL), 275 ime_keyboard_for_testing_(NULL),
sadrul 2017/03/14 01:15:41 While you are here: nullptr?
Peng 2017/03/14 16:06:52 Done. And replace all NULL with nullptr.
308 pref_service_for_testing_(NULL), 276 delegate_(delegate),
309 sticky_keys_controller_(sticky_keys_controller), 277 sticky_keys_controller_(sticky_keys_controller),
310 pressed_modifier_latches_(ui::EF_NONE), 278 pressed_modifier_latches_(ui::EF_NONE),
311 latched_modifier_latches_(ui::EF_NONE), 279 latched_modifier_latches_(ui::EF_NONE),
312 used_modifier_latches_(ui::EF_NONE) {} 280 used_modifier_latches_(ui::EF_NONE) {}
313 281
314 EventRewriter::~EventRewriter() {} 282 EventRewriter::~EventRewriter() {}
315 283
316 EventRewriter::DeviceType EventRewriter::KeyboardDeviceAddedForTesting( 284 EventRewriter::DeviceType EventRewriter::KeyboardDeviceAddedForTesting(
317 int device_id, 285 int device_id,
318 const std::string& device_name) { 286 const std::string& device_name) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 361
394 // Ignore virtual Xorg keyboard (magic that generates key repeat 362 // Ignore virtual Xorg keyboard (magic that generates key repeat
395 // events). Pretend that the previous real keyboard is the one that is still 363 // events). Pretend that the previous real keyboard is the one that is still
396 // in use. 364 // in use.
397 if (type == kDeviceVirtualCoreKeyboard) 365 if (type == kDeviceVirtualCoreKeyboard)
398 return; 366 return;
399 367
400 last_keyboard_device_id_ = device_id; 368 last_keyboard_device_id_ = device_id;
401 } 369 }
402 370
403 const PrefService* EventRewriter::GetPrefService() const {
404 if (pref_service_for_testing_)
405 return pref_service_for_testing_;
406 Profile* profile = ProfileManager::GetActiveUserProfile();
407 return profile ? profile->GetPrefs() : NULL;
408 }
409
410 bool EventRewriter::IsAppleKeyboard() const { 371 bool EventRewriter::IsAppleKeyboard() const {
411 return IsLastKeyboardOfType(kDeviceAppleKeyboard); 372 return IsLastKeyboardOfType(kDeviceAppleKeyboard);
412 } 373 }
413 374
414 bool EventRewriter::IsHotrodRemote() const { 375 bool EventRewriter::IsHotrodRemote() const {
415 return IsLastKeyboardOfType(kDeviceHotrodRemote); 376 return IsLastKeyboardOfType(kDeviceHotrodRemote);
416 } 377 }
417 378
418 bool EventRewriter::IsLastKeyboardOfType(DeviceType device_type) const { 379 bool EventRewriter::IsLastKeyboardOfType(DeviceType device_type) const {
419 if (last_keyboard_device_id_ == ui::ED_UNKNOWN_DEVICE) 380 if (last_keyboard_device_id_ == ui::ED_UNKNOWN_DEVICE)
420 return false; 381 return false;
421 382
422 // Check which device generated |event|. 383 // Check which device generated |event|.
423 std::map<int, DeviceType>::const_iterator iter = 384 std::map<int, DeviceType>::const_iterator iter =
424 device_id_to_type_.find(last_keyboard_device_id_); 385 device_id_to_type_.find(last_keyboard_device_id_);
425 if (iter == device_id_to_type_.end()) { 386 if (iter == device_id_to_type_.end()) {
426 LOG(ERROR) << "Device ID " << last_keyboard_device_id_ << " is unknown."; 387 LOG(ERROR) << "Device ID " << last_keyboard_device_id_ << " is unknown.";
427 return false; 388 return false;
428 } 389 }
429 390
430 const DeviceType type = iter->second; 391 const DeviceType type = iter->second;
431 return type == device_type; 392 return type == device_type;
432 } 393 }
433 394
434 bool EventRewriter::TopRowKeysAreFunctionKeys(const ui::KeyEvent& event) const { 395 int EventRewriter::GetRemappedModifierMasks(const ui::Event& event,
435 const PrefService* prefs = GetPrefService();
436 return prefs && prefs->FindPreference(prefs::kLanguageSendFunctionKeys) &&
437 prefs->GetBoolean(prefs::kLanguageSendFunctionKeys);
438 }
439
440 int EventRewriter::GetRemappedModifierMasks(const PrefService& pref_service,
441 const ui::Event& event,
442 int original_flags) const { 396 int original_flags) const {
443 int unmodified_flags = original_flags; 397 int unmodified_flags = original_flags;
444 int rewritten_flags = pressed_modifier_latches_ | latched_modifier_latches_; 398 int rewritten_flags = pressed_modifier_latches_ | latched_modifier_latches_;
445 for (size_t i = 0; unmodified_flags && (i < arraysize(kModifierRemappings)); 399 for (size_t i = 0; unmodified_flags && (i < arraysize(kModifierRemappings));
446 ++i) { 400 ++i) {
447 const ModifierRemapping* remapped_key = NULL; 401 const ModifierRemapping* remapped_key = NULL;
448 if (!(unmodified_flags & kModifierRemappings[i].flag)) 402 if (!(unmodified_flags & kModifierRemappings[i].flag))
449 continue; 403 continue;
450 switch (kModifierRemappings[i].flag) { 404 switch (kModifierRemappings[i].flag) {
451 case ui::EF_COMMAND_DOWN: 405 case ui::EF_COMMAND_DOWN:
(...skipping 18 matching lines...) Expand all
470 if ((original_flags & ui::EF_ALTGR_DOWN) && 424 if ((original_flags & ui::EF_ALTGR_DOWN) &&
471 IsISOLevel5ShiftUsedByCurrentInputMethod()) { 425 IsISOLevel5ShiftUsedByCurrentInputMethod()) {
472 remapped_key = kModifierRemappingNeoMod3; 426 remapped_key = kModifierRemappingNeoMod3;
473 } 427 }
474 break; 428 break;
475 default: 429 default:
476 break; 430 break;
477 } 431 }
478 if (!remapped_key && kModifierRemappings[i].pref_name) { 432 if (!remapped_key && kModifierRemappings[i].pref_name) {
479 remapped_key = 433 remapped_key =
480 GetRemappedKey(kModifierRemappings[i].pref_name, pref_service); 434 GetRemappedKey(kModifierRemappings[i].pref_name, delegate_);
481 } 435 }
482 if (remapped_key) { 436 if (remapped_key) {
483 unmodified_flags &= ~kModifierRemappings[i].flag; 437 unmodified_flags &= ~kModifierRemappings[i].flag;
484 rewritten_flags |= remapped_key->flag; 438 rewritten_flags |= remapped_key->flag;
485 } 439 }
486 } 440 }
487 return rewritten_flags | unmodified_flags; 441 return rewritten_flags | unmodified_flags;
488 } 442 }
489 443
490 ui::EventRewriteStatus EventRewriter::RewriteKeyEvent( 444 ui::EventRewriteStatus EventRewriter::RewriteKeyEvent(
491 const ui::KeyEvent& key_event, 445 const ui::KeyEvent& key_event,
492 std::unique_ptr<ui::Event>* rewritten_event) { 446 std::unique_ptr<ui::Event>* rewritten_event) {
493 if (IsExtensionCommandRegistered(key_event.key_code(), key_event.flags())) 447 if (delegate_ && delegate_->IsExtensionCommandRegistered(key_event.key_code(),
448 key_event.flags()))
494 return ui::EVENT_REWRITE_CONTINUE; 449 return ui::EVENT_REWRITE_CONTINUE;
495 if (key_event.source_device_id() != ui::ED_UNKNOWN_DEVICE) 450 if (key_event.source_device_id() != ui::ED_UNKNOWN_DEVICE)
496 DeviceKeyPressedOrReleased(key_event.source_device_id()); 451 DeviceKeyPressedOrReleased(key_event.source_device_id());
497 452
498 // Drop repeated keys from Hotrod remote. 453 // Drop repeated keys from Hotrod remote.
499 if ((key_event.flags() & ui::EF_IS_REPEAT) && 454 if ((key_event.flags() & ui::EF_IS_REPEAT) &&
500 (key_event.type() == ui::ET_KEY_PRESSED) && IsHotrodRemote() && 455 (key_event.type() == ui::ET_KEY_PRESSED) && IsHotrodRemote() &&
501 key_event.key_code() != ui::VKEY_BACK) { 456 key_event.key_code() != ui::VKEY_BACK) {
502 return ui::EVENT_REWRITE_DISCARD; 457 return ui::EVENT_REWRITE_DISCARD;
503 } 458 }
(...skipping 19 matching lines...) Expand all
523 tmp_event.set_key_code(state.key_code); 478 tmp_event.set_key_code(state.key_code);
524 tmp_event.set_flags(state.flags); 479 tmp_event.set_flags(state.flags);
525 std::unique_ptr<ui::Event> output_event; 480 std::unique_ptr<ui::Event> output_event;
526 status = sticky_keys_controller_->RewriteEvent(tmp_event, &output_event); 481 status = sticky_keys_controller_->RewriteEvent(tmp_event, &output_event);
527 if (status == ui::EVENT_REWRITE_REWRITTEN || 482 if (status == ui::EVENT_REWRITE_REWRITTEN ||
528 status == ui::EVENT_REWRITE_DISPATCH_ANOTHER) 483 status == ui::EVENT_REWRITE_DISPATCH_ANOTHER)
529 state.flags = output_event->flags(); 484 state.flags = output_event->flags();
530 if (status == ui::EVENT_REWRITE_DISCARD) 485 if (status == ui::EVENT_REWRITE_DISCARD)
531 return ui::EVENT_REWRITE_DISCARD; 486 return ui::EVENT_REWRITE_DISCARD;
532 is_sticky_key_extension_command = 487 is_sticky_key_extension_command =
533 IsExtensionCommandRegistered(state.key_code, state.flags); 488 delegate_ &&
489 delegate_->IsExtensionCommandRegistered(state.key_code, state.flags);
534 } 490 }
535 491
536 // If flags have changed, this may change the interpretation of the key, 492 // If flags have changed, this may change the interpretation of the key,
537 // so reapply layout. 493 // so reapply layout.
538 if (state.flags != key_event.flags()) 494 if (state.flags != key_event.flags())
539 SetMeaningForLayout(key_event.type(), &state); 495 SetMeaningForLayout(key_event.type(), &state);
540 496
541 // If sticky key rewrites the event, and it matches an extension command, do 497 // If sticky key rewrites the event, and it matches an extension command, do
542 // not further rewrite the event since it won't match the extension command 498 // not further rewrite the event since it won't match the extension command
543 // thereafter. 499 // thereafter.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 ui::UpdateX11EventForFlags(rewritten_event->get()); 634 ui::UpdateX11EventForFlags(rewritten_event->get());
679 #endif 635 #endif
680 return status; 636 return status;
681 } 637 }
682 638
683 bool EventRewriter::RewriteModifierKeys(const ui::KeyEvent& key_event, 639 bool EventRewriter::RewriteModifierKeys(const ui::KeyEvent& key_event,
684 MutableKeyState* state) { 640 MutableKeyState* state) {
685 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || 641 DCHECK(key_event.type() == ui::ET_KEY_PRESSED ||
686 key_event.type() == ui::ET_KEY_RELEASED); 642 key_event.type() == ui::ET_KEY_RELEASED);
687 643
688 // Do nothing if we have just logged in as guest but have not restarted chrome 644 if (!delegate_ || !delegate_->RewriteModifierKeys())
689 // process yet (so we are still on the login screen). In this situations we
690 // have no user profile so can not do anything useful.
691 // Note that currently, unlike other accounts, when user logs in as guest, we
692 // restart chrome process. In future this is to be changed.
693 // TODO(glotov): remove the following condition when we do not restart chrome
694 // when user logs in as guest.
695 // TODO(kpschoedel): check whether this is still necessary.
696 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() &&
697 LoginDisplayHost::default_host())
698 return false;
699
700 const PrefService* pref_service = GetPrefService();
701 if (!pref_service)
702 return false; 645 return false;
703 646
704 // Preserve a copy of the original before rewriting |state| based on 647 // Preserve a copy of the original before rewriting |state| based on
705 // user preferences, device configuration, and certain IME properties. 648 // user preferences, device configuration, and certain IME properties.
706 MutableKeyState incoming = *state; 649 MutableKeyState incoming = *state;
707 state->flags = ui::EF_NONE; 650 state->flags = ui::EF_NONE;
708 int characteristic_flag = ui::EF_NONE; 651 int characteristic_flag = ui::EF_NONE;
709 bool exact_event = false; 652 bool exact_event = false;
710 653
711 // First, remap the key code. 654 // First, remap the key code.
712 const ModifierRemapping* remapped_key = NULL; 655 const ModifierRemapping* remapped_key = NULL;
713 // Remapping based on DomKey. 656 // Remapping based on DomKey.
714 switch (incoming.key) { 657 switch (incoming.key) {
715 // On Chrome OS, F15 (XF86XK_Launch6) with NumLock (Mod2Mask) is sent 658 // On Chrome OS, F15 (XF86XK_Launch6) with NumLock (Mod2Mask) is sent
716 // when Diamond key is pressed. 659 // when Diamond key is pressed.
717 case ui::DomKey::F15: 660 case ui::DomKey::F15:
718 // When diamond key is not available, the configuration UI for Diamond 661 // When diamond key is not available, the configuration UI for Diamond
719 // key is not shown. Therefore, ignore the kLanguageRemapDiamondKeyTo 662 // key is not shown. Therefore, ignore the kLanguageRemapDiamondKeyTo
720 // syncable pref. 663 // syncable pref.
721 if (HasDiamondKey()) 664 if (HasDiamondKey())
722 remapped_key = 665 remapped_key =
723 GetRemappedKey(prefs::kLanguageRemapDiamondKeyTo, *pref_service); 666 GetRemappedKey(prefs::kLanguageRemapDiamondKeyTo, delegate_);
724 // Default behavior of F15 is Control, even if --has-chromeos-diamond-key 667 // Default behavior of F15 is Control, even if --has-chromeos-diamond-key
725 // is absent, according to unit test comments. 668 // is absent, according to unit test comments.
726 if (!remapped_key) { 669 if (!remapped_key) {
727 DCHECK_EQ(ui::VKEY_CONTROL, kModifierRemappingCtrl->result.key_code); 670 DCHECK_EQ(ui::VKEY_CONTROL, kModifierRemappingCtrl->result.key_code);
728 remapped_key = kModifierRemappingCtrl; 671 remapped_key = kModifierRemappingCtrl;
729 } 672 }
730 break; 673 break;
731 case ui::DomKey::ALT_GRAPH: 674 case ui::DomKey::ALT_GRAPH:
732 // The Neo2 codes modifiers such that CapsLock appears as VKEY_ALTGR, 675 // The Neo2 codes modifiers such that CapsLock appears as VKEY_ALTGR,
733 // but AltGraph (right Alt) also appears as VKEY_ALTGR in Neo2, 676 // but AltGraph (right Alt) also appears as VKEY_ALTGR in Neo2,
734 // as it does in other layouts. Neo2's "Mod3" is represented in 677 // as it does in other layouts. Neo2's "Mod3" is represented in
735 // EventFlags by a combination of AltGr+Mod3, while its "Mod4" is 678 // EventFlags by a combination of AltGr+Mod3, while its "Mod4" is
736 // AltGr alone. 679 // AltGr alone.
737 if (IsISOLevel5ShiftUsedByCurrentInputMethod()) { 680 if (IsISOLevel5ShiftUsedByCurrentInputMethod()) {
738 if (incoming.code == ui::DomCode::CAPS_LOCK) { 681 if (incoming.code == ui::DomCode::CAPS_LOCK) {
739 characteristic_flag = ui::EF_ALTGR_DOWN | ui::EF_MOD3_DOWN; 682 characteristic_flag = ui::EF_ALTGR_DOWN | ui::EF_MOD3_DOWN;
740 remapped_key = 683 remapped_key =
741 GetRemappedKey(prefs::kLanguageRemapCapsLockKeyTo, *pref_service); 684 GetRemappedKey(prefs::kLanguageRemapCapsLockKeyTo, delegate_);
742 } else { 685 } else {
743 characteristic_flag = ui::EF_ALTGR_DOWN; 686 characteristic_flag = ui::EF_ALTGR_DOWN;
744 remapped_key = 687 remapped_key =
745 GetRemappedKey(prefs::kLanguageRemapSearchKeyTo, *pref_service); 688 GetRemappedKey(prefs::kLanguageRemapSearchKeyTo, delegate_);
746 } 689 }
747 } 690 }
748 if (remapped_key && remapped_key->result.key_code == ui::VKEY_CAPITAL) 691 if (remapped_key && remapped_key->result.key_code == ui::VKEY_CAPITAL)
749 remapped_key = kModifierRemappingNeoMod3; 692 remapped_key = kModifierRemappingNeoMod3;
750 break; 693 break;
751 #if !defined(USE_X11) 694 #if !defined(USE_X11)
752 case ui::DomKey::ALT_GRAPH_LATCH: 695 case ui::DomKey::ALT_GRAPH_LATCH:
753 if (key_event.type() == ui::ET_KEY_PRESSED) { 696 if (key_event.type() == ui::ET_KEY_PRESSED) {
754 pressed_modifier_latches_ |= ui::EF_ALTGR_DOWN; 697 pressed_modifier_latches_ |= ui::EF_ALTGR_DOWN;
755 } else { 698 } else {
(...skipping 20 matching lines...) Expand all
776 // Remapping based on DomCode. 719 // Remapping based on DomCode.
777 switch (incoming.code) { 720 switch (incoming.code) {
778 // On Chrome OS, XF86XK_Launch7 (F16) with Mod3Mask is sent when Caps Lock 721 // On Chrome OS, XF86XK_Launch7 (F16) with Mod3Mask is sent when Caps Lock
779 // is pressed (with one exception: when 722 // is pressed (with one exception: when
780 // IsISOLevel5ShiftUsedByCurrentInputMethod() is true, the key generates 723 // IsISOLevel5ShiftUsedByCurrentInputMethod() is true, the key generates
781 // XK_ISO_Level3_Shift with Mod3Mask, not XF86XK_Launch7). 724 // XK_ISO_Level3_Shift with Mod3Mask, not XF86XK_Launch7).
782 case ui::DomCode::F16: 725 case ui::DomCode::F16:
783 case ui::DomCode::CAPS_LOCK: 726 case ui::DomCode::CAPS_LOCK:
784 characteristic_flag = ui::EF_CAPS_LOCK_ON; 727 characteristic_flag = ui::EF_CAPS_LOCK_ON;
785 remapped_key = 728 remapped_key =
786 GetRemappedKey(prefs::kLanguageRemapCapsLockKeyTo, *pref_service); 729 GetRemappedKey(prefs::kLanguageRemapCapsLockKeyTo, delegate_);
787 break; 730 break;
788 case ui::DomCode::META_LEFT: 731 case ui::DomCode::META_LEFT:
789 case ui::DomCode::META_RIGHT: 732 case ui::DomCode::META_RIGHT:
790 characteristic_flag = ui::EF_COMMAND_DOWN; 733 characteristic_flag = ui::EF_COMMAND_DOWN;
791 // Rewrite Command-L/R key presses on an Apple keyboard to Control. 734 // Rewrite Command-L/R key presses on an Apple keyboard to Control.
792 if (IsAppleKeyboard()) { 735 if (IsAppleKeyboard()) {
793 DCHECK_EQ(ui::VKEY_CONTROL, kModifierRemappingCtrl->result.key_code); 736 DCHECK_EQ(ui::VKEY_CONTROL, kModifierRemappingCtrl->result.key_code);
794 remapped_key = kModifierRemappingCtrl; 737 remapped_key = kModifierRemappingCtrl;
795 } else { 738 } else {
796 remapped_key = 739 remapped_key =
797 GetRemappedKey(prefs::kLanguageRemapSearchKeyTo, *pref_service); 740 GetRemappedKey(prefs::kLanguageRemapSearchKeyTo, delegate_);
798 } 741 }
799 // Default behavior is Super key, hence don't remap the event if the pref 742 // Default behavior is Super key, hence don't remap the event if the pref
800 // is unavailable. 743 // is unavailable.
801 break; 744 break;
802 case ui::DomCode::CONTROL_LEFT: 745 case ui::DomCode::CONTROL_LEFT:
803 case ui::DomCode::CONTROL_RIGHT: 746 case ui::DomCode::CONTROL_RIGHT:
804 characteristic_flag = ui::EF_CONTROL_DOWN; 747 characteristic_flag = ui::EF_CONTROL_DOWN;
805 remapped_key = 748 remapped_key =
806 GetRemappedKey(prefs::kLanguageRemapControlKeyTo, *pref_service); 749 GetRemappedKey(prefs::kLanguageRemapControlKeyTo, delegate_);
807 break; 750 break;
808 case ui::DomCode::ALT_LEFT: 751 case ui::DomCode::ALT_LEFT:
809 case ui::DomCode::ALT_RIGHT: 752 case ui::DomCode::ALT_RIGHT:
810 // ALT key 753 // ALT key
811 characteristic_flag = ui::EF_ALT_DOWN; 754 characteristic_flag = ui::EF_ALT_DOWN;
812 remapped_key = 755 remapped_key = GetRemappedKey(prefs::kLanguageRemapAltKeyTo, delegate_);
813 GetRemappedKey(prefs::kLanguageRemapAltKeyTo, *pref_service);
814 break; 756 break;
815 case ui::DomCode::ESCAPE: 757 case ui::DomCode::ESCAPE:
816 remapped_key = 758 remapped_key =
817 GetRemappedKey(prefs::kLanguageRemapEscapeKeyTo, *pref_service); 759 GetRemappedKey(prefs::kLanguageRemapEscapeKeyTo, delegate_);
818 break; 760 break;
819 case ui::DomCode::BACKSPACE: 761 case ui::DomCode::BACKSPACE:
820 remapped_key = 762 remapped_key =
821 GetRemappedKey(prefs::kLanguageRemapBackspaceKeyTo, *pref_service); 763 GetRemappedKey(prefs::kLanguageRemapBackspaceKeyTo, delegate_);
822 break; 764 break;
823 default: 765 default:
824 break; 766 break;
825 } 767 }
826 768
827 if (remapped_key) { 769 if (remapped_key) {
828 state->key_code = remapped_key->result.key_code; 770 state->key_code = remapped_key->result.key_code;
829 state->code = remapped_key->result.code; 771 state->code = remapped_key->result.code;
830 state->key = remapped_key->result.key; 772 state->key = remapped_key->result.key;
831 incoming.flags |= characteristic_flag; 773 incoming.flags |= characteristic_flag;
832 characteristic_flag = remapped_key->flag; 774 characteristic_flag = remapped_key->flag;
833 if (remapped_key->remap_to == input_method::kCapsLockKey) 775 if (remapped_key->remap_to == ::chromeos::input_method::kCapsLockKey)
834 characteristic_flag |= ui::EF_CAPS_LOCK_ON; 776 characteristic_flag |= ui::EF_CAPS_LOCK_ON;
835 state->code = RelocateModifier( 777 state->code = RelocateModifier(
836 state->code, ui::KeycodeConverter::DomCodeToLocation(incoming.code)); 778 state->code, ui::KeycodeConverter::DomCodeToLocation(incoming.code));
837 } 779 }
838 780
839 // Next, remap modifier bits. 781 // Next, remap modifier bits.
840 state->flags |= 782 state->flags |= GetRemappedModifierMasks(key_event, incoming.flags);
841 GetRemappedModifierMasks(*pref_service, key_event, incoming.flags);
842 783
843 // If the DomKey is not a modifier before remapping but is after, set the 784 // If the DomKey is not a modifier before remapping but is after, set the
844 // modifier latches for the later non-modifier key's modifier states. 785 // modifier latches for the later non-modifier key's modifier states.
845 bool non_modifier_to_modifier = 786 bool non_modifier_to_modifier =
846 !ui::KeycodeConverter::IsDomKeyForModifier(incoming.key) && 787 !ui::KeycodeConverter::IsDomKeyForModifier(incoming.key) &&
847 ui::KeycodeConverter::IsDomKeyForModifier(state->key); 788 ui::KeycodeConverter::IsDomKeyForModifier(state->key);
848 if (key_event.type() == ui::ET_KEY_PRESSED) { 789 if (key_event.type() == ui::ET_KEY_PRESSED) {
849 state->flags |= characteristic_flag; 790 state->flags |= characteristic_flag;
850 if (non_modifier_to_modifier) 791 if (non_modifier_to_modifier)
851 pressed_modifier_latches_ |= characteristic_flag; 792 pressed_modifier_latches_ |= characteristic_flag;
(...skipping 12 matching lines...) Expand all
864 if (state->key_code == ui::VKEY_CAPITAL 805 if (state->key_code == ui::VKEY_CAPITAL
865 // ... except on linux Chrome OS, where InputMethodChromeOS handles it. 806 // ... except on linux Chrome OS, where InputMethodChromeOS handles it.
866 && (base::SysInfo::IsRunningOnChromeOS() || ime_keyboard_for_testing_) 807 && (base::SysInfo::IsRunningOnChromeOS() || ime_keyboard_for_testing_)
867 #if defined(USE_X11) 808 #if defined(USE_X11)
868 // ... but for X11, do nothing if the original key is ui::VKEY_CAPITAL 809 // ... but for X11, do nothing if the original key is ui::VKEY_CAPITAL
869 // (i.e. a Caps Lock key on an external keyboard is pressed) since X 810 // (i.e. a Caps Lock key on an external keyboard is pressed) since X
870 // handles that itself. 811 // handles that itself.
871 && incoming.key_code != ui::VKEY_CAPITAL 812 && incoming.key_code != ui::VKEY_CAPITAL
872 #endif 813 #endif
873 ) { 814 ) {
874 chromeos::input_method::ImeKeyboard* ime_keyboard = 815 ::chromeos::input_method::ImeKeyboard* ime_keyboard =
875 ime_keyboard_for_testing_ 816 ime_keyboard_for_testing_
876 ? ime_keyboard_for_testing_ 817 ? ime_keyboard_for_testing_
877 : chromeos::input_method::InputMethodManager::Get() 818 : ::chromeos::input_method::InputMethodManager::Get()
878 ->GetImeKeyboard(); 819 ->GetImeKeyboard();
879 ime_keyboard->SetCapsLockEnabled(!ime_keyboard->CapsLockIsEnabled()); 820 ime_keyboard->SetCapsLockEnabled(!ime_keyboard->CapsLockIsEnabled());
880 } 821 }
881 } 822 }
882 return exact_event; 823 return exact_event;
883 } 824 }
884 825
885 void EventRewriter::RewriteNumPadKeys(const ui::KeyEvent& key_event, 826 void EventRewriter::RewriteNumPadKeys(const ui::KeyEvent& key_event,
886 MutableKeyState* state) { 827 MutableKeyState* state) {
887 DCHECK(key_event.type() == ui::ET_KEY_PRESSED || 828 DCHECK(key_event.type() == ui::ET_KEY_PRESSED ||
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 964
1024 void EventRewriter::RewriteFunctionKeys(const ui::KeyEvent& key_event, 965 void EventRewriter::RewriteFunctionKeys(const ui::KeyEvent& key_event,
1025 MutableKeyState* state) { 966 MutableKeyState* state) {
1026 CHECK(key_event.type() == ui::ET_KEY_PRESSED || 967 CHECK(key_event.type() == ui::ET_KEY_PRESSED ||
1027 key_event.type() == ui::ET_KEY_RELEASED); 968 key_event.type() == ui::ET_KEY_RELEASED);
1028 969
1029 if ((state->key_code >= ui::VKEY_F1) && (state->key_code <= ui::VKEY_F12)) { 970 if ((state->key_code >= ui::VKEY_F1) && (state->key_code <= ui::VKEY_F12)) {
1030 // By default the top row (F1-F12) keys are system keys for back, forward, 971 // By default the top row (F1-F12) keys are system keys for back, forward,
1031 // brightness, volume, etc. However, windows for v2 apps can optionally 972 // brightness, volume, etc. However, windows for v2 apps can optionally
1032 // request raw function keys for these keys. 973 // request raw function keys for these keys.
1033 bool top_row_keys_are_function_keys = TopRowKeysAreFunctionKeys(key_event); 974 const bool top_row_keys_are_function_keys =
1034 bool search_is_pressed = (state->flags & ui::EF_COMMAND_DOWN) != 0; 975 delegate_ && delegate_->TopRowKeysAreFunctionKeys();
976 const bool search_is_pressed = (state->flags & ui::EF_COMMAND_DOWN) != 0;
1035 977
1036 // Search? Top Row Result 978 // Search? Top Row Result
1037 // ------- -------- ------ 979 // ------- -------- ------
1038 // No Fn Unchanged 980 // No Fn Unchanged
1039 // No System Fn -> System 981 // No System Fn -> System
1040 // Yes Fn Fn -> System 982 // Yes Fn Fn -> System
1041 // Yes System Search+Fn -> Fn 983 // Yes System Search+Fn -> Fn
1042 if (top_row_keys_are_function_keys == search_is_pressed) { 984 if (top_row_keys_are_function_keys == search_is_pressed) {
1043 // Rewrite the F1-F12 keys on a Chromebook keyboard to system keys. 985 // Rewrite the F1-F12 keys on a Chromebook keyboard to system keys.
1044 static const KeyboardRemapping kFkeysToSystemKeys[] = { 986 static const KeyboardRemapping kFkeysToSystemKeys[] = {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 if (state->code == map.input_dom_code) { 1065 if (state->code == map.input_dom_code) {
1124 state->flags &= ~ui::EF_COMMAND_DOWN; 1066 state->flags &= ~ui::EF_COMMAND_DOWN;
1125 ApplyRemapping(map.result, state); 1067 ApplyRemapping(map.result, state);
1126 return; 1068 return;
1127 } 1069 }
1128 } 1070 }
1129 } 1071 }
1130 } 1072 }
1131 1073
1132 void EventRewriter::RewriteLocatedEvent(const ui::Event& event, int* flags) { 1074 void EventRewriter::RewriteLocatedEvent(const ui::Event& event, int* flags) {
1133 const PrefService* pref_service = GetPrefService(); 1075 if (!delegate_)
1134 if (!pref_service)
1135 return; 1076 return;
1136 *flags = GetRemappedModifierMasks(*pref_service, event, *flags); 1077 *flags = GetRemappedModifierMasks(event, *flags);
1137 } 1078 }
1138 1079
1139 int EventRewriter::RewriteModifierClick(const ui::MouseEvent& mouse_event, 1080 int EventRewriter::RewriteModifierClick(const ui::MouseEvent& mouse_event,
1140 int* flags) { 1081 int* flags) {
1141 // Remap Alt+Button1 to Button3. 1082 // Remap Alt+Button1 to Button3.
1142 const int kAltLeftButton = (ui::EF_ALT_DOWN | ui::EF_LEFT_MOUSE_BUTTON); 1083 const int kAltLeftButton = (ui::EF_ALT_DOWN | ui::EF_LEFT_MOUSE_BUTTON);
1143 if (((*flags & kAltLeftButton) == kAltLeftButton) && 1084 if (((*flags & kAltLeftButton) == kAltLeftButton) &&
1144 ((mouse_event.type() == ui::ET_MOUSE_PRESSED) || 1085 ((mouse_event.type() == ui::ET_MOUSE_PRESSED) ||
1145 pressed_device_ids_.count(mouse_event.source_device_id()))) { 1086 pressed_device_ids_.count(mouse_event.source_device_id()))) {
1146 *flags &= ~kAltLeftButton; 1087 *flags &= ~kAltLeftButton;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 for (const auto& keyboard : keyboard_devices) { 1128 for (const auto& keyboard : keyboard_devices) {
1188 if (keyboard.id == device_id) { 1129 if (keyboard.id == device_id) {
1189 return KeyboardDeviceAddedInternal( 1130 return KeyboardDeviceAddedInternal(
1190 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); 1131 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id);
1191 } 1132 }
1192 } 1133 }
1193 return kDeviceUnknown; 1134 return kDeviceUnknown;
1194 } 1135 }
1195 1136
1196 } // namespace chromeos 1137 } // namespace chromeos
1138 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698