ChromeObjectWrapper.h (1623B)
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 __ChromeObjectWrapper_h__ 8 #define __ChromeObjectWrapper_h__ 9 10 #include "FilteringWrapper.h" 11 12 namespace xpc { 13 14 struct OpaqueWithSilentFailing; 15 16 // When a vanilla chrome JS object is exposed to content, we use a wrapper that 17 // fails silently on GET, ENUMERATE, and GET_PROPERTY_DESCRIPTOR for legacy 18 // reasons. For extra security, we override the traps that allow content to pass 19 // an object to chrome, and perform extra security checks on them. 20 #define ChromeObjectWrapperBase \ 21 FilteringWrapper<js::CrossCompartmentSecurityWrapper, OpaqueWithSilentFailing> 22 23 class ChromeObjectWrapper : public ChromeObjectWrapperBase { 24 public: 25 constexpr ChromeObjectWrapper() : ChromeObjectWrapperBase(0) {} 26 27 virtual bool defineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, 28 JS::Handle<jsid> id, 29 JS::Handle<JS::PropertyDescriptor> desc, 30 JS::ObjectOpResult& result) const override; 31 virtual bool set(JSContext* cx, JS::HandleObject wrapper, JS::HandleId id, 32 JS::HandleValue v, JS::HandleValue receiver, 33 JS::ObjectOpResult& result) const override; 34 35 static const ChromeObjectWrapper singleton; 36 }; 37 38 } /* namespace xpc */ 39 40 #endif /* __ChromeObjectWrapper_h__ */