| 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 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 EventHandler* event_handler) | 115 EventHandler* event_handler) |
| 116 : event_handler_(event_handler), | 116 : event_handler_(event_handler), |
| 117 server_endpoint_(server_endpoint), | 117 server_endpoint_(server_endpoint), |
| 118 terminal_id_(terminal_id) { | 118 terminal_id_(terminal_id) { |
| 119 } | 119 } |
| 120 | 120 |
| 121 RdpClientWindow::~RdpClientWindow() { | 121 RdpClientWindow::~RdpClientWindow() { |
| 122 if (m_hWnd) | 122 if (m_hWnd) |
| 123 DestroyWindow(); | 123 DestroyWindow(); |
| 124 | 124 |
| 125 DCHECK(!client_); | 125 DCHECK(!client_.get()); |
| 126 DCHECK(!client_settings_); | 126 DCHECK(!client_settings_.get()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool RdpClientWindow::Connect(const webrtc::DesktopSize& screen_size) { | 129 bool RdpClientWindow::Connect(const webrtc::DesktopSize& screen_size) { |
| 130 DCHECK(!m_hWnd); | 130 DCHECK(!m_hWnd); |
| 131 | 131 |
| 132 screen_size_ = screen_size; | 132 screen_size_ = screen_size; |
| 133 RECT rect = { 0, 0, screen_size_.width(), screen_size_.height() }; | 133 RECT rect = { 0, 0, screen_size_.width(), screen_size_.height() }; |
| 134 bool result = Create(NULL, rect, NULL) != NULL; | 134 bool result = Create(NULL, rect, NULL) != NULL; |
| 135 | 135 |
| 136 // Hide the window since this class is about establishing a connection, not | 136 // Hide the window since this class is about establishing a connection, not |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 SendMessage(input_window, WM_KEYUP, VK_MENU, MAKELPARAM(1, alt | up)); | 202 SendMessage(input_window, WM_KEYUP, VK_MENU, MAKELPARAM(1, alt | up)); |
| 203 | 203 |
| 204 // Release 'Ctrl'. | 204 // Release 'Ctrl'. |
| 205 keyboard_state[VK_CONTROL] &= ~kKeyPressedFlag; | 205 keyboard_state[VK_CONTROL] &= ~kKeyPressedFlag; |
| 206 keyboard_state[VK_LCONTROL] &= ~kKeyPressedFlag; | 206 keyboard_state[VK_LCONTROL] &= ~kKeyPressedFlag; |
| 207 CHECK(SetKeyboardState(keyboard_state)); | 207 CHECK(SetKeyboardState(keyboard_state)); |
| 208 SendMessage(input_window, WM_KEYUP, VK_CONTROL, MAKELPARAM(1, control | up)); | 208 SendMessage(input_window, WM_KEYUP, VK_CONTROL, MAKELPARAM(1, control | up)); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void RdpClientWindow::OnClose() { | 211 void RdpClientWindow::OnClose() { |
| 212 if (!client_) { | 212 if (!client_.get()) { |
| 213 NotifyDisconnected(); | 213 NotifyDisconnected(); |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Request a graceful shutdown. | 217 // Request a graceful shutdown. |
| 218 mstsc::ControlCloseStatus close_status; | 218 mstsc::ControlCloseStatus close_status; |
| 219 HRESULT result = client_->RequestClose(&close_status); | 219 HRESULT result = client_->RequestClose(&close_status); |
| 220 if (FAILED(result)) { | 220 if (FAILED(result)) { |
| 221 LOG(ERROR) << "Failed to request a graceful shutdown of an RDP connection" | 221 LOG(ERROR) << "Failed to request a graceful shutdown of an RDP connection" |
| 222 << ", result=0x" << std::hex << result << std::dec; | 222 << ", result=0x" << std::hex << result << std::dec; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 EventHandler* event_handler = event_handler_; | 471 EventHandler* event_handler = event_handler_; |
| 472 event_handler_ = NULL; | 472 event_handler_ = NULL; |
| 473 event_handler->OnDisconnected(); | 473 event_handler->OnDisconnected(); |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 | 476 |
| 477 scoped_refptr<RdpClientWindow::WindowHook> | 477 scoped_refptr<RdpClientWindow::WindowHook> |
| 478 RdpClientWindow::WindowHook::Create() { | 478 RdpClientWindow::WindowHook::Create() { |
| 479 scoped_refptr<WindowHook> window_hook = g_window_hook.Pointer()->Get(); | 479 scoped_refptr<WindowHook> window_hook = g_window_hook.Pointer()->Get(); |
| 480 | 480 |
| 481 if (!window_hook) | 481 if (!window_hook.get()) |
| 482 window_hook = new WindowHook(); | 482 window_hook = new WindowHook(); |
| 483 | 483 |
| 484 return window_hook; | 484 return window_hook; |
| 485 } | 485 } |
| 486 | 486 |
| 487 RdpClientWindow::WindowHook::WindowHook() : hook_(NULL) { | 487 RdpClientWindow::WindowHook::WindowHook() : hook_(NULL) { |
| 488 DCHECK(!g_window_hook.Pointer()->Get()); | 488 DCHECK(!g_window_hook.Pointer()->Get()); |
| 489 | 489 |
| 490 // Install a window hook to be called on window activation. | 490 // Install a window hook to be called on window activation. |
| 491 hook_ = SetWindowsHookEx(WH_CBT, | 491 hook_ = SetWindowsHookEx(WH_CBT, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 520 return CallNextHookEx(hook, code, wparam, lparam); | 520 return CallNextHookEx(hook, code, wparam, lparam); |
| 521 | 521 |
| 522 // Close the window once all pending window messages are processed. | 522 // Close the window once all pending window messages are processed. |
| 523 HWND window = reinterpret_cast<HWND>(wparam); | 523 HWND window = reinterpret_cast<HWND>(wparam); |
| 524 LOG(WARNING) << "RDP: closing a window: " << std::hex << window << std::dec; | 524 LOG(WARNING) << "RDP: closing a window: " << std::hex << window << std::dec; |
| 525 ::PostMessage(window, WM_CLOSE, 0, 0); | 525 ::PostMessage(window, WM_CLOSE, 0, 0); |
| 526 return 0; | 526 return 0; |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace remoting | 529 } // namespace remoting |
| OLD | NEW |