OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 virtual void Show(remoting::ChromotingHost* host) OVERRIDE; | 35 virtual void Show(remoting::ChromotingHost* host) OVERRIDE; |
36 virtual void Hide() OVERRIDE; | 36 virtual void Hide() OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 static BOOL CALLBACK DialogProc(HWND hwmd, UINT msg, WPARAM wParam, | 39 static BOOL CALLBACK DialogProc(HWND hwmd, UINT msg, WPARAM wParam, |
40 LPARAM lParam); | 40 LPARAM lParam); |
41 | 41 |
42 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); | 42 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); |
43 | 43 |
44 void EndDialog(); | 44 void EndDialog(); |
| 45 void SetStrings(const UiStrings& strings); |
45 | 46 |
46 remoting::ChromotingHost* host_; | 47 remoting::ChromotingHost* host_; |
47 HWND hwnd_; | 48 HWND hwnd_; |
48 | 49 |
49 DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin); | 50 DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin); |
50 }; | 51 }; |
51 | 52 |
52 ContinueWindowWin::ContinueWindowWin() | 53 ContinueWindowWin::ContinueWindowWin() |
53 : host_(NULL), | 54 : host_(NULL), |
54 hwnd_(NULL) { | 55 hwnd_(NULL) { |
(...skipping 15 matching lines...) Expand all Loading... |
70 win = reinterpret_cast<ContinueWindowWin*>(lp); | 71 win = reinterpret_cast<ContinueWindowWin*>(lp); |
71 } | 72 } |
72 if (win == NULL) | 73 if (win == NULL) |
73 return FALSE; | 74 return FALSE; |
74 return win->OnDialogMessage(hwnd, msg, wParam, lParam); | 75 return win->OnDialogMessage(hwnd, msg, wParam, lParam); |
75 } | 76 } |
76 | 77 |
77 BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg, | 78 BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg, |
78 WPARAM wParam, LPARAM lParam) { | 79 WPARAM wParam, LPARAM lParam) { |
79 switch (msg) { | 80 switch (msg) { |
80 case WM_INITDIALOG: | |
81 { | |
82 // Update UI string placeholders with actual strings. | |
83 std::wstring w_title = UTF8ToWide(kTitle); | |
84 SetWindowText(hwnd, w_title.c_str()); | |
85 | |
86 HWND hwndMessage = GetDlgItem(hwnd, IDC_CONTINUE_MESSAGE); | |
87 CHECK(hwndMessage); | |
88 std::wstring w_message = UTF8ToWide(kMessage); | |
89 SetWindowText(hwndMessage, w_message.c_str()); | |
90 | |
91 HWND hwndDefault = GetDlgItem(hwnd, IDC_CONTINUE_DEFAULT); | |
92 CHECK(hwndDefault); | |
93 std::wstring w_default = UTF8ToWide(kDefaultButtonText); | |
94 SetWindowText(hwndDefault, w_default.c_str()); | |
95 | |
96 HWND hwndCancel = GetDlgItem(hwnd, IDC_CONTINUE_CANCEL); | |
97 CHECK(hwndCancel); | |
98 std::wstring w_cancel = UTF8ToWide(kCancelButtonText); | |
99 SetWindowText(hwndCancel, w_cancel.c_str()); | |
100 } | |
101 return TRUE; | |
102 case WM_CLOSE: | 81 case WM_CLOSE: |
103 // Ignore close messages. | 82 // Ignore close messages. |
104 return TRUE; | 83 return TRUE; |
105 case WM_DESTROY: | 84 case WM_DESTROY: |
106 // Ensure we don't try to use the HWND anymore. | 85 // Ensure we don't try to use the HWND anymore. |
107 hwnd_ = NULL; | 86 hwnd_ = NULL; |
108 return TRUE; | 87 return TRUE; |
109 case WM_COMMAND: | 88 case WM_COMMAND: |
110 switch (LOWORD(wParam)) { | 89 switch (LOWORD(wParam)) { |
111 case IDC_CONTINUE_DEFAULT: | 90 case IDC_CONTINUE_DEFAULT: |
112 { | 91 CHECK(host_); |
113 CHECK(host_); | 92 host_->PauseSession(false); |
114 host_->PauseSession(false); | 93 ::EndDialog(hwnd, LOWORD(wParam)); |
115 ::EndDialog(hwnd, LOWORD(wParam)); | 94 hwnd_ = NULL; |
116 hwnd_ = NULL; | |
117 } | |
118 return TRUE; | 95 return TRUE; |
119 case IDC_CONTINUE_CANCEL: | 96 case IDC_CONTINUE_CANCEL: |
120 { | 97 CHECK(host_); |
121 CHECK(host_); | 98 host_->Shutdown(NULL); |
122 host_->Shutdown(NULL); | 99 ::EndDialog(hwnd, LOWORD(wParam)); |
123 ::EndDialog(hwnd, LOWORD(wParam)); | 100 hwnd_ = NULL; |
124 hwnd_ = NULL; | |
125 } | |
126 return TRUE; | 101 return TRUE; |
127 } | 102 } |
128 } | 103 } |
129 return FALSE; | 104 return FALSE; |
130 } | 105 } |
131 | 106 |
132 void ContinueWindowWin::Show(ChromotingHost* host) { | 107 void ContinueWindowWin::Show(ChromotingHost* host) { |
133 host_ = host; | 108 host_ = host; |
134 | 109 |
135 CHECK(!hwnd_); | 110 CHECK(!hwnd_); |
136 hwnd_ = CreateDialogParam(g_hModule, MAKEINTRESOURCE(IDD_CONTINUE), NULL, | 111 hwnd_ = CreateDialogParam(g_hModule, MAKEINTRESOURCE(IDD_CONTINUE), NULL, |
137 (DLGPROC)DialogProc, (LPARAM)this); | 112 (DLGPROC)DialogProc, (LPARAM)this); |
138 if (!hwnd_) { | 113 if (!hwnd_) { |
139 LOG(ERROR) << "Unable to create Disconnect dialog for remoting."; | 114 LOG(ERROR) << "Unable to create Disconnect dialog for remoting."; |
140 return; | 115 return; |
141 } | 116 } |
142 | 117 |
| 118 SetStrings(host->ui_strings()); |
143 ShowWindow(hwnd_, SW_SHOW); | 119 ShowWindow(hwnd_, SW_SHOW); |
144 } | 120 } |
145 | 121 |
146 void ContinueWindowWin::Hide() { | 122 void ContinueWindowWin::Hide() { |
147 EndDialog(); | 123 EndDialog(); |
148 } | 124 } |
149 | 125 |
150 void ContinueWindowWin::EndDialog() { | 126 void ContinueWindowWin::EndDialog() { |
151 if (hwnd_) { | 127 if (hwnd_) { |
152 ::EndDialog(hwnd_, 0); | 128 ::EndDialog(hwnd_, 0); |
153 hwnd_ = NULL; | 129 hwnd_ = NULL; |
154 } | 130 } |
155 } | 131 } |
156 | 132 |
| 133 void ContinueWindowWin::SetStrings(const UiStrings& strings) { |
| 134 SetWindowText(hwnd_, strings.product_name.c_str()); |
| 135 |
| 136 HWND hwndMessage = GetDlgItem(hwnd_, IDC_CONTINUE_MESSAGE); |
| 137 CHECK(hwndMessage); |
| 138 SetWindowText(hwndMessage, strings.continue_prompt.c_str()); |
| 139 |
| 140 HWND hwndDefault = GetDlgItem(hwnd_, IDC_CONTINUE_DEFAULT); |
| 141 CHECK(hwndDefault); |
| 142 SetWindowText(hwndDefault, strings.continue_button_text.c_str()); |
| 143 |
| 144 HWND hwndCancel = GetDlgItem(hwnd_, IDC_CONTINUE_CANCEL); |
| 145 CHECK(hwndCancel); |
| 146 SetWindowText(hwndCancel, strings.stop_sharing_button_text.c_str()); |
| 147 } |
| 148 |
157 ContinueWindow* ContinueWindow::Create() { | 149 ContinueWindow* ContinueWindow::Create() { |
158 return new ContinueWindowWin(); | 150 return new ContinueWindowWin(); |
159 } | 151 } |
160 | 152 |
161 } // namespace remoting | 153 } // namespace remoting |
OLD | NEW |