blob: ac1c566732243bdac0e33fbd25447906f118ecb2 [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.
34 void SetModalDialogNotificationHandler(base::Closure notification_handler);
[email protected]9a47c432013-04-19 20:33:5535
36 // Returns the ProcessSingleton::NotificationCallback.
37 // The callback is only valid during the lifetime of the
38 // ProcessSingletonModalDialogLock instance.
39 ProcessSingleton::NotificationCallback AsNotificationCallback();
40
41 private:
[email protected]2f3b1cc2014-03-17 23:07:1542 bool NotificationCallbackImpl(const base::CommandLine& command_line,
[email protected]9a47c432013-04-19 20:33:5543 const base::FilePath& current_directory);
44
Greg Thompsoneafda51e2017-09-05 23:09:4545 base::Closure notification_handler_;
[email protected]9a47c432013-04-19 20:33:5546 ProcessSingleton::NotificationCallback original_callback_;
[email protected]9a47c432013-04-19 20:33:5547
48 DISALLOW_COPY_AND_ASSIGN(ProcessSingletonModalDialogLock);
49};
50
51#endif // CHROME_BROWSER_PROCESS_SINGLETON_MODAL_DIALOG_LOCK_H_