Index: chrome/browser/chrome_browser_application_mac.mm |
diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm |
index 282ecc3ddb2dcfa8e0c7a248098fa05c41149d0b..f203f07ef9aef5290b4ec926bfece8896257b344 100644 |
--- a/chrome/browser/chrome_browser_application_mac.mm |
+++ b/chrome/browser/chrome_browser_application_mac.mm |
@@ -221,6 +221,24 @@ void SwizzleInit() { |
return self; |
} |
+// Initialize NSApplication using the custom subclass. Check whether NSApp |
+// was already initialized using another class, because that would break |
+// some things. |
++ (NSApplication*)sharedApplication { |
+ NSApplication* app = [super sharedApplication]; |
+ if (![NSApp isKindOfClass:self]) { |
+ LOG(ERROR) << "NSApp should be of type " << [[self className] UTF8String] |
Robert Sesek
2011/12/02 17:10:17
LOG(FATAL)?
Scott Hess - ex-Googler
2011/12/02 19:15:25
My goal was crash-if-debug, but warn-if-release.
|
+ << ", not " << [[NSApp className] UTF8String]; |
+ DCHECK(false) << "NSApp is of wrong type"; |
+ } |
+ if (!base::MessagePumpMac::UsingCrApp()) { |
+ LOG(ERROR) << "MessagePumpMac::Create() was called before " |
+ << [[self className] UTF8String] << " was initialized."; |
+ DCHECK(false) << "MessagePumpMac is using the wrong pump implementation."; |
+ } |
+ return app; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// HISTORICAL COMMENT (by viettrungluu, from |
// http://codereview.chromium.org/1520006 with mild editing): |
@@ -368,6 +386,14 @@ void SwizzleInit() { |
[eventHooks_ removeObject:handler]; |
} |
+- (BOOL)isHandlingSendEvent { |
+ return handlingSendEvent_; |
+} |
+ |
+- (void)setHandlingSendEvent:(BOOL)handlingSendEvent { |
+ handlingSendEvent_ = handlingSendEvent; |
+} |
+ |
- (void)sendEvent:(NSEvent*)event { |
base::mac::ScopedSendingEvent sendingEventScoper; |
for (id<CrApplicationEventHookProtocol> handler in eventHooks_.get()) { |
@@ -396,7 +422,7 @@ void SwizzleInit() { |
// sidestep scopers is setjmp/longjmp (see above). The following |
// is to "fix" this while the more fundamental concern is |
// addressed elsewhere. |
- [self clearIsHandlingSendEvent]; |
+ [self setHandlingSendEvent:NO]; |
// If |ScopedNSExceptionEnabler| is used to allow exceptions, and an |
// uncaught exception is thrown, it will throw past all of the scopers. |