| Index: chrome/browser/ui/unload_controller.h
|
| diff --git a/chrome/browser/ui/unload_controller.h b/chrome/browser/ui/unload_controller.h
|
| index fb51668b0554bd67d563d351b8c5db5ee7081f75..048005360461aa5205ac9a4dab1941ba8eeb0042 100644
|
| --- a/chrome/browser/ui/unload_controller.h
|
| +++ b/chrome/browser/ui/unload_controller.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include <set>
|
|
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
|
| #include "content/public/browser/notification_observer.h"
|
| @@ -23,7 +24,35 @@ class WebContents;
|
| }
|
|
|
| namespace chrome {
|
| -
|
| +class UnloadDetachedHandler;
|
| +
|
| +// UnloadController manages closing tabs and windows -- especially in
|
| +// regards to beforeunload handlers (proceed/cancel dialogs) and
|
| +// unload handlers (no user interaction).
|
| +//
|
| +// Typical flow of closing a tab:
|
| +// 1. Browser calls |CanCloseContents()|.
|
| +// If true, browser calls contents::CloseWebContents().
|
| +// 2. WebContents notifies us via its delegate and BeforeUnloadFired()
|
| +// that the beforeunload handler was run. If the user allowed the
|
| +// close to continue, we hand-off running the unload handler to
|
| +// UnloadDetachedHandler which decides if the tab can be unloaded
|
| +// in the background. If it can, the tab is removed from the tab
|
| +// strip at this point.
|
| +//
|
| +// Typical flow of closing a window:
|
| +// 1. Browser calls |ShouldCloseWindow()|.
|
| +// If beforeunload/unload handlers need to run, |UnloadController| returns
|
| +// false and calls |ProcessPendingTabs()| (private method).
|
| +// 2. For each tab with a beforeunload/unload handler, |ProcessPendingTabs()|
|
| +// calls |web_contents->OnCloseStarted()|
|
| +// and |web_contents->GetRenderViewHost()->FirePageBeforeUnload()|.
|
| +// 3. |UnloadController| waits for any tabs from the "closing a tab" flow above
|
| +// to finish detached unloads.
|
| +// 4. For each tab with a beforeunload/unload handler, |ProcessPendingTabs()|
|
| +// calls |web_contents->GetRenderViewHost()->ClosePage()|.
|
| +// 5. |ProcessPendingTabs()| calls |browser_->OnWindowClosing()|.
|
| +//
|
| class UnloadController : public content::NotificationObserver,
|
| public TabStripModelObserver {
|
| public:
|
| @@ -114,11 +143,11 @@ class UnloadController : public content::NotificationObserver,
|
|
|
| content::NotificationRegistrar registrar_;
|
|
|
| - // Tracks tabs that need there beforeunload event fired before we can
|
| + // Tracks tabs that need their beforeunload event fired before we can
|
| // close the browser. Only gets populated when we try to close the browser.
|
| UnloadListenerSet tabs_needing_before_unload_fired_;
|
|
|
| - // Tracks tabs that need there unload event fired before we can
|
| + // Tracks tabs that need their unload event fired before we can
|
| // close the browser. Only gets populated when we try to close the browser.
|
| UnloadListenerSet tabs_needing_unload_fired_;
|
|
|
| @@ -128,6 +157,9 @@ class UnloadController : public content::NotificationObserver,
|
| // Browser window isn't just immediately closed.
|
| bool is_attempting_to_close_browser_;
|
|
|
| + // Allow unload handlers to run without holding up the UI.
|
| + scoped_ptr<UnloadDetachedHandler> unload_detached_handler_;
|
| +
|
| base::WeakPtrFactory<UnloadController> weak_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(UnloadController);
|
|
|