| 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/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "remoting/host/capturer.h" | 12 #include "remoting/host/capturer.h" |
| 13 #include "remoting/proto/event.pb.h" | 13 #include "remoting/proto/event.pb.h" |
| 14 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 using protocol::ClipboardEvent; |
| 19 using protocol::KeyEvent; |
| 18 using protocol::MouseEvent; | 20 using protocol::MouseEvent; |
| 19 using protocol::KeyEvent; | |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // A class to generate events on Windows. | 24 // A class to generate events on Windows. |
| 24 class EventExecutorWin : public EventExecutor { | 25 class EventExecutorWin : public EventExecutor { |
| 25 public: | 26 public: |
| 26 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); | 27 EventExecutorWin(MessageLoop* message_loop, Capturer* capturer); |
| 27 virtual ~EventExecutorWin() {} | 28 virtual ~EventExecutorWin() {} |
| 28 | 29 |
| 30 // ClipboardStub interface. |
| 31 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
| 32 |
| 33 // InputStub interface. |
| 29 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 34 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
| 30 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 35 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
| 31 | 36 |
| 32 private: | 37 private: |
| 33 void HandleKey(const KeyEvent& event); | 38 void HandleKey(const KeyEvent& event); |
| 34 void HandleMouse(const MouseEvent& event); | 39 void HandleMouse(const MouseEvent& event); |
| 35 | 40 |
| 36 MessageLoop* message_loop_; | 41 MessageLoop* message_loop_; |
| 37 Capturer* capturer_; | 42 Capturer* capturer_; |
| 38 | 43 |
| 39 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); | 44 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); |
| 40 }; | 45 }; |
| 41 | 46 |
| 42 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, | 47 EventExecutorWin::EventExecutorWin(MessageLoop* message_loop, |
| 43 Capturer* capturer) | 48 Capturer* capturer) |
| 44 : message_loop_(message_loop), | 49 : message_loop_(message_loop), |
| 45 capturer_(capturer) { | 50 capturer_(capturer) { |
| 46 } | 51 } |
| 47 | 52 |
| 53 void EventExecutorWin::InjectClipboardEvent(const ClipboardEvent& event) { |
| 54 // TODO(simonmorris): Implement clipboard injection. |
| 55 } |
| 56 |
| 48 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { | 57 void EventExecutorWin::InjectKeyEvent(const KeyEvent& event) { |
| 49 if (MessageLoop::current() != message_loop_) { | 58 if (MessageLoop::current() != message_loop_) { |
| 50 message_loop_->PostTask( | 59 message_loop_->PostTask( |
| 51 FROM_HERE, | 60 FROM_HERE, |
| 52 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), | 61 base::Bind(&EventExecutorWin::InjectKeyEvent, base::Unretained(this), |
| 53 event)); | 62 event)); |
| 54 return; | 63 return; |
| 55 } | 64 } |
| 56 | 65 |
| 57 HandleKey(event); | 66 HandleKey(event); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 button_event.mi.dwFlags = | 169 button_event.mi.dwFlags = |
| 161 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; | 170 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; |
| 162 } | 171 } |
| 163 | 172 |
| 164 SendInput(1, &button_event, sizeof(INPUT)); | 173 SendInput(1, &button_event, sizeof(INPUT)); |
| 165 } | 174 } |
| 166 } | 175 } |
| 167 | 176 |
| 168 } // namespace | 177 } // namespace |
| 169 | 178 |
| 170 scoped_ptr<protocol::InputStub> EventExecutor::Create(MessageLoop* message_loop, | 179 scoped_ptr<protocol::HostEventStub> EventExecutor::Create( |
| 171 Capturer* capturer) { | 180 MessageLoop* message_loop, Capturer* capturer) { |
| 172 return scoped_ptr<protocol::InputStub>( | 181 return scoped_ptr<protocol::HostEventStub>( |
| 173 new EventExecutorWin(message_loop, capturer)); | 182 new EventExecutorWin(message_loop, capturer)); |
| 174 } | 183 } |
| 175 | 184 |
| 176 } // namespace remoting | 185 } // namespace remoting |
| OLD | NEW |