Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1659)

Side by Side Diff: remoting/host/continue_window_win.cc

Issue 8624009: Refactor ContinueWindow::Show() to accept a callback parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac compile Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/continue_window.h" 5 #include "remoting/host/continue_window.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 14 matching lines...) Expand all
25 // SimpleHost: simple_host_process.cc 25 // SimpleHost: simple_host_process.cc
26 extern HMODULE g_hModule; 26 extern HMODULE g_hModule;
27 27
28 namespace remoting { 28 namespace remoting {
29 29
30 class ContinueWindowWin : public ContinueWindow { 30 class ContinueWindowWin : public ContinueWindow {
31 public: 31 public:
32 ContinueWindowWin(); 32 ContinueWindowWin();
33 virtual ~ContinueWindowWin(); 33 virtual ~ContinueWindowWin();
34 34
35 virtual void Show(remoting::ChromotingHost* host) OVERRIDE; 35 virtual void Show(remoting::ChromotingHost* host,
36 const ContinueSessionCallback& callback) OVERRIDE;
36 virtual void Hide() OVERRIDE; 37 virtual void Hide() OVERRIDE;
37 38
38 private: 39 private:
39 static BOOL CALLBACK DialogProc(HWND hwmd, UINT msg, WPARAM wParam, 40 static BOOL CALLBACK DialogProc(HWND hwmd, UINT msg, WPARAM wParam,
40 LPARAM lParam); 41 LPARAM lParam);
41 42
42 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 43 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
43 44
44 void EndDialog(); 45 void EndDialog();
45 void SetStrings(const UiStrings& strings); 46 void SetStrings(const UiStrings& strings);
46 47
47 remoting::ChromotingHost* host_; 48 remoting::ChromotingHost* host_;
49 ContinueSessionCallback callback_;
48 HWND hwnd_; 50 HWND hwnd_;
49 51
50 DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin); 52 DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin);
51 }; 53 };
52 54
53 ContinueWindowWin::ContinueWindowWin() 55 ContinueWindowWin::ContinueWindowWin()
54 : host_(NULL), 56 : host_(NULL),
55 hwnd_(NULL) { 57 hwnd_(NULL) {
56 } 58 }
57 59
(...skipping 23 matching lines...) Expand all
81 case WM_CLOSE: 83 case WM_CLOSE:
82 // Ignore close messages. 84 // Ignore close messages.
83 return TRUE; 85 return TRUE;
84 case WM_DESTROY: 86 case WM_DESTROY:
85 // Ensure we don't try to use the HWND anymore. 87 // Ensure we don't try to use the HWND anymore.
86 hwnd_ = NULL; 88 hwnd_ = NULL;
87 return TRUE; 89 return TRUE;
88 case WM_COMMAND: 90 case WM_COMMAND:
89 switch (LOWORD(wParam)) { 91 switch (LOWORD(wParam)) {
90 case IDC_CONTINUE_DEFAULT: 92 case IDC_CONTINUE_DEFAULT:
91 CHECK(host_); 93 callback_.Run(true);
92 host_->PauseSession(false);
93 ::EndDialog(hwnd, LOWORD(wParam)); 94 ::EndDialog(hwnd, LOWORD(wParam));
94 hwnd_ = NULL; 95 hwnd_ = NULL;
95 return TRUE; 96 return TRUE;
96 case IDC_CONTINUE_CANCEL: 97 case IDC_CONTINUE_CANCEL:
97 CHECK(host_); 98 callback_.Run(false);
98 host_->Shutdown(base::Closure());
99 ::EndDialog(hwnd, LOWORD(wParam)); 99 ::EndDialog(hwnd, LOWORD(wParam));
100 hwnd_ = NULL; 100 hwnd_ = NULL;
101 return TRUE; 101 return TRUE;
102 } 102 }
103 } 103 }
104 return FALSE; 104 return FALSE;
105 } 105 }
106 106
107 void ContinueWindowWin::Show(ChromotingHost* host) { 107 void ContinueWindowWin::Show(ChromotingHost* host,
108 const ContinueSessionCallback& callback) {
108 host_ = host; 109 host_ = host;
110 callback_ = callback;
109 111
110 CHECK(!hwnd_); 112 CHECK(!hwnd_);
111 hwnd_ = CreateDialogParam(g_hModule, MAKEINTRESOURCE(IDD_CONTINUE), NULL, 113 hwnd_ = CreateDialogParam(g_hModule, MAKEINTRESOURCE(IDD_CONTINUE), NULL,
112 (DLGPROC)DialogProc, (LPARAM)this); 114 (DLGPROC)DialogProc, (LPARAM)this);
113 if (!hwnd_) { 115 if (!hwnd_) {
114 LOG(ERROR) << "Unable to create Disconnect dialog for remoting."; 116 LOG(ERROR) << "Unable to create Disconnect dialog for remoting.";
115 return; 117 return;
116 } 118 }
117 119
118 SetStrings(host->ui_strings()); 120 SetStrings(host->ui_strings());
(...skipping 25 matching lines...) Expand all
144 HWND hwndCancel = GetDlgItem(hwnd_, IDC_CONTINUE_CANCEL); 146 HWND hwndCancel = GetDlgItem(hwnd_, IDC_CONTINUE_CANCEL);
145 CHECK(hwndCancel); 147 CHECK(hwndCancel);
146 SetWindowText(hwndCancel, strings.stop_sharing_button_text.c_str()); 148 SetWindowText(hwndCancel, strings.stop_sharing_button_text.c_str());
147 } 149 }
148 150
149 ContinueWindow* ContinueWindow::Create() { 151 ContinueWindow* ContinueWindow::Create() {
150 return new ContinueWindowWin(); 152 return new ContinueWindowWin();
151 } 153 }
152 154
153 } // namespace remoting 155 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698