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 #include "remoting/host/win/rdp_client.h" | 5 #include "remoting/host/win/rdp_client.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 DCHECK(base::MessageLoopForUI::IsCurrent()); | 131 DCHECK(base::MessageLoopForUI::IsCurrent()); |
132 DCHECK(!rdp_client_window_); | 132 DCHECK(!rdp_client_window_); |
133 DCHECK(!self_); | 133 DCHECK(!self_); |
134 | 134 |
135 // Read the port number used by RDP. | 135 // Read the port number used by RDP. |
136 DWORD server_port; | 136 DWORD server_port; |
137 base::win::RegKey key(HKEY_LOCAL_MACHINE, kRdpPortKeyName, KEY_READ); | 137 base::win::RegKey key(HKEY_LOCAL_MACHINE, kRdpPortKeyName, KEY_READ); |
138 if (!key.Valid() || | 138 if (!key.Valid() || |
139 (key.ReadValueDW(kRdpPortValueName, &server_port) != ERROR_SUCCESS)) { | 139 (key.ReadValueDW(kRdpPortValueName, &server_port) != ERROR_SUCCESS) || |
| 140 server_port > 65535) { |
140 server_port = kDefaultRdpPort; | 141 server_port = kDefaultRdpPort; |
141 } | 142 } |
142 | 143 |
143 net::IPAddressNumber server_address( | 144 net::IPAddressNumber server_address( |
144 kRdpLoopbackAddress, | 145 kRdpLoopbackAddress, |
145 kRdpLoopbackAddress + arraysize(kRdpLoopbackAddress)); | 146 kRdpLoopbackAddress + arraysize(kRdpLoopbackAddress)); |
146 net::IPEndPoint server_endpoint(server_address, server_port); | 147 net::IPEndPoint server_endpoint(server_address, |
| 148 static_cast<uint16>(server_port)); |
147 | 149 |
148 // Create the ActiveX control window. | 150 // Create the ActiveX control window. |
149 rdp_client_window_.reset(new RdpClientWindow(server_endpoint, terminal_id, | 151 rdp_client_window_.reset(new RdpClientWindow(server_endpoint, terminal_id, |
150 this)); | 152 this)); |
151 if (!rdp_client_window_->Connect(screen_size)) { | 153 if (!rdp_client_window_->Connect(screen_size)) { |
152 rdp_client_window_.reset(); | 154 rdp_client_window_.reset(); |
153 | 155 |
154 // Notify the caller that connection attempt failed. | 156 // Notify the caller that connection attempt failed. |
155 NotifyClosed(); | 157 NotifyClosed(); |
156 } | 158 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 227 } |
226 | 228 |
227 if (event_handler_) { | 229 if (event_handler_) { |
228 RdpClient::EventHandler* event_handler = event_handler_; | 230 RdpClient::EventHandler* event_handler = event_handler_; |
229 event_handler_ = NULL; | 231 event_handler_ = NULL; |
230 event_handler->OnRdpClosed(); | 232 event_handler->OnRdpClosed(); |
231 } | 233 } |
232 } | 234 } |
233 | 235 |
234 } // namespace remoting | 236 } // namespace remoting |
OLD | NEW |