Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: remoting/host/chromoting_host.cc

Issue 7134023: Notify calling web-app when Host plugin becomes connected to a client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stop accepting connections once there is one active in Me2Mom. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/chromoting_host.cc
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 7f3cadd24de9411605b8446be262038672ef696e..7ffb04b7488e1abde48ff19f1caa3611f533e13a 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -183,8 +183,8 @@ void ChromotingHost::AddStatusObserver(
void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) {
DCHECK_EQ(context_->network_message_loop(), MessageLoop::current());
VLOG(1) << "Connection to client established.";
+ // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom.
if (is_me2mom_) {
- // TODO(wez): Improve our authentication framework.
context_->main_message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromotingHost::ProcessPreAuthentication,
@@ -280,6 +280,14 @@ void ChromotingHost::OnNewClientSession(
return;
}
+ // If we are running Me2Mom and already have an authenticated client then
+ // reject the connection immediately.
Jamie 2011/06/10 18:00:38 What's the concern here? If we're worried that a b
Wez 2011/06/13 20:30:35 The Access Code is one-shot by design, so from a s
+ // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom.
+ if (is_me2mom_ && AuthenticatedClientsCount() > 0) {
+ *response = protocol::SessionManager::DECLINE;
+ return;
+ }
+
// Check that the client has access to the host.
if (!access_verifier_->VerifyPermissions(session->jid(),
session->initiator_token())) {
@@ -367,10 +375,22 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) {
connection->Disconnect();
// Also remove reference to ConnectionToClient from this object.
+ int old_authenticated_clients = AuthenticatedClientsCount();
clients_.erase(client);
- if (!HasAuthenticatedClients()) {
+ // Notify the observers of the change, if any.
+ int authenticated_clients = AuthenticatedClientsCount();
+ if (old_authenticated_clients != authenticated_clients) {
+ for (StatusObserverList::iterator it = status_observers_.begin();
+ it != status_observers_.end(); ++it) {
+ (*it)->OnAuthenticatedClientsChanged(authenticated_clients);
+ }
+ }
+
+ // Enable the "curtain", if at least one client is actually authenticated.
+ if (AuthenticatedClientsCount() > 0) {
EnableCurtainMode(false);
+ // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom.
if (is_me2mom_)
desktop_environment_->disconnect_window()->Hide();
}
@@ -401,18 +421,20 @@ std::string ChromotingHost::GenerateHostAuthToken(
return encoded_client_token;
}
-bool ChromotingHost::HasAuthenticatedClients() const {
+int ChromotingHost::AuthenticatedClientsCount() const {
+ int authenticated_clients = 0;
for (ClientList::const_iterator it = clients_.begin(); it != clients_.end();
++it) {
if (it->get()->authenticated())
- return true;
+ ++authenticated_clients;
}
- return false;
+ return authenticated_clients;
}
void ChromotingHost::EnableCurtainMode(bool enable) {
// TODO(jamiewalch): This will need to be more sophisticated when we think
// about proper crash recovery and daemon mode.
+ // TODO(wez): CurtainMode shouldn't be driven directly by ChromotingHost.
Jamie 2011/06/10 18:00:38 +1
Wez 2011/06/13 20:30:35 As requested, I've removed the dups of this commen
if (is_me2mom_ || enable == is_curtained_)
return;
desktop_environment_->curtain()->EnableCurtainMode(enable);
@@ -466,6 +488,7 @@ void ChromotingHost::LocalLoginSucceeded(
recorder_->AddConnection(connection);
recorder_->Start();
EnableCurtainMode(true);
+ // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom.
if (is_me2mom_) {
std::string username = connection->session()->jid();
size_t pos = username.find('/');
@@ -473,6 +496,12 @@ void ChromotingHost::LocalLoginSucceeded(
username.replace(pos, std::string::npos, "");
desktop_environment_->disconnect_window()->Show(this, username);
}
+
+ // Notify observers that there is at least one authenticated client.
+ for (StatusObserverList::iterator it = status_observers_.begin();
+ it != status_observers_.end(); ++it) {
+ (*it)->OnAuthenticatedClientsChanged(AuthenticatedClientsCount());
+ }
}
void ChromotingHost::LocalLoginFailed(

Powered by Google App Engine
This is Rietveld 408576698