[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_ | ||||
6 | #define CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_ | ||||
7 | |||||
Greg Thompson | eafda51e | 2017-09-05 23:09:45 | [diff] [blame] | 8 | #include "base/callback.h" |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 9 | #include "base/macros.h" |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 10 | #include "chrome/browser/process_singleton.h" |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 11 | |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 12 | namespace base { |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 13 | class CommandLine; |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 14 | class FilePath; |
15 | } | ||||
16 | |||||
Greg Thompson | eafda51e | 2017-09-05 23:09:45 | [diff] [blame] | 17 | // Provides a ProcessSingleton::NotificationCallback that allows for closing a |
18 | // modal dialog that is active during startup. The client must ensure that | ||||
19 | // SetModalDialogCallback is called appropriately when such dialogs are | ||||
20 | // displayed or dismissed. | ||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 21 | // |
Greg Thompson | eafda51e | 2017-09-05 23:09:45 | [diff] [blame] | 22 | // After invoking the modal dialog's callback, this process will continue normal |
23 | // processing of the command line by forwarding the notification to a wrapped | ||||
24 | // NotificationCallback. | ||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 25 | class ProcessSingletonModalDialogLock { |
26 | public: | ||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 27 | explicit ProcessSingletonModalDialogLock( |
28 | const ProcessSingleton::NotificationCallback& original_callback); | ||||
29 | |||||
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame^] | 30 | ProcessSingletonModalDialogLock(const ProcessSingletonModalDialogLock&) = |
31 | delete; | ||||
32 | ProcessSingletonModalDialogLock& operator=( | ||||
33 | const ProcessSingletonModalDialogLock&) = delete; | ||||
34 | |||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 35 | ~ProcessSingletonModalDialogLock(); |
36 | |||||
Greg Thompson | eafda51e | 2017-09-05 23:09:45 | [diff] [blame] | 37 | // Receives a callback to be run to close the active modal dialog, or an empty |
38 | // closure if the active dialog is dismissed. | ||||
Alexander Cooper | 4bcb0ce | 2020-07-16 23:10:38 | [diff] [blame] | 39 | void SetModalDialogNotificationHandler( |
40 | base::RepeatingClosure notification_handler); | ||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 41 | |
42 | // Returns the ProcessSingleton::NotificationCallback. | ||||
43 | // The callback is only valid during the lifetime of the | ||||
44 | // ProcessSingletonModalDialogLock instance. | ||||
45 | ProcessSingleton::NotificationCallback AsNotificationCallback(); | ||||
46 | |||||
47 | private: | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 48 | bool NotificationCallbackImpl(const base::CommandLine& command_line, |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 49 | const base::FilePath& current_directory); |
50 | |||||
Alexander Cooper | 4bcb0ce | 2020-07-16 23:10:38 | [diff] [blame] | 51 | base::RepeatingClosure notification_handler_; |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 52 | ProcessSingleton::NotificationCallback original_callback_; |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 53 | }; |
54 | |||||
55 | #endif // CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_ |