1 // Copyright 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_LIFETIME_BROWSER_CLOSE_MANAGER_H_
6 #define CHROME_BROWSER_LIFETIME_BROWSER_CLOSE_MANAGER_H_
8 #include "base/callback_forward.h"
9 #include "base/memory/ref_counted.h"
13 // Manages confirming that browser windows are closeable and closing them at
15 class BrowserCloseManager
: public base::RefCounted
<BrowserCloseManager
> {
17 BrowserCloseManager();
19 // Starts closing all browser windows.
20 void StartClosingBrowsers();
23 friend class base::RefCounted
<BrowserCloseManager
>;
25 virtual ~BrowserCloseManager();
27 virtual void ConfirmCloseWithPendingDownloads(
29 const base::Callback
<void(bool)>& callback
);
32 // Notifies all browser windows that the close is cancelled.
33 void CancelBrowserClose();
35 // Checks whether all browser windows are ready to close and closes them if
37 void TryToCloseBrowsers();
39 // Called to report whether a beforeunload dialog was accepted.
40 void OnBrowserReportCloseable(bool proceed
);
42 // Closes all browser windows.
45 // Checks whether there are any downloads in-progress and prompts the user to
46 // cancel them. If there are no downloads or the user accepts the cancel
47 // downloads dialog, CloseBrowsers is called to continue with the shutdown.
48 // Otherwise, if the user declines to cancel downloads, the shutdown is
49 // aborted and the downloads page is shown for each profile with in-progress
51 void CheckForDownloadsInProgress();
53 // Called to report whether downloads may be cancelled during shutdown.
54 void OnReportDownloadsCancellable(bool proceed
);
56 // The browser for which we are waiting for a callback to
57 // OnBrowserReportCloseable.
58 Browser
* current_browser_
;
60 DISALLOW_COPY_AND_ASSIGN(BrowserCloseManager
);
63 #endif // CHROME_BROWSER_LIFETIME_BROWSER_CLOSE_MANAGER_H_