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

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

Issue 11016023: Quickly close tabs/window with long-running unload handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep original TabsNeedBeforeUnloadFired implementation. Created 8 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 } 1440 }
1441 1441
1442 bool BrowserWindowGtk::CanClose() const { 1442 bool BrowserWindowGtk::CanClose() const {
1443 // You cannot close a frame for which there is an active originating drag 1443 // You cannot close a frame for which there is an active originating drag
1444 // session. 1444 // session.
1445 if (tabstrip_->IsDragSessionActive()) 1445 if (tabstrip_->IsDragSessionActive())
1446 return false; 1446 return false;
1447 1447
1448 // Give beforeunload handlers the chance to cancel the close before we hide 1448 // Give beforeunload handlers the chance to cancel the close before we hide
1449 // the window below. 1449 // the window below.
1450 if (!browser_->ShouldCloseWindow()) 1450 if (!browser_->ShouldCloseWindow()) {
1451 return false; 1451 if (browser_->tab_strip_model()->empty()) {
1452 1452 // The browser needs to finish running unload handlers.
1453 if (!browser_->tab_strip_model()->empty()) { 1453 // Hide the window (so it appears to have closed immediately), and
1454 // Tab strip isn't empty. Hide the window (so it appears to have closed 1454 // the browser will call us back again when it is ready to close.
1455 // immediately) and close all the tabs, allowing the renderers to shut 1455 gtk_widget_hide(GTK_WIDGET(window_));
1456 // down. When the tab strip is empty we'll be called back again. 1456 }
1457 gtk_widget_hide(GTK_WIDGET(window_));
1458 browser_->OnWindowClosing();
1459 return false; 1457 return false;
1460 } 1458 }
1461 1459
1462 // Empty TabStripModel, it's now safe to allow the Window to be closed. 1460 // Empty TabStripModel, it's now safe to allow the Window to be closed.
1463 content::NotificationService::current()->Notify( 1461 content::NotificationService::current()->Notify(
1464 chrome::NOTIFICATION_WINDOW_CLOSED, 1462 chrome::NOTIFICATION_WINDOW_CLOSED,
1465 content::Source<GtkWindow>(window_), 1463 content::Source<GtkWindow>(window_),
1466 content::NotificationService::NoDetails()); 1464 content::NotificationService::NoDetails());
1467 return true; 1465 return true;
1468 } 1466 }
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 wm_type == ui::WM_OPENBOX || 2421 wm_type == ui::WM_OPENBOX ||
2424 wm_type == ui::WM_XFWM4); 2422 wm_type == ui::WM_XFWM4);
2425 } 2423 }
2426 2424
2427 // static 2425 // static
2428 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2426 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2429 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2427 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2430 browser_window_gtk->Init(); 2428 browser_window_gtk->Init();
2431 return browser_window_gtk; 2429 return browser_window_gtk;
2432 } 2430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698