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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 30 matching lines...) Expand all Loading... |
41 using protocol::ClipboardEvent; | 41 using protocol::ClipboardEvent; |
42 using protocol::KeyEvent; | 42 using protocol::KeyEvent; |
43 using protocol::MouseEvent; | 43 using protocol::MouseEvent; |
44 using protocol::TextEvent; | 44 using protocol::TextEvent; |
45 using protocol::TouchEvent; | 45 using protocol::TouchEvent; |
46 | 46 |
47 class SessionInputInjectorWin::Core | 47 class SessionInputInjectorWin::Core |
48 : public base::RefCountedThreadSafe<SessionInputInjectorWin::Core>, | 48 : public base::RefCountedThreadSafe<SessionInputInjectorWin::Core>, |
49 public InputInjector { | 49 public InputInjector { |
50 public: | 50 public: |
51 Core( | 51 Core(scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
52 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 52 std::unique_ptr<InputInjector> nested_executor, |
53 scoped_ptr<InputInjector> nested_executor, | 53 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, |
54 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, | 54 const base::Closure& inject_sas); |
55 const base::Closure& inject_sas); | |
56 | 55 |
57 // InputInjector implementation. | 56 // InputInjector implementation. |
58 void Start(scoped_ptr<ClipboardStub> client_clipboard) override; | 57 void Start(std::unique_ptr<ClipboardStub> client_clipboard) override; |
59 | 58 |
60 // protocol::ClipboardStub implementation. | 59 // protocol::ClipboardStub implementation. |
61 void InjectClipboardEvent(const ClipboardEvent& event) override; | 60 void InjectClipboardEvent(const ClipboardEvent& event) override; |
62 | 61 |
63 // protocol::InputStub implementation. | 62 // protocol::InputStub implementation. |
64 void InjectKeyEvent(const KeyEvent& event) override; | 63 void InjectKeyEvent(const KeyEvent& event) override; |
65 void InjectTextEvent(const TextEvent& event) override; | 64 void InjectTextEvent(const TextEvent& event) override; |
66 void InjectMouseEvent(const MouseEvent& event) override; | 65 void InjectMouseEvent(const MouseEvent& event) override; |
67 void InjectTouchEvent(const TouchEvent& event) override; | 66 void InjectTouchEvent(const TouchEvent& event) override; |
68 | 67 |
69 private: | 68 private: |
70 friend class base::RefCountedThreadSafe<Core>; | 69 friend class base::RefCountedThreadSafe<Core>; |
71 ~Core() override; | 70 ~Core() override; |
72 | 71 |
73 // Switches to the desktop receiving a user input if different from | 72 // Switches to the desktop receiving a user input if different from |
74 // the current one. | 73 // the current one. |
75 void SwitchToInputDesktop(); | 74 void SwitchToInputDesktop(); |
76 | 75 |
77 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; |
78 | 77 |
79 // Pointer to the next event executor. | 78 // Pointer to the next event executor. |
80 scoped_ptr<InputInjector> nested_executor_; | 79 std::unique_ptr<InputInjector> nested_executor_; |
81 | 80 |
82 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner_; | 81 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner_; |
83 | 82 |
84 webrtc::ScopedThreadDesktop desktop_; | 83 webrtc::ScopedThreadDesktop desktop_; |
85 | 84 |
86 // Used to inject Secure Attention Sequence on Vista+. | 85 // Used to inject Secure Attention Sequence on Vista+. |
87 base::Closure inject_sas_; | 86 base::Closure inject_sas_; |
88 | 87 |
89 // Used to inject Secure Attention Sequence on XP. | 88 // Used to inject Secure Attention Sequence on XP. |
90 scoped_ptr<SasInjector> sas_injector_; | 89 std::unique_ptr<SasInjector> sas_injector_; |
91 | 90 |
92 // Keys currently pressed by the client, used to detect Ctrl-Alt-Del. | 91 // Keys currently pressed by the client, used to detect Ctrl-Alt-Del. |
93 std::set<ui::DomCode> pressed_keys_; | 92 std::set<ui::DomCode> pressed_keys_; |
94 | 93 |
95 DISALLOW_COPY_AND_ASSIGN(Core); | 94 DISALLOW_COPY_AND_ASSIGN(Core); |
96 }; | 95 }; |
97 | 96 |
98 SessionInputInjectorWin::Core::Core( | 97 SessionInputInjectorWin::Core::Core( |
99 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 98 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
100 scoped_ptr<InputInjector> nested_executor, | 99 std::unique_ptr<InputInjector> nested_executor, |
101 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, | 100 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, |
102 const base::Closure& inject_sas) | 101 const base::Closure& inject_sas) |
103 : input_task_runner_(input_task_runner), | 102 : input_task_runner_(input_task_runner), |
104 nested_executor_(std::move(nested_executor)), | 103 nested_executor_(std::move(nested_executor)), |
105 inject_sas_task_runner_(inject_sas_task_runner), | 104 inject_sas_task_runner_(inject_sas_task_runner), |
106 inject_sas_(inject_sas) {} | 105 inject_sas_(inject_sas) {} |
107 | 106 |
108 void SessionInputInjectorWin::Core::Start( | 107 void SessionInputInjectorWin::Core::Start( |
109 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 108 std::unique_ptr<protocol::ClipboardStub> client_clipboard) { |
110 if (!input_task_runner_->BelongsToCurrentThread()) { | 109 if (!input_task_runner_->BelongsToCurrentThread()) { |
111 input_task_runner_->PostTask( | 110 input_task_runner_->PostTask( |
112 FROM_HERE, | 111 FROM_HERE, |
113 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); | 112 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); |
114 return; | 113 return; |
115 } | 114 } |
116 | 115 |
117 nested_executor_->Start(std::move(client_clipboard)); | 116 nested_executor_->Start(std::move(client_clipboard)); |
118 } | 117 } |
119 | 118 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 SwitchToInputDesktop(); | 197 SwitchToInputDesktop(); |
199 nested_executor_->InjectTouchEvent(event); | 198 nested_executor_->InjectTouchEvent(event); |
200 } | 199 } |
201 | 200 |
202 SessionInputInjectorWin::Core::~Core() { | 201 SessionInputInjectorWin::Core::~Core() { |
203 } | 202 } |
204 | 203 |
205 void SessionInputInjectorWin::Core::SwitchToInputDesktop() { | 204 void SessionInputInjectorWin::Core::SwitchToInputDesktop() { |
206 // Switch to the desktop receiving user input if different from the current | 205 // Switch to the desktop receiving user input if different from the current |
207 // one. | 206 // one. |
208 scoped_ptr<webrtc::Desktop> input_desktop( | 207 std::unique_ptr<webrtc::Desktop> input_desktop( |
209 webrtc::Desktop::GetInputDesktop()); | 208 webrtc::Desktop::GetInputDesktop()); |
210 if (input_desktop.get() != nullptr && !desktop_.IsSame(*input_desktop)) { | 209 if (input_desktop.get() != nullptr && !desktop_.IsSame(*input_desktop)) { |
211 // If SetThreadDesktop() fails, the thread is still assigned a desktop. | 210 // If SetThreadDesktop() fails, the thread is still assigned a desktop. |
212 // So we can continue capture screen bits, just from a diffected desktop. | 211 // So we can continue capture screen bits, just from a diffected desktop. |
213 desktop_.SetThreadDesktop(input_desktop.release()); | 212 desktop_.SetThreadDesktop(input_desktop.release()); |
214 } | 213 } |
215 } | 214 } |
216 | 215 |
217 SessionInputInjectorWin::SessionInputInjectorWin( | 216 SessionInputInjectorWin::SessionInputInjectorWin( |
218 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 217 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
219 scoped_ptr<InputInjector> nested_executor, | 218 std::unique_ptr<InputInjector> nested_executor, |
220 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, | 219 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, |
221 const base::Closure& inject_sas) { | 220 const base::Closure& inject_sas) { |
222 core_ = new Core(input_task_runner, std::move(nested_executor), | 221 core_ = new Core(input_task_runner, std::move(nested_executor), |
223 inject_sas_task_runner, inject_sas); | 222 inject_sas_task_runner, inject_sas); |
224 } | 223 } |
225 | 224 |
226 SessionInputInjectorWin::~SessionInputInjectorWin() { | 225 SessionInputInjectorWin::~SessionInputInjectorWin() { |
227 } | 226 } |
228 | 227 |
229 void SessionInputInjectorWin::Start( | 228 void SessionInputInjectorWin::Start( |
230 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 229 std::unique_ptr<protocol::ClipboardStub> client_clipboard) { |
231 core_->Start(std::move(client_clipboard)); | 230 core_->Start(std::move(client_clipboard)); |
232 } | 231 } |
233 | 232 |
234 void SessionInputInjectorWin::InjectClipboardEvent( | 233 void SessionInputInjectorWin::InjectClipboardEvent( |
235 const protocol::ClipboardEvent& event) { | 234 const protocol::ClipboardEvent& event) { |
236 core_->InjectClipboardEvent(event); | 235 core_->InjectClipboardEvent(event); |
237 } | 236 } |
238 | 237 |
239 void SessionInputInjectorWin::InjectKeyEvent(const protocol::KeyEvent& event) { | 238 void SessionInputInjectorWin::InjectKeyEvent(const protocol::KeyEvent& event) { |
240 core_->InjectKeyEvent(event); | 239 core_->InjectKeyEvent(event); |
241 } | 240 } |
242 | 241 |
243 void SessionInputInjectorWin::InjectTextEvent( | 242 void SessionInputInjectorWin::InjectTextEvent( |
244 const protocol::TextEvent& event) { | 243 const protocol::TextEvent& event) { |
245 core_->InjectTextEvent(event); | 244 core_->InjectTextEvent(event); |
246 } | 245 } |
247 | 246 |
248 void SessionInputInjectorWin::InjectMouseEvent( | 247 void SessionInputInjectorWin::InjectMouseEvent( |
249 const protocol::MouseEvent& event) { | 248 const protocol::MouseEvent& event) { |
250 core_->InjectMouseEvent(event); | 249 core_->InjectMouseEvent(event); |
251 } | 250 } |
252 | 251 |
253 void SessionInputInjectorWin::InjectTouchEvent( | 252 void SessionInputInjectorWin::InjectTouchEvent( |
254 const protocol::TouchEvent& event) { | 253 const protocol::TouchEvent& event) { |
255 core_->InjectTouchEvent(event); | 254 core_->InjectTouchEvent(event); |
256 } | 255 } |
257 | 256 |
258 } // namespace remoting | 257 } // namespace remoting |
OLD | NEW |