diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 21:31:44 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 21:31:44 +0000 |
commit | f0a9d1b2f35d1a0ae2c532b86fb3fd78b1c5465b (patch) | |
tree | cdbb2dde6847f6f36f8a0f8f6fe33d0192382b7a /remoting | |
parent | 0e5eeb0f24d0874a2ff2e8f491d0d7fbd1921527 (diff) | |
download | chromium_src-f0a9d1b2f35d1a0ae2c532b86fb3fd78b1c5465b.zip chromium_src-f0a9d1b2f35d1a0ae2c532b86fb3fd78b1c5465b.tar.gz chromium_src-f0a9d1b2f35d1a0ae2c532b86fb3fd78b1c5465b.tar.bz2 |
Block event processing on host/client until the client has authenticated.
Input events:
* Client will not send them
* Host will not process them
Control events:
* Client will only process BeginSessionResponse
* Host will only process BeginSessionRequest
All other control messages will be ignored.
BUG=72466
TEST=manual+tests
Review URL: http://codereview.chromium.org/6594138
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/chromoting_client.cc | 6 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.cc | 3 | ||||
-rw-r--r-- | remoting/host/chromoting_host.cc | 1 | ||||
-rw-r--r-- | remoting/host/chromoting_host_unittest.cc | 40 | ||||
-rw-r--r-- | remoting/host/screen_recorder_unittest.cc | 12 | ||||
-rw-r--r-- | remoting/protocol/client_message_dispatcher.cc | 34 | ||||
-rw-r--r-- | remoting/protocol/client_stub.cc | 30 | ||||
-rw-r--r-- | remoting/protocol/client_stub.h | 18 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.cc | 20 | ||||
-rw-r--r-- | remoting/protocol/connection_to_client.h | 10 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 18 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.h | 8 | ||||
-rw-r--r-- | remoting/protocol/host_message_dispatcher.cc | 52 | ||||
-rw-r--r-- | remoting/protocol/host_stub.cc | 29 | ||||
-rw-r--r-- | remoting/protocol/host_stub.h | 20 | ||||
-rw-r--r-- | remoting/protocol/input_stub.cc | 29 | ||||
-rw-r--r-- | remoting/protocol/input_stub.h | 19 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.h | 5 | ||||
-rw-r--r-- | remoting/remoting.gyp | 4 |
20 files changed, 304 insertions, 61 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 0449d8f..f205d1e 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -233,6 +233,12 @@ void ChromotingClient::BeginSessionResponse( return; } + // Inform the connection that the client has been authenticated. This will + // enable the communication channels. + if (msg->success()) { + connection_->OnClientAuthenticated(); + } + view_->UpdateLoginStatus(msg->success(), msg->error_info()); done->Run(); delete done; diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc index 81ace4e..16a5738 100644 --- a/remoting/client/plugin/pepper_input_handler.cc +++ b/remoting/client/plugin/pepper_input_handler.cc @@ -33,7 +33,8 @@ void PepperInputHandler::HandleCharacterEvent( // TODO(garykac): Coordinate key and char events. } -void PepperInputHandler::HandleMouseMoveEvent(const PP_InputEvent_Mouse& event) { +void PepperInputHandler::HandleMouseMoveEvent( + const PP_InputEvent_Mouse& event) { SendMouseMoveEvent(static_cast<int>(event.x), static_cast<int>(event.y)); } diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 5b2a21d..7039d87 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -383,6 +383,7 @@ void ChromotingHost::LocalLoginSucceeded() { connection_->client_stub()->BeginSessionResponse( status, new DeleteTask<protocol::LocalLoginStatus>(status)); + connection_->OnClientAuthenticated(); recorder_->Start(); } diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index 576aeae..23295ae 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -15,6 +15,16 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using ::remoting::protocol::LocalLoginCredentials; +using ::remoting::protocol::MockClientStub; +using ::remoting::protocol::MockConnectionToClient; +using ::remoting::protocol::MockConnectionToClientEventHandler; +using ::remoting::protocol::MockHostStub; +using ::remoting::protocol::MockInputStub; +using ::remoting::protocol::MockSession; +using ::remoting::protocol::MockVideoStub; +using ::remoting::protocol::SessionConfig; + using testing::_; using testing::AnyNumber; using testing::DeleteArg; @@ -32,8 +42,8 @@ void PostQuitTask(MessageLoop* message_loop) { } void BeginSessionRequest(protocol::HostStub* host_stub) { - protocol::LocalLoginCredentials* credentials = - new protocol::LocalLoginCredentials(); + LocalLoginCredentials* credentials = + new LocalLoginCredentials(); credentials->set_type(protocol::PASSWORD); credentials->set_username("hello"); @@ -42,7 +52,7 @@ void BeginSessionRequest(protocol::HostStub* host_stub) { host_stub->BeginSessionRequest( credentials, - new DeleteTask<protocol::LocalLoginCredentials>(credentials)); + new DeleteTask<LocalLoginCredentials>(credentials)); } // Run the task and delete it afterwards. This action is used to deal with @@ -79,13 +89,15 @@ class ChromotingHostTest : public testing::Test { .Times(AnyNumber()); Capturer* capturer = new CapturerFake(context_.main_message_loop()); - input_stub_ = new protocol::MockInputStub(); + host_stub_ = new MockHostStub(); + input_stub_ = new MockInputStub(); DesktopEnvironment* desktop = new DesktopEnvironmentFake(capturer, input_stub_); host_ = ChromotingHost::Create(&context_, config_, desktop); - connection_ = new protocol::MockConnectionToClient(); - session_ = new protocol::MockSession(); - session_config_.reset(protocol::SessionConfig::CreateDefault()); + connection_ = new MockConnectionToClient( + &message_loop_, &handler_, host_stub_, input_stub_); + session_ = new MockSession(); + session_config_.reset(SessionConfig::CreateDefault()); ON_CALL(video_stub_, ProcessVideoPacket(_, _)) .WillByDefault( @@ -139,15 +151,17 @@ class ChromotingHostTest : public testing::Test { protected: MessageLoop message_loop_; + MockConnectionToClientEventHandler handler_; scoped_refptr<ChromotingHost> host_; scoped_refptr<InMemoryHostConfig> config_; MockChromotingHostContext context_; - scoped_refptr<protocol::MockConnectionToClient> connection_; - scoped_refptr<protocol::MockSession> session_; - scoped_ptr<protocol::SessionConfig> session_config_; - protocol::MockVideoStub video_stub_; - protocol::MockClientStub client_stub_; - protocol::MockInputStub* input_stub_; + scoped_refptr<MockConnectionToClient> connection_; + scoped_refptr<MockSession> session_; + scoped_ptr<SessionConfig> session_config_; + MockVideoStub video_stub_; + MockClientStub client_stub_; + MockHostStub* host_stub_; + MockInputStub* input_stub_; }; TEST_F(ChromotingHostTest, StartAndShutdown) { diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc index 412ce6d..b4fa40a 100644 --- a/remoting/host/screen_recorder_unittest.cc +++ b/remoting/host/screen_recorder_unittest.cc @@ -13,6 +13,9 @@ #include "testing/gtest/include/gtest/gtest.h" using ::remoting::protocol::MockConnectionToClient; +using ::remoting::protocol::MockConnectionToClientEventHandler; +using ::remoting::protocol::MockHostStub; +using ::remoting::protocol::MockInputStub; using ::remoting::protocol::MockVideoStub; using ::testing::_; @@ -77,7 +80,10 @@ class ScreenRecorderTest : public testing::Test { virtual void SetUp() { // Capturer and Encoder are owned by ScreenRecorder. encoder_ = new MockEncoder(); - connection_ = new MockConnectionToClient(); + + connection_ = new MockConnectionToClient(&message_loop_, &handler_, + &host_stub_, &input_stub_); + record_ = new ScreenRecorder( &message_loop_, &message_loop_, &message_loop_, &capturer_, encoder_); @@ -85,6 +91,10 @@ class ScreenRecorderTest : public testing::Test { protected: scoped_refptr<ScreenRecorder> record_; + + MockConnectionToClientEventHandler handler_; + MockHostStub host_stub_; + MockInputStub input_stub_; scoped_refptr<MockConnectionToClient> connection_; // The following mock objects are owned by ScreenRecorder. diff --git a/remoting/protocol/client_message_dispatcher.cc b/remoting/protocol/client_message_dispatcher.cc index e7b6dd6..657e30d 100644 --- a/remoting/protocol/client_message_dispatcher.cc +++ b/remoting/protocol/client_message_dispatcher.cc @@ -39,18 +39,32 @@ void ClientMessageDispatcher::Initialize( void ClientMessageDispatcher::OnControlMessageReceived( ControlMessage* message, Task* done_task) { - // TODO(sergeyu): Add message validation. - if (message->has_notify_resolution()) { - client_stub_->NotifyResolution( - &message->notify_resolution(), done_task); - } else if (message->has_begin_session_response()) { - client_stub_->BeginSessionResponse( - &message->begin_session_response().login_status(), done_task); + if (!client_stub_->authenticated()) { + // When the client has not authenticated with the host, we restrict the + // control messages that we support. + if (message->has_begin_session_response()) { + client_stub_->BeginSessionResponse( + &message->begin_session_response().login_status(), done_task); + return; + } else { + LOG(WARNING) << "Invalid control message received " + << "(client not authenticated)."; + } } else { - LOG(WARNING) << "Invalid control message received."; - done_task->Run(); - delete done_task; + // TODO(sergeyu): Add message validation. + if (message->has_notify_resolution()) { + client_stub_->NotifyResolution( + &message->notify_resolution(), done_task); + return; + } else if (message->has_begin_session_response()) { + LOG(WARNING) << "BeginSessionResponse sent after client already " + << "authorized."; + } else { + LOG(WARNING) << "Invalid control message received."; + } } + done_task->Run(); + delete done_task; } } // namespace protocol diff --git a/remoting/protocol/client_stub.cc b/remoting/protocol/client_stub.cc new file mode 100644 index 0000000..d766f5b --- /dev/null +++ b/remoting/protocol/client_stub.cc @@ -0,0 +1,30 @@ +// 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. + +// Interface of a client that receives commands from a Chromoting host. +// +// This interface is responsible for a subset of control messages sent to +// the Chromoting client. + +#include "remoting/protocol/client_stub.h" + +namespace remoting { +namespace protocol { + +ClientStub::ClientStub() : authenticated_(false) { +} + +ClientStub::~ClientStub() { +} + +void ClientStub::OnAuthenticated() { + authenticated_ = true; +} + +bool ClientStub::authenticated() { + return authenticated_; +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/client_stub.h b/remoting/protocol/client_stub.h index 4b73789..a2bd565 100644 --- a/remoting/protocol/client_stub.h +++ b/remoting/protocol/client_stub.h @@ -22,15 +22,29 @@ class NotifyResolutionRequest; class ClientStub { public: - ClientStub() {} - virtual ~ClientStub() {} + ClientStub(); + virtual ~ClientStub(); virtual void NotifyResolution(const NotifyResolutionRequest* msg, Task* done) = 0; virtual void BeginSessionResponse(const LocalLoginStatus* msg, Task* done) = 0; + // Called when the client has authenticated with the host to enable the + // host->client control channel. + // Before this is called, only a limited set of control messages will be + // processed. + void OnAuthenticated(); + + // Has the client successfully authenticated with the host? + // I.e., should we be processing control events? + bool authenticated(); + private: + // Initially false, this records whether the client has authenticated with + // the host. + bool authenticated_; + DISALLOW_COPY_AND_ASSIGN(ClientStub); }; diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc index 3b4bd3f..383451b 100644 --- a/remoting/protocol/connection_to_client.cc +++ b/remoting/protocol/connection_to_client.cc @@ -8,6 +8,8 @@ #include "net/base/io_buffer.h" #include "remoting/protocol/client_control_sender.h" #include "remoting/protocol/host_message_dispatcher.h" +#include "remoting/protocol/host_stub.h" +#include "remoting/protocol/input_stub.h" // TODO(hclam): Remove this header once MessageDispatcher is used. #include "remoting/base/compound_buffer.h" @@ -23,7 +25,8 @@ ConnectionToClient::ConnectionToClient(MessageLoop* message_loop, EventHandler* handler, HostStub* host_stub, InputStub* input_stub) - : loop_(message_loop), + : client_authenticated_(false), + loop_(message_loop), handler_(handler), host_stub_(host_stub), input_stub_(input_stub) { @@ -73,9 +76,6 @@ ClientStub* ConnectionToClient::client_stub() { return client_stub_.get(); } -ConnectionToClient::ConnectionToClient() { -} - void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { if (state == protocol::Session::CONNECTED) { client_stub_.reset(new ClientControlSender(session_->control_channel())); @@ -123,5 +123,17 @@ void ConnectionToClient::StateChangeTask(protocol::Session::State state) { void ConnectionToClient::OnClosed() { } +void ConnectionToClient::OnClientAuthenticated() { + client_authenticated_ = true; + + // Enable/disable each of the channels. + if (input_stub_) + input_stub_->OnAuthenticated(); + if (host_stub_) + host_stub_->OnAuthenticated(); + if (client_stub_.get()) + client_stub_->OnAuthenticated(); +} + } // namespace protocol } // namespace remoting diff --git a/remoting/protocol/connection_to_client.h b/remoting/protocol/connection_to_client.h index b7aa052..d2721f3 100644 --- a/remoting/protocol/connection_to_client.h +++ b/remoting/protocol/connection_to_client.h @@ -72,9 +72,8 @@ class ConnectionToClient : // Return pointer to ClientStub. virtual ClientStub* client_stub(); - protected: - // Protected constructor used by unit test. - ConnectionToClient(); + // Called when the host accepts the client authentication. + void OnClientAuthenticated(); private: // Callback for protocol Session. @@ -85,6 +84,11 @@ class ConnectionToClient : void OnClosed(); + // Initially false, this is set to true once the client has authenticated + // properly. When this is false, many client messages (like input events) + // will be ignored. + bool client_authenticated_; + // The libjingle channel used to send and receive data from the remote client. scoped_refptr<Session> session_; diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 3d34997..2ef3a22 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -25,7 +25,8 @@ ConnectionToHost::ConnectionToHost( JingleThread* thread, talk_base::NetworkManager* network_manager, talk_base::PacketSocketFactory* socket_factory) - : thread_(thread), + : client_authenticated_(false), + thread_(thread), network_manager_(network_manager), socket_factory_(socket_factory), event_callback_(NULL), @@ -190,7 +191,6 @@ void ConnectionToHost::OnSessionStateChange( // Initialize reader and writer. video_reader_.reset(VideoReader::Create(session_->config())); video_reader_->Init(session_, video_stub_); - input_stub_.reset(new InputSender(session_->event_channel())); host_stub_.reset(new HostControlSender(session_->control_channel())); dispatcher_->Initialize(session_.get(), client_stub_); event_callback_->OnConnectionOpened(this); @@ -202,5 +202,19 @@ void ConnectionToHost::OnSessionStateChange( } } +void ConnectionToHost::OnClientAuthenticated() { + client_authenticated_ = true; + + // Create and enable the input stub now that we're authenticated. + input_stub_.reset(new InputSender(session_->event_channel())); + input_stub_->OnAuthenticated(); + + // Enable control channel stubs. + if (host_stub_.get()) + host_stub_->OnAuthenticated(); + if (client_stub_) + client_stub_->OnAuthenticated(); +} + } // namespace protocol } // namespace remoting diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index 2f661ca..3962c32 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -85,6 +85,9 @@ class ConnectionToHost : public JingleClient::Callback { // Callback for chromotocol Session. void OnSessionStateChange(Session::State state); + // Called when the host accepts the client authentication. + void OnClientAuthenticated(); + private: // The message loop for the jingle thread this object works on. MessageLoop* message_loop(); @@ -101,6 +104,11 @@ class ConnectionToHost : public JingleClient::Callback { void OnDisconnected(); void OnServerClosed(); + // Initially false, this is set to true once the client has authenticated + // properly. When this is false, many messages to the host (like input events) + // will be suppressed. + bool client_authenticated_; + JingleThread* thread_; scoped_ptr<talk_base::NetworkManager> network_manager_; diff --git a/remoting/protocol/host_message_dispatcher.cc b/remoting/protocol/host_message_dispatcher.cc index 1e1eea8..f4391a7 100644 --- a/remoting/protocol/host_message_dispatcher.cc +++ b/remoting/protocol/host_message_dispatcher.cc @@ -48,30 +48,46 @@ void HostMessageDispatcher::Initialize( void HostMessageDispatcher::OnControlMessageReceived( ControlMessage* message, Task* done_task) { - // TODO(sergeyu): Add message validation. - if (message->has_suggest_resolution()) { - host_stub_->SuggestResolution(&message->suggest_resolution(), done_task); - } else if (message->has_begin_session_request()) { - host_stub_->BeginSessionRequest( - &message->begin_session_request().credentials(), done_task); + if (!host_stub_->authenticated()) { + // When the client has not authenticated with the host, we restrict the + // control messages that we support. + if (message->has_begin_session_request()) { + host_stub_->BeginSessionRequest( + &message->begin_session_request().credentials(), done_task); + return; + } else { + LOG(WARNING) << "Invalid control message received " + << "(client not authenticated)."; + } } else { - LOG(WARNING) << "Invalid control message received."; - done_task->Run(); - delete done_task; + // TODO(sergeyu): Add message validation. + if (message->has_suggest_resolution()) { + host_stub_->SuggestResolution(&message->suggest_resolution(), done_task); + return; + } else if (message->has_begin_session_request()) { + LOG(WARNING) << "BeginSessionRequest sent after client already " + << "authorized."; + } else { + LOG(WARNING) << "Invalid control message received."; + } } + done_task->Run(); + delete done_task; } void HostMessageDispatcher::OnEventMessageReceived( EventMessage* message, Task* done_task) { - // TODO(sergeyu): Add message validation. - if (message->has_key_event()) { - input_stub_->InjectKeyEvent(&message->key_event(), done_task); - } else if (message->has_mouse_event()) { - input_stub_->InjectMouseEvent(&message->mouse_event(), done_task); - } else { - LOG(WARNING) << "Invalid event message received."; - done_task->Run(); - delete done_task; + if (input_stub_->authenticated()) { + // TODO(sergeyu): Add message validation. + if (message->has_key_event()) { + input_stub_->InjectKeyEvent(&message->key_event(), done_task); + } else if (message->has_mouse_event()) { + input_stub_->InjectMouseEvent(&message->mouse_event(), done_task); + } else { + LOG(WARNING) << "Invalid event message received."; + done_task->Run(); + delete done_task; + } } } diff --git a/remoting/protocol/host_stub.cc b/remoting/protocol/host_stub.cc new file mode 100644 index 0000000..3ab1029 --- /dev/null +++ b/remoting/protocol/host_stub.cc @@ -0,0 +1,29 @@ +// 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. + +// Interface of a host that receives commands from a Chromoting client. +// +// This interface handles control messages defined in contro.proto. + +#include "remoting/protocol/host_stub.h" + +namespace remoting { +namespace protocol { + +HostStub::HostStub() : authenticated_(false) { +} + +HostStub::~HostStub() { +} + +void HostStub::OnAuthenticated() { + authenticated_ = true; +} + +bool HostStub::authenticated() { + return authenticated_; +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/host_stub.h b/remoting/protocol/host_stub.h index 1a26225..c8fa4ac 100644 --- a/remoting/protocol/host_stub.h +++ b/remoting/protocol/host_stub.h @@ -4,7 +4,7 @@ // Interface of a host that receives commands from a Chromoting client. // -// This interterface handles control messages defined in contro.proto. +// This interface handles control messages defined in contro.proto. #ifndef REMOTING_PROTOCOL_HOST_STUB_H_ #define REMOTING_PROTOCOL_HOST_STUB_H_ @@ -21,15 +21,29 @@ class LocalLoginCredentials; class HostStub { public: - HostStub() {} - virtual ~HostStub() {}; + HostStub(); + virtual ~HostStub(); virtual void SuggestResolution( const SuggestResolutionRequest* msg, Task* done) = 0; virtual void BeginSessionRequest( const LocalLoginCredentials* credentials, Task* done) = 0; + // Called when the client has authenticated with the host to enable the + // client->host control channel. + // Before this is called, only a limited set of control messages will be + // processed. + void OnAuthenticated(); + + // Has the client successfully authenticated with the host? + // I.e., should we be processing control events? + bool authenticated(); + private: + // Initially false, this records whether the client has authenticated with + // the host. + bool authenticated_; + DISALLOW_COPY_AND_ASSIGN(HostStub); }; diff --git a/remoting/protocol/input_stub.cc b/remoting/protocol/input_stub.cc new file mode 100644 index 0000000..8bb1ffb --- /dev/null +++ b/remoting/protocol/input_stub.cc @@ -0,0 +1,29 @@ +// 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. + +// Interface for a device that receives input events. +// This interface handles event messages defined in event.proto. + +#include "remoting/protocol/input_stub.h" + +namespace remoting { +namespace protocol { + + +InputStub::InputStub() : authenticated_(false) { +} + +InputStub::~InputStub() { +} + +void InputStub::OnAuthenticated() { + authenticated_ = true; +} + +bool InputStub::authenticated() { + return authenticated_; +} + +} // namespace protocol +} // namespace remoting diff --git a/remoting/protocol/input_stub.h b/remoting/protocol/input_stub.h index 8b89c7a..8c80d16 100644 --- a/remoting/protocol/input_stub.h +++ b/remoting/protocol/input_stub.h @@ -8,6 +8,8 @@ #ifndef REMOTING_PROTOCOL_INPUT_STUB_H_ #define REMOTING_PROTOCOL_INPUT_STUB_H_ +#include "base/basictypes.h" + class Task; namespace remoting { @@ -18,13 +20,26 @@ class MouseEvent; class InputStub { public: - InputStub() {} - virtual ~InputStub() {} + InputStub(); + virtual ~InputStub(); virtual void InjectKeyEvent(const KeyEvent* event, Task* done) = 0; virtual void InjectMouseEvent(const MouseEvent* event, Task* done) = 0; + // Called when the client has authenticated with the host to enable the + // input event channel. + // Before this is called, all input event will be ignored. + void OnAuthenticated(); + + // Has the client successfully authenticated with the host? + // I.e., should we be processing input events? + bool authenticated(); + private: + // Initially false, this records whether the client has authenticated with + // the host. + bool authenticated_; + DISALLOW_COPY_AND_ASSIGN(InputStub); }; diff --git a/remoting/protocol/protocol_mock_objects.cc b/remoting/protocol/protocol_mock_objects.cc index 8b38954..5deb40f 100644 --- a/remoting/protocol/protocol_mock_objects.cc +++ b/remoting/protocol/protocol_mock_objects.cc @@ -7,7 +7,12 @@ namespace remoting { namespace protocol { -MockConnectionToClient::MockConnectionToClient() {} +MockConnectionToClient::MockConnectionToClient(MessageLoop* message_loop, + EventHandler* handler, + HostStub* host_stub, + InputStub* input_stub) + : ConnectionToClient(message_loop, handler, host_stub, input_stub) { +} MockConnectionToClient::~MockConnectionToClient() {} diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index e9dd57e..57dad6a 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.h @@ -21,7 +21,10 @@ class ChromotocolConnection; class MockConnectionToClient : public ConnectionToClient { public: - MockConnectionToClient(); + MockConnectionToClient(MessageLoop* message_loop, + EventHandler* handler, + HostStub* host_stub, + InputStub* input_stub); virtual ~MockConnectionToClient(); MOCK_METHOD1(Init, void(Session* session)); diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 81a9867..ba5507d 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -382,6 +382,7 @@ 'protocol/client_control_Sender.h', 'protocol/client_message_dispatcher.cc', 'protocol/client_message_dispatcher.h', + 'protocol/client_stub.cc', 'protocol/client_stub.h', 'protocol/connection_to_client.cc', 'protocol/connection_to_client.h', @@ -391,9 +392,12 @@ 'protocol/host_control_sender.h', 'protocol/host_message_dispatcher.cc', 'protocol/host_message_dispatcher.h', + 'protocol/host_stub.cc', 'protocol/host_stub.h', 'protocol/input_sender.cc', 'protocol/input_sender.h', + 'protocol/input_stub.cc', + 'protocol/input_stub.h', 'protocol/jingle_session.cc', 'protocol/jingle_session.h', 'protocol/jingle_session_manager.cc', |