| 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 #import "base/scoped_nsobject.h" |
| 8 #import "chrome/app/breakpad_mac.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 // Helper to make it easy to get crash keys right. |
| 13 // TODO(shess): Find a better home for this. app/breakpad_mac.h |
| 14 // doesn't work. |
| 15 class ScopedCrashKey { |
| 16 public: |
| 17 ScopedCrashKey(NSString* key, NSString* value) |
| 18 : crash_key_([key retain]) { |
| 19 SetCrashKeyValue(crash_key_.get(), value); |
| 20 } |
| 21 ~ScopedCrashKey() { |
| 22 ClearCrashKeyValue(crash_key_.get()); |
| 23 } |
| 24 |
| 25 private: |
| 26 scoped_nsobject<NSString> crash_key_; |
| 27 }; |
| 28 |
| 29 } // namespace |
| 30 |
| 7 @implementation CrApplication | 31 @implementation CrApplication |
| 8 | 32 |
| 9 // -terminate: is the entry point for orderly "quit" operations in Cocoa. | 33 // -terminate: is the entry point for orderly "quit" operations in Cocoa. |
| 10 // This includes the application menu's quit menu item and keyboard | 34 // This includes the application menu's quit menu item and keyboard |
| 11 // equivalent, the application's dock icon menu's quit menu item, "quit" (not | 35 // equivalent, the application's dock icon menu's quit menu item, "quit" (not |
| 12 // "force quit") in the Activity Monitor, and quits triggered by user logout | 36 // "force quit") in the Activity Monitor, and quits triggered by user logout |
| 13 // and system restart and shutdown. | 37 // and system restart and shutdown. |
| 14 // | 38 // |
| 15 // The default NSApplication -terminate: implementation will end the process | 39 // The default NSApplication -terminate: implementation will end the process |
| 16 // by calling exit(), and thus never leave the main run loop. This is | 40 // by calling exit(), and thus never leave the main run loop. This is |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (window == aTarget) { | 97 if (window == aTarget) { |
| 74 found = YES; | 98 found = YES; |
| 75 break; | 99 break; |
| 76 } | 100 } |
| 77 } | 101 } |
| 78 if (!found) { | 102 if (!found) { |
| 79 return NO; | 103 return NO; |
| 80 } | 104 } |
| 81 } | 105 } |
| 82 | 106 |
| 107 // When a Cocoa control is wired to a freed object, we get crashers |
| 108 // in the call to |super| with no useful information in the |
| 109 // backtrace. Attempt to add some useful information. |
| 110 static const NSString* kActionKey = @"sendaction"; |
| 111 |
| 112 // If the action is something generic like -commandDispatch:, then |
| 113 // the tag is essential. |
| 114 NSInteger tag = 0; |
| 115 if ([sender isKindOfClass:[NSControl class]]) { |
| 116 tag = [sender tag]; |
| 117 if (tag == 0 || tag == -1) { |
| 118 tag = [sender selectedTag]; |
| 119 } |
| 120 } else if ([sender isKindOfClass:[NSMenuItem class]]) { |
| 121 tag = [sender tag]; |
| 122 } |
| 123 |
| 124 NSString* actionString = NSStringFromSelector(anAction); |
| 125 NSString* value = |
| 126 [NSString stringWithFormat:@"%@ tag %d sending %@ to %p", |
| 127 [sender className], tag, actionString, aTarget]; |
| 128 |
| 129 ScopedCrashKey key(kActionKey, value); |
| 83 return [super sendAction:anAction to:aTarget from:sender]; | 130 return [super sendAction:anAction to:aTarget from:sender]; |
| 84 } | 131 } |
| 85 | 132 |
| 86 @end | 133 @end |
| 87 | 134 |
| 88 namespace CrApplicationCC { | 135 namespace CrApplicationCC { |
| 89 | 136 |
| 90 void Terminate() { | 137 void Terminate() { |
| 91 [NSApp terminate:nil]; | 138 [NSApp terminate:nil]; |
| 92 } | 139 } |
| 93 | 140 |
| 94 } // namespace CrApplicationCC | 141 } // namespace CrApplicationCC |
| OLD | NEW |