Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=4 et sw=4 tw=99: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef _xpc_WRAPPERFACTORY_H |
michael@0 | 8 | #define _xpc_WRAPPERFACTORY_H |
michael@0 | 9 | |
michael@0 | 10 | #include "jswrapper.h" |
michael@0 | 11 | |
michael@0 | 12 | namespace xpc { |
michael@0 | 13 | |
michael@0 | 14 | class WrapperFactory { |
michael@0 | 15 | public: |
michael@0 | 16 | enum { WAIVE_XRAY_WRAPPER_FLAG = js::Wrapper::LAST_USED_FLAG << 1, |
michael@0 | 17 | IS_XRAY_WRAPPER_FLAG = WAIVE_XRAY_WRAPPER_FLAG << 1 }; |
michael@0 | 18 | |
michael@0 | 19 | // Return true if any of any of the nested wrappers have the flag set. |
michael@0 | 20 | static bool HasWrapperFlag(JSObject *wrapper, unsigned flag) { |
michael@0 | 21 | unsigned flags = 0; |
michael@0 | 22 | js::UncheckedUnwrap(wrapper, true, &flags); |
michael@0 | 23 | return !!(flags & flag); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | static bool IsXrayWrapper(JSObject *wrapper) { |
michael@0 | 27 | return HasWrapperFlag(wrapper, IS_XRAY_WRAPPER_FLAG); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | static bool HasWaiveXrayFlag(JSObject *wrapper) { |
michael@0 | 31 | return HasWrapperFlag(wrapper, WAIVE_XRAY_WRAPPER_FLAG); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | static bool IsSecurityWrapper(JSObject *obj) { |
michael@0 | 35 | return !js::CheckedUnwrap(obj); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | static bool IsCOW(JSObject *wrapper); |
michael@0 | 39 | |
michael@0 | 40 | static JSObject *GetXrayWaiver(JS::HandleObject obj); |
michael@0 | 41 | static JSObject *CreateXrayWaiver(JSContext *cx, JS::HandleObject obj); |
michael@0 | 42 | static JSObject *WaiveXray(JSContext *cx, JSObject *obj); |
michael@0 | 43 | |
michael@0 | 44 | static JSObject *DoubleWrap(JSContext *cx, JS::HandleObject obj, unsigned flags); |
michael@0 | 45 | |
michael@0 | 46 | // Prepare a given object for wrapping in a new compartment. |
michael@0 | 47 | static JSObject *PrepareForWrapping(JSContext *cx, |
michael@0 | 48 | JS::HandleObject scope, |
michael@0 | 49 | JS::HandleObject obj, |
michael@0 | 50 | unsigned flags); |
michael@0 | 51 | |
michael@0 | 52 | // Rewrap an object that is about to cross compartment boundaries. |
michael@0 | 53 | static JSObject *Rewrap(JSContext *cx, |
michael@0 | 54 | JS::HandleObject existing, |
michael@0 | 55 | JS::HandleObject obj, |
michael@0 | 56 | JS::HandleObject wrappedProto, |
michael@0 | 57 | JS::HandleObject parent, |
michael@0 | 58 | unsigned flags); |
michael@0 | 59 | |
michael@0 | 60 | // Wrap wrapped object into a waiver wrapper and then re-wrap it. |
michael@0 | 61 | static bool WaiveXrayAndWrap(JSContext *cx, JS::MutableHandleValue vp); |
michael@0 | 62 | static bool WaiveXrayAndWrap(JSContext *cx, JS::MutableHandleObject object); |
michael@0 | 63 | |
michael@0 | 64 | // Returns true if the wrapper is in not shadowing mode for the id. |
michael@0 | 65 | static bool XrayWrapperNotShadowing(JSObject *wrapper, jsid id); |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | extern js::Wrapper XrayWaiver; |
michael@0 | 69 | |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | #endif /* _xpc_WRAPPERFACTORY_H */ |