OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_WIN_RDP_HOST_WINDOW_H_ | 5 #ifndef REMOTING_HOST_WIN_RDP_HOST_WINDOW_H_ |
6 #define REMOTING_HOST_WIN_RDP_HOST_WINDOW_H_ | 6 #define REMOTING_HOST_WIN_RDP_HOST_WINDOW_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
11 #include <atlctl.h> | 11 #include <atlctl.h> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/timer/timer.h" |
15 #include "base/win/scoped_comptr.h" | 16 #include "base/win/scoped_comptr.h" |
16 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
17 #include "remoting/host/screen_resolution.h" | 18 #include "remoting/host/screen_resolution.h" |
18 // The following header was generated by Visual Studio. We had to check it in | 19 // The following header was generated by Visual Studio. We had to check it in |
19 // due to a bug in VS2013. See crbug.com/318952 for details. | 20 // due to a bug in VS2013. See crbug.com/318952 for details. |
20 #include "remoting/host/win/com_imported_mstscax.tlh" | 21 #include "remoting/host/win/com_imported_mstscax.tlh" |
21 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 22 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
22 | 23 |
23 namespace remoting { | 24 namespace remoting { |
24 | 25 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 STDMETHOD(OnAuthenticationWarningDismissed)(); | 129 STDMETHOD(OnAuthenticationWarningDismissed)(); |
129 STDMETHOD(OnConnected)(); | 130 STDMETHOD(OnConnected)(); |
130 STDMETHOD(OnLoginComplete)(); | 131 STDMETHOD(OnLoginComplete)(); |
131 STDMETHOD(OnDisconnected)(long reason); | 132 STDMETHOD(OnDisconnected)(long reason); |
132 STDMETHOD(OnFatalError)(long error_code); | 133 STDMETHOD(OnFatalError)(long error_code); |
133 STDMETHOD(OnConfirmClose)(VARIANT_BOOL* allow_close); | 134 STDMETHOD(OnConfirmClose)(VARIANT_BOOL* allow_close); |
134 | 135 |
135 int LogOnCreateError(HRESULT error); | 136 int LogOnCreateError(HRESULT error); |
136 | 137 |
137 // Wrappers for the event handler's methods that make sure that | 138 // Wrappers for the event handler's methods that make sure that |
138 // OnDisconnected() is the last notification delivered and is delevered | 139 // OnDisconnected() is the last notification delivered and is delivered |
139 // only once. | 140 // only once. |
140 void NotifyConnected(); | 141 void NotifyConnected(); |
141 void NotifyDisconnected(); | 142 void NotifyDisconnected(); |
142 | 143 |
143 // Updates the desktop using |screen_resolution_| if resizing is supported. | 144 // Updates the desktop using |screen_resolution_| if resizing is supported. |
144 void UpdateDesktopResolution(); | 145 HRESULT UpdateDesktopResolution(); |
| 146 |
| 147 // Attempts to reapply the requested screen resolution. This method is used |
| 148 // to workaround the inconsistent behavior seen by the RDP API which can fail |
| 149 // for an indeterminate amount of time (i.e. a few seconds) after the user has |
| 150 // logged into the session. In practice retrying after ~100ms will succeed, |
| 151 // but we will use |apply_resolution_timer_| to try a few times if the machine |
| 152 // is under load. |
| 153 void ReapplyDesktopResolution(); |
145 | 154 |
146 // Invoked to report connect/disconnect events. | 155 // Invoked to report connect/disconnect events. |
147 EventHandler* event_handler_; | 156 EventHandler* event_handler_; |
148 | 157 |
149 // Contains the requested dimensions of the screen. | 158 // Contains the requested dimensions of the screen. |
150 remoting::ScreenResolution screen_resolution_; | 159 remoting::ScreenResolution screen_resolution_; |
151 | 160 |
| 161 // Used for applying resolution changes after a timeout. |
| 162 base::RepeatingTimer apply_resolution_timer_; |
| 163 |
| 164 // Tracks the number of resolution change retries. |
| 165 int apply_resolution_attempts_ = 0; |
| 166 |
152 // The endpoint to connect to. | 167 // The endpoint to connect to. |
153 net::IPEndPoint server_endpoint_; | 168 net::IPEndPoint server_endpoint_; |
154 | 169 |
155 // The terminal ID assigned to this connection. | 170 // The terminal ID assigned to this connection. |
156 std::string terminal_id_; | 171 std::string terminal_id_; |
157 | 172 |
158 // Our RDP session always starts logged out (i.e. at the logon screen), some | 173 // Our RDP session always starts logged out (i.e. at the logon screen), some |
159 // functions do not work until the user has logged in so we want to track that | 174 // functions do not work until the user has logged in so we want to track that |
160 // event. We don't support logging out so this value should never revert from | 175 // event. We don't support logging out so this value should never revert from |
161 // true to false. | 176 // true to false. |
162 bool user_logged_in_ = false; | 177 bool user_logged_in_ = false; |
163 | 178 |
164 // Interfaces exposed by the RDP ActiveX control. | 179 // Interfaces exposed by the RDP ActiveX control. |
165 base::win::ScopedComPtr<mstsc::IMsRdpClient> client_; | 180 base::win::ScopedComPtr<mstsc::IMsRdpClient> client_; |
166 base::win::ScopedComPtr<mstsc::IMsRdpClient9> client_9_; | 181 base::win::ScopedComPtr<mstsc::IMsRdpClient9> client_9_; |
167 base::win::ScopedComPtr<mstsc::IMsRdpClientAdvancedSettings> client_settings_; | 182 base::win::ScopedComPtr<mstsc::IMsRdpClientAdvancedSettings> client_settings_; |
168 | 183 |
169 // Used to cancel modal dialog boxes shown by the RDP control. | 184 // Used to cancel modal dialog boxes shown by the RDP control. |
170 class WindowHook; | 185 class WindowHook; |
171 scoped_refptr<WindowHook> window_activate_hook_; | 186 scoped_refptr<WindowHook> window_activate_hook_; |
172 }; | 187 }; |
173 | 188 |
174 } // namespace remoting | 189 } // namespace remoting |
175 | 190 |
176 #endif // REMOTING_HOST_WIN_RDP_HOST_WINDOW_H_ | 191 #endif // REMOTING_HOST_WIN_RDP_HOST_WINDOW_H_ |
OLD | NEW |