OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include <commctrl.h> | 6 #include <commctrl.h> |
7 | 7 |
| 8 #include <cstdint> |
8 #include <memory> | 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
14 #include "base/i18n/message_formatter.h" | 15 #include "base/i18n/message_formatter.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" |
20 #include "remoting/host/it2me/it2me_confirmation_dialog.h" | 22 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
21 #include "remoting/host/win/core_resource.h" | 23 #include "remoting/host/win/core_resource.h" |
22 | 24 |
23 namespace remoting { | 25 namespace remoting { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 // Time to wait before closing the dialog and cancelling the connection. | 29 // Time to wait before closing the dialog and cancelling the connection. |
28 const int kDialogTimeoutMs = 60 * 1000; | 30 constexpr base::TimeDelta kDialogTimeout = base::TimeDelta::FromMinutes(1); |
29 | 31 |
30 const HRESULT kTimeoutErrorCode = E_ABORT; | 32 const HRESULT kTimeoutErrorCode = E_ABORT; |
31 | 33 |
32 // Loads an embedded string resource from the specified module. | 34 // Loads an embedded string resource from the specified module. |
33 bool LoadStringResource(HMODULE resource_module, | 35 bool LoadStringResource(HMODULE resource_module, |
34 int resource_id, | 36 int resource_id, |
35 base::string16* string) { | 37 base::string16* string) { |
36 DCHECK(resource_module); | 38 DCHECK(resource_module); |
37 DCHECK(string); | 39 DCHECK(string); |
38 | 40 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 callback.Run(result); | 174 callback.Run(result); |
173 } | 175 } |
174 | 176 |
175 HRESULT CALLBACK | 177 HRESULT CALLBACK |
176 It2MeConfirmationDialogWin::TaskDialogCallbackProc(HWND hwnd, | 178 It2MeConfirmationDialogWin::TaskDialogCallbackProc(HWND hwnd, |
177 UINT notification, | 179 UINT notification, |
178 WPARAM w_param, | 180 WPARAM w_param, |
179 LPARAM l_param, | 181 LPARAM l_param, |
180 LONG_PTR ref_data) { | 182 LONG_PTR ref_data) { |
181 if (notification == TDN_TIMER) { | 183 if (notification == TDN_TIMER) { |
182 if (w_param >= kDialogTimeoutMs) { | 184 if (static_cast<int64_t>(w_param) >= kDialogTimeout.InMilliseconds()) { |
183 // Close the dialog window if we have reached the timeout. | 185 // Close the dialog window if we have reached the timeout. |
184 return kTimeoutErrorCode; | 186 return kTimeoutErrorCode; |
185 } | 187 } |
186 | 188 |
187 // Ensure the window is visible before checking if it is in the foreground. | 189 // Ensure the window is visible before checking if it is in the foreground. |
188 if (!IsWindowVisible(hwnd)) { | 190 if (!IsWindowVisible(hwnd)) { |
189 ShowWindow(hwnd, SW_SHOWNORMAL); | 191 ShowWindow(hwnd, SW_SHOWNORMAL); |
190 } | 192 } |
191 | 193 |
192 // Attempt to bring the dialog window to the foreground if needed. If the | 194 // Attempt to bring the dialog window to the foreground if needed. If the |
(...skipping 14 matching lines...) Expand all Loading... |
207 } | 209 } |
208 | 210 |
209 } // namespace | 211 } // namespace |
210 | 212 |
211 std::unique_ptr<It2MeConfirmationDialog> | 213 std::unique_ptr<It2MeConfirmationDialog> |
212 It2MeConfirmationDialogFactory::Create() { | 214 It2MeConfirmationDialogFactory::Create() { |
213 return base::MakeUnique<It2MeConfirmationDialogWin>(); | 215 return base::MakeUnique<It2MeConfirmationDialogWin>(); |
214 } | 216 } |
215 | 217 |
216 } // namespace remoting | 218 } // namespace remoting |
OLD | NEW |