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