[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / lifetime / browser_close_manager.h
blob0e2c4a7f6cf315bdd1cb297860e7b4d856cbeaae
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"
11 class Browser;
13 // Manages confirming that browser windows are closeable and closing them at
14 // shutdown.
15 class BrowserCloseManager : public base::RefCounted<BrowserCloseManager> {
16 public:
17 BrowserCloseManager();
19 // Starts closing all browser windows.
20 void StartClosingBrowsers();
22 protected:
23 friend class base::RefCounted<BrowserCloseManager>;
25 virtual ~BrowserCloseManager();
27 virtual void ConfirmCloseWithPendingDownloads(
28 int download_count,
29 const base::Callback<void(bool)>& callback);
31 private:
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
36 // they are.
37 void TryToCloseBrowsers();
39 // Called to report whether a beforeunload dialog was accepted.
40 void OnBrowserReportCloseable(bool proceed);
42 // Closes all browser windows.
43 void CloseBrowsers();
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
50 // downloads.
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_