| 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/win/session_input_injector.h" | 5 #include "remoting/host/win/session_input_injector.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 namespace remoting { | 40 namespace remoting { |
| 41 | 41 |
| 42 using protocol::ClipboardEvent; | 42 using protocol::ClipboardEvent; |
| 43 using protocol::KeyEvent; | 43 using protocol::KeyEvent; |
| 44 using protocol::MouseEvent; | 44 using protocol::MouseEvent; |
| 45 using protocol::TextEvent; | 45 using protocol::TextEvent; |
| 46 using protocol::TouchEvent; |
| 46 | 47 |
| 47 class SessionInputInjectorWin::Core | 48 class SessionInputInjectorWin::Core |
| 48 : public base::RefCountedThreadSafe<SessionInputInjectorWin::Core>, | 49 : public base::RefCountedThreadSafe<SessionInputInjectorWin::Core>, |
| 49 public InputInjector { | 50 public InputInjector { |
| 50 public: | 51 public: |
| 51 Core( | 52 Core( |
| 52 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 53 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 53 scoped_ptr<InputInjector> nested_executor, | 54 scoped_ptr<InputInjector> nested_executor, |
| 54 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, | 55 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, |
| 55 const base::Closure& inject_sas); | 56 const base::Closure& inject_sas); |
| 56 | 57 |
| 57 // InputInjector implementation. | 58 // InputInjector implementation. |
| 58 virtual void Start( | 59 virtual void Start(scoped_ptr<ClipboardStub> client_clipboard) override; |
| 59 scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | |
| 60 | 60 |
| 61 // protocol::ClipboardStub implementation. | 61 // protocol::ClipboardStub implementation. |
| 62 virtual void InjectClipboardEvent( | 62 virtual void InjectClipboardEvent(const ClipboardEvent& event) override; |
| 63 const protocol::ClipboardEvent& event) override; | |
| 64 | 63 |
| 65 // protocol::InputStub implementation. | 64 // protocol::InputStub implementation. |
| 66 virtual void InjectKeyEvent(const protocol::KeyEvent& event) override; | 65 virtual void InjectKeyEvent(const KeyEvent& event) override; |
| 67 virtual void InjectTextEvent(const protocol::TextEvent& event) override; | 66 virtual void InjectTextEvent(const TextEvent& event) override; |
| 68 virtual void InjectMouseEvent(const protocol::MouseEvent& event) override; | 67 virtual void InjectMouseEvent(const MouseEvent& event) override; |
| 68 virtual void InjectTouchEvent(const TouchEvent& event) override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 friend class base::RefCountedThreadSafe<Core>; | 71 friend class base::RefCountedThreadSafe<Core>; |
| 72 virtual ~Core(); | 72 virtual ~Core(); |
| 73 | 73 |
| 74 // Switches to the desktop receiving a user input if different from | 74 // Switches to the desktop receiving a user input if different from |
| 75 // the current one. | 75 // the current one. |
| 76 void SwitchToInputDesktop(); | 76 void SwitchToInputDesktop(); |
| 77 | 77 |
| 78 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | 78 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 if (!input_task_runner_->BelongsToCurrentThread()) { | 182 if (!input_task_runner_->BelongsToCurrentThread()) { |
| 183 input_task_runner_->PostTask( | 183 input_task_runner_->PostTask( |
| 184 FROM_HERE, base::Bind(&Core::InjectMouseEvent, this, event)); | 184 FROM_HERE, base::Bind(&Core::InjectMouseEvent, this, event)); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 | 187 |
| 188 SwitchToInputDesktop(); | 188 SwitchToInputDesktop(); |
| 189 nested_executor_->InjectMouseEvent(event); | 189 nested_executor_->InjectMouseEvent(event); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void SessionInputInjectorWin::Core::InjectTouchEvent(const TouchEvent& event) { |
| 193 NOTIMPLEMENTED(); |
| 194 } |
| 195 |
| 192 SessionInputInjectorWin::Core::~Core() { | 196 SessionInputInjectorWin::Core::~Core() { |
| 193 } | 197 } |
| 194 | 198 |
| 195 void SessionInputInjectorWin::Core::SwitchToInputDesktop() { | 199 void SessionInputInjectorWin::Core::SwitchToInputDesktop() { |
| 196 // Switch to the desktop receiving user input if different from the current | 200 // Switch to the desktop receiving user input if different from the current |
| 197 // one. | 201 // one. |
| 198 scoped_ptr<webrtc::Desktop> input_desktop( | 202 scoped_ptr<webrtc::Desktop> input_desktop( |
| 199 webrtc::Desktop::GetInputDesktop()); | 203 webrtc::Desktop::GetInputDesktop()); |
| 200 if (input_desktop.get() != nullptr && !desktop_.IsSame(*input_desktop)) { | 204 if (input_desktop.get() != nullptr && !desktop_.IsSame(*input_desktop)) { |
| 201 // If SetThreadDesktop() fails, the thread is still assigned a desktop. | 205 // If SetThreadDesktop() fails, the thread is still assigned a desktop. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void SessionInputInjectorWin::InjectTextEvent( | 237 void SessionInputInjectorWin::InjectTextEvent( |
| 234 const protocol::TextEvent& event) { | 238 const protocol::TextEvent& event) { |
| 235 core_->InjectTextEvent(event); | 239 core_->InjectTextEvent(event); |
| 236 } | 240 } |
| 237 | 241 |
| 238 void SessionInputInjectorWin::InjectMouseEvent( | 242 void SessionInputInjectorWin::InjectMouseEvent( |
| 239 const protocol::MouseEvent& event) { | 243 const protocol::MouseEvent& event) { |
| 240 core_->InjectMouseEvent(event); | 244 core_->InjectMouseEvent(event); |
| 241 } | 245 } |
| 242 | 246 |
| 247 void SessionInputInjectorWin::InjectTouchEvent( |
| 248 const protocol::TouchEvent& event) { |
| 249 core_->InjectTouchEvent(event); |
| 250 } |
| 251 |
| 243 } // namespace remoting | 252 } // namespace remoting |
| OLD | NEW |