blob: 318e2a38a7b64c60a1149af383e4a5c561981064 [file] [log] [blame]
[email protected]9a47c432013-04-19 20:33:551// 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 Thompsoneafda51e2017-09-05 23:09:458#include "base/callback.h"
avib896c712015-12-26 02:10:439#include "base/macros.h"
[email protected]9a47c432013-04-19 20:33:5510#include "chrome/browser/process_singleton.h"
[email protected]9a47c432013-04-19 20:33:5511
[email protected]9a47c432013-04-19 20:33:5512namespace base {
[email protected]2f3b1cc2014-03-17 23:07:1513class CommandLine;
[email protected]9a47c432013-04-19 20:33:5514class FilePath;
15}
16
Greg Thompsoneafda51e2017-09-05 23:09:4517// 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]9a47c432013-04-19 20:33:5521//
Greg Thompsoneafda51e2017-09-05 23:09:4522// 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]9a47c432013-04-19 20:33:5525class ProcessSingletonModalDialogLock {
26 public:
[email protected]9a47c432013-04-19 20:33:5527 explicit ProcessSingletonModalDialogLock(
28 const ProcessSingleton::NotificationCallback& original_callback);
29
[email protected]9a47c432013-04-19 20:33:5530 ~ProcessSingletonModalDialogLock();
31
Greg Thompsoneafda51e2017-09-05 23:09:4532 // Receives a callback to be run to close the active modal dialog, or an empty
33 // closure if the active dialog is dismissed.
Alexander Cooper4bcb0ce2020-07-16 23:10:3834 void SetModalDialogNotificationHandler(
35 base::RepeatingClosure notification_handler);
[email protected]9a47c432013-04-19 20:33:5536
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]2f3b1cc2014-03-17 23:07:1543 bool NotificationCallbackImpl(const base::CommandLine& command_line,
[email protected]9a47c432013-04-19 20:33:5544 const base::FilePath& current_directory);
45
Alexander Cooper4bcb0ce2020-07-16 23:10:3846 base::RepeatingClosure notification_handler_;
[email protected]9a47c432013-04-19 20:33:5547 ProcessSingleton::NotificationCallback original_callback_;
[email protected]9a47c432013-04-19 20:33:5548
49 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonModalDialogLock);
50};
51
52#endif // CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_