| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> | |
| 10 | 9 |
| 11 #include "base/time.h" | 10 #include "base/time.h" |
| 12 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 13 #include "remoting/protocol/connection_to_client.h" | 12 #include "remoting/protocol/connection_to_client.h" |
| 14 #include "remoting/protocol/host_stub.h" | 13 #include "remoting/protocol/host_stub.h" |
| 14 #include "remoting/protocol/input_event_tracker.h" |
| 15 #include "remoting/protocol/input_filter.h" |
| 15 #include "remoting/protocol/input_stub.h" | 16 #include "remoting/protocol/input_stub.h" |
| 16 #include "third_party/skia/include/core/SkPoint.h" | 17 #include "third_party/skia/include/core/SkPoint.h" |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 | 20 |
| 20 class Capturer; | 21 class Capturer; |
| 21 | 22 |
| 22 // A ClientSession keeps a reference to a connection to a client, and maintains | 23 // A ClientSession keeps a reference to a connection to a client, and maintains |
| 23 // per-client state. | 24 // per-client state. |
| 24 class ClientSession : public protocol::HostStub, | 25 class ClientSession : public protocol::HostStub, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Disconnects the session and destroys the transport. Event handler | 87 // Disconnects the session and destroys the transport. Event handler |
| 87 // is guaranteed not to be called after this method is called. Can | 88 // is guaranteed not to be called after this method is called. Can |
| 88 // be called multiple times. The object should not be used after | 89 // be called multiple times. The object should not be used after |
| 89 // this method returns. | 90 // this method returns. |
| 90 void Disconnect(); | 91 void Disconnect(); |
| 91 | 92 |
| 92 protocol::ConnectionToClient* connection() const { | 93 protocol::ConnectionToClient* connection() const { |
| 93 return connection_.get(); | 94 return connection_.get(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 bool authenticated() const { | |
| 97 return authenticated_; | |
| 98 } | |
| 99 | |
| 100 void set_awaiting_continue_approval(bool awaiting) { | |
| 101 awaiting_continue_approval_ = awaiting; | |
| 102 } | |
| 103 | |
| 104 const std::string& client_jid() { return client_jid_; } | 97 const std::string& client_jid() { return client_jid_; } |
| 105 | 98 |
| 106 // Indicate that local mouse activity has been detected. This causes remote | 99 // Indicate that local mouse activity has been detected. This causes remote |
| 107 // inputs to be ignored for a short time so that the local user will always | 100 // inputs to be ignored for a short time so that the local user will always |
| 108 // have the upper hand in 'pointer wars'. | 101 // have the upper hand in 'pointer wars'. |
| 109 void LocalMouseMoved(const SkIPoint& new_pos); | 102 void LocalMouseMoved(const SkIPoint& new_pos); |
| 110 | 103 |
| 111 bool ShouldIgnoreRemoteMouseInput(const protocol::MouseEvent& event) const; | 104 // Disable handling of input events from this client. If the client has any |
| 112 bool ShouldIgnoreRemoteKeyboardInput(const protocol::KeyEvent& event) const; | 105 // keys or mouse buttons pressed then these will be released. |
| 106 void SetDisableInputs(bool disable_inputs); |
| 113 | 107 |
| 114 private: | 108 private: |
| 115 friend class ClientSessionTest_RestoreEventState_Test; | 109 friend class ClientSessionTest_RestoreEventState_Test; |
| 116 | 110 |
| 117 // Keep track of input state so that we can clean up the event queue when | 111 // Returns whether input should be ignored because of local activity. |
| 118 // the user disconnects. | 112 bool ShouldIgnoreInput() const; |
| 119 void RecordKeyEvent(const protocol::KeyEvent& event); | |
| 120 void RecordMouseButtonState(const protocol::MouseEvent& event); | |
| 121 | |
| 122 // Synthesize KeyUp and MouseUp events so that we can undo these events | |
| 123 // when the user disconnects. | |
| 124 void RestoreEventState(); | |
| 125 | 113 |
| 126 EventHandler* event_handler_; | 114 EventHandler* event_handler_; |
| 127 | 115 |
| 128 // The connection to the client. | 116 // The connection to the client. |
| 129 scoped_ptr<protocol::ConnectionToClient> connection_; | 117 scoped_ptr<protocol::ConnectionToClient> connection_; |
| 130 | 118 |
| 131 std::string client_jid_; | 119 std::string client_jid_; |
| 132 | 120 |
| 133 // The input stub to which this object delegates. | 121 // Tracker used to release pressed keys and buttons when disconnecting. |
| 134 protocol::InputStub* input_stub_; | 122 protocol::InputEventTracker input_tracker_; |
| 123 |
| 124 // Filter used to manage enabling & disabling of client input events. |
| 125 protocol::InputFilter input_filter_; |
| 135 | 126 |
| 136 // Capturer, used to determine current screen size for ensuring injected | 127 // Capturer, used to determine current screen size for ensuring injected |
| 137 // mouse events fall within the screen area. | 128 // mouse events fall within the screen area. |
| 138 // TODO(lambroslambrou): Move floor-control logic, and clamping to screen | 129 // TODO(lambroslambrou): Move floor-control logic, and clamping to screen |
| 139 // area, out of this class (crbug.com/96508). | 130 // area, out of this class (crbug.com/96508). |
| 140 Capturer* capturer_; | 131 Capturer* capturer_; |
| 141 | 132 |
| 142 // Whether this client is authenticated. | |
| 143 bool authenticated_; | |
| 144 | |
| 145 // Whether or not inputs from this client are blocked pending approval from | |
| 146 // the host user to continue the connection. | |
| 147 bool awaiting_continue_approval_; | |
| 148 | |
| 149 // State to control remote input blocking while the local pointer is in use. | |
| 150 uint32 remote_mouse_button_state_; | |
| 151 | |
| 152 // Current location of the mouse pointer. This is used to provide appropriate | |
| 153 // coordinates when we release the mouse buttons after a user disconnects. | |
| 154 SkIPoint remote_mouse_pos_; | |
| 155 | |
| 156 // Queue of recently-injected mouse positions. This is used to detect whether | 133 // Queue of recently-injected mouse positions. This is used to detect whether |
| 157 // mouse events from the local input monitor are echoes of injected positions, | 134 // mouse events from the local input monitor are echoes of injected positions, |
| 158 // or genuine mouse movements of a local input device. | 135 // or genuine mouse movements of a local input device. |
| 159 std::list<SkIPoint> injected_mouse_positions_; | 136 std::list<SkIPoint> injected_mouse_positions_; |
| 160 | 137 |
| 161 base::Time latest_local_input_time_; | 138 base::Time latest_local_input_time_; |
| 162 | 139 |
| 163 // Set of keys that are currently pressed down by the user. This is used so | |
| 164 // we can release them if the user disconnects. | |
| 165 std::set<int> pressed_keys_; | |
| 166 | |
| 167 DISALLOW_COPY_AND_ASSIGN(ClientSession); | 140 DISALLOW_COPY_AND_ASSIGN(ClientSession); |
| 168 }; | 141 }; |
| 169 | 142 |
| 170 } // namespace remoting | 143 } // namespace remoting |
| 171 | 144 |
| 172 #endif // REMOTING_HOST_CLIENT_SESSION_H_ | 145 #endif // REMOTING_HOST_CLIENT_SESSION_H_ |
| OLD | NEW |