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

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

Issue 11090029: [Mac] In BrowserWindowCocoa::Close() do not use -[NSWindow performClose:]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ask the window, too Created 8 years, 2 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
Index: chrome/browser/ui/cocoa/browser_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 31116d4f1b1a3370dfabfe9c0bca767f58a50207..91d9c00c04011a9d300eaa10c7deb54878e43a1d 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -170,7 +170,22 @@ void BrowserWindowCocoa::Close() {
if ([controller_ overlayWindow]) {
[controller_ deferPerformClose];
} else {
- [window() performClose:controller_];
+ // Using |-performClose:| can prevent the window from actually closing if
+ // a JavaScript beforeunload handler opens an alert during shutdown, as
+ // documented at <http://crbug.com/118424>. Re-implement
+ // -[NSWindow performClose:] as closely as possible to how Apple documents
+ // it.
+ id<NSWindowDelegate> delegate = [window() delegate];
+ SEL windowShouldClose = @selector(windowShouldClose:);
Mark Mentovai 2012/10/11 15:44:57 window_should_close
Robert Sesek 2012/10/11 15:58:39 Done.
+ if ([delegate respondsToSelector:windowShouldClose]) {
+ if ([delegate windowShouldClose:window()])
+ [window() close];
+ } else if ([window() respondsToSelector:windowShouldClose]) {
+ if ([window() performSelector:windowShouldClose withObject:window()])
Mark Mentovai 2012/10/11 15:44:57 Why not just [window windowShouldClose:window()]?
Robert Sesek 2012/10/11 15:58:39 NSWindow does implement windowShouldClose: and it'
Mark Mentovai 2012/10/11 16:04:03 Oh yeah, duh, your comment even said that.
+ [window() close];
+ } else {
+ [window() close];
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698