Chromium Code Reviews| Index: chrome/browser/ui/unload_detached_handler.h |
| diff --git a/chrome/browser/ui/unload_detached_handler.h b/chrome/browser/ui/unload_detached_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..91cd9150dcd9b597a7cd5bc533d38f6930c96d25 |
| --- /dev/null |
| +++ b/chrome/browser/ui/unload_detached_handler.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright (c) 2012 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_UI_UNLOAD_DETACHED_HANDLER_H_ |
| +#define CHROME_BROWSER_UI_UNLOAD_DETACHED_HANDLER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_vector.h" |
| + |
| +class TabStripModel; |
| + |
| +namespace content { |
| +class WebContents; |
| +} |
| + |
| +namespace chrome { |
| + |
| +class UnloadController; |
| + |
| +typedef base::Callback<void(void)> TabsClosedCallback; |
| + |
| +// UnloadDetachedHandler is used to close tabs quickly, http://crbug.com/142458. |
| +// - Allows unload handlers to run in the background. |
| +// - Comes into play after the beforeunload handlers (if any) have run. |
| +// - Does not close the tabs; it holds tabs while they are closed. |
| +// |
| +// TODO(slamm): Support closes that destroy the browser: last tab close, window. |
| +// http://crbug.com/156896 |
| +// TODO(slamm): Hide unload time from the user for cross-process navigations. |
| +// http://crbug.com/156958 |
| +class UnloadDetachedHandler { |
| + public: |
| + explicit UnloadDetachedHandler(const TabsClosedCallback& callback); |
| + ~UnloadDetachedHandler(); |
| + |
| + // Returns true if is succeeds. |
| + bool DetachWebContents(TabStripModel* tab_strip_model, |
| + content::WebContents* web_contents); |
| + bool HasTabs(); |
|
Ben Goodger (Google)
2012/10/29 22:12:43
this kind of method can be const.
slamm
2012/10/31 18:03:59
Done.
|
| + |
| + private: |
| + class WebContentsDelegateImpl; |
| + |
| + // Clean-up when the tab finishes closing. |
| + void Destroy(WebContentsDelegateImpl* delegate); |
| + |
| + const TabsClosedCallback tabs_closed_callback_; |
| + |
| + ScopedVector<WebContentsDelegateImpl> delegates_; |
| + |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(UnloadDetachedHandler); |
| +}; |
| + |
| +} // namespace chrome |
| + |
| +#endif // CHROME_BROWSER_UI_UNLOAD_DETACHED_HANDLER_H_ |