diff options
author | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 05:45:56 +0000 |
---|---|---|
committer | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 05:45:56 +0000 |
commit | 2e9d79f5f464c68f5f5d957fa32ffc2c72ef3881 (patch) | |
tree | 31c76e43c68306b0035cd1d13433b322b12f458d /chrome/browser/lifetime/browser_close_manager.h | |
parent | 1e7ed9716c2c13cd2d74a62879370d0d8cd6dc84 (diff) | |
download | chromium_src-2e9d79f5f464c68f5f5d957fa32ffc2c72ef3881.zip chromium_src-2e9d79f5f464c68f5f5d957fa32ffc2c72ef3881.tar.gz chromium_src-2e9d79f5f464c68f5f5d957fa32ffc2c72ef3881.tar.bz2 |
Don't close tabs at shutdown until all beforeunload handlers have run.
Previously, when Chrome shuts down, each window independently runs its
beforeunload handlers and aborts closing if the user decides to stay on
the current page; there is no communication between windows and only
windows containing tabs that the user chose to keep open remain open.
The session manager is disabled when the shutdown begins so any tabs
opened after shutdown is aborted won't be noticed by the session
manager.
With this change, all beforeunload handlers across all windows are run
before any windows start closing, so the browser will return to its
pre-shutdown state if a shutdown is aborted due to a beforeunload
dialog.
BUG=265764
Review URL: https://chromiumcodereview.appspot.com/21143003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/lifetime/browser_close_manager.h')
-rw-r--r-- | chrome/browser/lifetime/browser_close_manager.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/lifetime/browser_close_manager.h b/chrome/browser/lifetime/browser_close_manager.h new file mode 100644 index 0000000..74436d9 --- /dev/null +++ b/chrome/browser/lifetime/browser_close_manager.h @@ -0,0 +1,46 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_LIFETIME_BROWSER_CLOSE_MANAGER_H_ +#define CHROME_BROWSER_LIFETIME_BROWSER_CLOSE_MANAGER_H_ + +#include "base/memory/ref_counted.h" + +class Browser; + +// Manages confirming that browser windows are closeable and closing them at +// shutdown. +class BrowserCloseManager : public base::RefCounted<BrowserCloseManager> { + public: + BrowserCloseManager(); + + // Starts closing all browser windows. + void StartClosingBrowsers(); + + private: + friend class base::RefCounted<BrowserCloseManager>; + + virtual ~BrowserCloseManager(); + + // Notifies all browser windows that the close is cancelled. + void CancelBrowserClose(); + + // Checks whether all browser windows are ready to close and closes them if + // they are. + void TryToCloseBrowsers(); + + // Called to report whether a beforeunload dialog was accepted. + void OnBrowserReportCloseable(bool proceed); + + // Closes all browser windows. + void CloseBrowsers(); + + // The browser for which we are waiting for a callback to + // OnBrowserReportCloseable. + Browser* current_browser_; + + DISALLOW_COPY_AND_ASSIGN(BrowserCloseManager); +}; + +#endif // CHROME_BROWSER_LIFETIME_BROWSER_CLOSE_MANAGER_H_ |