Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2904)

Unified Diff: chrome/browser/chrome_browser_application_mac.mm

Issue 7038010: [Mac] Allow NSExceptions in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move crash-key scoper back by crash-key setup code. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8760d26cc9b9361eb66d12deab07afd06f8cd10f 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);
}
}
@@ -329,6 +331,19 @@ BOOL SwizzleNSExceptionInit() {
[sender className], tag, actionString, aTarget];
ScopedCrashKey key(kActionKey, value);
Mark Mentovai 2011/05/24 00:05:16 Yup, seeing this here, I agree that it’s fine.
+
+ // 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:)) {
Mark Mentovai 2011/05/24 00:05:16 If you know something about aTarget (or possibly e
Scott Hess - ex-Googler 2011/05/24 00:31:25 This info is from the backtrace on http://crbug.co
Mark Mentovai 2011/05/24 00:39:05 shess wrote:
+ enableNSExceptions = true;
+ }
+
+ // Minimize the window by keeping this close to the super call.
+ base::mac::ScopedNSExceptionEnabler enabler(enableNSExceptions);
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, it will throw past all of the scopers.
+ // Reset the flag so that future exceptions are not masked.
+ 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

Powered by Google App Engine
This is Rietveld 408576698