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