|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef XPC_WRAPPER_H |
|
8 #define XPC_WRAPPER_H 1 |
|
9 |
|
10 #include "xpcprivate.h" |
|
11 #include "jswrapper.h" |
|
12 |
|
13 class nsIScriptSecurityManager; |
|
14 |
|
15 namespace XPCNativeWrapper { |
|
16 |
|
17 // Given an XPCWrappedNative pointer and the name of the function on |
|
18 // XPCNativeScriptableFlags corresponding with a flag, returns 'true' |
|
19 // if the flag is set. |
|
20 // XXX Convert to using GetFlags() and not a macro. |
|
21 #define NATIVE_HAS_FLAG(_wn, _flag) \ |
|
22 ((_wn)->GetScriptableInfo() && \ |
|
23 (_wn)->GetScriptableInfo()->GetFlags()._flag()) |
|
24 |
|
25 bool |
|
26 AttachNewConstructorObject(JSContext *aCx, JS::HandleObject aGlobalObject); |
|
27 |
|
28 } // namespace XPCNativeWrapper |
|
29 |
|
30 // This namespace wraps some common functionality between the three existing |
|
31 // wrappers. Its main purpose is to allow XPCCrossOriginWrapper to act both |
|
32 // as an XPCSafeJSObjectWrapper and as an XPCNativeWrapper when required to |
|
33 // do so (the decision is based on the principals of the wrapper and wrapped |
|
34 // objects). |
|
35 namespace XPCWrapper { |
|
36 |
|
37 /** |
|
38 * Returns the script security manager used by XPConnect. |
|
39 */ |
|
40 inline nsIScriptSecurityManager * |
|
41 GetSecurityManager() |
|
42 { |
|
43 return nsXPConnect::gScriptSecurityManager; |
|
44 } |
|
45 |
|
46 inline bool |
|
47 IsSecurityWrapper(JSObject *wrapper) |
|
48 { |
|
49 return js::IsWrapper(wrapper); |
|
50 } |
|
51 |
|
52 JSObject * |
|
53 UnsafeUnwrapSecurityWrapper(JSObject *obj); |
|
54 |
|
55 } // namespace XPCWrapper |
|
56 |
|
57 |
|
58 #endif |