[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef REMOTING_HOST_CLIENT_SESSION_H_ |
| 6 | #define REMOTING_HOST_CLIENT_SESSION_H_ |
| 7 | |
| 8 | #include "remoting/protocol/connection_to_client.h" |
| 9 | #include "remoting/protocol/host_stub.h" |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 10 | #include "remoting/protocol/input_stub.h" |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 11 | |
| 12 | namespace remoting { |
| 13 | |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 14 | class UserAuthenticator; |
| 15 | |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 16 | // A ClientSession keeps a reference to a connection to a client, and maintains |
| 17 | // per-client state. |
| 18 | class ClientSession : public protocol::HostStub, |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 19 | public protocol::InputStub, |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 20 | public base::RefCountedThreadSafe<ClientSession> { |
| 21 | public: |
| 22 | // Callback interface for passing events to the ChromotingHost. |
| 23 | class EventHandler { |
| 24 | public: |
| 25 | virtual ~EventHandler() {} |
| 26 | |
| 27 | // Called to signal that local login has succeeded and ChromotingHost can |
| 28 | // proceed with the next step. |
| 29 | virtual void LocalLoginSucceeded( |
| 30 | scoped_refptr<protocol::ConnectionToClient> client) = 0; |
| 31 | |
| 32 | // Called to signal that local login has failed. |
| 33 | virtual void LocalLoginFailed( |
| 34 | scoped_refptr<protocol::ConnectionToClient> client) = 0; |
| 35 | }; |
| 36 | |
[email protected] | 844a372 | 2011-05-13 00:32:02 | [diff] [blame] | 37 | // Takes ownership of |user_authenticator|. Does not take ownership of |
| 38 | // |event_handler| or |input_stub|. |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 39 | ClientSession(EventHandler* event_handler, |
[email protected] | 0b7e428 | 2011-04-04 22:44:11 | [diff] [blame] | 40 | UserAuthenticator* user_authenticator, |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 41 | scoped_refptr<protocol::ConnectionToClient> connection, |
| 42 | protocol::InputStub* input_stub); |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 43 | |
| 44 | // protocol::HostStub interface. |
| 45 | virtual void SuggestResolution( |
| 46 | const protocol::SuggestResolutionRequest* msg, Task* done); |
| 47 | virtual void BeginSessionRequest( |
| 48 | const protocol::LocalLoginCredentials* credentials, Task* done); |
| 49 | |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 50 | // protocol::InputStub interface. |
| 51 | virtual void InjectKeyEvent(const protocol::KeyEvent* event, Task* done); |
| 52 | virtual void InjectMouseEvent(const protocol::MouseEvent* event, Task* done); |
| 53 | |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 54 | // Disconnect this client session. |
| 55 | void Disconnect(); |
| 56 | |
[email protected] | 1ce457a | 2011-05-19 19:59:48 | [diff] [blame^] | 57 | // Set the authenticated flag or log a failure message as appropriate. |
| 58 | void OnAuthorizationComplete(bool success); |
| 59 | |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 60 | protocol::ConnectionToClient* connection() const { |
| 61 | return connection_.get(); |
| 62 | } |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 63 | |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 64 | bool authenticated() const { |
| 65 | return authenticated_; |
| 66 | } |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 67 | |
| 68 | private: |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 69 | friend class base::RefCountedThreadSafe<ClientSession>; |
| 70 | virtual ~ClientSession(); |
| 71 | |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 72 | EventHandler* event_handler_; |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 73 | |
| 74 | // A factory for user authenticators. |
[email protected] | 0b7e428 | 2011-04-04 22:44:11 | [diff] [blame] | 75 | scoped_ptr<UserAuthenticator> user_authenticator_; |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 76 | |
| 77 | // The connection to the client. |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 78 | scoped_refptr<protocol::ConnectionToClient> connection_; |
| 79 | |
[email protected] | 4ea2c7c | 2011-03-31 14:20:06 | [diff] [blame] | 80 | // The input stub to which this object delegates. |
| 81 | protocol::InputStub* input_stub_; |
| 82 | |
| 83 | // Whether this client is authenticated. |
| 84 | bool authenticated_; |
| 85 | |
[email protected] | 44f6076 | 2011-03-23 12:13:35 | [diff] [blame] | 86 | DISALLOW_COPY_AND_ASSIGN(ClientSession); |
| 87 | }; |
| 88 | |
| 89 | } // namespace remoting |
| 90 | |
| 91 | #endif // REMOTING_HOST_CLIENT_SESSION_H_ |