1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_MAC_SCOPED_NSEXCEPTION_ENABLER_H_
6 #define BASE_MAC_SCOPED_NSEXCEPTION_ENABLER_H_
9 #include "base/basictypes.h"
14 // BrowserCrApplication attempts to restrict throwing of NSExceptions
15 // because they interact badly with C++ scoping rules. Unfortunately,
16 // there are some cases where exceptions must be supported, such as
17 // when third-party printer drivers are used. These helpers can be
18 // used to enable exceptions for narrow windows.
20 // Make it easy to safely allow NSException to be thrown in a limited
21 // scope. Note that if an exception is thrown, then this object will
22 // not be appropriately destructed! If the exception ends up in the
23 // top-level event loop, things are cleared in -reportException:. If
24 // the exception is caught at a lower level, a higher level scoper
25 // should eventually reset things.
26 class ScopedNSExceptionEnabler
{
28 ScopedNSExceptionEnabler();
29 ~ScopedNSExceptionEnabler();
34 DISALLOW_COPY_AND_ASSIGN(ScopedNSExceptionEnabler
);
37 // Access the exception setting for the current thread. This is for
38 // the support code in BrowserCrApplication, other code should use
40 bool GetNSExceptionsAllowed();
41 void SetNSExceptionsAllowed(bool allowed
);
46 #endif // BASE_MAC_SCOPED_NSEXCEPTION_ENABLER_H_