summaryrefslogtreecommitdiffstats
path: root/base/mac
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-08 03:25:07 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-08 03:25:07 +0000
commit02ee53c59c21939d49cb9b0965250034268f2cdb (patch)
treeb32f1a2c10f596d102de1244ba8ffd627278d60d /base/mac
parentc9a175d61280d2135445ecc1cc22b070d926260f (diff)
downloadchromium_src-02ee53c59c21939d49cb9b0965250034268f2cdb.zip
chromium_src-02ee53c59c21939d49cb9b0965250034268f2cdb.tar.gz
chromium_src-02ee53c59c21939d49cb9b0965250034268f2cdb.tar.bz2
[Mac] Allow NSExceptions in third-party webcam code.
Chromium cannot control that code, and NSExceptions should be safe-ish since there is no Chromium code on the stack. BUG=174708 Review URL: https://chromiumcodereview.appspot.com/12208053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac')
-rw-r--r--base/mac/scoped_nsexception_enabler.h7
-rw-r--r--base/mac/scoped_nsexception_enabler.mm11
2 files changed, 18 insertions, 0 deletions
diff --git a/base/mac/scoped_nsexception_enabler.h b/base/mac/scoped_nsexception_enabler.h
index e1d0b3c..e28e516 100644
--- a/base/mac/scoped_nsexception_enabler.h
+++ b/base/mac/scoped_nsexception_enabler.h
@@ -45,8 +45,15 @@ BASE_EXPORT void SetNSExceptionsAllowed(bool allowed);
// Executes [target performSelector:sel] with fatal-exceptions turned
// off, and returns the result. If an exception is thrown during the
// perform, nil is returned.
+// TODO(shess): Deprecated, convert to RunBlockIgnoringExceptions().
BASE_EXPORT id PerformSelectorIgnoringExceptions(NSObject* target, SEL sel);
+// Executes |block| with fatal-exceptions turned off, and returns the
+// result. If an exception is thrown during the perform, nil is
+// returned.
+typedef id (^BlockReturningId)();
+BASE_EXPORT id RunBlockIgnoringExceptions(BlockReturningId block);
+
} // namespace mac
} // namespace base
diff --git a/base/mac/scoped_nsexception_enabler.mm b/base/mac/scoped_nsexception_enabler.mm
index 9898789..44d4e19 100644
--- a/base/mac/scoped_nsexception_enabler.mm
+++ b/base/mac/scoped_nsexception_enabler.mm
@@ -50,6 +50,17 @@ id PerformSelectorIgnoringExceptions(NSObject* target, SEL sel) {
return ret;
}
+id RunBlockIgnoringExceptions(BlockReturningId block) {
+ id ret = nil;
+ @try {
+ base::mac::ScopedNSExceptionEnabler enable;
+ ret = block();
+ }
+ @catch(id exception) {
+ }
+ return ret;
+}
+
ScopedNSExceptionEnabler::ScopedNSExceptionEnabler() {
was_enabled_ = GetNSExceptionsAllowed();
SetNSExceptionsAllowed(true);