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

Side by Side Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 17571018: Reland fast tab closure behind a flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased, 2nd attempt to land. Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 // You cannot close a frame for which there is an active originating drag 1436 // You cannot close a frame for which there is an active originating drag
1437 // session. 1437 // session.
1438 if (tabstrip_->IsDragSessionActive()) 1438 if (tabstrip_->IsDragSessionActive())
1439 return false; 1439 return false;
1440 1440
1441 // Give beforeunload handlers the chance to cancel the close before we hide 1441 // Give beforeunload handlers the chance to cancel the close before we hide
1442 // the window below. 1442 // the window below.
1443 if (!browser_->ShouldCloseWindow()) 1443 if (!browser_->ShouldCloseWindow())
1444 return false; 1444 return false;
1445 1445
1446 bool fast_tab_closing_enabled =
1447 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableFastUnload);
1448
1446 if (!browser_->tab_strip_model()->empty()) { 1449 if (!browser_->tab_strip_model()->empty()) {
1447 // Tab strip isn't empty. Hide the window (so it appears to have closed 1450 // Tab strip isn't empty. Hide the window (so it appears to have closed
1448 // immediately) and close all the tabs, allowing the renderers to shut 1451 // immediately) and close all the tabs, allowing the renderers to shut
1449 // down. When the tab strip is empty we'll be called back again. 1452 // down. When the tab strip is empty we'll be called back again.
1450 gtk_widget_hide(GTK_WIDGET(window_)); 1453 gtk_widget_hide(GTK_WIDGET(window_));
1451 browser_->OnWindowClosing(); 1454 browser_->OnWindowClosing();
1455
1456 if (fast_tab_closing_enabled)
1457 browser_->tab_strip_model()->CloseAllTabs();
1458 return false;
1459 } else if (fast_tab_closing_enabled &&
1460 !browser_->HasCompletedUnloadProcessing()) {
1461 // The browser needs to finish running unload handlers.
1462 // Hide the window (so it appears to have closed immediately), and
1463 // the browser will call us back again when it is ready to close.
1464 gtk_widget_hide(GTK_WIDGET(window_));
1452 return false; 1465 return false;
1453 } 1466 }
1454 1467
1455 // Empty TabStripModel, it's now safe to allow the Window to be closed. 1468 // Empty TabStripModel, it's now safe to allow the Window to be closed.
1456 content::NotificationService::current()->Notify( 1469 content::NotificationService::current()->Notify(
1457 chrome::NOTIFICATION_WINDOW_CLOSED, 1470 chrome::NOTIFICATION_WINDOW_CLOSED,
1458 content::Source<GtkWindow>(window_), 1471 content::Source<GtkWindow>(window_),
1459 content::NotificationService::NoDetails()); 1472 content::NotificationService::NoDetails());
1460 return true; 1473 return true;
1461 } 1474 }
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 wm_type == ui::WM_OPENBOX || 2417 wm_type == ui::WM_OPENBOX ||
2405 wm_type == ui::WM_XFWM4); 2418 wm_type == ui::WM_XFWM4);
2406 } 2419 }
2407 2420
2408 // static 2421 // static
2409 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2422 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2410 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2423 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2411 browser_window_gtk->Init(); 2424 browser_window_gtk->Init();
2412 return browser_window_gtk; 2425 return browser_window_gtk;
2413 } 2426 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698