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 745e0ab4dbb9396913f4db9a7f0da5232da12271..2d9b65b99f10274992da21b9ca998af2faf2ad65 100644 |
--- a/chrome/browser/chrome_browser_application_mac.mm |
+++ b/chrome/browser/chrome_browser_application_mac.mm |
@@ -5,6 +5,7 @@ |
#import "chrome/browser/chrome_browser_application_mac.h" |
#import "base/logging.h" |
+#import "base/mac/scoped_nsexception_enabler.h" |
#import "base/metrics/histogram.h" |
#import "base/memory/scoped_nsobject.h" |
#import "base/sys_string_conversions.h" |
@@ -93,7 +94,8 @@ static IMP gOriginalInitIMP = NULL; |
// (destructors are skipped). Chrome should be NSException-free, |
// please check your backtrace and see if you can't file a bug |
// with a repro case. |
- if (fatal) { |
+ const bool allow = base::mac::GetNSExceptionsAllowed(); |
+ if (fatal && !allow) { |
LOG(FATAL) << "Someone is trying to raise an exception! " |
<< base::SysNSStringToUTF8(value); |
} else { |
@@ -101,7 +103,7 @@ static IMP gOriginalInitIMP = NULL; |
// exceptions. |
DLOG(ERROR) << "Someone is trying to raise an exception! " |
<< base::SysNSStringToUTF8(value); |
- NOTREACHED(); |
+ DCHECK(allow); |
} |
} |
@@ -328,7 +330,20 @@ BOOL SwizzleNSExceptionInit() { |
[NSString stringWithFormat:@"%@ tag %d sending %@ to %p", |
[sender className], tag, actionString, aTarget]; |
+ // Certain third-party code, such as print drivers, can still throw |
+ // exceptions and Chromium cannot fix them. This provides a way to |
+ // work around those on a spot basis. |
+ bool enableNSExceptions = false; |
+ |
+ // http://crbug.com/80686 , an Epson printer driver. |
+ if (anAction == @selector(selectPDE:)) { |
+ enableNSExceptions = true; |
+ } |
+ |
+ // These should be as close to the super call as reasonable. |
+ base::mac::ScopedNSExceptionEnabler enabler(enableNSExceptions); |
ScopedCrashKey key(kActionKey, value); |
Mark Mentovai
2011/05/17 22:23:27
Can’t this precede ScopedNSExceptionEnabler? You c
Scott Hess - ex-Googler
2011/05/17 22:48:30
I'm not entirely sure I understand what you'd like
|
+ |
return [super sendAction:anAction to:aTarget from:sender]; |
} |
@@ -354,6 +369,11 @@ BOOL SwizzleNSExceptionInit() { |
// addressed elsewhere. |
[self clearIsHandlingSendEvent]; |
+ // If |ScopedNSExceptionEnabler| is used to allow exceptions, and |
+ // an uncaught exception is thrown, the flag must be reset so that |
+ // future exceptions are not masked. |
Mark Mentovai
2011/05/17 22:23:27
Can you at least say here that stuff will have unw
Scott Hess - ex-Googler
2011/05/17 22:48:30
OK.
|
+ base::mac::SetNSExceptionsAllowed(false); |
+ |
// Store some human-readable information in breakpad keys in case |
// there is a crash. Since breakpad does not provide infinite |
// storage, we track two exceptions. The first exception thrown |