blob: 854e4d3adb6b068761478ceefac32d7408dcfd51 [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
Peter Boström53c6c5952021-09-17 09:41:2630 ProcessSingletonModalDialogLock(const ProcessSingletonModalDialogLock&) =
31 delete;
32 ProcessSingletonModalDialogLock& operator=(
33 const ProcessSingletonModalDialogLock&) = delete;
34
[email protected]9a47c432013-04-19 20:33:5535 ~ProcessSingletonModalDialogLock();
36
Greg Thompsoneafda51e2017-09-05 23:09:4537 // Receives a callback to be run to close the active modal dialog, or an empty
38 // closure if the active dialog is dismissed.
Alexander Cooper4bcb0ce2020-07-16 23:10:3839 void SetModalDialogNotificationHandler(
40 base::RepeatingClosure notification_handler);
[email protected]9a47c432013-04-19 20:33:5541
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]2f3b1cc2014-03-17 23:07:1548 bool NotificationCallbackImpl(const base::CommandLine& command_line,
[email protected]9a47c432013-04-19 20:33:5549 const base::FilePath& current_directory);
50
Alexander Cooper4bcb0ce2020-07-16 23:10:3851 base::RepeatingClosure notification_handler_;
[email protected]9a47c432013-04-19 20:33:5552 ProcessSingleton::NotificationCallback original_callback_;
[email protected]9a47c432013-04-19 20:33:5553};
54
55#endif // CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_