| 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..9d34a898790f92020bc0e63dd6016b2a0a1592f8 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 window_should_close = @selector(windowShouldClose:);
|
| + if ([delegate respondsToSelector:window_should_close]) {
|
| + if ([delegate windowShouldClose:window()])
|
| + [window() close];
|
| + } else if ([window() respondsToSelector:window_should_close]) {
|
| + if ([window() performSelector:window_should_close withObject:window()])
|
| + [window() close];
|
| + } else {
|
| + [window() close];
|
| + }
|
| }
|
| }
|
|
|
|
|