15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions are 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Redistributions of source code must retain the above copyright 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Redistributions in binary form must reproduce the above 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * in the documentation and/or other materials provided with the 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * distribution. 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * contributors may be used to endorse or promote products derived from 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * this software without specific prior written permission. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef V8NPObject_h 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define V8NPObject_h 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <bindings/npruntime.h> 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <v8.h> 365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WebCore { 385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// These functions can be replaced by normal JS operation. 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Getters 41521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>&); 42521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectIndexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&); 43521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>&); 44521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&); 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Setters 47521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&); 48521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectIndexedPropertySetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&); 49521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&); 50521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)void npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&); 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)void npObjectInvokeDefaultHandler(const v8::FunctionCallbackInfo<v8::Value>&); 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Get a wrapper for a NPObject. 555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// If the object is already wrapped, the pre-existing wrapper will be returned. If the object is not wrapped, wrap it, and 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// give V8 a weak reference to the wrapper which will cleanup when there are no more JS references to the object. 578abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)v8::Local<v8::Object> createV8ObjectForNPObject(NPObject*, NPObject* root, v8::Isolate*); 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Tell V8 to forcibly remove an object. 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// This is used at plugin teardown so that the caller can aggressively unload the plugin library. After calling this 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// function, the persistent handle to the wrapper will be gone, and the wrapped NPObject will be removed so that it 625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// cannot be referred to. 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)void forgetV8ObjectForNPObject(NPObject*); 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 653fb1c1e2db3001008a6d8ccbe2f9345ec50363d2Mikhail Naganov// De-associate an NPObject with the current JS wrapper, but preserve the backward connection from the wrapper to NPObject. 663fb1c1e2db3001008a6d8ccbe2f9345ec50363d2Mikhail Naganov// This allows to have a single NPObject to be called from several wrappers, so each context can have its own wrapper. 673fb1c1e2db3001008a6d8ccbe2f9345ec50363d2Mikhail Naganovvoid dropV8WrapperForNPObject(NPObject*); 683fb1c1e2db3001008a6d8ccbe2f9345ec50363d2Mikhail Naganov 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace WebCore 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // V8NPObject_h 72