2014-04-03 04:58:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-07-27 03:15:46 -07:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef __ChromeObjectWrapper_h__
|
|
|
|
#define __ChromeObjectWrapper_h__
|
|
|
|
|
2013-01-03 13:31:36 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2012-07-27 03:15:46 -07:00
|
|
|
#include "FilteringWrapper.h"
|
|
|
|
|
|
|
|
namespace xpc {
|
|
|
|
|
2013-09-09 14:14:10 -07:00
|
|
|
struct ExposedPropertiesOnly;
|
|
|
|
|
2014-10-20 06:52:53 -07:00
|
|
|
// When a vanilla chrome JS object is exposed to content, we use a wrapper that
|
|
|
|
// supports __exposedProps__ for legacy reasons. For extra security, we override
|
|
|
|
// the traps that allow content to pass an object to chrome, and perform extra
|
|
|
|
// security checks on them.
|
2012-07-27 03:15:46 -07:00
|
|
|
#define ChromeObjectWrapperBase \
|
|
|
|
FilteringWrapper<js::CrossCompartmentSecurityWrapper, ExposedPropertiesOnly>
|
|
|
|
|
|
|
|
class ChromeObjectWrapper : public ChromeObjectWrapperBase
|
|
|
|
{
|
|
|
|
public:
|
2014-08-28 13:47:16 -07:00
|
|
|
MOZ_CONSTEXPR ChromeObjectWrapper() : ChromeObjectWrapperBase(0) {}
|
2012-07-27 03:15:46 -07:00
|
|
|
|
2014-07-20 14:36:32 -07:00
|
|
|
virtual bool defineProperty(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
|
|
|
JS::Handle<jsid> id,
|
|
|
|
JS::MutableHandle<JSPropertyDescriptor> desc) const MOZ_OVERRIDE;
|
2014-10-08 10:09:08 -07:00
|
|
|
virtual bool set(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
|
|
|
JS::Handle<JSObject*> receiver, JS::Handle<jsid> id,
|
|
|
|
bool strict, JS::MutableHandle<JS::Value> vp) const MOZ_OVERRIDE;
|
2014-07-20 14:36:32 -07:00
|
|
|
|
2014-06-27 04:44:04 -07:00
|
|
|
static const ChromeObjectWrapper singleton;
|
2012-07-27 03:15:46 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace xpc */
|
|
|
|
|
|
|
|
#endif /* __ChromeObjectWrapper_h__ */
|