| OLD | NEW |
| 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/event_executor.h" | 5 #include "remoting/host/event_executor.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "remoting/host/capturer.h" | 13 #include "remoting/host/video_frame_capturer.h" |
| 14 #include "remoting/host/clipboard.h" | 14 #include "remoting/host/clipboard.h" |
| 15 #include "remoting/proto/event.pb.h" | 15 #include "remoting/proto/event.pb.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 using protocol::ClipboardEvent; | 21 using protocol::ClipboardEvent; |
| 22 using protocol::KeyEvent; | 22 using protocol::KeyEvent; |
| 23 using protocol::MouseEvent; | 23 using protocol::MouseEvent; |
| 24 | 24 |
| 25 // USB to XKB keycode map table. | 25 // USB to XKB keycode map table. |
| 26 #define USB_KEYMAP(usb, xkb, win, mac) {usb, win} | 26 #define USB_KEYMAP(usb, xkb, win, mac) {usb, win} |
| 27 #include "ui/base/keycodes/usb_keycode_map.h" | 27 #include "ui/base/keycodes/usb_keycode_map.h" |
| 28 #undef USB_KEYMAP | 28 #undef USB_KEYMAP |
| 29 | 29 |
| 30 // A class to generate events on Windows. | 30 // A class to generate events on Windows. |
| 31 class EventExecutorWin : public EventExecutor { | 31 class EventExecutorWin : public EventExecutor { |
| 32 public: | 32 public: |
| 33 EventExecutorWin(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 33 EventExecutorWin(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 35 Capturer* capturer); | 35 VideoFrameCapturer* capturer); |
| 36 virtual ~EventExecutorWin() {} | 36 virtual ~EventExecutorWin() {} |
| 37 | 37 |
| 38 // ClipboardStub interface. | 38 // ClipboardStub interface. |
| 39 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | 39 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
| 40 | 40 |
| 41 // InputStub interface. | 41 // InputStub interface. |
| 42 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 42 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
| 43 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 43 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
| 44 | 44 |
| 45 // EventExecutor interface. | 45 // EventExecutor interface. |
| 46 virtual void OnSessionStarted( | 46 virtual void OnSessionStarted( |
| 47 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 47 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
| 48 virtual void OnSessionFinished() OVERRIDE; | 48 virtual void OnSessionFinished() OVERRIDE; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 HKL GetForegroundKeyboardLayout(); | 51 HKL GetForegroundKeyboardLayout(); |
| 52 void HandleKey(const KeyEvent& event); | 52 void HandleKey(const KeyEvent& event); |
| 53 void HandleMouse(const MouseEvent& event); | 53 void HandleMouse(const MouseEvent& event); |
| 54 | 54 |
| 55 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 55 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 56 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 56 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 57 Capturer* capturer_; | 57 VideoFrameCapturer* capturer_; |
| 58 scoped_ptr<Clipboard> clipboard_; | 58 scoped_ptr<Clipboard> clipboard_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); | 60 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 EventExecutorWin::EventExecutorWin( | 63 EventExecutorWin::EventExecutorWin( |
| 64 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 64 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 65 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 65 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 66 Capturer* capturer) | 66 VideoFrameCapturer* capturer) |
| 67 : main_task_runner_(main_task_runner), | 67 : main_task_runner_(main_task_runner), |
| 68 ui_task_runner_(ui_task_runner), | 68 ui_task_runner_(ui_task_runner), |
| 69 capturer_(capturer), | 69 capturer_(capturer), |
| 70 clipboard_(Clipboard::Create()) { | 70 clipboard_(Clipboard::Create()) { |
| 71 } | 71 } |
| 72 | 72 |
| 73 void EventExecutorWin::InjectClipboardEvent(const ClipboardEvent& event) { | 73 void EventExecutorWin::InjectClipboardEvent(const ClipboardEvent& event) { |
| 74 if (!ui_task_runner_->BelongsToCurrentThread()) { | 74 if (!ui_task_runner_->BelongsToCurrentThread()) { |
| 75 ui_task_runner_->PostTask( | 75 ui_task_runner_->PostTask( |
| 76 FROM_HERE, | 76 FROM_HERE, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 LOG_GETLASTERROR(ERROR) << "Failed to inject a mouse button event"; | 283 LOG_GETLASTERROR(ERROR) << "Failed to inject a mouse button event"; |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| 289 | 289 |
| 290 scoped_ptr<EventExecutor> EventExecutor::Create( | 290 scoped_ptr<EventExecutor> EventExecutor::Create( |
| 291 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 291 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 292 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 292 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 293 Capturer* capturer) { | 293 VideoFrameCapturer* capturer) { |
| 294 return scoped_ptr<EventExecutor>( | 294 return scoped_ptr<EventExecutor>( |
| 295 new EventExecutorWin(main_task_runner, ui_task_runner, capturer)); | 295 new EventExecutorWin(main_task_runner, ui_task_runner, capturer)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace remoting | 298 } // namespace remoting |
| OLD | NEW |