diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 14:20:06 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-31 14:20:06 +0000 |
commit | 4ea2c7cfa0f6a2177dedcf69b117408a868a4eb8 (patch) | |
tree | f3423e34f77859d918ed5af5b4345a7dd646f4c0 /remoting/host/client_session.cc | |
parent | 22efa086fc27f192a1805d4bd62c576fe23580a4 (diff) | |
download | chromium_src-4ea2c7cfa0f6a2177dedcf69b117408a868a4eb8.zip chromium_src-4ea2c7cfa0f6a2177dedcf69b117408a868a4eb8.tar.gz chromium_src-4ea2c7cfa0f6a2177dedcf69b117408a868a4eb8.tar.bz2 |
The authenticated_ fields are moved out of stubs and into
ClientSession. Messages to the stubs are dispatched via
ClientSession, and the stub classes are pure virtual.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6724033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/client_session.cc')
-rw-r--r-- | remoting/host/client_session.cc | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 72cd5ba..b946a0a 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -6,6 +6,7 @@ #include "base/memory/scoped_ptr.h" #include "base/task.h" +#include "media/base/callback.h" #include "remoting/host/user_authenticator.h" #include "remoting/proto/auth.pb.h" @@ -13,9 +14,14 @@ namespace remoting { ClientSession::ClientSession( EventHandler* event_handler, - scoped_refptr<protocol::ConnectionToClient> connection) + const base::Callback<UserAuthenticatorFactory>& auth_factory, + scoped_refptr<protocol::ConnectionToClient> connection, + protocol::InputStub* input_stub) : event_handler_(event_handler), - connection_(connection) { + auth_factory_(auth_factory), + connection_(connection), + input_stub_(input_stub), + authenticated_(false) { } ClientSession::~ClientSession() { @@ -23,16 +29,23 @@ ClientSession::~ClientSession() { void ClientSession::SuggestResolution( const protocol::SuggestResolutionRequest* msg, Task* done) { - done->Run(); - delete done; + media::AutoTaskRunner done_runner(done); + + if (!authenticated_) { + LOG(WARNING) << "Invalid control message received " + << "(client not authenticated)."; + return; + } } void ClientSession::BeginSessionRequest( const protocol::LocalLoginCredentials* credentials, Task* done) { DCHECK(event_handler_); + media::AutoTaskRunner done_runner(done); + bool success = false; - scoped_ptr<UserAuthenticator> authenticator(UserAuthenticator::Create()); + scoped_ptr<UserAuthenticator> authenticator(auth_factory_.Run()); switch (credentials->type()) { case protocol::PASSWORD: success = authenticator->Authenticate(credentials->username(), @@ -45,22 +58,35 @@ void ClientSession::BeginSessionRequest( } if (success) { + authenticated_ = true; event_handler_->LocalLoginSucceeded(connection_.get()); } else { LOG(WARNING) << "Login failed for user " << credentials->username(); event_handler_->LocalLoginFailed(connection_.get()); } +} + +void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event, + Task* done) { + media::AutoTaskRunner done_runner(done); + if (authenticated_) { + done_runner.release(); + input_stub_->InjectKeyEvent(event, done); + } +} - done->Run(); - delete done; +void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event, + Task* done) { + media::AutoTaskRunner done_runner(done); + if (authenticated_) { + done_runner.release(); + input_stub_->InjectMouseEvent(event, done); + } } void ClientSession::Disconnect() { connection_->Disconnect(); -} - -protocol::ConnectionToClient* ClientSession::connection() const { - return connection_.get(); + authenticated_ = false; } } // namespace remoting |