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.
5 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_
6 #define CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "chrome/browser/process_singleton.h"
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.
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.
25 class ProcessSingletonModalDialogLock {
27 explicit ProcessSingletonModalDialogLock(
28 const ProcessSingleton::NotificationCallback& original_callback);
30 ~ProcessSingletonModalDialogLock();
32 // Receives a callback to be run to close the active modal dialog, or an empty
33 // closure if the active dialog is dismissed.
34 void SetModalDialogNotificationHandler(base::Closure notification_handler);
36 // Returns the ProcessSingleton::NotificationCallback.
37 // The callback is only valid during the lifetime of the
38 // ProcessSingletonModalDialogLock instance.
39 ProcessSingleton::NotificationCallback AsNotificationCallback();
42 bool NotificationCallbackImpl(const base::CommandLine& command_line,
43 const base::FilePath& current_directory);
45 base::Closure notification_handler_;
46 ProcessSingleton::NotificationCallback original_callback_;
48 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonModalDialogLock);
51 #endif // CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_