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

Side by Side 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: '' 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 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/cocoa/browser_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // Callers assume that this doesn't immediately delete the Browser object. 163 // Callers assume that this doesn't immediately delete the Browser object.
164 // The controller implementing the window delegate methods called from 164 // The controller implementing the window delegate methods called from
165 // |-performClose:| must take precautions to ensure that. 165 // |-performClose:| must take precautions to ensure that.
166 void BrowserWindowCocoa::Close() { 166 void BrowserWindowCocoa::Close() {
167 // If there is an overlay window, we contain a tab being dragged between 167 // If there is an overlay window, we contain a tab being dragged between
168 // windows. Don't hide the window as it makes the UI extra confused. We can 168 // windows. Don't hide the window as it makes the UI extra confused. We can
169 // still close the window, as that will happen when the drag completes. 169 // still close the window, as that will happen when the drag completes.
170 if ([controller_ overlayWindow]) { 170 if ([controller_ overlayWindow]) {
171 [controller_ deferPerformClose]; 171 [controller_ deferPerformClose];
172 } else { 172 } else {
173 [window() performClose:controller_]; 173 // Using |-performClose:| can prevent the window from actually closing if
174 // a JavaScript beforeunload handler opens an alert during shutdown, as
175 // documented at <http://crbug.com/118424>. Re-implement
176 // -[NSWindow performClose:] as closely as possible to how Apple documents
177 // it.
178 id<NSWindowDelegate> delegate = [window() delegate];
179 SEL window_should_close = @selector(windowShouldClose:);
180 if ([delegate respondsToSelector:window_should_close]) {
181 if ([delegate windowShouldClose:window()])
182 [window() close];
183 } else if ([window() respondsToSelector:window_should_close]) {
184 if ([window() performSelector:window_should_close withObject:window()])
185 [window() close];
186 } else {
187 [window() close];
188 }
174 } 189 }
175 } 190 }
176 191
177 void BrowserWindowCocoa::Activate() { 192 void BrowserWindowCocoa::Activate() {
178 [controller_ activate]; 193 [controller_ activate];
179 } 194 }
180 195
181 void BrowserWindowCocoa::Deactivate() { 196 void BrowserWindowCocoa::Deactivate() {
182 // TODO(jcivelli): http://crbug.com/51364 Implement me. 197 // TODO(jcivelli): http://crbug.com/51364 Implement me.
183 NOTIMPLEMENTED(); 198 NOTIMPLEMENTED();
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 AvatarMenuBubbleController* menu = 670 AvatarMenuBubbleController* menu =
656 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 671 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
657 anchoredAt:point]; 672 anchoredAt:point];
658 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; 673 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge];
659 [menu showWindow:nil]; 674 [menu showWindow:nil];
660 } 675 }
661 676
662 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { 677 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() {
663 [[controller_ avatarButtonController] showAvatarBubble]; 678 [[controller_ avatarButtonController] showAvatarBubble];
664 } 679 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698