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;
|
|
|
|
|
2012-07-27 03:15:46 -07:00
|
|
|
// When chrome JS objects are exposed to content, they get a ChromeObjectWrapper.
|
|
|
|
//
|
|
|
|
// The base filtering wrapper here does most of the work for us. We define a
|
|
|
|
// custom class here to introduce custom behavior with respect to the prototype
|
|
|
|
// chain.
|
|
|
|
#define ChromeObjectWrapperBase \
|
|
|
|
FilteringWrapper<js::CrossCompartmentSecurityWrapper, ExposedPropertiesOnly>
|
|
|
|
|
|
|
|
class ChromeObjectWrapper : public ChromeObjectWrapperBase
|
|
|
|
{
|
|
|
|
public:
|
2012-12-09 09:23:19 -08:00
|
|
|
ChromeObjectWrapper() : ChromeObjectWrapperBase(0) {}
|
2012-07-27 03:15:46 -07:00
|
|
|
|
2012-07-27 03:15:46 -07:00
|
|
|
/* Custom traps. */
|
2013-03-21 15:23:48 -07:00
|
|
|
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
2013-04-30 10:29:40 -07:00
|
|
|
JS::Handle<jsid> id,
|
2014-04-25 14:11:01 -07:00
|
|
|
JS::MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE;
|
2013-03-21 15:23:48 -07:00
|
|
|
virtual bool has(JSContext *cx, JS::Handle<JSObject*> wrapper,
|
|
|
|
JS::Handle<jsid> id, bool *bp) MOZ_OVERRIDE;
|
|
|
|
virtual bool get(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> receiver,
|
|
|
|
JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) MOZ_OVERRIDE;
|
2012-07-27 03:15:46 -07:00
|
|
|
|
2013-03-21 15:23:48 -07:00
|
|
|
virtual bool objectClassIs(JS::Handle<JSObject*> obj, js::ESClassValue classValue,
|
2013-03-13 14:48:59 -07:00
|
|
|
JSContext *cx) MOZ_OVERRIDE;
|
|
|
|
|
2013-03-21 15:23:48 -07:00
|
|
|
virtual bool enter(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
|
2013-02-25 13:54:18 -08:00
|
|
|
js::Wrapper::Action act, bool *bp) MOZ_OVERRIDE;
|
|
|
|
|
2012-07-27 03:15:46 -07:00
|
|
|
// NB: One might think we'd need to implement enumerate(), keys(), iterate(),
|
|
|
|
// and getPropertyNames() here. However, ES5 built-in properties aren't
|
|
|
|
// enumerable (and SpiderMonkey's implementation seems to match the spec
|
|
|
|
// modulo Error.prototype.fileName and Error.prototype.lineNumber). Since
|
|
|
|
// we're only remapping the prototypes of standard objects, there would
|
|
|
|
// never be anything more to enumerate up the prototype chain. So we can
|
|
|
|
// atually skip these.
|
|
|
|
|
2012-07-27 03:15:46 -07:00
|
|
|
static ChromeObjectWrapper singleton;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace xpc */
|
|
|
|
|
|
|
|
#endif /* __ChromeObjectWrapper_h__ */
|