js/xpconnect/src/XPCWrapper.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/xpconnect/src/XPCWrapper.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef XPC_WRAPPER_H
    1.11 +#define XPC_WRAPPER_H 1
    1.12 +
    1.13 +#include "xpcprivate.h"
    1.14 +#include "jswrapper.h"
    1.15 +
    1.16 +class nsIScriptSecurityManager;
    1.17 +
    1.18 +namespace XPCNativeWrapper {
    1.19 +
    1.20 +// Given an XPCWrappedNative pointer and the name of the function on
    1.21 +// XPCNativeScriptableFlags corresponding with a flag, returns 'true'
    1.22 +// if the flag is set.
    1.23 +// XXX Convert to using GetFlags() and not a macro.
    1.24 +#define NATIVE_HAS_FLAG(_wn, _flag)                                           \
    1.25 +  ((_wn)->GetScriptableInfo() &&                                              \
    1.26 +   (_wn)->GetScriptableInfo()->GetFlags()._flag())
    1.27 +
    1.28 +bool
    1.29 +AttachNewConstructorObject(JSContext *aCx, JS::HandleObject aGlobalObject);
    1.30 +
    1.31 +} // namespace XPCNativeWrapper
    1.32 +
    1.33 +// This namespace wraps some common functionality between the three existing
    1.34 +// wrappers. Its main purpose is to allow XPCCrossOriginWrapper to act both
    1.35 +// as an XPCSafeJSObjectWrapper and as an XPCNativeWrapper when required to
    1.36 +// do so (the decision is based on the principals of the wrapper and wrapped
    1.37 +// objects).
    1.38 +namespace XPCWrapper {
    1.39 +
    1.40 +/**
    1.41 + * Returns the script security manager used by XPConnect.
    1.42 + */
    1.43 +inline nsIScriptSecurityManager *
    1.44 +GetSecurityManager()
    1.45 +{
    1.46 +  return nsXPConnect::gScriptSecurityManager;
    1.47 +}
    1.48 +
    1.49 +inline bool
    1.50 +IsSecurityWrapper(JSObject *wrapper)
    1.51 +{
    1.52 +  return js::IsWrapper(wrapper);
    1.53 +}
    1.54 +
    1.55 +JSObject *
    1.56 +UnsafeUnwrapSecurityWrapper(JSObject *obj);
    1.57 +
    1.58 +} // namespace XPCWrapper
    1.59 +
    1.60 +
    1.61 +#endif

mercurial