Index: remoting/host/client_session.cc |
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc |
index fd1e441d7d673966286828f562c52936cb76909c..a531b17d7ed7bcc49113936875f1c9895d4182b9 100644 |
--- a/remoting/host/client_session.cc |
+++ b/remoting/host/client_session.cc |
@@ -18,6 +18,7 @@ |
#include "remoting/host/audio_capturer.h" |
#include "remoting/host/audio_scheduler.h" |
#include "remoting/host/desktop_environment.h" |
+#include "remoting/host/extension_session.h" |
#include "remoting/host/input_injector.h" |
#include "remoting/host/screen_controls.h" |
#include "remoting/host/screen_resolution.h" |
@@ -45,7 +46,8 @@ ClientSession::ClientSession( |
scoped_ptr<protocol::ConnectionToClient> connection, |
DesktopEnvironmentFactory* desktop_environment_factory, |
const base::TimeDelta& max_duration, |
- scoped_refptr<protocol::PairingRegistry> pairing_registry) |
+ scoped_refptr<protocol::PairingRegistry> pairing_registry, |
+ const ExtensionList* extensions) |
: event_handler_(event_handler), |
connection_(connection.Pass()), |
client_jid_(connection_->session()->jid()), |
@@ -66,7 +68,8 @@ ClientSession::ClientSession( |
video_encode_task_runner_(video_encode_task_runner), |
network_task_runner_(network_task_runner), |
ui_task_runner_(ui_task_runner), |
- pairing_registry_(pairing_registry) { |
+ pairing_registry_(pairing_registry), |
+ extensions_(extensions) { |
connection_->SetEventHandler(this); |
// TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
@@ -169,6 +172,8 @@ void ClientSession::SetCapabilities( |
VLOG(1) << "Client capabilities: " << *client_capabilities_; |
+ CreateExtensionSessions(); |
Wez
2014/05/28 01:05:59
Why are we doing this here *and* in OnConnectionAu
dcaiafa
2014/05/28 22:44:58
They are the two sites where client_capabilities_
|
+ |
// Calculate the set of capabilities enabled by both client and host and |
// pass it to the desktop environment if it is available. |
desktop_environment_->SetCapabilities( |
@@ -204,6 +209,13 @@ void ClientSession::DeliverClientMessage( |
HOST_LOG << "gnubby auth is not enabled"; |
} |
return; |
+ } else { |
+ for(ExtensionSessionList::iterator it = extension_sessions_.begin(); |
+ it != extension_sessions_.end(); ++it) { |
+ // Extension returns |true| to indicate that the message was handled. |
+ if ((*it)->OnExtensionMessage(this, message)) |
+ return; |
+ } |
} |
} |
HOST_LOG << "Unexpected message received: " |
@@ -253,7 +265,19 @@ void ClientSession::OnConnectionAuthenticated( |
return; |
} |
+ // Compile a list of capabilities from the desktop environment and the |
+ // extensions. It is formatted as a space-separated list of words. |
host_capabilities_ = desktop_environment_->GetCapabilities(); |
+ for (ExtensionList::const_iterator extension = extensions_->begin(); |
+ extension != extensions_->end(); ++extension) { |
+ std::string extension_capabilities = (*extension)->GetCapabilities(); |
+ if (!extension_capabilities.empty()) { |
+ if (!host_capabilities_.empty()) |
+ host_capabilities_.append(" "); |
+ |
+ host_capabilities_.append(extension_capabilities); |
+ } |
+ } |
// Ignore protocol::Capabilities messages from the client if it does not |
// support any capabilities. |
@@ -261,6 +285,8 @@ void ClientSession::OnConnectionAuthenticated( |
VLOG(1) << "The client does not support any capabilities."; |
client_capabilities_ = make_scoped_ptr(new std::string()); |
+ CreateExtensionSessions(); |
Wez
2014/05/28 01:05:59
Could you have the ChromotingHost add the extensio
dcaiafa
2014/05/28 22:44:58
Done.
|
+ |
desktop_environment_->SetCapabilities(*client_capabilities_); |
} |
@@ -472,4 +498,14 @@ scoped_ptr<AudioEncoder> ClientSession::CreateAudioEncoder( |
return scoped_ptr<AudioEncoder>(); |
} |
+void ClientSession::CreateExtensionSessions() { |
+ DCHECK(extension_sessions_.empty()); |
+ |
+ for (ExtensionList::const_iterator extension = extensions_->begin(); |
+ extension != extensions_->end(); ++extension) { |
+ extension_sessions_.push_back( |
+ (*extension)->CreateExtensionSession(this).release()); |
+ } |
+} |
+ |
} // namespace remoting |