| 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/desktop_session_proxy.h" | 5 #include "remoting/host/desktop_session_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(IpcSharedBuffer); | 87 DISALLOW_COPY_AND_ASSIGN(IpcSharedBuffer); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 DesktopSessionProxy::DesktopSessionProxy( | 90 DesktopSessionProxy::DesktopSessionProxy( |
| 91 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner, | 91 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner, |
| 92 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 92 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 93 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 93 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 94 base::WeakPtr<ClientSessionControl> client_session_control, | 94 base::WeakPtr<ClientSessionControl> client_session_control, |
| 95 base::WeakPtr<DesktopSessionConnector> desktop_session_connector, | 95 base::WeakPtr<DesktopSessionConnector> desktop_session_connector, |
| 96 bool virtual_terminal) | 96 const DesktopEnvironmentOptions& options) |
| 97 : audio_capture_task_runner_(audio_capture_task_runner), | 97 : audio_capture_task_runner_(audio_capture_task_runner), |
| 98 caller_task_runner_(caller_task_runner), | 98 caller_task_runner_(caller_task_runner), |
| 99 io_task_runner_(io_task_runner), | 99 io_task_runner_(io_task_runner), |
| 100 client_session_control_(client_session_control), | 100 client_session_control_(client_session_control), |
| 101 desktop_session_connector_(desktop_session_connector), | 101 desktop_session_connector_(desktop_session_connector), |
| 102 pending_capture_frame_requests_(0), | 102 pending_capture_frame_requests_(0), |
| 103 is_desktop_session_connected_(false), | 103 is_desktop_session_connected_(false), |
| 104 virtual_terminal_(virtual_terminal) { | 104 options_(options) { |
| 105 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 105 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 std::unique_ptr<AudioCapturer> DesktopSessionProxy::CreateAudioCapturer() { | 108 std::unique_ptr<AudioCapturer> DesktopSessionProxy::CreateAudioCapturer() { |
| 109 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 109 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 110 | 110 |
| 111 return base::MakeUnique<IpcAudioCapturer>(this); | 111 return base::MakeUnique<IpcAudioCapturer>(this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 std::unique_ptr<InputInjector> DesktopSessionProxy::CreateInputInjector() { | 114 std::unique_ptr<InputInjector> DesktopSessionProxy::CreateInputInjector() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 std::unique_ptr<webrtc::MouseCursorMonitor> | 133 std::unique_ptr<webrtc::MouseCursorMonitor> |
| 134 DesktopSessionProxy::CreateMouseCursorMonitor() { | 134 DesktopSessionProxy::CreateMouseCursorMonitor() { |
| 135 return base::MakeUnique<IpcMouseCursorMonitor>(this); | 135 return base::MakeUnique<IpcMouseCursorMonitor>(this); |
| 136 } | 136 } |
| 137 | 137 |
| 138 std::string DesktopSessionProxy::GetCapabilities() const { | 138 std::string DesktopSessionProxy::GetCapabilities() const { |
| 139 std::string result = protocol::kRateLimitResizeRequests; | 139 std::string result = protocol::kRateLimitResizeRequests; |
| 140 // Ask the client to send its resolution unconditionally. | 140 // Ask the client to send its resolution unconditionally. |
| 141 if (virtual_terminal_) { | 141 if (options_.enable_curtaining()) { |
| 142 result += " "; | 142 result += " "; |
| 143 result += protocol::kSendInitialResolution; | 143 result += protocol::kSendInitialResolution; |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (InputInjector::SupportsTouchEvents()) { | 146 if (InputInjector::SupportsTouchEvents()) { |
| 147 result += " "; | 147 result += " "; |
| 148 result += protocol::kTouchEventsCapability; | 148 result += protocol::kTouchEventsCapability; |
| 149 } | 149 } |
| 150 | 150 |
| 151 return result; | 151 return result; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) { | 154 void DesktopSessionProxy::SetCapabilities(const std::string& capabilities) { |
| 155 // Delay creation of the desktop session until the client screen resolution is | 155 // Delay creation of the desktop session until the client screen resolution is |
| 156 // received if the desktop session requires the initial screen resolution | 156 // received if the desktop session requires the initial screen resolution |
| 157 // (when |virtual_terminal_| is true) and the client is expected to | 157 // (when enable_curtaining() is true) and the client is expected to |
| 158 // sent its screen resolution (the 'sendInitialResolution' capability is | 158 // sent its screen resolution (the 'sendInitialResolution' capability is |
| 159 // supported). | 159 // supported). |
| 160 if (virtual_terminal_ && | 160 if (options_.enable_curtaining() && |
| 161 HasCapability(capabilities, protocol::kSendInitialResolution)) { | 161 HasCapability(capabilities, protocol::kSendInitialResolution)) { |
| 162 VLOG(1) << "Waiting for the client screen resolution."; | 162 VLOG(1) << "Waiting for the client screen resolution."; |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Connect to the desktop session. | 166 // Connect to the desktop session. |
| 167 if (!is_desktop_session_connected_) { | 167 if (!is_desktop_session_connected_) { |
| 168 is_desktop_session_connected_ = true; | 168 is_desktop_session_connected_ = true; |
| 169 if (desktop_session_connector_.get()) { | 169 if (desktop_session_connector_.get()) { |
| 170 desktop_session_connector_->ConnectTerminal( | 170 desktop_session_connector_->ConnectTerminal(this, screen_resolution_, |
| 171 this, screen_resolution_, virtual_terminal_); | 171 options_.enable_curtaining()); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool DesktopSessionProxy::OnMessageReceived(const IPC::Message& message) { | 176 bool DesktopSessionProxy::OnMessageReceived(const IPC::Message& message) { |
| 177 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 177 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 178 | 178 |
| 179 bool handled = true; | 179 bool handled = true; |
| 180 IPC_BEGIN_MESSAGE_MAP(DesktopSessionProxy, message) | 180 IPC_BEGIN_MESSAGE_MAP(DesktopSessionProxy, message) |
| 181 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_AudioPacket, | 181 IPC_MESSAGE_HANDLER(ChromotingDesktopNetworkMsg_AudioPacket, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return false; | 222 return false; |
| 223 | 223 |
| 224 // Connect to the desktop process. | 224 // Connect to the desktop process. |
| 225 desktop_channel_ = IPC::ChannelProxy::Create(desktop_pipe, | 225 desktop_channel_ = IPC::ChannelProxy::Create(desktop_pipe, |
| 226 IPC::Channel::MODE_CLIENT, this, | 226 IPC::Channel::MODE_CLIENT, this, |
| 227 io_task_runner_.get()); | 227 io_task_runner_.get()); |
| 228 | 228 |
| 229 // Pass ID of the client (which is authenticated at this point) to the desktop | 229 // Pass ID of the client (which is authenticated at this point) to the desktop |
| 230 // session agent and start the agent. | 230 // session agent and start the agent. |
| 231 SendToDesktop(new ChromotingNetworkDesktopMsg_StartSessionAgent( | 231 SendToDesktop(new ChromotingNetworkDesktopMsg_StartSessionAgent( |
| 232 client_session_control_->client_jid(), | 232 client_session_control_->client_jid(), screen_resolution_, options_)); |
| 233 screen_resolution_, | |
| 234 virtual_terminal_)); | |
| 235 | 233 |
| 236 desktop_session_id_ = session_id; | 234 desktop_session_id_ = session_id; |
| 237 | 235 |
| 238 return true; | 236 return true; |
| 239 } | 237 } |
| 240 | 238 |
| 241 void DesktopSessionProxy::DetachFromDesktop() { | 239 void DesktopSessionProxy::DetachFromDesktop() { |
| 242 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 240 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 243 | 241 |
| 244 desktop_channel_.reset(); | 242 desktop_channel_.reset(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 372 |
| 375 if (resolution.IsEmpty()) | 373 if (resolution.IsEmpty()) |
| 376 return; | 374 return; |
| 377 | 375 |
| 378 screen_resolution_ = resolution; | 376 screen_resolution_ = resolution; |
| 379 | 377 |
| 380 // Connect to the desktop session if it is not done yet. | 378 // Connect to the desktop session if it is not done yet. |
| 381 if (!is_desktop_session_connected_) { | 379 if (!is_desktop_session_connected_) { |
| 382 is_desktop_session_connected_ = true; | 380 is_desktop_session_connected_ = true; |
| 383 if (desktop_session_connector_.get()) { | 381 if (desktop_session_connector_.get()) { |
| 384 desktop_session_connector_->ConnectTerminal( | 382 desktop_session_connector_->ConnectTerminal(this, screen_resolution_, |
| 385 this, screen_resolution_, virtual_terminal_); | 383 options_.enable_curtaining()); |
| 386 } | 384 } |
| 387 return; | 385 return; |
| 388 } | 386 } |
| 389 | 387 |
| 390 // Pass the client's resolution to both daemon and desktop session agent. | 388 // Pass the client's resolution to both daemon and desktop session agent. |
| 391 // Depending on the session kind the screen resolution can be set by either | 389 // Depending on the session kind the screen resolution can be set by either |
| 392 // the daemon (for example RDP sessions on Windows) or by the desktop session | 390 // the daemon (for example RDP sessions on Windows) or by the desktop session |
| 393 // agent (when sharing the physical console). | 391 // agent (when sharing the physical console). |
| 394 if (desktop_session_connector_.get()) | 392 if (desktop_session_connector_.get()) |
| 395 desktop_session_connector_->SetScreenResolution(this, screen_resolution_); | 393 desktop_session_connector_->SetScreenResolution(this, screen_resolution_); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 } | 527 } |
| 530 | 528 |
| 531 // static | 529 // static |
| 532 void DesktopSessionProxyTraits::Destruct( | 530 void DesktopSessionProxyTraits::Destruct( |
| 533 const DesktopSessionProxy* desktop_session_proxy) { | 531 const DesktopSessionProxy* desktop_session_proxy) { |
| 534 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, | 532 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, |
| 535 desktop_session_proxy); | 533 desktop_session_proxy); |
| 536 } | 534 } |
| 537 | 535 |
| 538 } // namespace remoting | 536 } // namespace remoting |
| OLD | NEW |