michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef XPC_WRAPPER_H michael@0: #define XPC_WRAPPER_H 1 michael@0: michael@0: #include "xpcprivate.h" michael@0: #include "jswrapper.h" michael@0: michael@0: class nsIScriptSecurityManager; michael@0: michael@0: namespace XPCNativeWrapper { michael@0: michael@0: // Given an XPCWrappedNative pointer and the name of the function on michael@0: // XPCNativeScriptableFlags corresponding with a flag, returns 'true' michael@0: // if the flag is set. michael@0: // XXX Convert to using GetFlags() and not a macro. michael@0: #define NATIVE_HAS_FLAG(_wn, _flag) \ michael@0: ((_wn)->GetScriptableInfo() && \ michael@0: (_wn)->GetScriptableInfo()->GetFlags()._flag()) michael@0: michael@0: bool michael@0: AttachNewConstructorObject(JSContext *aCx, JS::HandleObject aGlobalObject); michael@0: michael@0: } // namespace XPCNativeWrapper michael@0: michael@0: // This namespace wraps some common functionality between the three existing michael@0: // wrappers. Its main purpose is to allow XPCCrossOriginWrapper to act both michael@0: // as an XPCSafeJSObjectWrapper and as an XPCNativeWrapper when required to michael@0: // do so (the decision is based on the principals of the wrapper and wrapped michael@0: // objects). michael@0: namespace XPCWrapper { michael@0: michael@0: /** michael@0: * Returns the script security manager used by XPConnect. michael@0: */ michael@0: inline nsIScriptSecurityManager * michael@0: GetSecurityManager() michael@0: { michael@0: return nsXPConnect::gScriptSecurityManager; michael@0: } michael@0: michael@0: inline bool michael@0: IsSecurityWrapper(JSObject *wrapper) michael@0: { michael@0: return js::IsWrapper(wrapper); michael@0: } michael@0: michael@0: JSObject * michael@0: UnsafeUnwrapSecurityWrapper(JSObject *obj); michael@0: michael@0: } // namespace XPCWrapper michael@0: michael@0: michael@0: #endif