| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_HOST_CLIENT_SESSION_H_ | 5 #ifndef REMOTING_HOST_CLIENT_SESSION_H_ |
| 6 #define REMOTING_HOST_CLIENT_SESSION_H_ | 6 #define REMOTING_HOST_CLIENT_SESSION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "remoting/protocol/connection_to_client.h" | 12 #include "remoting/protocol/connection_to_client.h" |
| 13 #include "remoting/protocol/host_stub.h" | 13 #include "remoting/protocol/host_stub.h" |
| 14 #include "remoting/protocol/input_stub.h" | 14 #include "remoting/protocol/input_stub.h" |
| 15 #include "third_party/skia/include/core/SkPoint.h" | 15 #include "third_party/skia/include/core/SkPoint.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 class Capturer; | 19 class Capturer; |
| 20 class UserAuthenticator; | |
| 21 | 20 |
| 22 // A ClientSession keeps a reference to a connection to a client, and maintains | 21 // A ClientSession keeps a reference to a connection to a client, and maintains |
| 23 // per-client state. | 22 // per-client state. |
| 24 class ClientSession : public protocol::HostStub, | 23 class ClientSession : public protocol::HostStub, |
| 25 public protocol::InputStub, | 24 public protocol::InputStub, |
| 26 public base::RefCountedThreadSafe<ClientSession> { | 25 public base::RefCountedThreadSafe<ClientSession> { |
| 27 public: | 26 public: |
| 28 // Callback interface for passing events to the ChromotingHost. | 27 // Callback interface for passing events to the ChromotingHost. |
| 29 class EventHandler { | 28 class EventHandler { |
| 30 public: | 29 public: |
| 31 virtual ~EventHandler() {} | 30 virtual ~EventHandler() {} |
| 32 | 31 |
| 33 // Called to signal that local login has succeeded and ChromotingHost can | 32 // Called to signal that authentication has succeeded. |
| 34 // proceed with the next step. | 33 virtual void OnAuthenticationComplete( |
| 35 virtual void LocalLoginSucceeded( | |
| 36 scoped_refptr<protocol::ConnectionToClient> client) = 0; | |
| 37 | |
| 38 // Called to signal that local login has failed. | |
| 39 virtual void LocalLoginFailed( | |
| 40 scoped_refptr<protocol::ConnectionToClient> client) = 0; | 34 scoped_refptr<protocol::ConnectionToClient> client) = 0; |
| 41 }; | 35 }; |
| 42 | 36 |
| 43 // Takes ownership of |user_authenticator|. Does not take ownership of | 37 // Takes ownership of |user_authenticator|. Does not take ownership of |
| 44 // |event_handler|, |input_stub| or |capturer|. | 38 // |event_handler|, |input_stub| or |capturer|. |
| 45 ClientSession(EventHandler* event_handler, | 39 ClientSession(EventHandler* event_handler, |
| 46 UserAuthenticator* user_authenticator, | |
| 47 scoped_refptr<protocol::ConnectionToClient> connection, | 40 scoped_refptr<protocol::ConnectionToClient> connection, |
| 48 protocol::InputStub* input_stub, | 41 protocol::InputStub* input_stub, |
| 49 Capturer* capturer); | 42 Capturer* capturer); |
| 50 | 43 |
| 51 // protocol::HostStub interface. | |
| 52 virtual void BeginSessionRequest( | |
| 53 const protocol::LocalLoginCredentials* credentials, | |
| 54 const base::Closure& done); | |
| 55 | |
| 56 // protocol::InputStub interface. | 44 // protocol::InputStub interface. |
| 57 virtual void InjectKeyEvent(const protocol::KeyEvent& event); | 45 virtual void InjectKeyEvent(const protocol::KeyEvent& event); |
| 58 virtual void InjectMouseEvent(const protocol::MouseEvent& event); | 46 virtual void InjectMouseEvent(const protocol::MouseEvent& event); |
| 59 | 47 |
| 60 // Notifier called when the client is being disconnected. | 48 // Notifier called when the client is being disconnected. |
| 61 // This should only be called by ChromotingHost. | 49 // This should only be called by ChromotingHost. |
| 62 void OnDisconnected(); | 50 void OnDisconnected(); |
| 63 | 51 |
| 64 // Set the authenticated flag or log a failure message as appropriate. | 52 // Set the authenticated flag. |
| 65 void OnAuthorizationComplete(bool success); | 53 void OnAuthenticationComplete(); |
| 66 | 54 |
| 67 protocol::ConnectionToClient* connection() const { | 55 protocol::ConnectionToClient* connection() const { |
| 68 return connection_.get(); | 56 return connection_.get(); |
| 69 } | 57 } |
| 70 | 58 |
| 71 bool authenticated() const { | 59 bool authenticated() const { |
| 72 return authenticated_; | 60 return authenticated_; |
| 73 } | 61 } |
| 74 | 62 |
| 75 void set_awaiting_continue_approval(bool awaiting) { | 63 void set_awaiting_continue_approval(bool awaiting) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 95 // the user disconnects. | 83 // the user disconnects. |
| 96 void RecordKeyEvent(const protocol::KeyEvent& event); | 84 void RecordKeyEvent(const protocol::KeyEvent& event); |
| 97 void RecordMouseButtonState(const protocol::MouseEvent& event); | 85 void RecordMouseButtonState(const protocol::MouseEvent& event); |
| 98 | 86 |
| 99 // Synthesize KeyUp and MouseUp events so that we can undo these events | 87 // Synthesize KeyUp and MouseUp events so that we can undo these events |
| 100 // when the user disconnects. | 88 // when the user disconnects. |
| 101 void RestoreEventState(); | 89 void RestoreEventState(); |
| 102 | 90 |
| 103 EventHandler* event_handler_; | 91 EventHandler* event_handler_; |
| 104 | 92 |
| 105 // A factory for user authenticators. | |
| 106 scoped_ptr<UserAuthenticator> user_authenticator_; | |
| 107 | |
| 108 // The connection to the client. | 93 // The connection to the client. |
| 109 scoped_refptr<protocol::ConnectionToClient> connection_; | 94 scoped_refptr<protocol::ConnectionToClient> connection_; |
| 110 | 95 |
| 111 std::string client_jid_; | 96 std::string client_jid_; |
| 112 | 97 |
| 113 // The input stub to which this object delegates. | 98 // The input stub to which this object delegates. |
| 114 protocol::InputStub* input_stub_; | 99 protocol::InputStub* input_stub_; |
| 115 | 100 |
| 116 // Capturer, used to determine current screen size for ensuring injected | 101 // Capturer, used to determine current screen size for ensuring injected |
| 117 // mouse events fall within the screen area. | 102 // mouse events fall within the screen area. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 143 // Set of keys that are currently pressed down by the user. This is used so | 128 // Set of keys that are currently pressed down by the user. This is used so |
| 144 // we can release them if the user disconnects. | 129 // we can release them if the user disconnects. |
| 145 std::set<int> pressed_keys_; | 130 std::set<int> pressed_keys_; |
| 146 | 131 |
| 147 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 132 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
| 148 }; | 133 }; |
| 149 | 134 |
| 150 } // namespace remoting | 135 } // namespace remoting |
| 151 | 136 |
| 152 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 137 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
| OLD | NEW |