| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 16 #include "media/video/capture/screen/win/desktop.h" | |
| 17 #include "media/video/capture/screen/win/scoped_thread_desktop.h" | |
| 18 #include "remoting/host/sas_injector.h" | 16 #include "remoting/host/sas_injector.h" |
| 19 #include "remoting/proto/event.pb.h" | 17 #include "remoting/proto/event.pb.h" |
| 18 #include "third_party/webrtc/modules/desktop_capture/win/desktop.h" |
| 19 #include "third_party/webrtc/modules/desktop_capture/win/scoped_thread_desktop.h
" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const uint32 kUsbLeftControl = 0x0700e0; | 23 const uint32 kUsbLeftControl = 0x0700e0; |
| 24 const uint32 kUsbRightControl = 0x0700e4; | 24 const uint32 kUsbRightControl = 0x0700e4; |
| 25 const uint32 kUsbLeftAlt = 0x0700e2; | 25 const uint32 kUsbLeftAlt = 0x0700e2; |
| 26 const uint32 kUsbRightAlt = 0x0700e6; | 26 const uint32 kUsbRightAlt = 0x0700e6; |
| 27 const uint32 kUsbDelete = 0x07004c; | 27 const uint32 kUsbDelete = 0x07004c; |
| 28 | 28 |
| 29 bool CheckCtrlAndAltArePressed(const std::set<uint32>& pressed_keys) { | 29 bool CheckCtrlAndAltArePressed(const std::set<uint32>& pressed_keys) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // the current one. | 73 // the current one. |
| 74 void SwitchToInputDesktop(); | 74 void SwitchToInputDesktop(); |
| 75 | 75 |
| 76 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; |
| 77 | 77 |
| 78 // Pointer to the next event executor. | 78 // Pointer to the next event executor. |
| 79 scoped_ptr<InputInjector> nested_executor_; | 79 scoped_ptr<InputInjector> nested_executor_; |
| 80 | 80 |
| 81 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner_; | 81 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner_; |
| 82 | 82 |
| 83 media::ScopedThreadDesktop desktop_; | 83 webrtc::ScopedThreadDesktop desktop_; |
| 84 | 84 |
| 85 // Used to inject Secure Attention Sequence on Vista+. | 85 // Used to inject Secure Attention Sequence on Vista+. |
| 86 base::Closure inject_sas_; | 86 base::Closure inject_sas_; |
| 87 | 87 |
| 88 // Used to inject Secure Attention Sequence on XP. | 88 // Used to inject Secure Attention Sequence on XP. |
| 89 scoped_ptr<SasInjector> sas_injector_; | 89 scoped_ptr<SasInjector> sas_injector_; |
| 90 | 90 |
| 91 // 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. |
| 92 std::set<uint32> pressed_keys_; | 92 std::set<uint32> pressed_keys_; |
| 93 | 93 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 SwitchToInputDesktop(); | 175 SwitchToInputDesktop(); |
| 176 nested_executor_->InjectMouseEvent(event); | 176 nested_executor_->InjectMouseEvent(event); |
| 177 } | 177 } |
| 178 | 178 |
| 179 SessionInputInjectorWin::Core::~Core() { | 179 SessionInputInjectorWin::Core::~Core() { |
| 180 } | 180 } |
| 181 | 181 |
| 182 void SessionInputInjectorWin::Core::SwitchToInputDesktop() { | 182 void SessionInputInjectorWin::Core::SwitchToInputDesktop() { |
| 183 // Switch to the desktop receiving user input if different from the current | 183 // Switch to the desktop receiving user input if different from the current |
| 184 // one. | 184 // one. |
| 185 scoped_ptr<media::Desktop> input_desktop = media::Desktop::GetInputDesktop(); | 185 scoped_ptr<webrtc::Desktop> input_desktop( |
| 186 webrtc::Desktop::GetInputDesktop()); |
| 186 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { | 187 if (input_desktop.get() != NULL && !desktop_.IsSame(*input_desktop)) { |
| 187 // If SetThreadDesktop() fails, the thread is still assigned a desktop. | 188 // If SetThreadDesktop() fails, the thread is still assigned a desktop. |
| 188 // So we can continue capture screen bits, just from a diffected desktop. | 189 // So we can continue capture screen bits, just from a diffected desktop. |
| 189 desktop_.SetThreadDesktop(input_desktop.Pass()); | 190 desktop_.SetThreadDesktop(input_desktop.release()); |
| 190 } | 191 } |
| 191 } | 192 } |
| 192 | 193 |
| 193 SessionInputInjectorWin::SessionInputInjectorWin( | 194 SessionInputInjectorWin::SessionInputInjectorWin( |
| 194 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 195 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 195 scoped_ptr<InputInjector> nested_executor, | 196 scoped_ptr<InputInjector> nested_executor, |
| 196 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, | 197 scoped_refptr<base::SingleThreadTaskRunner> inject_sas_task_runner, |
| 197 const base::Closure& inject_sas) { | 198 const base::Closure& inject_sas) { |
| 198 core_ = new Core(input_task_runner, nested_executor.Pass(), | 199 core_ = new Core(input_task_runner, nested_executor.Pass(), |
| 199 inject_sas_task_runner, inject_sas); | 200 inject_sas_task_runner, inject_sas); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 215 void SessionInputInjectorWin::InjectKeyEvent(const protocol::KeyEvent& event) { | 216 void SessionInputInjectorWin::InjectKeyEvent(const protocol::KeyEvent& event) { |
| 216 core_->InjectKeyEvent(event); | 217 core_->InjectKeyEvent(event); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void SessionInputInjectorWin::InjectMouseEvent( | 220 void SessionInputInjectorWin::InjectMouseEvent( |
| 220 const protocol::MouseEvent& event) { | 221 const protocol::MouseEvent& event) { |
| 221 core_->InjectMouseEvent(event); | 222 core_->InjectMouseEvent(event); |
| 222 } | 223 } |
| 223 | 224 |
| 224 } // namespace remoting | 225 } // namespace remoting |
| OLD | NEW |