diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 18:36:52 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 18:36:52 +0000 |
commit | db97348d16cedf07f4dc520014dd6e80cb67f1d3 (patch) | |
tree | cdacbe0f0bd4aef3937efa2e462f464487671cc9 /remoting/host/chromoting_host.cc | |
parent | 268b10337c65d2e6fbdf3263beeec4240e9aeb23 (diff) | |
download | chromium_src-db97348d16cedf07f4dc520014dd6e80cb67f1d3.zip chromium_src-db97348d16cedf07f4dc520014dd6e80cb67f1d3.tar.gz chromium_src-db97348d16cedf07f4dc520014dd6e80cb67f1d3.tar.bz2 |
Notify calling web-app when Host plugin becomes connected to a client.
BUG=85110
TEST=
Review URL: http://codereview.chromium.org/7134023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/chromoting_host.cc')
-rw-r--r-- | remoting/host/chromoting_host.cc | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index ace4f71..81f1f86 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -186,8 +186,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, @@ -283,13 +283,6 @@ void ChromotingHost::OnNewClientSession( return; } - // If we are running Me2Mom and already have an authenticated client then - // reject the connection immediately. - if (is_me2mom_ && HasAuthenticatedClients()) { - *response = protocol::SessionManager::DECLINE; - return; - } - // Check that the client has access to the host. if (!access_verifier_->VerifyPermissions(session->jid(), session->initiator_token())) { @@ -392,9 +385,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_me2mom_) { MonitorLocalInputs(false); @@ -428,19 +432,19 @@ 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. if (is_me2mom_ || enable == is_curtained_) return; desktop_environment_->curtain()->EnableCurtainMode(enable); @@ -515,6 +519,12 @@ void ChromotingHost::LocalLoginSucceeded( username.replace(pos, std::string::npos, ""); ShowDisconnectWindow(true, 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( |