diff options
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.cc | 57 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.h | 24 | ||||
-rw-r--r-- | third_party/npapi/bindings/npapi_extensions.h | 18 | ||||
-rw-r--r-- | webkit/glue/plugins/npapi_extension_thunk.cc | 262 | ||||
-rw-r--r-- | webkit/glue/plugins/npapi_extension_thunk.h | 23 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 719 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_lib.cc | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_lib.h | 25 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_2d_device_delegate.h | 57 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_3d_device_delegate.h | 57 | ||||
-rw-r--r-- | webkit/glue/webplugin_delegate.h | 40 | ||||
-rw-r--r-- | webkit/webkit.gyp | 4 |
12 files changed, 796 insertions, 493 deletions
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc index 0be5924..47eea91 100644 --- a/chrome/renderer/webplugin_delegate_pepper.cc +++ b/chrome/renderer/webplugin_delegate_pepper.cc @@ -295,6 +295,7 @@ NPError WebPluginDelegatePepper::Device2DGetStateContext( } NPError WebPluginDelegatePepper::Device2DFlushContext( + NPP id, NPDeviceContext2D* context, NPDeviceFlushContextCallbackPtr callback, void* user_data) { @@ -302,7 +303,7 @@ NPError WebPluginDelegatePepper::Device2DFlushContext( OpenPaintContextMap::iterator found = open_paint_contexts_.find( context->u.graphicsRgba.region); if (found == open_paint_contexts_.end()) - return NPERR_INVALID_PARAM; + return NPERR_INVALID_PARAM; // TODO(brettw) call callback. OpenPaintContext* paint_context = found->second.get(); @@ -330,6 +331,16 @@ NPError WebPluginDelegatePepper::Device2DFlushContext( &src_rect, dest_rect); committed_bitmap_.setIsOpaque(false); + + // Invoke the callback to inform the caller the work was done. + // TODO(brettw) this is not how we want this to work, this should + // happen when the frame is painted so the plugin knows when it can draw + // the next frame. + // + // This should also be called in the failure cases as well. + if (callback != NULL) + (*callback)(id, context, NPERR_NO_ERROR, user_data); + return NPERR_NO_ERROR; } @@ -344,6 +355,50 @@ NPError WebPluginDelegatePepper::Device2DDestroyContext( return NPERR_NO_ERROR; } +NPError WebPluginDelegatePepper::Device3DQueryCapability(int32 capability, + int32* value) { + return NPERR_GENERIC_ERROR; +} + +NPError WebPluginDelegatePepper::Device3DQueryConfig( + const NPDeviceContext3DConfig* request, + NPDeviceContext3DConfig* obtain) { + return NPERR_GENERIC_ERROR; +} + +NPError WebPluginDelegatePepper::Device3DInitializeContext( + const NPDeviceContext3DConfig* config, + NPDeviceContext3D* context) { + return NPERR_GENERIC_ERROR; +} + +NPError WebPluginDelegatePepper::Device3DSetStateContext( + NPDeviceContext3D* context, + int32 state, + int32 value) { + return NPERR_GENERIC_ERROR; +} + +NPError WebPluginDelegatePepper::Device3DGetStateContext( + NPDeviceContext3D* context, + int32 state, + int32* value) { + return NPERR_GENERIC_ERROR; +} + +NPError WebPluginDelegatePepper::Device3DFlushContext( + NPP id, + NPDeviceContext3D* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data) { + return NPERR_GENERIC_ERROR; +} + +NPError WebPluginDelegatePepper::Device3DDestroyContext( + NPDeviceContext3D* context) { + return NPERR_GENERIC_ERROR; +} + bool WebPluginDelegatePepper::IsPluginDelegateWindow( gfx::NativeWindow window) { return false; diff --git a/chrome/renderer/webplugin_delegate_pepper.h b/chrome/renderer/webplugin_delegate_pepper.h index afb6630..aa798d7 100644 --- a/chrome/renderer/webplugin_delegate_pepper.h +++ b/chrome/renderer/webplugin_delegate_pepper.h @@ -80,6 +80,8 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { bool notify_needed, intptr_t notify_data, intptr_t stream); + + // WebPlugin2DDeviceDelegate implementation. virtual NPError Device2DQueryCapability(int32 capability, int32* value); virtual NPError Device2DQueryConfig(const NPDeviceContext2DConfig* request, NPDeviceContext2DConfig* obtain); @@ -92,10 +94,30 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { virtual NPError Device2DGetStateContext(NPDeviceContext2D* context, int32 state, int32* value); - virtual NPError Device2DFlushContext(NPDeviceContext2D* context, + virtual NPError Device2DFlushContext(NPP id, + NPDeviceContext2D* context, NPDeviceFlushContextCallbackPtr callback, void* user_data); virtual NPError Device2DDestroyContext(NPDeviceContext2D* context); + + // WebPlugin3DDeviceDelegate implementation. + virtual NPError Device3DQueryCapability(int32 capability, int32* value); + virtual NPError Device3DQueryConfig(const NPDeviceContext3DConfig* request, + NPDeviceContext3DConfig* obtain); + virtual NPError Device3DInitializeContext( + const NPDeviceContext3DConfig* config, + NPDeviceContext3D* context); + virtual NPError Device3DSetStateContext(NPDeviceContext3D* context, + int32 state, + int32 value); + virtual NPError Device3DGetStateContext(NPDeviceContext3D* context, + int32 state, + int32* value); + virtual NPError Device3DFlushContext(NPP id, + NPDeviceContext3D* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data); + virtual NPError Device3DDestroyContext(NPDeviceContext3D* context); // End of WebPluginDelegate implementation. bool IsWindowless() const { return true; } diff --git a/third_party/npapi/bindings/npapi_extensions.h b/third_party/npapi/bindings/npapi_extensions.h index 7ca636d..f72a9aa 100644 --- a/third_party/npapi/bindings/npapi_extensions.h +++ b/third_party/npapi/bindings/npapi_extensions.h @@ -198,11 +198,6 @@ typedef struct _NPPepperEvent #define NPPepper2DDevice 1 -typedef enum _NPRenderType -{ - NPRenderGraphicsRGBA -} NPRenderType; - typedef struct _NPDeviceContext2DConfig { } NPDeviceContext2DConfig; @@ -228,4 +223,17 @@ typedef struct _NPDeviceContext2D } u; } NPDeviceContext2D; +/* 3D -----------------------------------------------------------------------*/ + +#define NPPepper3DDevice 2 + +typedef struct _NPDeviceContext3DConfig { +} NPDeviceContext3DConfig; + +typedef struct _NPDeviceContext3D +{ + void* buffer; + int32 bufferLength; +} NPDeviceContext3D; + #endif /* _NP_EXTENSIONS_H_ */ diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc new file mode 100644 index 0000000..db1ca2e --- /dev/null +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -0,0 +1,262 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/plugins/npapi_extension_thunk.h" + +#include "base/logging.h" +#include "third_party/npapi/bindings/npapi_extensions.h" +#include "webkit/glue/plugins/plugin_instance.h" +#include "webkit/glue/webplugin.h" +#include "webkit/glue/webplugin_delegate.h" +//#include "third_party/npapi/bindings/npruntime.h" + +#if defined(ENABLE_PEPPER) + +// FindInstance() +// Finds a PluginInstance from an NPP. +// The caller must take a reference if needed. +static NPAPI::PluginInstance* FindInstance(NPP id) { + if (id == NULL) { + NOTREACHED(); + return NULL; + } + return static_cast<NPAPI::PluginInstance*>(id->ndata); +} + +// 2D device API --------------------------------------------------------------- + +static NPError Device2DQueryCapability(NPP id, int32 capability, int32* value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value); + return NPERR_NO_ERROR; + } else { + return NPERR_GENERIC_ERROR; + } +} + +static NPError Device2DQueryConfig(NPP id, + const NPDeviceConfig* request, + NPDeviceConfig* obtain) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device2DQueryConfig( + static_cast<const NPDeviceContext2DConfig*>(request), + static_cast<NPDeviceContext2DConfig*>(obtain)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device2DInitializeContext(NPP id, + const NPDeviceConfig* config, + NPDeviceContext* context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device2DInitializeContext( + static_cast<const NPDeviceContext2DConfig*>(config), + static_cast<NPDeviceContext2D*>(context)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device2DSetStateContext(NPP id, + NPDeviceContext* context, + int32 state, + int32 value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device2DSetStateContext( + static_cast<NPDeviceContext2D*>(context), state, value); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device2DGetStateContext(NPP id, + NPDeviceContext* context, + int32 state, + int32* value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device2DGetStateContext( + static_cast<NPDeviceContext2D*>(context), state, value); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device2DFlushContext(NPP id, + NPDeviceContext* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + NPError err = plugin->webplugin()->delegate()->Device2DFlushContext( + id, static_cast<NPDeviceContext2D*>(context), callback, user_data); + + // Invoke the callback to inform the caller the work was done. + // TODO(brettw) this is probably not how we want this to work, this should + // happen when the frame is painted so the plugin knows when it can draw + // the next frame. + if (callback != NULL) + (*callback)(id, context, err, user_data); + + // Return any errors. + return err; + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device2DDestroyContext(NPP id, + NPDeviceContext* context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device2DDestroyContext( + static_cast<NPDeviceContext2D*>(context)); + } + return NPERR_GENERIC_ERROR; +} + +// 3D device API --------------------------------------------------------------- + +static NPError Device3DQueryCapability(NPP id, int32 capability, int32* value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); + return NPERR_NO_ERROR; + } else { + return NPERR_GENERIC_ERROR; + } +} + +static NPError Device3DQueryConfig(NPP id, + const NPDeviceConfig* request, + NPDeviceConfig* obtain) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DQueryConfig( + static_cast<const NPDeviceContext3DConfig*>(request), + static_cast<NPDeviceContext3DConfig*>(obtain)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DInitializeContext(NPP id, + const NPDeviceConfig* config, + NPDeviceContext* context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DInitializeContext( + static_cast<const NPDeviceContext3DConfig*>(config), + static_cast<NPDeviceContext3D*>(context)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DSetStateContext(NPP id, + NPDeviceContext* context, + int32 state, + int32 value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DSetStateContext( + static_cast<NPDeviceContext3D*>(context), state, value); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DGetStateContext(NPP id, + NPDeviceContext* context, + int32 state, + int32* value) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DGetStateContext( + static_cast<NPDeviceContext3D*>(context), state, value); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DFlushContext(NPP id, + NPDeviceContext* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DFlushContext( + id, static_cast<NPDeviceContext3D*>(context), callback, user_data); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DDestroyContext(NPP id, + NPDeviceContext* context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DDestroyContext( + static_cast<NPDeviceContext3D*>(context)); + } + return NPERR_GENERIC_ERROR; +} + +// ----------------------------------------------------------------------------- + +static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { + static NPDevice device_2d = { + Device2DQueryCapability, + Device2DQueryConfig, + Device2DInitializeContext, + Device2DSetStateContext, + Device2DGetStateContext, + Device2DFlushContext, + Device2DDestroyContext, + }; + static NPDevice device_3d = { + Device3DQueryCapability, + Device3DQueryConfig, + Device3DInitializeContext, + Device3DSetStateContext, + Device3DGetStateContext, + Device3DFlushContext, + Device3DDestroyContext, + }; + + switch (device_id) { + case NPPepper2DDevice: + return const_cast<NPDevice*>(&device_2d); + case NPPepper3DDevice: + return const_cast<NPDevice*>(&device_3d); + default: + return NULL; + } +} + +namespace NPAPI { + +NPError GetPepperExtensionsFunctions(void* value) { + static const NPExtensions kExtensions = { + &AcquireDevice, + }; + + // Return a pointer to the canonical function table. + NPExtensions* extensions = const_cast<NPExtensions*>(&kExtensions); + NPExtensions** exts = reinterpret_cast<NPExtensions**>(value); + *exts = extensions; + return NPERR_NO_ERROR; +} + +} // namespace NPAPI + +#else // Not compiling with pepper support + +namespace NPAPI { + +// This NOP function implements the getter for the extensions when the +// extensions aren't available. +NPError GetPepperExtensionsFunctions(void* value) { + return NPERR_GENERIC_ERROR; +} + +} // namespace NPAPI + +#endif // defined(ENABLE_PEPPER) + diff --git a/webkit/glue/plugins/npapi_extension_thunk.h b/webkit/glue/plugins/npapi_extension_thunk.h new file mode 100644 index 0000000..fada6bc --- /dev/null +++ b/webkit/glue/plugins/npapi_extension_thunk.h @@ -0,0 +1,23 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_NPAPI_EXTENSION_THUNK_H_ +#define WEBKIT_GLUE_PLUGINS_NPAPI_EXTENSION_THUNK_H_ + +#include "third_party/npapi/bindings/npapi_extensions.h" + +// This file implements forwarding for the NPAPI "Pepper" extensions through to +// the WebPluginDelegate associated with the plugin. + +namespace NPAPI { + +// Implements NPN_GetValue for the case of NPNVPepperExtensions. The function +// pointers in the returned structure implement all the extensions. +NPError GetPepperExtensionsFunctions(void* value); + +} // namespace NPAPI + +#endif // WEBKIT_GLUE_PLUGINS_NPAPI_EXTENSION_THUNK_H_ + + diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index 21240c1..291aa13 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -20,6 +20,7 @@ #include "webkit/glue/webplugininfo.h" #include "webkit/glue/webplugin_delegate.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/plugins/npapi_extension_thunk.h" #include "webkit/glue/plugins/plugin_instance.h" #include "webkit/glue/plugins/plugin_lib.h" #include "webkit/glue/plugins/plugin_list.h" @@ -29,8 +30,18 @@ using WebKit::WebBindings; -namespace NPAPI -{ +// Finds a PluginInstance from an NPP. +// The caller must take a reference if needed. +static NPAPI::PluginInstance* FindInstance(NPP id) { + if (id == NULL) { + NOTREACHED(); + return NULL; + } + return reinterpret_cast<NPAPI::PluginInstance*>(id->ndata); +} + +namespace NPAPI { + scoped_refptr<PluginHost> PluginHost::singleton_; PluginHost::PluginHost() { @@ -151,7 +162,7 @@ void PluginHost::PatchNPNetscapeFuncs(NPNetscapeFuncs* overrides) { host_funcs_.enumerate = overrides->enumerate; } -bool PluginHost::SetPostData(const char *buf, +bool PluginHost::SetPostData(const char* buf, uint32 length, std::vector<std::string>* names, std::vector<std::string>* values, @@ -179,8 +190,8 @@ bool PluginHost::SetPostData(const char *buf, { GETVALUE, GETNAME, DONE, GETVALUE }, { GETDATA, GETDATA, DONE, GETDATA } }; std::string name, value; - char *ptr = (char*)buf; - char *start = ptr; + const char* ptr = static_cast<const char*>(buf); + const char* start = ptr; int state = GETNAME; // initial state bool done = false; bool err = false; @@ -209,42 +220,41 @@ bool PluginHost::SetPostData(const char *buf, // Take action based on the new state. if (state != newstate) { switch (newstate) { - case GETNAME: - // Got a value. - value = std::string(start, ptr - start); - TrimWhitespace(value, TRIM_ALL, &value); - // If the name field is empty, we'll skip this header - // but we won't error out. - if (!name.empty() && name != "content-length") { - names->push_back(name); - values->push_back(value); - } - start = ptr + 1; - break; - case GETVALUE: - // Got a header. - name = StringToLowerASCII(std::string(start, ptr - start)); - TrimWhitespace(name, TRIM_ALL, &name); - start = ptr + 1; - break; - case GETDATA: - { - // Finished headers, now get body - if (*ptr) + case GETNAME: + // Got a value. + value = std::string(start, ptr - start); + TrimWhitespace(value, TRIM_ALL, &value); + // If the name field is empty, we'll skip this header + // but we won't error out. + if (!name.empty() && name != "content-length") { + names->push_back(name); + values->push_back(value); + } start = ptr + 1; - size_t previous_size = body->size(); - size_t new_body_size = length - static_cast<int>(start - buf); - body->resize(previous_size + new_body_size); - if (!body->empty()) - memcpy(&body->front() + previous_size, start, new_body_size); - done = true; - break; - } - case ERR: - // error - err = true; - done = true; - break; + break; + case GETVALUE: + // Got a header. + name = StringToLowerASCII(std::string(start, ptr - start)); + TrimWhitespace(name, TRIM_ALL, &name); + start = ptr + 1; + break; + case GETDATA: { + // Finished headers, now get body + if (*ptr) + start = ptr + 1; + size_t previous_size = body->size(); + size_t new_body_size = length - static_cast<int>(start - buf); + body->resize(previous_size + new_body_size); + if (!body->empty()) + memcpy(&body->front() + previous_size, start, new_body_size); + done = true; + break; + } + case ERR: + // error + err = true; + done = true; + break; } } state = newstate; @@ -254,22 +264,10 @@ bool PluginHost::SetPostData(const char *buf, return !err; } -} // namespace NPAPI +} // namespace NPAPI extern "C" { -// FindInstance() -// Finds a PluginInstance from an NPP. -// The caller must take a reference if needed. -NPAPI::PluginInstance* FindInstance(NPP id) { - if (id == NULL) { - NOTREACHED(); - return NULL; - } - - return (NPAPI::PluginInstance *)id->ndata; -} - // Allocates memory from the host's memory space. void* NPN_MemAlloc(uint32 size) { scoped_refptr<NPAPI::PluginHost> host = NPAPI::PluginHost::Singleton(); @@ -287,9 +285,8 @@ void* NPN_MemAlloc(uint32 size) { void NPN_MemFree(void* ptr) { scoped_refptr<NPAPI::PluginHost> host = NPAPI::PluginHost::Singleton(); if (host != NULL) { - if (ptr != NULL && ptr != (void*)-1) { + if (ptr != NULL && ptr != reinterpret_cast<void*>(-1)) free(ptr); - } } } @@ -301,22 +298,20 @@ uint32 NPN_MemFlush(uint32 size) { // This is for dynamic discovery of new plugins. // Should force a re-scan of the plugins directory to load new ones. -void NPN_ReloadPlugins(NPBool reloadPages) { +void NPN_ReloadPlugins(NPBool reloadPages) { // TODO: implement me DLOG(INFO) << "NPN_ReloadPlugin is not implemented yet."; } // Requests a range of bytes for a seekable stream. -NPError NPN_RequestRead(NPStream* stream, NPByteRange* range_list) { - if (!stream || !range_list) { +NPError NPN_RequestRead(NPStream* stream, NPByteRange* range_list) { + if (!stream || !range_list) return NPERR_GENERIC_ERROR; - } scoped_refptr<NPAPI::PluginInstance> plugin = reinterpret_cast<NPAPI::PluginInstance*>(stream->ndata); - if (!plugin.get()) { + if (!plugin.get()) return NPERR_GENERIC_ERROR; - } plugin->RequestRead(stream, range_list); return NPERR_NO_ERROR; @@ -377,7 +372,7 @@ NPError NPN_GetURLNotify(NPP id, return GetURLNotify(id, url, target, true, notify_data); } -NPError NPN_GetURL(NPP id, const char* url, const char* target) { +NPError NPN_GetURL(NPP id, const char* url, const char* target) { // Notes: // Request from the Plugin to fetch content either for the plugin // or to be placed into a browser window. @@ -487,22 +482,22 @@ static NPError PostURLNotify(NPP id, return NPERR_NO_ERROR; } -NPError NPN_PostURLNotify(NPP id, - const char* url, - const char* target, - uint32 len, - const char* buf, - NPBool file, - void* notify_data) { +NPError NPN_PostURLNotify(NPP id, + const char* url, + const char* target, + uint32 len, + const char* buf, + NPBool file, + void* notify_data) { return PostURLNotify(id, url, target, len, buf, file, true, notify_data); } -NPError NPN_PostURL(NPP id, - const char* url, - const char* target, - uint32 len, - const char* buf, - NPBool file) { +NPError NPN_PostURL(NPP id, + const char* url, + const char* target, + uint32 len, + const char* buf, + NPBool file) { // POSTs data to an URL, either from a temp file or a buffer. // If file is true, buf contains a temp file (which host will delete after // completing), and len contains the length of the filename. @@ -643,9 +638,8 @@ void NPN_InvalidateRegion(NPP id, NPRegion invalidRegion) { // very least, fetch the region's bounding box and pass it to InvalidateRect). scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); DCHECK(plugin.get() != NULL); - if (plugin.get() && plugin->webplugin()) { + if (plugin.get() && plugin->webplugin()) plugin->webplugin()->Invalidate(); - } } void NPN_ForceRedraw(NPP id) { @@ -667,122 +661,7 @@ void NPN_ForceRedraw(NPP id) { NOTIMPLEMENTED(); } -#if defined(PEPPER_APIS_ENABLED) -// Pepper 2D device API -------------------------------------------------------- - -static NPError Device2DQueryCapability(NPP id, int32 capability, int32* value) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value); - return NPERR_NO_ERROR; - } else { - return NPERR_GENERIC_ERROR; - } -} - -static NPError Device2DQueryConfig(NPP id, - const NPDeviceConfig* request, - NPDeviceConfig* obtain) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - return plugin->webplugin()->delegate()->Device2DQueryConfig( - static_cast<const NPDeviceContext2DConfig*>(request), - static_cast<NPDeviceContext2DConfig*>(obtain)); - } - return NPERR_GENERIC_ERROR; -} - -static NPError Device2DInitializeContext(NPP id, - const NPDeviceConfig* config, - NPDeviceContext* context) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - return plugin->webplugin()->delegate()->Device2DInitializeContext( - static_cast<const NPDeviceContext2DConfig*>(config), - static_cast<NPDeviceContext2D*>(context)); - } - return NPERR_GENERIC_ERROR; -} - -static NPError Device2DSetStateContext(NPP id, - NPDeviceContext* context, - int32 state, - int32 value) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - return plugin->webplugin()->delegate()->Device2DSetStateContext( - static_cast<NPDeviceContext2D*>(context), state, value); - } - return NPERR_GENERIC_ERROR; -} - -static NPError Device2DGetStateContext(NPP id, - NPDeviceContext* context, - int32 state, - int32* value) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - return plugin->webplugin()->delegate()->Device2DGetStateContext( - static_cast<NPDeviceContext2D*>(context), state, value); - } - return NPERR_GENERIC_ERROR; -} - -static NPError Device2DFlushContext(NPP id, - NPDeviceContext* context, - NPDeviceFlushContextCallbackPtr callback, - void* user_data) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - NPError err = plugin->webplugin()->delegate()->Device2DFlushContext( - static_cast<NPDeviceContext2D*>(context), callback, user_data); - - // Invoke the callback to inform the caller the work was done. - // TODO(brettw) this is probably not how we want this to work, this should - // happen when the frame is painted so the plugin knows when it can draw - // the next frame. - if (callback != NULL) - (*callback)(id, context, err, user_data); - - // Return any errors. - return err; - } - return NPERR_GENERIC_ERROR; -} - -static NPError Device2DDestroyContext(NPP id, - NPDeviceContext* context) { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - return plugin->webplugin()->delegate()->Device2DDestroyContext( - static_cast<NPDeviceContext2D*>(context)); - } - return NPERR_GENERIC_ERROR; -} - -// ----------------------------------------------------------------------------- - -static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { - static NPDevice device_2d = { - Device2DQueryCapability, - Device2DQueryConfig, - Device2DInitializeContext, - Device2DSetStateContext, - Device2DGetStateContext, - Device2DFlushContext, - Device2DDestroyContext, - }; - switch (device_id) { - case NPPepper2DDevice: - return const_cast<NPDevice*>(&device_2d); - default: - return NULL; - } -} - -#endif // defined(PEPPER_APIS_ENABLED) - -NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { +NPError NPN_GetValue(NPP id, NPNVariable variable, void* value) { // Allows the plugin to query the browser for information // // Variables: @@ -797,251 +676,223 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { NPError rv = NPERR_GENERIC_ERROR; switch (variable) { - case NPNVWindowNPObject: - { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - NPObject *np_object = plugin->webplugin()->GetWindowScriptNPObject(); - // Return value is expected to be retained, as - // described here: - // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> - if (np_object) { - WebBindings::retainObject(np_object); - void **v = (void **)value; - *v = np_object; + case NPNVWindowNPObject: { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + NPObject *np_object = plugin->webplugin()->GetWindowScriptNPObject(); + // Return value is expected to be retained, as + // described here: + // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> + if (np_object) { + WebBindings::retainObject(np_object); + void **v = (void **)value; + *v = np_object; + rv = NPERR_NO_ERROR; + } else { + NOTREACHED(); + } + break; + } + case NPNVPluginElementNPObject: { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + NPObject *np_object = plugin->webplugin()->GetPluginElement(); + // Return value is expected to be retained, as + // described here: + // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> + if (np_object) { + WebBindings::retainObject(np_object); + void** v = static_cast<void**>(value); + *v = np_object; + rv = NPERR_NO_ERROR; + } else { + NOTREACHED(); + } + break; + } + case NPNVnetscapeWindow: { + #if defined(OS_WIN) || defined(OS_LINUX) + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + gfx::PluginWindowHandle handle = plugin->window_handle(); + *((void**)value) = (void*)handle; rv = NPERR_NO_ERROR; - } else { - NOTREACHED(); + #else + NOTIMPLEMENTED(); + #endif + break; } - break; - } - case NPNVPluginElementNPObject: - { - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - NPObject *np_object = plugin->webplugin()->GetPluginElement(); - // Return value is expected to be retained, as - // described here: - // <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess> - if (np_object) { - WebBindings::retainObject(np_object); - void **v = (void **)value; - *v = np_object; + case NPNVjavascriptEnabledBool: { + // yes, JS is enabled. + *((void**)value) = (void*)1; rv = NPERR_NO_ERROR; - } else { - NOTREACHED(); + break; } - break; - } - case NPNVnetscapeWindow: - { -#if defined(OS_WIN) || defined(OS_LINUX) - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - gfx::PluginWindowHandle handle = plugin->window_handle(); - *((void**)value) = (void*)handle; - rv = NPERR_NO_ERROR; -#else - NOTIMPLEMENTED(); -#endif - break; - } - case NPNVjavascriptEnabledBool: - { - // yes, JS is enabled. - *((void**)value) = (void*)1; - rv = NPERR_NO_ERROR; - break; - } -#if defined(OS_LINUX) - case NPNVToolkit: - // Tell them we are GTK2. (The alternative is GTK 1.2.) - *reinterpret_cast<int*>(value) = NPNVGtk2; - rv = NPERR_NO_ERROR; - break; - - case NPNVSupportsXEmbedBool: - // Yes, we support XEmbed. - *reinterpret_cast<NPBool*>(value) = TRUE; - rv = NPERR_NO_ERROR; - break; -#endif - case NPNVSupportsWindowless: - { - NPBool* supports_windowless = reinterpret_cast<NPBool*>(value); - *supports_windowless = TRUE; - rv = NPERR_NO_ERROR; - break; - } - case NPNVprivateModeBool: - { - NPBool* private_mode = reinterpret_cast<NPBool*>(value); - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - *private_mode = plugin->webplugin()->IsOffTheRecord(); - rv = NPERR_NO_ERROR; - break; - } - case default_plugin::kMissingPluginStatusStart + - default_plugin::MISSING_PLUGIN_AVAILABLE: - // fall through - case default_plugin::kMissingPluginStatusStart + - default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: - { - // This is a hack for the default plugin to send notification to renderer. - // Even though we check if the plugin is the default plugin, we still need - // to worry about future standard change that may conflict with the - // variable definition, in order to avoid duplicate case clauses in this - // big switch statement. - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin->plugin_lib()->plugin_info().path.value() == - kDefaultPluginLibraryName) { - plugin->webplugin()->OnMissingPluginStatus( - variable - default_plugin::kMissingPluginStatusStart); + #if defined(OS_LINUX) + case NPNVToolkit: + // Tell them we are GTK2. (The alternative is GTK 1.2.) + *reinterpret_cast<int*>(value) = NPNVGtk2; + rv = NPERR_NO_ERROR; + break; + + case NPNVSupportsXEmbedBool: + // Yes, we support XEmbed. + *reinterpret_cast<NPBool*>(value) = TRUE; + rv = NPERR_NO_ERROR; + break; + #endif + case NPNVSupportsWindowless: { + NPBool* supports_windowless = reinterpret_cast<NPBool*>(value); + *supports_windowless = TRUE; + rv = NPERR_NO_ERROR; + break; } - break; - } -#if defined(OS_MACOSX) - case NPNVpluginDrawingModel: - { - // return the drawing model that was negotiated when we initialized. - scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - *reinterpret_cast<int*>(value) = plugin->drawing_model(); - rv = NPERR_NO_ERROR; - break; - } - case NPNVsupportsQuickDrawBool: - { - // we do not admit to supporting the QuickDraw drawing model. - NPBool* supports_qd = reinterpret_cast<NPBool*>(value); - *supports_qd = FALSE; - rv = NPERR_NO_ERROR; - break; - } - case NPNVsupportsCoreGraphicsBool: - case NPNVsupportsCarbonBool: - case NPNVsupportsCocoaBool: - { - // we do support these drawing and event models. - NPBool* supports_model = reinterpret_cast<NPBool*>(value); - *supports_model = TRUE; - rv = NPERR_NO_ERROR; - break; - } - case NPNVsupportsOpenGLBool: - case NPNVsupportsCoreAnimationBool: - { - // we do not support these drawing and event models. - NPBool* supports_model = reinterpret_cast<NPBool*>(value); - *supports_model = FALSE; - rv = NPERR_NO_ERROR; - break; - } -#endif -#if defined(PEPPER_APIS_ENABLED) - case NPNVPepperExtensions: - { - static const NPExtensions kExtensions = { - AcquireDevice, - }; - // Return a pointer to the canonical function table. - NPExtensions* extensions = const_cast<NPExtensions*>(&kExtensions); - NPExtensions** exts = reinterpret_cast<NPExtensions**>(value); - *exts = extensions; - rv = NPERR_NO_ERROR; - break; - } -#endif // defined(PEPPER_APIS_ENABLED) - default: - { - // TODO: implement me - DLOG(INFO) << "NPN_GetValue(" << variable << ") is not implemented yet."; - break; - } + case NPNVprivateModeBool: { + NPBool* private_mode = reinterpret_cast<NPBool*>(value); + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + *private_mode = plugin->webplugin()->IsOffTheRecord(); + rv = NPERR_NO_ERROR; + break; + } + case default_plugin::kMissingPluginStatusStart + + default_plugin::MISSING_PLUGIN_AVAILABLE: + // fall through + case default_plugin::kMissingPluginStatusStart + + default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD: { + // This is a hack for the default plugin to send notification to + // renderer. Even though we check if the plugin is the default plugin, + // we still need to worry about future standard change that may conflict + // with the variable definition, in order to avoid duplicate case clauses + // in this big switch statement. + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin->plugin_lib()->plugin_info().path.value() == + kDefaultPluginLibraryName) { + plugin->webplugin()->OnMissingPluginStatus( + variable - default_plugin::kMissingPluginStatusStart); + } + break; + } + #if defined(OS_MACOSX) + case NPNVpluginDrawingModel: { + // return the drawing model that was negotiated when we initialized. + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + *reinterpret_cast<int*>(value) = plugin->drawing_model(); + rv = NPERR_NO_ERROR; + break; + } + case NPNVsupportsQuickDrawBool: { + // we do not admit to supporting the QuickDraw drawing model. + NPBool* supports_qd = reinterpret_cast<NPBool*>(value); + *supports_qd = FALSE; + rv = NPERR_NO_ERROR; + break; + } + case NPNVsupportsCoreGraphicsBool: + case NPNVsupportsCarbonBool: + case NPNVsupportsCocoaBool: { + // we do support these drawing and event models. + NPBool* supports_model = reinterpret_cast<NPBool*>(value); + *supports_model = TRUE; + rv = NPERR_NO_ERROR; + break; + } + case NPNVsupportsOpenGLBool: + case NPNVsupportsCoreAnimationBool: { + // we do not support these drawing and event models. + NPBool* supports_model = reinterpret_cast<NPBool*>(value); + *supports_model = FALSE; + rv = NPERR_NO_ERROR; + break; + } + #endif // OS_MACOSX + case NPNVPepperExtensions: + rv = NPAPI::GetPepperExtensionsFunctions(value); + break; + default: + DLOG(INFO) << "NPN_GetValue(" << variable << ") is not implemented yet."; + break; } return rv; } -NPError NPN_SetValue(NPP id, NPPVariable variable, void *value) { +NPError NPN_SetValue(NPP id, NPPVariable variable, void* value) { // Allows the plugin to set various modes scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - switch(variable) - { - case NPPVpluginWindowBool: - { - // Sets windowless mode for display of the plugin - // Note: the documentation at http://developer.mozilla.org/en/docs/NPN_SetValue - // is wrong. When value is NULL, the mode is set to true. This is the same - // way Mozilla works. - plugin->set_windowless(value == 0); - return NPERR_NO_ERROR; - } - case NPPVpluginTransparentBool: - { - // Sets transparent mode for display of the plugin - // - // Transparent plugins require the browser to paint the background - // before having the plugin paint. By default, windowless plugins - // are transparent. Making a windowless plugin opaque means that - // the plugin does not require the browser to paint the background. - // - bool mode = (value != 0); - plugin->set_transparent(mode); - return NPERR_NO_ERROR; - } - case NPPVjavascriptPushCallerBool: - // Specifies whether you are pushing or popping the JSContext off - // the stack - // TODO: implement me - DLOG(INFO) << "NPN_SetValue(NPPVJavascriptPushCallerBool) is not implemented."; - return NPERR_GENERIC_ERROR; - case NPPVpluginKeepLibraryInMemory: - // Tells browser that plugin library should live longer than usual. - // TODO: implement me - DLOG(INFO) << "NPN_SetValue(NPPVpluginKeepLibraryInMemory) is not implemented."; - return NPERR_GENERIC_ERROR; -#if defined(OS_MACOSX) - case NPPVpluginDrawingModel: - { - // we only admit to supporting the CoreGraphics drawing model. The logic - // here is that our QuickDraw plugin support is so rudimentary that we - // only want to use it as a fallback to keep plugins from crashing: if - // a plugin knows enough to ask, we want them to use CoreGraphics. - int model = reinterpret_cast<int>(value); - if (model == NPDrawingModelCoreGraphics) { - plugin->set_drawing_model(model); + switch(variable) { + case NPPVpluginWindowBool: { + // Sets windowless mode for display of the plugin + // Note: the documentation at + // http://developer.mozilla.org/en/docs/NPN_SetValue is wrong. When + // value is NULL, the mode is set to true. This is the same way Mozilla + // works. + plugin->set_windowless(value == 0); return NPERR_NO_ERROR; } - return NPERR_GENERIC_ERROR; - } - case NPPVpluginEventModel: - { - // we support Carbon and Cocoa event models - int model = reinterpret_cast<int>(value); - switch (model) { - case NPEventModelCarbon: - case NPEventModelCocoa: - plugin->set_event_model(model); + case NPPVpluginTransparentBool: { + // Sets transparent mode for display of the plugin + // + // Transparent plugins require the browser to paint the background + // before having the plugin paint. By default, windowless plugins + // are transparent. Making a windowless plugin opaque means that + // the plugin does not require the browser to paint the background. + bool mode = (value != 0); + plugin->set_transparent(mode); + return NPERR_NO_ERROR; + } + case NPPVjavascriptPushCallerBool: + // Specifies whether you are pushing or popping the JSContext off. + // the stack + // TODO: implement me + DLOG(INFO) << + "NPN_SetValue(NPPVJavascriptPushCallerBool) is not implemented."; + return NPERR_GENERIC_ERROR; + case NPPVpluginKeepLibraryInMemory: + // Tells browser that plugin library should live longer than usual. + // TODO: implement me + DLOG(INFO) << + "NPN_SetValue(NPPVpluginKeepLibraryInMemory) is not implemented."; + return NPERR_GENERIC_ERROR; + #if defined(OS_MACOSX) + case NPPVpluginDrawingModel: { + // We only admit to supporting the CoreGraphics drawing model. The logic + // here is that our QuickDraw plugin support is so rudimentary that we + // only want to use it as a fallback to keep plugins from crashing: if + // a plugin knows enough to ask, we want them to use CoreGraphics. + int model = reinterpret_cast<int>(value); + if (model == NPDrawingModelCoreGraphics) { + plugin->set_drawing_model(model); return NPERR_NO_ERROR; - break; + } + return NPERR_GENERIC_ERROR; } - return NPERR_GENERIC_ERROR; - } -#endif - default: - // TODO: implement me - DLOG(INFO) << "NPN_SetValue(" << variable << ") is not implemented."; - break; + case NPPVpluginEventModel: { + // we support Carbon and Cocoa event models + int model = reinterpret_cast<int>(value); + switch (model) { + case NPEventModelCarbon: + case NPEventModelCocoa: + plugin->set_event_model(model); + return NPERR_NO_ERROR; + break; + } + return NPERR_GENERIC_ERROR; + } + #endif + default: + // TODO: implement me + DLOG(INFO) << "NPN_SetValue(" << variable << ") is not implemented."; + break; } NOTREACHED(); return NPERR_GENERIC_ERROR; } -void *NPN_GetJavaEnv() { +void* NPN_GetJavaEnv() { // TODO: implement me DLOG(INFO) << "NPN_GetJavaEnv is not implemented."; return NULL; } -void *NPN_GetJavaPeer(NPP) { +void* NPN_GetJavaPeer(NPP) { // TODO: implement me DLOG(INFO) << "NPN_GetJavaPeer is not implemented."; return NULL; @@ -1049,32 +900,29 @@ void *NPN_GetJavaPeer(NPP) { void NPN_PushPopupsEnabledState(NPP id, NPBool enabled) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { + if (plugin) plugin->PushPopupsEnabledState(enabled); - } } void NPN_PopPopupsEnabledState(NPP id) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { + if (plugin) plugin->PopPopupsEnabledState(); - } } void NPN_PluginThreadAsyncCall(NPP id, - void (*func)(void *), - void *userData) { + void (*func)(void*), + void* user_data) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - if (plugin) { - plugin->PluginThreadAsyncCall(func, userData); - } + if (plugin) + plugin->PluginThreadAsyncCall(func, user_data); } NPError NPN_GetValueForURL(NPP id, NPNURLVariable variable, - const char *url, - char **value, - uint32_t *len) { + const char* url, + char** value, + uint32* len) { if (!id) return NPERR_INVALID_PARAM; @@ -1122,9 +970,9 @@ NPError NPN_GetValueForURL(NPP id, NPError NPN_SetValueForURL(NPP id, NPNURLVariable variable, - const char *url, - const char *value, - uint32_t len) { + const char* url, + const char* value, + uint32 len) { if (!id) return NPERR_INVALID_PARAM; @@ -1158,15 +1006,15 @@ NPError NPN_SetValueForURL(NPP id, } NPError NPN_GetAuthenticationInfo(NPP id, - const char *protocol, - const char *host, + const char* protocol, + const char* host, int32_t port, - const char *scheme, - const char *realm, - char **username, - uint32_t *ulen, - char **password, - uint32_t *plen) { + const char* scheme, + const char* realm, + char** username, + uint32* ulen, + char** password, + uint32* plen) { if (!id || !protocol || !host || !scheme || !realm || !username || !ulen || !password || !plen) return NPERR_INVALID_PARAM; @@ -1208,4 +1056,5 @@ NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, *destY = sourceY; return FALSE; } -} // extern "C" + +} // extern "C" diff --git a/webkit/glue/plugins/plugin_lib.cc b/webkit/glue/plugins/plugin_lib.cc index 1ca03ed..0e5ccf6 100644 --- a/webkit/glue/plugins/plugin_lib.cc +++ b/webkit/glue/plugins/plugin_lib.cc @@ -13,8 +13,7 @@ #include "webkit/glue/plugins/plugin_host.h" #include "webkit/glue/plugins/plugin_list.h" -namespace NPAPI -{ +namespace NPAPI { const char kPluginLibrariesLoadedCounter[] = "PluginLibrariesLoaded"; const char kPluginInstancesActiveCounter[] = "PluginInstancesActive"; diff --git a/webkit/glue/plugins/plugin_lib.h b/webkit/glue/plugins/plugin_lib.h index 18efbef..6af8f9c 100644 --- a/webkit/glue/plugins/plugin_lib.h +++ b/webkit/glue/plugins/plugin_lib.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_LIB_H__ -#define WEBKIT_GLUE_PLUGIN_PLUGIN_LIB_H__ +#ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_LIB_H_ +#define WEBKIT_GLUE_PLUGIN_PLUGIN_LIB_H_ #include <string> #include <vector> @@ -18,8 +18,7 @@ struct WebPluginInfo; -namespace NPAPI -{ +namespace NPAPI { class PluginInstance; @@ -97,19 +96,19 @@ class PluginLib : public base::RefCounted<PluginLib> { private: bool internal_; // True for plugins that are built-in into chrome binaries. - WebPluginInfo web_plugin_info_; // supported mime types, description - base::NativeLibrary library_; // the opened library reference - NPPluginFuncs plugin_funcs_; // the struct of plugin side functions - bool initialized_; // is the plugin initialized - NPSavedData *saved_data_; // persisted plugin info for NPAPI - int instance_count_; // count of plugins in use + WebPluginInfo web_plugin_info_; // Supported mime types, description + base::NativeLibrary library_; // The opened library reference. + NPPluginFuncs plugin_funcs_; // The struct of plugin side functions. + bool initialized_; // Is the plugin initialized? + NPSavedData *saved_data_; // Persisted plugin info for NPAPI. + int instance_count_; // Count of plugins in use. // Function pointers to entry points into the plugin. PluginEntryPoints entry_points_; - DISALLOW_EVIL_CONSTRUCTORS(PluginLib); + DISALLOW_COPY_AND_ASSIGN(PluginLib); }; -} // namespace NPAPI +} // namespace NPAPI -#endif // WEBKIT_GLUE_PLUGIN_PLUGIN_LIB_H__ +#endif // WEBKIT_GLUE_PLUGIN_PLUGIN_LIB_H_ diff --git a/webkit/glue/plugins/webplugin_2d_device_delegate.h b/webkit/glue/plugins/webplugin_2d_device_delegate.h new file mode 100644 index 0000000..55b50b7 --- /dev/null +++ b/webkit/glue/plugins/webplugin_2d_device_delegate.h @@ -0,0 +1,57 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_WEBPLUGIN_2D_DEVICE_DELEGATE_H_ +#define WEBKIT_GLUE_PLUGINS_WEBPLUGIN_2D_DEVICE_DELEGATE_H_ + +#include "base/basictypes.h" +#include "third_party/npapi/bindings/npapi_extensions.h" + +namespace webkit_glue { + +// Interface for the NPAPI 2D device extension. This class implements "NOP" +// versions of all these functions so it can be used seamlessly by the +// "regular" plugin delegate while being overridden by the "pepper" one. +class WebPlugin2DDeviceDelegate { + public: + virtual NPError Device2DQueryCapability(int32 capability, int32* value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device2DQueryConfig(const NPDeviceContext2DConfig* request, + NPDeviceContext2DConfig* obtain) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device2DInitializeContext( + const NPDeviceContext2DConfig* config, + NPDeviceContext2D* context) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device2DSetStateContext(NPDeviceContext2D* context, + int32 state, + int32 value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device2DGetStateContext(NPDeviceContext2D* context, + int32 state, + int32* value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device2DFlushContext(NPP id, + NPDeviceContext2D* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device2DDestroyContext(NPDeviceContext2D* context) { + return NPERR_GENERIC_ERROR; + } + + protected: + WebPlugin2DDeviceDelegate() {} + virtual ~WebPlugin2DDeviceDelegate() {} +}; + +} // namespace webkit_glue + +#endif // WEBKIT_GLUE_PLUGINS_WEBPLUGIN_2D_DEVICE_DELEGATE_H_ diff --git a/webkit/glue/plugins/webplugin_3d_device_delegate.h b/webkit/glue/plugins/webplugin_3d_device_delegate.h new file mode 100644 index 0000000..78dbe0e --- /dev/null +++ b/webkit/glue/plugins/webplugin_3d_device_delegate.h @@ -0,0 +1,57 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_WEBPLUGIN_3D_DEVICE_DELEGATE_H_ +#define WEBKIT_GLUE_PLUGINS_WEBPLUGIN_3D_DEVICE_DELEGATE_H_ + +#include "base/basictypes.h" +#include "third_party/npapi/bindings/npapi_extensions.h" + +namespace webkit_glue { + +// Interface for the NPAPI 3D device extension. This class implements "NOP" +// versions of all these functions so it can be used seamlessly by the +// "regular" plugin delegate while being overridden by the "pepper" one. +class WebPlugin3DDeviceDelegate { + public: + virtual NPError Device3DQueryCapability(int32 capability, int32* value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DQueryConfig(const NPDeviceContext3DConfig* request, + NPDeviceContext3DConfig* obtain) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DInitializeContext( + const NPDeviceContext3DConfig* config, + NPDeviceContext3D* context) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DSetStateContext(NPDeviceContext3D* context, + int32 state, + int32 value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DGetStateContext(NPDeviceContext3D* context, + int32 state, + int32* value) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DFlushContext(NPP id, + NPDeviceContext3D* context, + NPDeviceFlushContextCallbackPtr callback, + void* user_data) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DDestroyContext(NPDeviceContext3D* context) { + return NPERR_GENERIC_ERROR; + } + + protected: + WebPlugin3DDeviceDelegate() {} + virtual ~WebPlugin3DDeviceDelegate() {} +}; + +} // namespace webkit_glue + +#endif // WEBKIT_GLUE_PLUGINS_WEBPLUGIN_3D_DEVICE_DELEGATE_H_ diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h index 6c38080..2920152 100644 --- a/webkit/glue/webplugin_delegate.h +++ b/webkit/glue/webplugin_delegate.h @@ -14,6 +14,8 @@ #include "third_party/npapi/bindings/npapi.h" #include "third_party/npapi/bindings/npapi_extensions.h" #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" +#include "webkit/glue/plugins/webplugin_2d_device_delegate.h" +#include "webkit/glue/plugins/webplugin_3d_device_delegate.h" class FilePath; class GURL; @@ -34,7 +36,8 @@ class WebPlugin; class WebPluginResourceClient; // This is the interface that a plugin implementation needs to provide. -class WebPluginDelegate { +class WebPluginDelegate : public WebPlugin2DDeviceDelegate, + public WebPlugin3DDeviceDelegate { public: virtual ~WebPluginDelegate() {} @@ -127,41 +130,6 @@ class WebPluginDelegate { bool notify_needed, intptr_t notify_data, intptr_t stream) = 0; - - // The following methods are for use in implementing Pepper renderers. - // They should not be called outside of that context. - - // Pepper 2D device API. - virtual NPError Device2DQueryCapability(int32 capability, int32* value) { - return NPERR_GENERIC_ERROR; - } - virtual NPError Device2DQueryConfig(const NPDeviceContext2DConfig* request, - NPDeviceContext2DConfig* obtain) { - return NPERR_GENERIC_ERROR; - } - virtual NPError Device2DInitializeContext( - const NPDeviceContext2DConfig* config, - NPDeviceContext2D* context) { - return NPERR_GENERIC_ERROR; - } - virtual NPError Device2DSetStateContext(NPDeviceContext2D* context, - int32 state, - int32 value) { - return NPERR_GENERIC_ERROR; - } - virtual NPError Device2DGetStateContext(NPDeviceContext2D* context, - int32 state, - int32* value) { - return NPERR_GENERIC_ERROR; - } - virtual NPError Device2DFlushContext(NPDeviceContext2D* context, - NPDeviceFlushContextCallbackPtr callback, - void* user_data) { - return NPERR_GENERIC_ERROR; - } - virtual NPError Device2DDestroyContext(NPDeviceContext2D* context) { - return NPERR_GENERIC_ERROR; - } }; } // namespace webkit_glue diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 8fed312..eaf5fff 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -261,6 +261,8 @@ 'glue/plugins/gtk_plugin_container.cc', 'glue/plugins/gtk_plugin_container_manager.h', 'glue/plugins/gtk_plugin_container_manager.cc', + 'glue/plugins/npapi_extension_thunk.cc', + 'glue/plugins/npapi_extension_thunk.h', 'glue/plugins/plugin_constants_win.h', 'glue/plugins/plugin_host.cc', 'glue/plugins/plugin_host.h', @@ -285,6 +287,8 @@ 'glue/plugins/plugin_string_stream.cc', 'glue/plugins/plugin_string_stream.h', 'glue/plugins/plugin_stubs.cc', + 'glue/plugins/webplugin_2d_device_delegate.h', + 'glue/plugins/webplugin_3d_device_delegate.h', 'glue/plugins/webplugin_delegate_impl.cc', 'glue/plugins/webplugin_delegate_impl.h', 'glue/plugins/webplugin_delegate_impl_gtk.cc', |