Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. Note that this implementation assumes that NSWindow does not | |
| 178 // implement |-windowShouldClose:|. | |
|
Mark Mentovai
2012/10/10 18:43:09
It wouldn’t be difficult to send the message to th
Robert Sesek
2012/10/11 14:13:37
Done. There's a new test for you to review, too.
| |
| 179 id<NSWindowDelegate> delegate = [window() delegate]; | |
| 180 if (![delegate respondsToSelector:@selector(windowShouldClose:)] || | |
|
Mark Mentovai
2012/10/10 18:43:09
What is this weird bracket syntax?
Robert Sesek
2012/10/11 14:13:37
http://bukk.it/noidea-golf.gif
| |
| 181 [delegate windowShouldClose:window()]) { | |
| 182 [window() close]; | |
| 183 } | |
| 174 } | 184 } |
| 175 } | 185 } |
| 176 | 186 |
| 177 void BrowserWindowCocoa::Activate() { | 187 void BrowserWindowCocoa::Activate() { |
| 178 [controller_ activate]; | 188 [controller_ activate]; |
| 179 } | 189 } |
| 180 | 190 |
| 181 void BrowserWindowCocoa::Deactivate() { | 191 void BrowserWindowCocoa::Deactivate() { |
| 182 // TODO(jcivelli): http://crbug.com/51364 Implement me. | 192 // TODO(jcivelli): http://crbug.com/51364 Implement me. |
| 183 NOTIMPLEMENTED(); | 193 NOTIMPLEMENTED(); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 AvatarMenuBubbleController* menu = | 665 AvatarMenuBubbleController* menu = |
| 656 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ | 666 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ |
| 657 anchoredAt:point]; | 667 anchoredAt:point]; |
| 658 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; | 668 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; |
| 659 [menu showWindow:nil]; | 669 [menu showWindow:nil]; |
| 660 } | 670 } |
| 661 | 671 |
| 662 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { | 672 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { |
| 663 [[controller_ avatarButtonController] showAvatarBubble]; | 673 [[controller_ avatarButtonController] showAvatarBubble]; |
| 664 } | 674 } |
| OLD | NEW |