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

Side by Side Diff: remoting/host/input_injector_mac.cc

Issue 494813002: events: keycodes: Remove the stateless singleton instance of KeycodeConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/input_injector_linux.cc ('k') | remoting/host/input_injector_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/input_injector.h" 5 #include "remoting/host/input_injector.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #include <Carbon/Carbon.h> 8 #include <Carbon/Carbon.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 // |clipboard_| will ignore unknown MIME-types, and verify the data's format. 173 // |clipboard_| will ignore unknown MIME-types, and verify the data's format.
174 clipboard_->InjectClipboardEvent(event); 174 clipboard_->InjectClipboardEvent(event);
175 } 175 }
176 176
177 void InputInjectorMac::Core::InjectKeyEvent(const KeyEvent& event) { 177 void InputInjectorMac::Core::InjectKeyEvent(const KeyEvent& event) {
178 // HostEventDispatcher should filter events missing the pressed field. 178 // HostEventDispatcher should filter events missing the pressed field.
179 if (!event.has_pressed() || !event.has_usb_keycode()) 179 if (!event.has_pressed() || !event.has_usb_keycode())
180 return; 180 return;
181 181
182 ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance(); 182 int keycode =
183 int keycode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode()); 183 ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode());
184 184
185 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() 185 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
186 << " to keycode: " << keycode << std::dec; 186 << " to keycode: " << keycode << std::dec;
187 187
188 // If we couldn't determine the Mac virtual key code then ignore the event. 188 // If we couldn't determine the Mac virtual key code then ignore the event.
189 if (keycode == key_converter->InvalidNativeKeycode()) 189 if (keycode == ui::KeycodeConverter::InvalidNativeKeycode())
190 return; 190 return;
191 191
192 // If this is a modifier key, remember its new state so that it can be 192 // If this is a modifier key, remember its new state so that it can be
193 // correctly applied to subsequent events. 193 // correctly applied to subsequent events.
194 if (keycode == kVK_Command) { 194 if (keycode == kVK_Command) {
195 SetOrClearBit(left_modifiers_, kCGEventFlagMaskCommand, event.pressed()); 195 SetOrClearBit(left_modifiers_, kCGEventFlagMaskCommand, event.pressed());
196 } else if (keycode == kVK_Shift) { 196 } else if (keycode == kVK_Shift) {
197 SetOrClearBit(left_modifiers_, kCGEventFlagMaskShift, event.pressed()); 197 SetOrClearBit(left_modifiers_, kCGEventFlagMaskShift, event.pressed());
198 } else if (keycode == kVK_Control) { 198 } else if (keycode == kVK_Control) {
199 SetOrClearBit(left_modifiers_, kCGEventFlagMaskControl, event.pressed()); 199 SetOrClearBit(left_modifiers_, kCGEventFlagMaskControl, event.pressed());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 } // namespace 336 } // namespace
337 337
338 scoped_ptr<InputInjector> InputInjector::Create( 338 scoped_ptr<InputInjector> InputInjector::Create(
339 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 339 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
340 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 340 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
341 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); 341 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner));
342 } 342 }
343 343
344 } // namespace remoting 344 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/input_injector_linux.cc ('k') | remoting/host/input_injector_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698