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

Side by Side Diff: base/mac/scoped_nsexception_enabler.h

Issue 7038010: [Mac] Allow NSExceptions in certain cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef BASE_MAC_SCOPED_NSEXCEPTION_ENABLER_H_
6 #define BASE_MAC_SCOPED_NSEXCEPTION_ENABLER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10
11 namespace base {
12 namespace mac {
13
14 // ChromeBrowserApplication attempts to restrict throwing of
15 // NSExceptions because they interact badly with C++ scoping rules.
16 // Unfortunately, there are some cases where exceptions must be
17 // supported, such as when third-party printer drivers are used.
18 // These helpers can be used to enable exceptions for narrow windows.
19
20 // Make it easy to safely allow NSException to be throw in a limited
21 // scope. Note that if an exception is throw, 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 {
27 public:
28 // Passing |true| enables exceptions within this scope, passing
29 // |false| leaves the current setting alone. This allows optionally
30 // enabling exceptions without requiring contrived code (like using
31 // |scoped_ptr<ScopedNSExceptionEnabler>|).
32 ScopedNSExceptionEnabler(bool enable);
Mark Mentovai 2011/05/17 19:07:34 Mark this “explicit.”
33 ~ScopedNSExceptionEnabler();
34
35 private:
36 bool was_enabled_;
37
38 DISALLOW_COPY_AND_ASSIGN(ScopedNSExceptionEnabler);
39 };
40
41 // Access the exception setting for the current thread. This is for
42 // the support code in ChromeBrowserApplication, other code should use
43 // the scoper.
44 bool GetNSExceptionsAllowed();
45 void SetNSExceptionsAllowed(bool allowed);
46
47 } // namespace mac
48 } // namespace base
49
50 #endif BASE_MAC_SCOPED_NSEXCEPTION_ENABLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698