Chromium Code Reviews| 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 "remoting/host/disconnect_window.h" | |
| 6 | |
| 7 #include <windows.h> | 5 #include <windows.h> |
| 8 | 6 |
| 9 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 8 #include "base/logging.h" |
| 11 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 12 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 14 #include "base/win/scoped_gdi_object.h" | 12 #include "base/win/scoped_gdi_object.h" |
| 15 #include "base/win/scoped_hdc.h" | 13 #include "base/win/scoped_hdc.h" |
| 16 #include "base/win/scoped_select_object.h" | 14 #include "base/win/scoped_select_object.h" |
| 15 #include "remoting/host/client_session_control.h" | |
| 16 #include "remoting/host/host_window.h" | |
| 17 #include "remoting/host/ui_strings.h" | 17 #include "remoting/host/ui_strings.h" |
| 18 #include "remoting/host/win/core_resource.h" | 18 #include "remoting/host/win/core_resource.h" |
| 19 | 19 |
| 20 // TODO(garykac): Lots of duplicated code in this file and | 20 namespace remoting { |
| 21 // continue_window_win.cc. If we need to expand this then we should | |
| 22 // create a class with the shared code. | |
| 23 | 21 |
| 24 namespace { | 22 namespace { |
| 25 | 23 |
| 26 const int DISCONNECT_HOTKEY_ID = 1000; | 24 const int DISCONNECT_HOTKEY_ID = 1000; |
| 27 | 25 |
| 28 // Maximum length of "Your desktop is shared with ..." message in UTF-16 | 26 // Maximum length of "Your desktop is shared with ..." message in UTF-16 |
| 29 // characters. | 27 // characters. |
| 30 const size_t kMaxSharingWithTextLength = 100; | 28 const size_t kMaxSharingWithTextLength = 100; |
| 31 | 29 |
| 32 const wchar_t kShellTrayWindowName[] = L"Shell_TrayWnd"; | 30 const wchar_t kShellTrayWindowName[] = L"Shell_TrayWnd"; |
| 33 const int kWindowBorderRadius = 14; | 31 const int kWindowBorderRadius = 14; |
| 34 | 32 |
| 35 } // namespace anonymous | 33 class DisconnectWindowWin : public HostWindow { |
| 36 | |
| 37 namespace remoting { | |
| 38 | |
| 39 class DisconnectWindowWin : public DisconnectWindow { | |
| 40 public: | 34 public: |
| 41 explicit DisconnectWindowWin(const UiStrings* ui_strings); | 35 explicit DisconnectWindowWin(const UiStrings& ui_strings); |
| 42 virtual ~DisconnectWindowWin(); | 36 virtual ~DisconnectWindowWin(); |
| 43 | 37 |
| 44 // DisconnectWindow interface. | 38 // HostWindow overrides. |
| 45 virtual bool Show(const base::Closure& disconnect_callback, | 39 virtual void Start( |
| 46 const std::string& username) OVERRIDE; | 40 const base::WeakPtr<ClientSessionControl>& client_session_control) |
| 47 virtual void Hide() OVERRIDE; | 41 OVERRIDE; |
| 48 | 42 |
| 49 private: | 43 protected: |
| 50 static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wparam, | 44 static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT message, WPARAM wparam, |
| 51 LPARAM lparam); | 45 LPARAM lparam); |
| 52 | 46 |
| 53 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); | 47 BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); |
| 54 | 48 |
| 55 // Creates the dialog window and registers the disconnect hot key. | 49 // Creates the dialog window and registers the disconnect hot key. |
| 56 bool BeginDialog(const std::string& username); | 50 bool BeginDialog(); |
| 57 | 51 |
| 58 // Closes the dialog, unregisters the hot key and invokes the disconnect | 52 // Closes the dialog, unregisters the hot key and invokes the disconnect |
| 59 // callback, if set. | 53 // callback, if set. |
| 60 void EndDialog(); | 54 void EndDialog(); |
| 61 | 55 |
| 62 // Trys to position the dialog window above the taskbar. | 56 // Trys to position the dialog window above the taskbar. |
| 63 void SetDialogPosition(); | 57 void SetDialogPosition(); |
| 64 | 58 |
| 65 // Applies localization string and resizes the dialog. | 59 // Applies localization string and resizes the dialog. |
| 66 bool SetStrings(const string16& username); | 60 bool SetStrings(); |
| 67 | 61 |
| 68 base::Closure disconnect_callback_; | 62 // Used to disconnect the client session. |
| 63 base::WeakPtr<ClientSessionControl> client_session_control_; | |
| 64 | |
| 65 // Localized UI strings. | |
| 66 UiStrings ui_strings_; | |
| 67 | |
| 68 // Specifies the remote user name. | |
| 69 std::string username_; | |
| 70 | |
| 69 HWND hwnd_; | 71 HWND hwnd_; |
| 70 bool has_hotkey_; | 72 bool has_hotkey_; |
| 71 base::win::ScopedGDIObject<HPEN> border_pen_; | 73 base::win::ScopedGDIObject<HPEN> border_pen_; |
| 72 | 74 |
| 73 // Points to the localized strings. | |
| 74 const UiStrings* ui_strings_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowWin); | 75 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowWin); |
| 77 }; | 76 }; |
| 78 | 77 |
| 79 static int GetControlTextWidth(HWND control) { | 78 int GetControlTextWidth(HWND control) { |
| 80 RECT rect = {0, 0, 0, 0}; | 79 RECT rect = {0, 0, 0, 0}; |
| 81 WCHAR text[256]; | 80 WCHAR text[256]; |
| 82 int result = GetWindowText(control, text, arraysize(text)); | 81 int result = GetWindowText(control, text, arraysize(text)); |
| 83 if (result) { | 82 if (result) { |
| 84 base::win::ScopedGetDC dc(control); | 83 base::win::ScopedGetDC dc(control); |
| 85 base::win::ScopedSelectObject font( | 84 base::win::ScopedSelectObject font( |
| 86 dc, (HFONT)SendMessage(control, WM_GETFONT, 0, 0)); | 85 dc, (HFONT)SendMessage(control, WM_GETFONT, 0, 0)); |
| 87 DrawText(dc, text, -1, &rect, DT_CALCRECT | DT_SINGLELINE); | 86 DrawText(dc, text, -1, &rect, DT_CALCRECT | DT_SINGLELINE); |
| 88 } | 87 } |
| 89 return rect.right; | 88 return rect.right; |
| 90 } | 89 } |
| 91 | 90 |
| 92 DisconnectWindowWin::DisconnectWindowWin(const UiStrings* ui_strings) | 91 DisconnectWindowWin::DisconnectWindowWin(const UiStrings& ui_strings) |
| 93 : hwnd_(NULL), | 92 : ui_strings_(ui_strings), |
| 93 hwnd_(NULL), | |
| 94 has_hotkey_(false), | 94 has_hotkey_(false), |
| 95 border_pen_(CreatePen(PS_SOLID, 5, | 95 border_pen_(CreatePen(PS_SOLID, 5, |
| 96 RGB(0.13 * 255, 0.69 * 255, 0.11 * 255))), | 96 RGB(0.13 * 255, 0.69 * 255, 0.11 * 255))) { |
| 97 ui_strings_(ui_strings) { | |
| 98 } | 97 } |
| 99 | 98 |
| 100 DisconnectWindowWin::~DisconnectWindowWin() { | 99 DisconnectWindowWin::~DisconnectWindowWin() { |
| 101 Hide(); | |
| 102 } | |
| 103 | |
| 104 bool DisconnectWindowWin::Show(const base::Closure& disconnect_callback, | |
| 105 const std::string& username) { | |
| 106 DCHECK(disconnect_callback_.is_null()); | |
| 107 DCHECK(!disconnect_callback.is_null()); | |
| 108 | |
| 109 disconnect_callback_ = disconnect_callback; | |
| 110 | |
| 111 if (BeginDialog(username)) { | |
| 112 return true; | |
| 113 } else { | |
| 114 Hide(); | |
| 115 return false; | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 void DisconnectWindowWin::Hide() { | |
| 120 // Clear the |disconnect_callback_| so it won't be invoked by EndDialog(). | |
| 121 disconnect_callback_.Reset(); | |
| 122 EndDialog(); | 100 EndDialog(); |
| 123 } | 101 } |
| 124 | 102 |
| 125 INT_PTR CALLBACK DisconnectWindowWin::DialogProc(HWND hwnd, UINT message, | 103 void DisconnectWindowWin::Start( |
| 126 WPARAM wparam, LPARAM lparam) { | 104 const base::WeakPtr<ClientSessionControl>& client_session_control) { |
| 105 DCHECK(CalledOnValidThread()); | |
| 106 DCHECK(!client_session_control_); | |
| 107 DCHECK(client_session_control); | |
| 108 | |
| 109 client_session_control_ = client_session_control; | |
| 110 | |
| 111 std::string client_jid = client_session_control_->client_jid(); | |
| 112 username_ = client_jid.substr(0, client_jid.find('/')); | |
| 113 if (!BeginDialog()) | |
| 114 EndDialog(); | |
| 115 } | |
| 116 | |
| 117 INT_PTR CALLBACK DisconnectWindowWin::DialogProc(HWND hwnd, | |
| 118 UINT message, | |
| 119 WPARAM wparam, | |
| 120 LPARAM lparam) { | |
| 127 LONG_PTR self = NULL; | 121 LONG_PTR self = NULL; |
| 128 if (message == WM_INITDIALOG) { | 122 if (message == WM_INITDIALOG) { |
| 129 self = lparam; | 123 self = lparam; |
| 130 | 124 |
| 131 // Store |this| to the window's user data. | 125 // Store |this| to the window's user data. |
| 132 SetLastError(ERROR_SUCCESS); | 126 SetLastError(ERROR_SUCCESS); |
| 133 LONG_PTR result = SetWindowLongPtr(hwnd, DWLP_USER, self); | 127 LONG_PTR result = SetWindowLongPtr(hwnd, DWLP_USER, self); |
| 134 if (result == 0 && GetLastError() != ERROR_SUCCESS) | 128 if (result == 0 && GetLastError() != ERROR_SUCCESS) |
| 135 reinterpret_cast<DisconnectWindowWin*>(self)->EndDialog(); | 129 reinterpret_cast<DisconnectWindowWin*>(self)->EndDialog(); |
| 136 } else { | 130 } else { |
| 137 self = GetWindowLongPtr(hwnd, DWLP_USER); | 131 self = GetWindowLongPtr(hwnd, DWLP_USER); |
| 138 } | 132 } |
| 139 | 133 |
| 140 if (self) { | 134 if (self) { |
| 141 return reinterpret_cast<DisconnectWindowWin*>(self)->OnDialogMessage( | 135 return reinterpret_cast<DisconnectWindowWin*>(self)->OnDialogMessage( |
| 142 hwnd, message, wparam, lparam); | 136 hwnd, message, wparam, lparam); |
| 143 } | 137 } |
| 144 return FALSE; | 138 return FALSE; |
| 145 } | 139 } |
| 146 | 140 |
| 147 BOOL DisconnectWindowWin::OnDialogMessage(HWND hwnd, UINT message, | 141 BOOL DisconnectWindowWin::OnDialogMessage(HWND hwnd, |
| 148 WPARAM wparam, LPARAM lparam) { | 142 UINT message, |
| 143 WPARAM wparam, | |
| 144 LPARAM lparam) { | |
| 145 DCHECK(CalledOnValidThread()); | |
| 146 | |
| 149 switch (message) { | 147 switch (message) { |
| 150 // Ignore close messages. | 148 // Ignore close messages. |
| 151 case WM_CLOSE: | 149 case WM_CLOSE: |
| 152 return TRUE; | 150 return TRUE; |
| 153 | 151 |
| 154 // Handle the Disconnect button. | 152 // Handle the Disconnect button. |
| 155 case WM_COMMAND: | 153 case WM_COMMAND: |
| 156 switch (LOWORD(wparam)) { | 154 switch (LOWORD(wparam)) { |
| 157 case IDC_DISCONNECT: | 155 case IDC_DISCONNECT: |
| 158 EndDialog(); | 156 EndDialog(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 RoundRect(hdc, rect.left, rect.top, rect.right - 1, rect.bottom - 1, | 201 RoundRect(hdc, rect.left, rect.top, rect.right - 1, rect.bottom - 1, |
| 204 kWindowBorderRadius, kWindowBorderRadius); | 202 kWindowBorderRadius, kWindowBorderRadius); |
| 205 } | 203 } |
| 206 EndPaint(hwnd_, &ps); | 204 EndPaint(hwnd_, &ps); |
| 207 return TRUE; | 205 return TRUE; |
| 208 } | 206 } |
| 209 } | 207 } |
| 210 return FALSE; | 208 return FALSE; |
| 211 } | 209 } |
| 212 | 210 |
| 213 bool DisconnectWindowWin::BeginDialog(const std::string& username) { | 211 bool DisconnectWindowWin::BeginDialog() { |
| 212 DCHECK(CalledOnValidThread()); | |
| 214 DCHECK(!hwnd_); | 213 DCHECK(!hwnd_); |
| 215 | 214 |
| 216 // Load the dialog resource so that we can modify the RTL flags if necessary. | 215 // Load the dialog resource so that we can modify the RTL flags if necessary. |
| 217 HMODULE module = base::GetModuleFromAddress(&DialogProc); | 216 HMODULE module = base::GetModuleFromAddress(&DialogProc); |
| 218 HRSRC dialog_resource = | 217 HRSRC dialog_resource = |
| 219 FindResource(module, MAKEINTRESOURCE(IDD_DISCONNECT), RT_DIALOG); | 218 FindResource(module, MAKEINTRESOURCE(IDD_DISCONNECT), RT_DIALOG); |
| 220 if (!dialog_resource) | 219 if (!dialog_resource) |
| 221 return false; | 220 return false; |
| 222 | 221 |
| 223 HGLOBAL dialog_template = LoadResource(module, dialog_resource); | 222 HGLOBAL dialog_template = LoadResource(module, dialog_resource); |
| 224 if (!dialog_template) | 223 if (!dialog_template) |
| 225 return false; | 224 return false; |
| 226 | 225 |
| 227 DLGTEMPLATE* dialog_pointer = | 226 DLGTEMPLATE* dialog_pointer = |
| 228 reinterpret_cast<DLGTEMPLATE*>(LockResource(dialog_template)); | 227 reinterpret_cast<DLGTEMPLATE*>(LockResource(dialog_template)); |
| 229 if (!dialog_pointer) | 228 if (!dialog_pointer) |
| 230 return false; | 229 return false; |
| 231 | 230 |
| 232 // The actual resource type is DLGTEMPLATEEX, but this is not defined in any | 231 // The actual resource type is DLGTEMPLATEEX, but this is not defined in any |
| 233 // standard headers, so we treat it as a generic pointer and manipulate the | 232 // standard headers, so we treat it as a generic pointer and manipulate the |
| 234 // correct offsets explicitly. | 233 // correct offsets explicitly. |
| 235 scoped_array<unsigned char> rtl_dialog_template; | 234 scoped_array<unsigned char> rtl_dialog_template; |
| 236 if (ui_strings_->direction == UiStrings::RTL) { | 235 if (ui_strings_.direction == UiStrings::RTL) { |
| 237 unsigned long dialog_template_size = | 236 unsigned long dialog_template_size = |
| 238 SizeofResource(module, dialog_resource); | 237 SizeofResource(module, dialog_resource); |
| 239 rtl_dialog_template.reset(new unsigned char[dialog_template_size]); | 238 rtl_dialog_template.reset(new unsigned char[dialog_template_size]); |
| 240 memcpy(rtl_dialog_template.get(), dialog_pointer, dialog_template_size); | 239 memcpy(rtl_dialog_template.get(), dialog_pointer, dialog_template_size); |
| 241 DWORD* rtl_dwords = reinterpret_cast<DWORD*>(rtl_dialog_template.get()); | 240 DWORD* rtl_dwords = reinterpret_cast<DWORD*>(rtl_dialog_template.get()); |
| 242 rtl_dwords[2] |= (WS_EX_LAYOUTRTL | WS_EX_RTLREADING); | 241 rtl_dwords[2] |= (WS_EX_LAYOUTRTL | WS_EX_RTLREADING); |
| 243 dialog_pointer = reinterpret_cast<DLGTEMPLATE*>(rtl_dwords); | 242 dialog_pointer = reinterpret_cast<DLGTEMPLATE*>(rtl_dwords); |
| 244 } | 243 } |
| 245 | 244 |
| 246 hwnd_ = CreateDialogIndirectParam(module, dialog_pointer, NULL, | 245 hwnd_ = CreateDialogIndirectParam(module, dialog_pointer, NULL, |
| 247 DialogProc, reinterpret_cast<LPARAM>(this)); | 246 DialogProc, reinterpret_cast<LPARAM>(this)); |
| 248 if (!hwnd_) | 247 if (!hwnd_) |
| 249 return false; | 248 return false; |
| 250 | 249 |
| 251 // Set up handler for Ctrl-Alt-Esc shortcut. | 250 // Set up handler for Ctrl-Alt-Esc shortcut. |
| 252 if (!has_hotkey_ && RegisterHotKey(hwnd_, DISCONNECT_HOTKEY_ID, | 251 if (!has_hotkey_ && RegisterHotKey(hwnd_, DISCONNECT_HOTKEY_ID, |
| 253 MOD_ALT | MOD_CONTROL, VK_ESCAPE)) { | 252 MOD_ALT | MOD_CONTROL, VK_ESCAPE)) { |
| 254 has_hotkey_ = true; | 253 has_hotkey_ = true; |
| 255 } | 254 } |
| 256 | 255 |
| 257 if (!SetStrings(UTF8ToUTF16(username))) | 256 if (!SetStrings()) |
| 258 return false; | 257 return false; |
| 259 | 258 |
| 260 SetDialogPosition(); | 259 SetDialogPosition(); |
| 261 ShowWindow(hwnd_, SW_SHOW); | 260 ShowWindow(hwnd_, SW_SHOW); |
| 262 return IsWindowVisible(hwnd_) != FALSE; | 261 return IsWindowVisible(hwnd_) != FALSE; |
| 263 } | 262 } |
| 264 | 263 |
| 265 void DisconnectWindowWin::EndDialog() { | 264 void DisconnectWindowWin::EndDialog() { |
| 265 DCHECK(CalledOnValidThread()); | |
| 266 | |
| 266 if (has_hotkey_) { | 267 if (has_hotkey_) { |
| 267 UnregisterHotKey(hwnd_, DISCONNECT_HOTKEY_ID); | 268 UnregisterHotKey(hwnd_, DISCONNECT_HOTKEY_ID); |
| 268 has_hotkey_ = false; | 269 has_hotkey_ = false; |
| 269 } | 270 } |
| 270 | 271 |
| 271 if (hwnd_) { | 272 if (hwnd_) { |
| 272 DestroyWindow(hwnd_); | 273 DestroyWindow(hwnd_); |
| 273 hwnd_ = NULL; | 274 hwnd_ = NULL; |
| 274 } | 275 } |
| 275 | 276 |
| 276 if (!disconnect_callback_.is_null()) { | 277 if (client_session_control_) { |
| 277 disconnect_callback_.Run(); | 278 client_session_control_->DisconnectSession(); |
| 278 disconnect_callback_.Reset(); | 279 client_session_control_.reset(); |
|
Sergey Ulanov
2013/04/04 00:10:03
don't need reset here
alexeypa (please no reviews)
2013/04/04 16:56:40
Done.
| |
| 279 } | 280 } |
| 280 } | 281 } |
| 281 | 282 |
| 282 void DisconnectWindowWin::SetDialogPosition() { | 283 void DisconnectWindowWin::SetDialogPosition() { |
| 284 DCHECK(CalledOnValidThread()); | |
| 285 | |
| 283 // Try to center the window above the task-bar. If that fails, use the | 286 // Try to center the window above the task-bar. If that fails, use the |
| 284 // primary monitor. If that fails (very unlikely), use the default position. | 287 // primary monitor. If that fails (very unlikely), use the default position. |
| 285 HWND taskbar = FindWindow(kShellTrayWindowName, NULL); | 288 HWND taskbar = FindWindow(kShellTrayWindowName, NULL); |
| 286 HMONITOR monitor = MonitorFromWindow(taskbar, MONITOR_DEFAULTTOPRIMARY); | 289 HMONITOR monitor = MonitorFromWindow(taskbar, MONITOR_DEFAULTTOPRIMARY); |
| 287 MONITORINFO monitor_info = {sizeof(monitor_info)}; | 290 MONITORINFO monitor_info = {sizeof(monitor_info)}; |
| 288 RECT window_rect; | 291 RECT window_rect; |
| 289 if (GetMonitorInfo(monitor, &monitor_info) && | 292 if (GetMonitorInfo(monitor, &monitor_info) && |
| 290 GetWindowRect(hwnd_, &window_rect)) { | 293 GetWindowRect(hwnd_, &window_rect)) { |
| 291 int window_width = window_rect.right - window_rect.left; | 294 int window_width = window_rect.right - window_rect.left; |
| 292 int window_height = window_rect.bottom - window_rect.top; | 295 int window_height = window_rect.bottom - window_rect.top; |
| 293 int top = monitor_info.rcWork.bottom - window_height; | 296 int top = monitor_info.rcWork.bottom - window_height; |
| 294 int left = (monitor_info.rcWork.right + monitor_info.rcWork.left - | 297 int left = (monitor_info.rcWork.right + monitor_info.rcWork.left - |
| 295 window_width) / 2; | 298 window_width) / 2; |
| 296 SetWindowPos(hwnd_, NULL, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); | 299 SetWindowPos(hwnd_, NULL, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); |
| 297 } | 300 } |
| 298 } | 301 } |
| 299 | 302 |
| 300 bool DisconnectWindowWin::SetStrings(const string16& username) { | 303 bool DisconnectWindowWin::SetStrings() { |
| 301 if (!SetWindowText(hwnd_, ui_strings_->product_name.c_str())) | 304 DCHECK(CalledOnValidThread()); |
| 305 | |
| 306 if (!SetWindowText(hwnd_, ui_strings_.product_name.c_str())) | |
| 302 return false; | 307 return false; |
| 303 | 308 |
| 304 // Localize the disconnect button text and measure length of the old and new | 309 // Localize the disconnect button text and measure length of the old and new |
| 305 // labels. | 310 // labels. |
| 306 HWND disconnect_button = GetDlgItem(hwnd_, IDC_DISCONNECT); | 311 HWND disconnect_button = GetDlgItem(hwnd_, IDC_DISCONNECT); |
| 307 if (!disconnect_button) | 312 if (!disconnect_button) |
| 308 return false; | 313 return false; |
| 309 int button_old_required_width = GetControlTextWidth(disconnect_button); | 314 int button_old_required_width = GetControlTextWidth(disconnect_button); |
| 310 if (!SetWindowText(disconnect_button, | 315 if (!SetWindowText(disconnect_button, |
| 311 ui_strings_->disconnect_button_text.c_str())) { | 316 ui_strings_.disconnect_button_text.c_str())) { |
| 312 return false; | 317 return false; |
| 313 } | 318 } |
| 314 int button_new_required_width = GetControlTextWidth(disconnect_button); | 319 int button_new_required_width = GetControlTextWidth(disconnect_button); |
| 315 int button_width_delta = | 320 int button_width_delta = |
| 316 button_new_required_width - button_old_required_width; | 321 button_new_required_width - button_old_required_width; |
| 317 | 322 |
| 318 // Format and truncate "Your desktop is shared with ..." message. | 323 // Format and truncate "Your desktop is shared with ..." message. |
| 319 string16 text = ReplaceStringPlaceholders(ui_strings_->disconnect_message, | 324 string16 text = ReplaceStringPlaceholders(ui_strings_.disconnect_message, |
| 320 username, NULL); | 325 UTF8ToUTF16(username_), NULL); |
| 321 if (text.length() > kMaxSharingWithTextLength) | 326 if (text.length() > kMaxSharingWithTextLength) |
| 322 text.erase(kMaxSharingWithTextLength); | 327 text.erase(kMaxSharingWithTextLength); |
| 323 | 328 |
| 324 // Set localized and truncated "Your desktop is shared with ..." message and | 329 // Set localized and truncated "Your desktop is shared with ..." message and |
| 325 // measure length of the old and new text. | 330 // measure length of the old and new text. |
| 326 HWND sharing_with_label = GetDlgItem(hwnd_, IDC_DISCONNECT_SHARINGWITH); | 331 HWND sharing_with_label = GetDlgItem(hwnd_, IDC_DISCONNECT_SHARINGWITH); |
| 327 if (!sharing_with_label) | 332 if (!sharing_with_label) |
| 328 return false; | 333 return false; |
| 329 int label_old_required_width = GetControlTextWidth(sharing_with_label); | 334 int label_old_required_width = GetControlTextWidth(sharing_with_label); |
| 330 if (!SetWindowText(sharing_with_label, text.c_str())) | 335 if (!SetWindowText(sharing_with_label, text.c_str())) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 HRGN rgn = CreateRoundRectRgn(0, 0, width, height, kWindowBorderRadius, | 383 HRGN rgn = CreateRoundRectRgn(0, 0, width, height, kWindowBorderRadius, |
| 379 kWindowBorderRadius); | 384 kWindowBorderRadius); |
| 380 if (!rgn) | 385 if (!rgn) |
| 381 return false; | 386 return false; |
| 382 if (!SetWindowRgn(hwnd_, rgn, TRUE)) | 387 if (!SetWindowRgn(hwnd_, rgn, TRUE)) |
| 383 return false; | 388 return false; |
| 384 | 389 |
| 385 return true; | 390 return true; |
| 386 } | 391 } |
| 387 | 392 |
| 388 scoped_ptr<DisconnectWindow> DisconnectWindow::Create( | 393 } // namespace |
| 389 const UiStrings* ui_strings) { | 394 |
| 390 return scoped_ptr<DisconnectWindow>(new DisconnectWindowWin(ui_strings)); | 395 // static |
| 396 scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow( | |
| 397 const UiStrings& ui_strings) { | |
| 398 return scoped_ptr<HostWindow>(new DisconnectWindowWin(ui_strings)); | |
| 391 } | 399 } |
| 392 | 400 |
| 393 } // namespace remoting | 401 } // namespace remoting |
| OLD | NEW |