diff options
author | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 19:02:18 +0000 |
---|---|---|
committer | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-16 19:02:18 +0000 |
commit | 00f93a6e497bf687e9c28030bd65e142401ee0aa (patch) | |
tree | 53aabfb3bed4b7ee1d42107c7737446524a61f7f /remoting/host | |
parent | e2341182c3230772e3438c2888d02af60ad4ffc3 (diff) | |
download | chromium_src-00f93a6e497bf687e9c28030bd65e142401ee0aa.zip chromium_src-00f93a6e497bf687e9c28030bd65e142401ee0aa.tar.gz chromium_src-00f93a6e497bf687e9c28030bd65e142401ee0aa.tar.bz2 |
Revert 89370 - Notify calling web-app when Host plugin becomes connected to a client.
BUG=85110
TEST=
Review URL: http://codereview.chromium.org/7134023
TBR=wez@chromium.org
Review URL: http://codereview.chromium.org/7189017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89375 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/chromoting_host.cc | 36 | ||||
-rw-r--r-- | remoting/host/chromoting_host.h | 3 | ||||
-rw-r--r-- | remoting/host/heartbeat_sender.cc | 5 | ||||
-rw-r--r-- | remoting/host/heartbeat_sender.h | 1 | ||||
-rw-r--r-- | remoting/host/host_plugin.cc | 19 | ||||
-rw-r--r-- | remoting/host/host_status_observer.h | 5 | ||||
-rw-r--r-- | remoting/host/register_support_host_request.cc | 3 | ||||
-rw-r--r-- | remoting/host/register_support_host_request.h | 1 |
8 files changed, 22 insertions, 51 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 81f1f86..ace4f71 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,6 +283,13 @@ 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())) { @@ -385,20 +392,9 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) { connection->Disconnect(); // Also remove reference to ConnectionToClient from this object. - int old_authenticated_clients = AuthenticatedClientsCount(); clients_.erase(client); - // 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) { + if (!HasAuthenticatedClients()) { EnableCurtainMode(false); if (is_me2mom_) { MonitorLocalInputs(false); @@ -432,19 +428,19 @@ std::string ChromotingHost::GenerateHostAuthToken( return encoded_client_token; } -int ChromotingHost::AuthenticatedClientsCount() const { - int authenticated_clients = 0; +bool ChromotingHost::HasAuthenticatedClients() const { for (ClientList::const_iterator it = clients_.begin(); it != clients_.end(); ++it) { if (it->get()->authenticated()) - ++authenticated_clients; + return true; } - return authenticated_clients; + return false; } 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); @@ -519,12 +515,6 @@ 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( diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 5f146b2..c05b06d 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -123,6 +123,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, // |config| is transferred to the object. Must be called before Start(). void set_protocol_config(protocol::CandidateSessionConfig* config); + // TODO(wez): ChromotingHost shouldn't need to know about Me2Mom. void set_me2mom(bool is_me2mom) { is_me2mom_ = is_me2mom; } @@ -163,7 +164,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, std::string GenerateHostAuthToken(const std::string& encoded_client_token); - int AuthenticatedClientsCount() const; + bool HasAuthenticatedClients() const; void EnableCurtainMode(bool enable); diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc index c726773..5ef02b7 100644 --- a/remoting/host/heartbeat_sender.cc +++ b/remoting/host/heartbeat_sender.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -86,9 +86,6 @@ void HeartbeatSender::OnSignallingDisconnected() { request_.reset(NULL); } -void HeartbeatSender::OnAuthenticatedClientsChanged(int clients) { -} - void HeartbeatSender::OnShutdown() { } diff --git a/remoting/host/heartbeat_sender.h b/remoting/host/heartbeat_sender.h index cdeb945..016db0f 100644 --- a/remoting/host/heartbeat_sender.h +++ b/remoting/host/heartbeat_sender.h @@ -70,7 +70,6 @@ class HeartbeatSender : public HostStatusObserver { virtual void OnSignallingConnected(SignalStrategy* signal_strategy, const std::string& full_jid) OVERRIDE; virtual void OnSignallingDisconnected() OVERRIDE; - virtual void OnAuthenticatedClientsChanged(int clients) OVERRIDE; virtual void OnShutdown() OVERRIDE; private: diff --git a/remoting/host/host_plugin.cc b/remoting/host/host_plugin.cc index 98f8a21..11b621e 100644 --- a/remoting/host/host_plugin.cc +++ b/remoting/host/host_plugin.cc @@ -131,7 +131,7 @@ NPObject* ObjectFromNPVariant(const NPVariant& variant) { } // NPAPI plugin implementation for remoting host script object. -class HostNPScriptObject : remoting::HostStatusObserver { +class HostNPScriptObject { public: HostNPScriptObject(NPP plugin, NPObject* parent) : plugin_(plugin), @@ -354,15 +354,9 @@ class HostNPScriptObject : remoting::HostStatusObserver { void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, bool success, const std::string& support_id); + void OnConnected(); void OnHostShutdown(); - // HostStatusObserver interface. - virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy, - const std::string& full_jid) {} - virtual void OnSignallingDisconnected() {} - virtual void OnAuthenticatedClientsChanged(int clients_connected); - virtual void OnShutdown() {} - // Call a JavaScript function wrapped as an NPObject. // If result is non-null, the result of the call will be stored in it. // Caller is responsible for releasing result if they ask for it. @@ -463,7 +457,6 @@ bool HostNPScriptObject::Connect(const NPVariant* args, remoting::ChromotingHost::Create(&host_context_, host_config, access_verifier.release()); host->AddStatusObserver(register_request); - host->AddStatusObserver(this); host->set_me2mom(true); // Nothing went wrong, so lets save the host, config and request. @@ -523,14 +516,14 @@ void HostNPScriptObject::OnReceivedSupportID( OnStateChanged(kReceivedAccessCode); } -void HostNPScriptObject::OnHostShutdown() { +void HostNPScriptObject::OnConnected() { CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_); - OnStateChanged(kDisconnected); + OnStateChanged(kConnected); } -void HostNPScriptObject::OnAuthenticatedClientsChanged(int clients_connected) { +void HostNPScriptObject::OnHostShutdown() { CHECK_NE(base::PlatformThread::CurrentId(), np_thread_id_); - OnStateChanged(clients_connected ? kConnected : kDisconnected); + OnStateChanged(kDisconnected); } void HostNPScriptObject::OnStateChanged(State state) { diff --git a/remoting/host/host_status_observer.h b/remoting/host/host_status_observer.h index daecba3..dd0ae85 100644 --- a/remoting/host/host_status_observer.h +++ b/remoting/host/host_status_observer.h @@ -21,11 +21,6 @@ class HostStatusObserver const std::string& full_jid) = 0; virtual void OnSignallingDisconnected() = 0; - // Called on the main thread when a client authenticates, or disconnects. - // The observer must not tear-down ChromotingHost state on receipt of - // this callback; it is purely informational. - virtual void OnAuthenticatedClientsChanged(int authenticated_clients) = 0; - // Called on the main thread when the host shuts down. virtual void OnShutdown() = 0; diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/register_support_host_request.cc index 6703bf0..fff4c6b 100644 --- a/remoting/host/register_support_host_request.cc +++ b/remoting/host/register_support_host_request.cc @@ -78,9 +78,6 @@ void RegisterSupportHostRequest::OnSignallingDisconnected() { request_.reset(); } -void RegisterSupportHostRequest::OnAuthenticatedClientsChanged(int clients) { -} - void RegisterSupportHostRequest::OnShutdown() { } diff --git a/remoting/host/register_support_host_request.h b/remoting/host/register_support_host_request.h index d831cf6..c9b1e60 100644 --- a/remoting/host/register_support_host_request.h +++ b/remoting/host/register_support_host_request.h @@ -53,7 +53,6 @@ class RegisterSupportHostRequest : public HostStatusObserver { virtual void OnSignallingConnected(SignalStrategy* signal_strategy, const std::string& full_jid) OVERRIDE; virtual void OnSignallingDisconnected() OVERRIDE; - virtual void OnAuthenticatedClientsChanged(int clients_connected) OVERRIDE; virtual void OnShutdown() OVERRIDE; private: |