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