Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5843)

Unified Diff: chrome/browser/ui/browser.cc

Issue 17571018: Reland fast tab closure behind a flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Diff against original patch Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 22df809cdc2fd0730f4ccca2e2a721531ea31519..11048c86a33e17fd091c8c2f59a8589472c76d68 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -108,6 +108,7 @@
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/extensions/shell_window.h"
+#include "chrome/browser/ui/fast_unload_controller.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/find_bar/find_tab_helper.h"
@@ -233,6 +234,12 @@ BrowserWindow* CreateBrowserWindow(Browser* browser) {
return BrowserWindow::CreateBrowserWindow(browser);
}
+// Is the fast tab unload experiment enabled?
+bool FastTabUnloadEnabled() {
sky 2013/06/27 16:13:16 IsFastTabUnloadEnabled?
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableFastUnload);
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -332,7 +339,6 @@ Browser::Browser(const CreateParams& params)
initial_show_state_(params.initial_show_state),
is_session_restore_(params.is_session_restore),
host_desktop_type_(params.host_desktop_type),
- unload_controller_(new chrome::UnloadController(this)),
weak_factory_(this),
content_setting_bubble_model_delegate_(
new BrowserContentSettingBubbleModelDelegate(this)),
@@ -348,6 +354,12 @@ Browser::Browser(const CreateParams& params)
// from opening at all, but the path that triggered it should be fixed.
CHECK(IncognitoModePrefs::CanOpenBrowser(profile_));
+ // TODO(jeremy): Move to initializer list once flag is removed.
+ if (FastTabUnloadEnabled())
+ fast_unload_controller_.reset(new chrome::FastUnloadController(this));
+ else
+ unload_controller_.reset(new chrome::UnloadController(this));
+
if (!app_name_.empty())
chrome::RegisterAppPrefs(app_name_, profile_);
tab_strip_model_->AddObserver(this);
@@ -585,7 +597,15 @@ bool Browser::ShouldCloseWindow() {
if (!CanCloseWithInProgressDownloads())
return false;
- return unload_controller_->ShouldCloseWindow();
+ if (FastTabUnloadEnabled())
+ return fast_unload_controller_->ShouldCloseWindow();
+ else
sky 2013/06/27 16:13:16 nit: no else after a return.
+ return unload_controller_->ShouldCloseWindow();
+}
+
+bool Browser::HasCompletedUnloadProcessing() const {
+ DCHECK(FastTabUnloadEnabled());
+ return fast_unload_controller_->HasCompletedUnloadProcessing();
}
bool Browser::HasCompletedUnloadProcessing() const {
@@ -593,7 +613,10 @@ bool Browser::HasCompletedUnloadProcessing() const {
}
bool Browser::IsAttemptingToCloseBrowser() const {
- return unload_controller_->is_attempting_to_close_browser();
+ if (FastTabUnloadEnabled())
+ return fast_unload_controller_->is_attempting_to_close_browser();
+ else
sky 2013/06/27 16:13:16 same nit here.
+ return unload_controller_->is_attempting_to_close_browser();
}
void Browser::OnWindowClosing() {
@@ -636,7 +659,8 @@ void Browser::OnWindowClosing() {
content::Source<Browser>(this),
content::NotificationService::NoDetails());
- tab_strip_model_->CloseAllTabs();
+ if (!FastTabUnloadEnabled())
+ tab_strip_model_->CloseAllTabs();
}
////////////////////////////////////////////////////////////////////////////////
@@ -1174,7 +1198,10 @@ void Browser::HandleKeyboardEvent(content::WebContents* source,
}
bool Browser::TabsNeedBeforeUnloadFired() {
- return unload_controller_->TabsNeedBeforeUnloadFired();
+ if (FastTabUnloadEnabled())
+ return fast_unload_controller_->TabsNeedBeforeUnloadFired();
+ else
sky 2013/06/27 16:13:16 and here.
+ return unload_controller_->TabsNeedBeforeUnloadFired();
}
bool Browser::IsMouseLocked() const {
@@ -1310,7 +1337,13 @@ void Browser::LoadingStateChanged(WebContents* source) {
}
void Browser::CloseContents(WebContents* source) {
- if (unload_controller_->CanCloseContents(source))
+ bool can_close_contents;
+ if (FastTabUnloadEnabled())
+ can_close_contents = fast_unload_controller_->CanCloseContents(source);
+ else
+ can_close_contents = unload_controller_->CanCloseContents(source);
+
+ if (can_close_contents)
chrome::CloseWebContents(this, source, true);
}
@@ -1373,8 +1406,12 @@ gfx::Rect Browser::GetRootWindowResizerRect() const {
void Browser::BeforeUnloadFired(WebContents* web_contents,
bool proceed,
bool* proceed_to_fire_unload) {
- *proceed_to_fire_unload =
- unload_controller_->BeforeUnloadFired(web_contents, proceed);
+ if (FastTabUnloadEnabled())
sky 2013/06/27 16:13:16 nit: use {} for multi-line ones.
+ *proceed_to_fire_unload =
+ fast_unload_controller_->BeforeUnloadFired(web_contents, proceed);
+ else
+ *proceed_to_fire_unload =
+ unload_controller_->BeforeUnloadFired(web_contents, proceed);
}
bool Browser::ShouldFocusLocationBarByDefault(WebContents* source) {
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698