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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_controller.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 90bb3720fdddb1777435f91faee83e6ee207740f..7dcf8de0c9aaeeb1a0f5f7836d13b2d7524466bd 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -550,23 +550,26 @@ enum {
gfx::ScopedNSDisableScreenUpdates disabler;
// Give beforeunload handlers the chance to cancel the close before we hide
// the window below.
- if (!browser_->ShouldCloseWindow())
+ if (!browser_->ShouldCloseWindow()) {
+ if (browser_->tab_strip_model()->empty()) {
+ // saveWindowPositionIfNeeded: only works if we are the last active
+ // window, but orderOut: ends up activating another window, so we
+ // have to save the window position before we call orderOut:.
+ [self saveWindowPositionIfNeeded];
+
+ // The browser needs to finish running unload handlers.
+ // Hide the window (so it appears to have closed immediately), and
+ // the browser will call us back again when it is ready to close.
+ [[self window] orderOut:self];
+ }
return NO;
+ }
// saveWindowPositionIfNeeded: only works if we are the last active
// window, but orderOut: ends up activating another window, so we
// have to save the window position before we call orderOut:.
[self saveWindowPositionIfNeeded];
- if (!browser_->tab_strip_model()->empty()) {
- // Tab strip isn't empty. Hide the frame (so it appears to have closed
- // immediately) and close all the tabs, allowing the renderers to shut
- // down. When the tab strip is empty we'll be called back again.
- [[self window] orderOut:self];
- browser_->OnWindowClosing();
- return NO;
- }
-
// the tab strip is empty, it's ok to close the window
return YES;
}

Powered by Google App Engine
This is Rietveld 408576698