[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 | |||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 30 | ~ProcessSingletonModalDialogLock(); |
31 | |||||
Greg Thompson | eafda51e | 2017-09-05 23:09:45 | [diff] [blame] | 32 | // Receives a callback to be run to close the active modal dialog, or an empty |
33 | // closure if the active dialog is dismissed. | ||||
Alexander Cooper | 4bcb0ce | 2020-07-16 23:10:38 | [diff] [blame] | 34 | void SetModalDialogNotificationHandler( |
35 | base::RepeatingClosure notification_handler); | ||||
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 36 | |
37 | // Returns the ProcessSingleton::NotificationCallback. | ||||
38 | // The callback is only valid during the lifetime of the | ||||
39 | // ProcessSingletonModalDialogLock instance. | ||||
40 | ProcessSingleton::NotificationCallback AsNotificationCallback(); | ||||
41 | |||||
42 | private: | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 43 | bool NotificationCallbackImpl(const base::CommandLine& command_line, |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 44 | const base::FilePath& current_directory); |
45 | |||||
Alexander Cooper | 4bcb0ce | 2020-07-16 23:10:38 | [diff] [blame] | 46 | base::RepeatingClosure notification_handler_; |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 47 | ProcessSingleton::NotificationCallback original_callback_; |
[email protected] | 9a47c43 | 2013-04-19 20:33:55 | [diff] [blame] | 48 | |
49 | DISALLOW_COPY_AND_ASSIGN(ProcessSingletonModalDialogLock); | ||||
50 | }; | ||||
51 | |||||
52 | #endif // CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_ |