Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / js / xpconnect / wrappers / ChromeObjectWrapper.cpp
blob28ea3d2c02806666eee0188179db8dd3ec651e9a
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/. */
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"
15 using namespace JS;
17 namespace xpc {
19 const ChromeObjectWrapper ChromeObjectWrapper::singleton;
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;
29 return ChromeObjectWrapperBase::defineProperty(cx, wrapper, id, desc, result);
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;
38 return ChromeObjectWrapperBase::set(cx, wrapper, id, v, receiver, result);
41 } // namespace xpc