OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "chrome/browser/chrome_application_mac.h" | 5 #import "chrome/browser/chrome_application_mac.h" |
6 | 6 |
7 @implementation CrApplication | 7 @implementation CrApplication |
8 | 8 |
9 // -terminate: is the entry point for orderly "quit" operations in Cocoa. | 9 // -terminate: is the entry point for orderly "quit" operations in Cocoa. |
10 // This includes the application menu's quit menu item and keyboard | 10 // This includes the application menu's quit menu item and keyboard |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return; | 51 return; |
52 | 52 |
53 [[NSNotificationCenter defaultCenter] | 53 [[NSNotificationCenter defaultCenter] |
54 postNotificationName:NSApplicationWillTerminateNotification | 54 postNotificationName:NSApplicationWillTerminateNotification |
55 object:self]; | 55 object:self]; |
56 | 56 |
57 // Return, don't exit. The application is responsible for exiting on its | 57 // Return, don't exit. The application is responsible for exiting on its |
58 // own. | 58 // own. |
59 } | 59 } |
60 | 60 |
| 61 - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender { |
| 62 // The Dock menu contains an automagic section where you can select |
| 63 // amongst open windows. If a window is closed via JavaScript while |
| 64 // the menu is up, the menu item for that window continues to exist. |
| 65 // When a window is selected this method is called with the |
| 66 // now-freed window as |aTarget|. Short-circuit the call if |
| 67 // |aTarget| is not a valid window. |
| 68 if (anAction == @selector(_selectWindow:)) { |
| 69 // Not using -[NSArray containsObject:] because |aTarget| may be a |
| 70 // freed object. |
| 71 BOOL found = NO; |
| 72 for (NSWindow* window in [self windows]) { |
| 73 if (window == aTarget) { |
| 74 found = YES; |
| 75 break; |
| 76 } |
| 77 } |
| 78 if (!found) { |
| 79 return NO; |
| 80 } |
| 81 } |
| 82 |
| 83 return [super sendAction:anAction to:aTarget from:sender]; |
| 84 } |
| 85 |
61 @end | 86 @end |
OLD | NEW |