js/xpconnect/wrappers/WrapperFactory.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* vim: set ts=8 sts=4 et sw=4 tw=99: */
     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/. */
     7 #ifndef _xpc_WRAPPERFACTORY_H
     8 #define _xpc_WRAPPERFACTORY_H
    10 #include "jswrapper.h"
    12 namespace xpc {
    14 class WrapperFactory {
    15   public:
    16     enum { WAIVE_XRAY_WRAPPER_FLAG = js::Wrapper::LAST_USED_FLAG << 1,
    17            IS_XRAY_WRAPPER_FLAG    = WAIVE_XRAY_WRAPPER_FLAG << 1 };
    19     // Return true if any of any of the nested wrappers have the flag set.
    20     static bool HasWrapperFlag(JSObject *wrapper, unsigned flag) {
    21         unsigned flags = 0;
    22         js::UncheckedUnwrap(wrapper, true, &flags);
    23         return !!(flags & flag);
    24     }
    26     static bool IsXrayWrapper(JSObject *wrapper) {
    27         return HasWrapperFlag(wrapper, IS_XRAY_WRAPPER_FLAG);
    28     }
    30     static bool HasWaiveXrayFlag(JSObject *wrapper) {
    31         return HasWrapperFlag(wrapper, WAIVE_XRAY_WRAPPER_FLAG);
    32     }
    34     static bool IsSecurityWrapper(JSObject *obj) {
    35         return !js::CheckedUnwrap(obj);
    36     }
    38     static bool IsCOW(JSObject *wrapper);
    40     static JSObject *GetXrayWaiver(JS::HandleObject obj);
    41     static JSObject *CreateXrayWaiver(JSContext *cx, JS::HandleObject obj);
    42     static JSObject *WaiveXray(JSContext *cx, JSObject *obj);
    44     static JSObject *DoubleWrap(JSContext *cx, JS::HandleObject obj, unsigned flags);
    46     // Prepare a given object for wrapping in a new compartment.
    47     static JSObject *PrepareForWrapping(JSContext *cx,
    48                                         JS::HandleObject scope,
    49                                         JS::HandleObject obj,
    50                                         unsigned flags);
    52     // Rewrap an object that is about to cross compartment boundaries.
    53     static JSObject *Rewrap(JSContext *cx,
    54                             JS::HandleObject existing,
    55                             JS::HandleObject obj,
    56                             JS::HandleObject wrappedProto,
    57                             JS::HandleObject parent,
    58                             unsigned flags);
    60     // Wrap wrapped object into a waiver wrapper and then re-wrap it.
    61     static bool WaiveXrayAndWrap(JSContext *cx, JS::MutableHandleValue vp);
    62     static bool WaiveXrayAndWrap(JSContext *cx, JS::MutableHandleObject object);
    64     // Returns true if the wrapper is in not shadowing mode for the id.
    65     static bool XrayWrapperNotShadowing(JSObject *wrapper, jsid id);
    66 };
    68 extern js::Wrapper XrayWaiver;
    70 }
    72 #endif /* _xpc_WRAPPERFACTORY_H */

mercurial