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]; |
+ } |
} |
} |