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_window.h" | 5 #include "remoting/host/win/rdp_client_window.h" |
6 | 6 |
7 #include <wtsdefs.h> | 7 #include <wtsdefs.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/threading/thread_local.h" | 16 #include "base/threading/thread_local.h" |
17 #include "base/win/scoped_bstr.h" | 17 #include "base/win/scoped_bstr.h" |
18 | 18 |
19 namespace remoting { | 19 namespace remoting { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // RDP connection disconnect reasons codes that should not be interpreted as | 23 // RDP session disconnect reason codes that should not be interpreted as errors. |
24 // errors. | |
25 const long kDisconnectReasonNoInfo = 0; | 24 const long kDisconnectReasonNoInfo = 0; |
26 const long kDisconnectReasonLocalNotError = 1; | 25 const long kDisconnectReasonLocalNotError = 1; |
27 const long kDisconnectReasonRemoteByUser = 2; | 26 const long kDisconnectReasonRemoteByUser = 2; |
28 const long kDisconnectReasonByServer = 3; | 27 const long kDisconnectReasonByServer = 3; |
29 | 28 |
30 // Maximum length of a window class name including the terminating nullptr. | 29 // Maximum length of a window class name including the terminating nullptr. |
31 const int kMaxWindowClassLength = 256; | 30 const int kMaxWindowClassLength = 256; |
32 | 31 |
33 // Each member of the array returned by GetKeyboardState() contains status data | 32 // Each member of the array returned by GetKeyboardState() contains status data |
34 // for a virtual key. If the high-order bit is 1, the key is down; otherwise, it | 33 // for a virtual key. If the high-order bit is 1, the key is down; otherwise, it |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 143 |
145 void RdpClientWindow::Disconnect() { | 144 void RdpClientWindow::Disconnect() { |
146 if (m_hWnd) | 145 if (m_hWnd) |
147 SendMessage(WM_CLOSE); | 146 SendMessage(WM_CLOSE); |
148 } | 147 } |
149 | 148 |
150 void RdpClientWindow::InjectSas() { | 149 void RdpClientWindow::InjectSas() { |
151 if (!m_hWnd) | 150 if (!m_hWnd) |
152 return; | 151 return; |
153 | 152 |
154 // Fins the window handling the keyboard input. | 153 // Find the window handling the keyboard input. |
155 HWND input_window = FindWindowRecursively(m_hWnd, kRdpInputWindowClass); | 154 HWND input_window = FindWindowRecursively(m_hWnd, kRdpInputWindowClass); |
156 if (!input_window) { | 155 if (!input_window) { |
157 LOG(ERROR) << "Failed to find the window handling the keyboard input."; | 156 LOG(ERROR) << "Failed to find the window handling the keyboard input."; |
158 return; | 157 return; |
159 } | 158 } |
160 | 159 |
161 VLOG(3) << "Injecting Ctrl+Alt+End to emulate SAS."; | 160 VLOG(3) << "Injecting Ctrl+Alt+End to emulate SAS."; |
162 | 161 |
163 BYTE keyboard_state[kKeyboardStateLength]; | 162 BYTE keyboard_state[kKeyboardStateLength]; |
164 if (!GetKeyboardState(keyboard_state)) { | 163 if (!GetKeyboardState(keyboard_state)) { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 return CallNextHookEx(hook, code, wparam, lparam); | 516 return CallNextHookEx(hook, code, wparam, lparam); |
518 | 517 |
519 // Close the window once all pending window messages are processed. | 518 // Close the window once all pending window messages are processed. |
520 HWND window = reinterpret_cast<HWND>(wparam); | 519 HWND window = reinterpret_cast<HWND>(wparam); |
521 LOG(WARNING) << "RDP: closing a window: " << std::hex << window << std::dec; | 520 LOG(WARNING) << "RDP: closing a window: " << std::hex << window << std::dec; |
522 ::PostMessage(window, WM_CLOSE, 0, 0); | 521 ::PostMessage(window, WM_CLOSE, 0, 0); |
523 return 0; | 522 return 0; |
524 } | 523 } |
525 | 524 |
526 } // namespace remoting | 525 } // namespace remoting |
OLD | NEW |