| 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 #include <windows.h> | 5 #include <windows.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); | 36 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); |
| 37 | 37 |
| 38 void EndDialog(); | 38 void EndDialog(); |
| 39 | 39 |
| 40 HWND hwnd_; | 40 HWND hwnd_; |
| 41 | 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin); | 42 DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 ContinueWindowWin::ContinueWindowWin() | 45 ContinueWindowWin::ContinueWindowWin() |
| 46 : hwnd_(NULL) { | 46 : hwnd_(nullptr) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 ContinueWindowWin::~ContinueWindowWin() { | 49 ContinueWindowWin::~ContinueWindowWin() { |
| 50 EndDialog(); | 50 EndDialog(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void ContinueWindowWin::ShowUi() { | 53 void ContinueWindowWin::ShowUi() { |
| 54 DCHECK(CalledOnValidThread()); | 54 DCHECK(CalledOnValidThread()); |
| 55 DCHECK(!hwnd_); | 55 DCHECK(!hwnd_); |
| 56 | 56 |
| 57 HMODULE instance = base::GetModuleFromAddress(&DialogProc); | 57 HMODULE instance = base::GetModuleFromAddress(&DialogProc); |
| 58 hwnd_ = CreateDialogParam(instance, MAKEINTRESOURCE(IDD_CONTINUE), NULL, | 58 hwnd_ = CreateDialogParam(instance, MAKEINTRESOURCE(IDD_CONTINUE), nullptr, |
| 59 (DLGPROC)DialogProc, (LPARAM)this); | 59 (DLGPROC)DialogProc, (LPARAM)this); |
| 60 if (!hwnd_) { | 60 if (!hwnd_) { |
| 61 LOG(ERROR) << "Unable to create Disconnect dialog for remoting."; | 61 LOG(ERROR) << "Unable to create Disconnect dialog for remoting."; |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 ShowWindow(hwnd_, SW_SHOW); | 65 ShowWindow(hwnd_, SW_SHOW); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ContinueWindowWin::HideUi() { | 68 void ContinueWindowWin::HideUi() { |
| 69 DCHECK(CalledOnValidThread()); | 69 DCHECK(CalledOnValidThread()); |
| 70 | 70 |
| 71 EndDialog(); | 71 EndDialog(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 BOOL CALLBACK ContinueWindowWin::DialogProc(HWND hwnd, UINT msg, | 74 BOOL CALLBACK ContinueWindowWin::DialogProc(HWND hwnd, UINT msg, |
| 75 WPARAM wParam, LPARAM lParam) { | 75 WPARAM wParam, LPARAM lParam) { |
| 76 ContinueWindowWin* win = NULL; | 76 ContinueWindowWin* win = nullptr; |
| 77 if (msg == WM_INITDIALOG) { | 77 if (msg == WM_INITDIALOG) { |
| 78 win = reinterpret_cast<ContinueWindowWin*>(lParam); | 78 win = reinterpret_cast<ContinueWindowWin*>(lParam); |
| 79 CHECK(win); | 79 CHECK(win); |
| 80 SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)win); | 80 SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)win); |
| 81 } else { | 81 } else { |
| 82 LONG_PTR lp = GetWindowLongPtr(hwnd, DWLP_USER); | 82 LONG_PTR lp = GetWindowLongPtr(hwnd, DWLP_USER); |
| 83 win = reinterpret_cast<ContinueWindowWin*>(lp); | 83 win = reinterpret_cast<ContinueWindowWin*>(lp); |
| 84 } | 84 } |
| 85 if (win == NULL) | 85 if (win == nullptr) |
| 86 return FALSE; | 86 return FALSE; |
| 87 return win->OnDialogMessage(hwnd, msg, wParam, lParam); | 87 return win->OnDialogMessage(hwnd, msg, wParam, lParam); |
| 88 } | 88 } |
| 89 | 89 |
| 90 BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg, | 90 BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg, |
| 91 WPARAM wParam, LPARAM lParam) { | 91 WPARAM wParam, LPARAM lParam) { |
| 92 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
| 93 | 93 |
| 94 switch (msg) { | 94 switch (msg) { |
| 95 case WM_CLOSE: | 95 case WM_CLOSE: |
| 96 // Ignore close messages. | 96 // Ignore close messages. |
| 97 return TRUE; | 97 return TRUE; |
| 98 case WM_DESTROY: | 98 case WM_DESTROY: |
| 99 // Ensure we don't try to use the HWND anymore. | 99 // Ensure we don't try to use the HWND anymore. |
| 100 hwnd_ = NULL; | 100 hwnd_ = nullptr; |
| 101 return TRUE; | 101 return TRUE; |
| 102 case WM_COMMAND: | 102 case WM_COMMAND: |
| 103 switch (LOWORD(wParam)) { | 103 switch (LOWORD(wParam)) { |
| 104 case IDC_CONTINUE_DEFAULT: | 104 case IDC_CONTINUE_DEFAULT: |
| 105 ContinueSession(); | 105 ContinueSession(); |
| 106 ::EndDialog(hwnd, LOWORD(wParam)); | 106 ::EndDialog(hwnd, LOWORD(wParam)); |
| 107 hwnd_ = NULL; | 107 hwnd_ = nullptr; |
| 108 return TRUE; | 108 return TRUE; |
| 109 case IDC_CONTINUE_CANCEL: | 109 case IDC_CONTINUE_CANCEL: |
| 110 DisconnectSession(); | 110 DisconnectSession(); |
| 111 ::EndDialog(hwnd, LOWORD(wParam)); | 111 ::EndDialog(hwnd, LOWORD(wParam)); |
| 112 hwnd_ = NULL; | 112 hwnd_ = nullptr; |
| 113 return TRUE; | 113 return TRUE; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 return FALSE; | 116 return FALSE; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void ContinueWindowWin::EndDialog() { | 119 void ContinueWindowWin::EndDialog() { |
| 120 DCHECK(CalledOnValidThread()); | 120 DCHECK(CalledOnValidThread()); |
| 121 | 121 |
| 122 if (hwnd_) { | 122 if (hwnd_) { |
| 123 ::DestroyWindow(hwnd_); | 123 ::DestroyWindow(hwnd_); |
| 124 hwnd_ = NULL; | 124 hwnd_ = nullptr; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 // static | 130 // static |
| 131 scoped_ptr<HostWindow> HostWindow::CreateContinueWindow() { | 131 scoped_ptr<HostWindow> HostWindow::CreateContinueWindow() { |
| 132 return make_scoped_ptr(new ContinueWindowWin()); | 132 return make_scoped_ptr(new ContinueWindowWin()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace remoting | 135 } // namespace remoting |
| OLD | NEW |