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

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

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « remoting/host/username.cc ('k') | remoting/host/video_frame_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/verify_config_window_win.h" 5 #include "remoting/host/verify_config_window_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlwin.h> 8 #include <atlwin.h>
9 #include <windows.h> 9 #include <windows.h>
10 10
(...skipping 18 matching lines...) Expand all
29 EndDialog(ERROR_CANCELLED); 29 EndDialog(ERROR_CANCELLED);
30 } 30 }
31 31
32 void VerifyConfigWindowWin::OnClose() { 32 void VerifyConfigWindowWin::OnClose() {
33 EndDialog(ERROR_CANCELLED); 33 EndDialog(ERROR_CANCELLED);
34 } 34 }
35 35
36 LRESULT VerifyConfigWindowWin::OnInitDialog(HWND wparam, LPARAM lparam) { 36 LRESULT VerifyConfigWindowWin::OnInitDialog(HWND wparam, LPARAM lparam) {
37 // Set the small window icon. 37 // Set the small window icon.
38 if (icon_.LoadIcon(IDD, ::GetSystemMetrics(SM_CXSMICON), 38 if (icon_.LoadIcon(IDD, ::GetSystemMetrics(SM_CXSMICON),
39 ::GetSystemMetrics(SM_CYSMICON)) != NULL) { 39 ::GetSystemMetrics(SM_CYSMICON)) != nullptr) {
40 SetIcon(icon_, FALSE); 40 SetIcon(icon_, FALSE);
41 } 41 }
42 42
43 CenterWindow(); 43 CenterWindow();
44 44
45 CWindow email_text(GetDlgItem(IDC_EMAIL)); 45 CWindow email_text(GetDlgItem(IDC_EMAIL));
46 email_text.SetWindowText(base::UTF8ToUTF16(email_).c_str()); 46 email_text.SetWindowText(base::UTF8ToUTF16(email_).c_str());
47 return TRUE; 47 return TRUE;
48 } 48 }
49 49
50 void VerifyConfigWindowWin::OnOk(UINT code, int id, HWND control) { 50 void VerifyConfigWindowWin::OnOk(UINT code, int id, HWND control) {
51 if (VerifyHostSecretHash()) { 51 if (VerifyHostSecretHash()) {
52 EndDialog(ERROR_SUCCESS); 52 EndDialog(ERROR_SUCCESS);
53 } else { 53 } else {
54 EndDialog(ERROR_LOGON_FAILURE); 54 EndDialog(ERROR_LOGON_FAILURE);
55 } 55 }
56 } 56 }
57 57
58 void VerifyConfigWindowWin::CenterWindow() { 58 void VerifyConfigWindowWin::CenterWindow() {
59 // Get the window dimensions. 59 // Get the window dimensions.
60 RECT rect; 60 RECT rect;
61 if (!GetWindowRect(&rect)) { 61 if (!GetWindowRect(&rect)) {
62 return; 62 return;
63 } 63 }
64 64
65 // Center against the owner window unless it is minimized or invisible. 65 // Center against the owner window unless it is minimized or invisible.
66 HWND owner = ::GetWindow(m_hWnd, GW_OWNER); 66 HWND owner = ::GetWindow(m_hWnd, GW_OWNER);
67 if (owner != NULL) { 67 if (owner != nullptr) {
68 DWORD style = ::GetWindowLong(owner, GWL_STYLE); 68 DWORD style = ::GetWindowLong(owner, GWL_STYLE);
69 if ((style & WS_MINIMIZE) != 0 || (style & WS_VISIBLE) == 0) { 69 if ((style & WS_MINIMIZE) != 0 || (style & WS_VISIBLE) == 0) {
70 owner = NULL; 70 owner = nullptr;
71 } 71 }
72 } 72 }
73 73
74 // Make sure that the window will not end up split by a monitor's boundary. 74 // Make sure that the window will not end up split by a monitor's boundary.
75 RECT area_rect; 75 RECT area_rect;
76 if (!::SystemParametersInfo(SPI_GETWORKAREA, NULL, &area_rect, NULL)) { 76 if (!::SystemParametersInfo(SPI_GETWORKAREA, 0, &area_rect, 0)) {
77 return; 77 return;
78 } 78 }
79 79
80 // On a multi-monitor system use the monitor where the owner window is shown. 80 // On a multi-monitor system use the monitor where the owner window is shown.
81 RECT owner_rect = area_rect; 81 RECT owner_rect = area_rect;
82 if (owner != NULL && ::GetWindowRect(owner, &owner_rect)) { 82 if (owner != nullptr && ::GetWindowRect(owner, &owner_rect)) {
83 HMONITOR monitor = ::MonitorFromRect(&owner_rect, MONITOR_DEFAULTTONEAREST); 83 HMONITOR monitor = ::MonitorFromRect(&owner_rect, MONITOR_DEFAULTTONEAREST);
84 if (monitor != NULL) { 84 if (monitor != nullptr) {
85 MONITORINFO monitor_info = {0}; 85 MONITORINFO monitor_info = {0};
86 monitor_info.cbSize = sizeof(monitor_info); 86 monitor_info.cbSize = sizeof(monitor_info);
87 if (::GetMonitorInfo(monitor, &monitor_info)) { 87 if (::GetMonitorInfo(monitor, &monitor_info)) {
88 area_rect = monitor_info.rcWork; 88 area_rect = monitor_info.rcWork;
89 } 89 }
90 } 90 }
91 } 91 }
92 92
93 LONG width = rect.right - rect.left; 93 LONG width = rect.right - rect.left;
94 LONG height = rect.bottom - rect.top; 94 LONG height = rect.bottom - rect.top;
95 LONG x = (owner_rect.left + owner_rect.right - width) / 2; 95 LONG x = (owner_rect.left + owner_rect.right - width) / 2;
96 LONG y = (owner_rect.top + owner_rect.bottom - height) / 2; 96 LONG y = (owner_rect.top + owner_rect.bottom - height) / 2;
97 97
98 x = std::max(x, area_rect.left); 98 x = std::max(x, area_rect.left);
99 x = std::min(x, area_rect.right - width); 99 x = std::min(x, area_rect.right - width);
100 y = std::max(y, area_rect.top); 100 y = std::max(y, area_rect.top);
101 y = std::min(y, area_rect.bottom - width); 101 y = std::min(y, area_rect.bottom - width);
102 102
103 SetWindowPos(NULL, x, y, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); 103 SetWindowPos(nullptr, x, y, -1, -1,
104 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
104 } 105 }
105 106
106 bool VerifyConfigWindowWin::VerifyHostSecretHash() { 107 bool VerifyConfigWindowWin::VerifyHostSecretHash() {
107 CWindow pin_edit(GetDlgItem(IDC_PIN)); 108 CWindow pin_edit(GetDlgItem(IDC_PIN));
108 109
109 // Get the PIN length. 110 // Get the PIN length.
110 int pin_length = pin_edit.GetWindowTextLength(); 111 int pin_length = pin_edit.GetWindowTextLength();
111 scoped_ptr<base::char16[]> pin(new base::char16[pin_length + 1]); 112 scoped_ptr<base::char16[]> pin(new base::char16[pin_length + 1]);
112 113
113 // Get the PIN making sure it is NULL terminated even if an error occurs. 114 // Get the PIN making sure it is nullptr terminated even if an error occurs.
114 int result = pin_edit.GetWindowText(pin.get(), pin_length + 1); 115 int result = pin_edit.GetWindowText(pin.get(), pin_length + 1);
115 pin[std::min(result, pin_length)] = 0; 116 pin[std::min(result, pin_length)] = 0;
116 117
117 return VerifyHostPinHash(host_secret_hash_, 118 return VerifyHostPinHash(host_secret_hash_,
118 host_id_, base::UTF16ToUTF8(pin.get())); 119 host_id_, base::UTF16ToUTF8(pin.get()));
119 } 120 }
120 121
121 } // namespace remoting 122 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/username.cc ('k') | remoting/host/video_frame_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698