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

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: Remove blank line from rebase. 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
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/heartbeat_sender.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromoting_host.cc
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index d5f37f3c6d97cc7ce428404a9507258a05225d3d..4f7db334dbf6e361d13e2a734487f27ec2ed6c0b 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -278,7 +278,7 @@ void ChromotingHost::OnNewClientSession(
// If we are running Me2Mom and already have an authenticated client then
// reject the connection immediately.
- if (is_it2me_ && HasAuthenticatedClients()) {
+ if (is_it2me_ && AuthenticatedClientsCount() > 0) {
*response = protocol::SessionManager::DECLINE;
return;
}
@@ -400,9 +400,20 @@ 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);
if (is_it2me_) {
MonitorLocalInputs(false);
@@ -438,13 +449,14 @@ 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) {
@@ -524,6 +536,12 @@ void ChromotingHost::LocalLoginSucceeded(
ShowDisconnectWindow(true, username);
StartContinueWindowTimer(true);
}
+
+ // 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(
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/heartbeat_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698