ChromeObjectWrapper.cpp (1485B)
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 #include "ChromeObjectWrapper.h" 8 #include "WrapperFactory.h" 9 #include "AccessCheck.h" 10 #include "xpcprivate.h" 11 #include "jsapi.h" 12 #include "js/Wrapper.h" 13 #include "nsXULAppAPI.h" 14 15 using namespace JS; 16 17 namespace xpc { 18 19 const ChromeObjectWrapper ChromeObjectWrapper::singleton; 20 21 bool ChromeObjectWrapper::defineProperty(JSContext* cx, HandleObject wrapper, 22 HandleId id, 23 Handle<PropertyDescriptor> desc, 24 ObjectOpResult& result) const { 25 if (desc.hasValue() && 26 !AccessCheck::checkPassToPrivilegedCode(cx, wrapper, desc.value())) { 27 return false; 28 } 29 return ChromeObjectWrapperBase::defineProperty(cx, wrapper, id, desc, result); 30 } 31 32 bool ChromeObjectWrapper::set(JSContext* cx, HandleObject wrapper, HandleId id, 33 HandleValue v, HandleValue receiver, 34 ObjectOpResult& result) const { 35 if (!AccessCheck::checkPassToPrivilegedCode(cx, wrapper, v)) { 36 return false; 37 } 38 return ChromeObjectWrapperBase::set(cx, wrapper, id, v, receiver, result); 39 } 40 41 } // namespace xpc