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/client_session.h" | 5 #include "remoting/host/client_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "remoting/base/capabilities.h" | 10 #include "remoting/base/capabilities.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 void ClientSession::DeliverClientMessage( | 190 void ClientSession::DeliverClientMessage( |
191 const protocol::ExtensionMessage& message) { | 191 const protocol::ExtensionMessage& message) { |
192 if (message.has_type()) { | 192 if (message.has_type()) { |
193 if (message.type() == "test-echo") { | 193 if (message.type() == "test-echo") { |
194 protocol::ExtensionMessage reply; | 194 protocol::ExtensionMessage reply; |
195 reply.set_type("test-echo-reply"); | 195 reply.set_type("test-echo-reply"); |
196 if (message.has_data()) | 196 if (message.has_data()) |
197 reply.set_data(message.data().substr(0, 16)); | 197 reply.set_data(message.data().substr(0, 16)); |
198 connection_->client_stub()->DeliverHostMessage(reply); | 198 connection_->client_stub()->DeliverHostMessage(reply); |
199 return; | 199 return; |
| 200 } else if (message.type() == "gnubby-auth") { |
| 201 if (gnubby_auth_handler_) { |
| 202 gnubby_auth_handler_->DeliverClientMessage(message.data()); |
| 203 } else { |
| 204 HOST_LOG << "gnubby auth is not enabled"; |
| 205 } |
| 206 return; |
200 } | 207 } |
201 } | 208 } |
202 // No messages are currently supported. | |
203 HOST_LOG << "Unexpected message received: " | 209 HOST_LOG << "Unexpected message received: " |
204 << message.type() << ": " << message.data(); | 210 << message.type() << ": " << message.data(); |
205 } | 211 } |
206 | 212 |
207 void ClientSession::OnConnectionAuthenticated( | 213 void ClientSession::OnConnectionAuthenticated( |
208 protocol::ConnectionToClient* connection) { | 214 protocol::ConnectionToClient* connection) { |
209 DCHECK(CalledOnValidThread()); | 215 DCHECK(CalledOnValidThread()); |
210 DCHECK_EQ(connection_.get(), connection); | 216 DCHECK_EQ(connection_.get(), connection); |
211 DCHECK(!audio_scheduler_.get()); | 217 DCHECK(!audio_scheduler_.get()); |
212 DCHECK(!desktop_environment_); | 218 DCHECK(!desktop_environment_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 if (connection_->session()->config().is_audio_enabled()) { | 287 if (connection_->session()->config().is_audio_enabled()) { |
282 scoped_ptr<AudioEncoder> audio_encoder = | 288 scoped_ptr<AudioEncoder> audio_encoder = |
283 CreateAudioEncoder(connection_->session()->config()); | 289 CreateAudioEncoder(connection_->session()->config()); |
284 audio_scheduler_ = new AudioScheduler( | 290 audio_scheduler_ = new AudioScheduler( |
285 audio_task_runner_, | 291 audio_task_runner_, |
286 network_task_runner_, | 292 network_task_runner_, |
287 desktop_environment_->CreateAudioCapturer(), | 293 desktop_environment_->CreateAudioCapturer(), |
288 audio_encoder.Pass(), | 294 audio_encoder.Pass(), |
289 connection_->audio_stub()); | 295 connection_->audio_stub()); |
290 } | 296 } |
| 297 |
| 298 // Create a GnubbyAuthHandler to proxy gnubbyd messages. |
| 299 gnubby_auth_handler_ = desktop_environment_->CreateGnubbyAuthHandler( |
| 300 connection_->client_stub()); |
291 } | 301 } |
292 | 302 |
293 void ClientSession::OnConnectionChannelsConnected( | 303 void ClientSession::OnConnectionChannelsConnected( |
294 protocol::ConnectionToClient* connection) { | 304 protocol::ConnectionToClient* connection) { |
295 DCHECK(CalledOnValidThread()); | 305 DCHECK(CalledOnValidThread()); |
296 DCHECK_EQ(connection_.get(), connection); | 306 DCHECK_EQ(connection_.get(), connection); |
297 | 307 |
298 // Negotiate capabilities with the client. | 308 // Negotiate capabilities with the client. |
299 if (connection_->session()->config().SupportsCapabilities()) { | 309 if (connection_->session()->config().SupportsCapabilities()) { |
300 VLOG(1) << "Host capabilities: " << host_capabilities_; | 310 VLOG(1) << "Host capabilities: " << host_capabilities_; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 void ClientSession::SetDisableInputs(bool disable_inputs) { | 415 void ClientSession::SetDisableInputs(bool disable_inputs) { |
406 DCHECK(CalledOnValidThread()); | 416 DCHECK(CalledOnValidThread()); |
407 | 417 |
408 if (disable_inputs) | 418 if (disable_inputs) |
409 input_tracker_.ReleaseAll(); | 419 input_tracker_.ReleaseAll(); |
410 | 420 |
411 disable_input_filter_.set_enabled(!disable_inputs); | 421 disable_input_filter_.set_enabled(!disable_inputs); |
412 disable_clipboard_filter_.set_enabled(!disable_inputs); | 422 disable_clipboard_filter_.set_enabled(!disable_inputs); |
413 } | 423 } |
414 | 424 |
| 425 void ClientSession::SetGnubbyAuthHandlerForTesting( |
| 426 GnubbyAuthHandler* gnubby_auth_handler) { |
| 427 gnubby_auth_handler_.reset(gnubby_auth_handler); |
| 428 } |
| 429 |
415 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 430 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
416 DCHECK(CalledOnValidThread()); | 431 DCHECK(CalledOnValidThread()); |
417 | 432 |
418 return scoped_ptr<protocol::ClipboardStub>( | 433 return scoped_ptr<protocol::ClipboardStub>( |
419 new protocol::ClipboardThreadProxy( | 434 new protocol::ClipboardThreadProxy( |
420 client_clipboard_factory_.GetWeakPtr(), | 435 client_clipboard_factory_.GetWeakPtr(), |
421 base::MessageLoopProxy::current())); | 436 base::MessageLoopProxy::current())); |
422 } | 437 } |
423 | 438 |
424 // TODO(sergeyu): Move this to SessionManager? | 439 // TODO(sergeyu): Move this to SessionManager? |
(...skipping 19 matching lines...) Expand all Loading... |
444 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); | 459 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); |
445 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 460 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
446 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); | 461 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); |
447 } | 462 } |
448 | 463 |
449 NOTREACHED(); | 464 NOTREACHED(); |
450 return scoped_ptr<AudioEncoder>(); | 465 return scoped_ptr<AudioEncoder>(); |
451 } | 466 } |
452 | 467 |
453 } // namespace remoting | 468 } // namespace remoting |
OLD | NEW |