summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 15:02:09 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 15:02:09 +0000
commitc571ef43567e267c677521f044bce9f401b344d1 (patch)
tree527294589acb53c9d119c0a427930e65f9a1fc53 /webkit
parentf72a657413fea276d186e65a59f47216e3a9a053 (diff)
downloadchromium_src-c571ef43567e267c677521f044bce9f401b344d1.zip
chromium_src-c571ef43567e267c677521f044bce9f401b344d1.tar.gz
chromium_src-c571ef43567e267c677521f044bce9f401b344d1.tar.bz2
Make main.cpp Google style and conver the filename and headers of the other
files (I didn't change the other .cc files since I think we'll delete most of them when I figure out what's going on). Add Skia dependency so we can add graphics later. BUG=none TEST=none Review URL: http://codereview.chromium.org/273066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/pepper_test_plugin/main.cc338
-rw-r--r--webkit/tools/pepper_test_plugin/main.cpp513
-rw-r--r--webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp11
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.cc (renamed from webkit/tools/pepper_test_plugin/PluginObject.cpp)21
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.h (renamed from webkit/tools/pepper_test_plugin/PluginObject.h)51
-rw-r--r--webkit/tools/pepper_test_plugin/test_object.cc (renamed from webkit/tools/pepper_test_plugin/TestObject.cpp)25
-rw-r--r--webkit/tools/pepper_test_plugin/test_object.h (renamed from webkit/tools/pepper_test_plugin/TestObject.h)17
7 files changed, 409 insertions, 567 deletions
diff --git a/webkit/tools/pepper_test_plugin/main.cc b/webkit/tools/pepper_test_plugin/main.cc
new file mode 100644
index 0000000..0edba17
--- /dev/null
+++ b/webkit/tools/pepper_test_plugin/main.cc
@@ -0,0 +1,338 @@
+/*
+ IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
+ consideration of your agreement to the following terms, and your use, installation,
+ modification or redistribution of this Apple software constitutes acceptance of these
+ terms. If you do not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and subject to these
+ terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in
+ this original Apple software (the "Apple Software"), to use, reproduce, modify and
+ redistribute the Apple Software, with or without modifications, in source and/or binary
+ forms; provided that if you redistribute the Apple Software in its entirety and without
+ modifications, you must retain this notice and the following text and disclaimers in all
+ such redistributions of the Apple Software. Neither the name, trademarks, service marks
+ or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
+ the Apple Software without specific prior written permission from Apple. Except as expressly
+ stated in this notice, no other rights or licenses, express or implied, are granted by Apple
+ herein, including but not limited to any patent rights that may be infringed by your
+ derivative works or by other works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
+ EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
+ USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
+ REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
+ WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
+ OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "webkit/tools/pepper_test_plugin/plugin_object.h"
+
+#ifdef WIN32
+#define strcasecmp _stricmp
+#define NPAPI WINAPI
+#else
+#define NPAPI
+#endif
+
+static void Log(NPP instance, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ char message[2048] = "PLUGIN: ";
+ vsprintf(message + strlen(message), format, args);
+ va_end(args);
+
+ NPObject* window_object = 0;
+ NPError error = browser->getvalue(instance, NPNVWindowNPObject,
+ &window_object);
+ if (error != NPERR_NO_ERROR) {
+ fprintf(stderr, "Failed to retrieve window object while logging: %s\n",
+ message);
+ return;
+ }
+
+ NPVariant console_variant;
+ if (!browser->getproperty(instance, window_object,
+ browser->getstringidentifier("console"),
+ &console_variant)) {
+ fprintf(stderr, "Failed to retrieve console object while logging: %s\n",
+ message);
+ browser->releaseobject(window_object);
+ return;
+ }
+
+ NPObject* console_object = NPVARIANT_TO_OBJECT(console_variant);
+
+ NPVariant message_variant;
+ STRINGZ_TO_NPVARIANT(message, message_variant);
+
+ NPVariant result;
+ if (!browser->invoke(instance, console_object,
+ browser->getstringidentifier("log"),
+ &message_variant, 1, &result)) {
+ fprintf(stderr, "Failed to invoke console.log while logging: %s\n",
+ message);
+ browser->releaseobject(console_object);
+ browser->releaseobject(window_object);
+ return;
+ }
+
+ browser->releasevariantvalue(&result);
+ browser->releaseobject(console_object);
+ browser->releaseobject(window_object);
+}
+
+// Plugin entry points
+extern "C" {
+
+NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs
+#if defined(OS_LINUX)
+ , NPPluginFuncs* plugin_funcs
+#endif
+ );
+NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs);
+void NPAPI NP_Shutdown();
+
+#if defined(OS_LINUX)
+NPError NP_GetValue(NPP instance, NPPVariable variable, void* value);
+const char* NP_GetMIMEDescription();
+#endif
+
+} // extern "C"
+
+// Plugin entry points
+NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs
+#if defined(OS_LINUX)
+ , NPPluginFuncs* plugin_funcs
+#endif
+ ) {
+ browser = browser_funcs;
+#if defined(OS_LINUX)
+ return NP_GetEntryPoints(plugin_funcs);
+#else
+ return NPERR_NO_ERROR;
+#endif
+}
+
+NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
+ plugin_funcs->version = 11;
+ plugin_funcs->size = sizeof(plugin_funcs);
+ plugin_funcs->newp = NPP_New;
+ plugin_funcs->destroy = NPP_Destroy;
+ plugin_funcs->setwindow = NPP_SetWindow;
+ plugin_funcs->newstream = NPP_NewStream;
+ plugin_funcs->destroystream = NPP_DestroyStream;
+ plugin_funcs->asfile = NPP_StreamAsFile;
+ plugin_funcs->writeready = NPP_WriteReady;
+ plugin_funcs->write = (NPP_WriteProcPtr)NPP_Write;
+ plugin_funcs->print = NPP_Print;
+ plugin_funcs->event = NPP_HandleEvent;
+ plugin_funcs->urlnotify = NPP_URLNotify;
+ plugin_funcs->getvalue = NPP_GetValue;
+ plugin_funcs->setvalue = NPP_SetValue;
+
+ return NPERR_NO_ERROR;
+}
+
+void NPAPI NP_Shutdown(void) {
+}
+
+static void executeScript(const PluginObject* obj, const char* script);
+
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData* saved) {
+ if (browser->version >= 14) {
+ PluginObject* obj = (PluginObject*)browser->createobject(instance,
+ GetPluginClass());
+
+ for (int i = 0; i < argc; i++) {
+ if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad) {
+ obj->onStreamLoad = strdup(argv[i]);
+ } else if (strcasecmp(argn[i], "onStreamDestroy") == 0 &&
+ !obj->onStreamDestroy) {
+ obj->onStreamDestroy = strdup(argv[i]);
+ } else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify) {
+ obj->onURLNotify = strdup(argv[i]);
+ } else if (strcasecmp(argn[i], "logfirstsetwindow") == 0) {
+ obj->logSetWindow = TRUE;
+ } else if (strcasecmp(argn[i], "testnpruntime") == 0) {
+ TestNPRuntime(instance);
+ } else if (strcasecmp(argn[i], "logSrc") == 0) {
+ for (int i = 0; i < argc; i++) {
+ if (strcasecmp(argn[i], "src") == 0) {
+ Log(instance, "src: %s", argv[i]);
+ fflush(stdout);
+ }
+ }
+ } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0) {
+ executeScript(obj, "document.body.innerHTML = ''");
+ }
+ }
+
+ instance->pdata = obj;
+ }
+
+ // On Windows and Unix, plugins only get events if they are windowless.
+ return browser->setvalue(instance, NPPVpluginWindowBool, NULL);
+}
+
+NPError NPP_Destroy(NPP instance, NPSavedData** save) {
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+ if (obj) {
+ if (obj->onStreamLoad)
+ free(obj->onStreamLoad);
+
+ if (obj->onURLNotify)
+ free(obj->onURLNotify);
+
+ if (obj->onStreamDestroy)
+ free(obj->onStreamDestroy);
+
+ if (obj->logDestroy)
+ Log(instance, "NPP_Destroy");
+
+ browser->releaseobject(&obj->header);
+ }
+
+ fflush(stdout);
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_SetWindow(NPP instance, NPWindow* window) {
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+
+ if (obj) {
+ if (obj->logSetWindow) {
+ Log(instance, "NPP_SetWindow: %d %d", static_cast<int>(window->width),
+ static_cast<int>(window->height));
+ fflush(stdout);
+ obj->logSetWindow = false;
+ }
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+static void executeScript(const PluginObject* obj, const char* script) {
+ NPObject* window_script_object;
+ browser->getvalue(obj->npp, NPNVWindowNPObject, &window_script_object);
+
+ NPString np_script;
+ np_script.UTF8Characters = script;
+ np_script.UTF8Length = strlen(script);
+
+ NPVariant browser_result;
+ browser->evaluate(obj->npp, window_script_object, &np_script,
+ &browser_result);
+ browser->releasevariantvalue(&browser_result);
+}
+
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype) {
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+
+ if (obj->returnErrorFromNewStream)
+ return NPERR_GENERIC_ERROR;
+
+ obj->stream = stream;
+ *stype = NP_ASFILEONLY;
+
+ if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)
+ NotifyStream(obj, stream->url, stream->headers);
+
+ if (obj->onStreamLoad)
+ executeScript(obj, obj->onStreamLoad);
+
+ return NPERR_NO_ERROR;
+}
+
+NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+
+ if (obj->onStreamDestroy)
+ executeScript(obj, obj->onStreamDestroy);
+
+ return NPERR_NO_ERROR;
+}
+
+int32 NPP_WriteReady(NPP instance, NPStream* stream) {
+ return 0;
+}
+
+int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
+ void* buffer) {
+ return 0;
+}
+
+void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) {
+}
+
+void NPP_Print(NPP instance, NPPrint* platformPrint) {
+}
+
+int16 NPP_HandleEvent(NPP instance, void* event) {
+ return 0;
+}
+
+void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
+ void* notify_data) {
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+ if (obj->onURLNotify)
+ executeScript(obj, obj->onURLNotify);
+
+ HandleCallback(obj, url, reason, notify_data);
+}
+
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
+ NPError err = NPERR_NO_ERROR;
+
+ switch (variable) {
+#if defined(OS_LINUX)
+ case NPPVpluginNameString:
+ *((const char**)value) = "Pepper Test PlugIn";
+ break;
+ case NPPVpluginDescriptionString:
+ *((const char**)value) = "Simple Pepper plug-in for manual testing.";
+ break;
+ case NPPVpluginNeedsXEmbed:
+ *((NPBool*)value) = TRUE;
+ break;
+#endif
+ case NPPVpluginScriptableNPObject: {
+ void** v = (void**)value;
+ PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
+ // Return value is expected to be retained
+ browser->retainobject((NPObject*)obj);
+ *v = obj;
+ break;
+ }
+ default:
+ fprintf(stderr, "Unhandled variable to NPP_GetValue\n");
+ err = NPERR_GENERIC_ERROR;
+ break;
+ }
+
+ return err;
+}
+
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
+ return NPERR_GENERIC_ERROR;
+}
+
+#if defined(OS_LINUX)
+NPError NP_GetValue(NPP instance, NPPVariable variable, void* value) {
+ return NPP_GetValue(instance, variable, value);
+}
+
+const char* NP_GetMIMEDescription() {
+ return "pepper-application/x-pepper-test-plugin pepper test;";
+}
+#endif
diff --git a/webkit/tools/pepper_test_plugin/main.cpp b/webkit/tools/pepper_test_plugin/main.cpp
deleted file mode 100644
index e0862fe..0000000
--- a/webkit/tools/pepper_test_plugin/main.cpp
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
- consideration of your agreement to the following terms, and your use, installation,
- modification or redistribution of this Apple software constitutes acceptance of these
- terms. If you do not agree with these terms, please do not use, install, modify or
- redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject to these
- terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in
- this original Apple software (the "Apple Software"), to use, reproduce, modify and
- redistribute the Apple Software, with or without modifications, in source and/or binary
- forms; provided that if you redistribute the Apple Software in its entirety and without
- modifications, you must retain this notice and the following text and disclaimers in all
- such redistributions of the Apple Software. Neither the name, trademarks, service marks
- or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
- the Apple Software without specific prior written permission from Apple. Except as expressly
- stated in this notice, no other rights or licenses, express or implied, are granted by Apple
- herein, including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
- EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
- USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
- REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
- WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
- OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "PluginObject.h"
-
-#ifdef WIN32
-#define strcasecmp _stricmp
-#define NPAPI WINAPI
-#else
-#define NPAPI
-#endif
-
-#if defined(OS_LINUX)
-#include <X11/Xlib.h>
-#endif
-
-static void log(NPP instance, const char* format, ...)
-{
- va_list args;
- va_start(args, format);
- char message[2048] = "PLUGIN: ";
- vsprintf(message + strlen(message), format, args);
- va_end(args);
-
- NPObject* windowObject = 0;
- NPError error = browser->getvalue(instance, NPNVWindowNPObject, &windowObject);
- if (error != NPERR_NO_ERROR) {
- fprintf(stderr, "Failed to retrieve window object while logging: %s\n", message);
- return;
- }
-
- NPVariant consoleVariant;
- if (!browser->getproperty(instance, windowObject, browser->getstringidentifier("console"), &consoleVariant)) {
- fprintf(stderr, "Failed to retrieve console object while logging: %s\n", message);
- browser->releaseobject(windowObject);
- return;
- }
-
- NPObject* consoleObject = NPVARIANT_TO_OBJECT(consoleVariant);
-
- NPVariant messageVariant;
- STRINGZ_TO_NPVARIANT(message, messageVariant);
-
- NPVariant result;
- if (!browser->invoke(instance, consoleObject, browser->getstringidentifier("log"), &messageVariant, 1, &result)) {
- fprintf(stderr, "Failed to invoke console.log while logging: %s\n", message);
- browser->releaseobject(consoleObject);
- browser->releaseobject(windowObject);
- return;
- }
-
- browser->releasevariantvalue(&result);
- browser->releaseobject(consoleObject);
- browser->releaseobject(windowObject);
-}
-
-// Plugin entry points
-extern "C" {
- NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs
-#if defined(OS_LINUX)
- , NPPluginFuncs *pluginFuncs
-#endif
- );
- NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
- void NPAPI NP_Shutdown(void);
-
-#if defined(OS_LINUX)
- NPError NP_GetValue(NPP instance, NPPVariable variable, void *value);
- const char* NP_GetMIMEDescription(void);
-#endif
-}
-
-// Plugin entry points
-NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs
-#if defined(OS_LINUX)
- , NPPluginFuncs *pluginFuncs
-#endif
-)
-{
- browser = browserFuncs;
-#if defined(OS_LINUX)
- return NP_GetEntryPoints(pluginFuncs);
-#else
- return NPERR_NO_ERROR;
-#endif
-}
-
-NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs)
-{
- pluginFuncs->version = 11;
- pluginFuncs->size = sizeof(pluginFuncs);
- pluginFuncs->newp = NPP_New;
- pluginFuncs->destroy = NPP_Destroy;
- pluginFuncs->setwindow = NPP_SetWindow;
- pluginFuncs->newstream = NPP_NewStream;
- pluginFuncs->destroystream = NPP_DestroyStream;
- pluginFuncs->asfile = NPP_StreamAsFile;
- pluginFuncs->writeready = NPP_WriteReady;
- pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
- pluginFuncs->print = NPP_Print;
- pluginFuncs->event = NPP_HandleEvent;
- pluginFuncs->urlnotify = NPP_URLNotify;
- pluginFuncs->getvalue = NPP_GetValue;
- pluginFuncs->setvalue = NPP_SetValue;
-
- return NPERR_NO_ERROR;
-}
-
-void NPAPI NP_Shutdown(void)
-{
-}
-
-static void executeScript(const PluginObject* obj, const char* script);
-
-NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
-{
- if (browser->version >= 14) {
- PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
-
- for (int i = 0; i < argc; i++) {
- if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
- obj->onStreamLoad = strdup(argv[i]);
- else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
- obj->onStreamDestroy = strdup(argv[i]);
- else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
- obj->onURLNotify = strdup(argv[i]);
- else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
- obj->logSetWindow = TRUE;
- else if (strcasecmp(argn[i], "testnpruntime") == 0)
- testNPRuntime(instance);
- else if (strcasecmp(argn[i], "logSrc") == 0) {
- for (int i = 0; i < argc; i++) {
- if (strcasecmp(argn[i], "src") == 0) {
- log(instance, "src: %s", argv[i]);
- fflush(stdout);
- }
- }
- } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0)
- executeScript(obj, "document.body.innerHTML = ''");
- }
-
- instance->pdata = obj;
- }
-
- // On Windows and Unix, plugins only get events if they are windowless.
- return browser->setvalue(instance, NPPVpluginWindowBool, NULL);
-}
-
-NPError NPP_Destroy(NPP instance, NPSavedData **save)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- if (obj) {
- if (obj->onStreamLoad)
- free(obj->onStreamLoad);
-
- if (obj->onURLNotify)
- free(obj->onURLNotify);
-
- if (obj->onStreamDestroy)
- free(obj->onStreamDestroy);
-
- if (obj->logDestroy)
- log(instance, "NPP_Destroy");
-
- browser->releaseobject(&obj->header);
- }
-
- fflush(stdout);
-
- return NPERR_NO_ERROR;
-}
-
-NPError NPP_SetWindow(NPP instance, NPWindow *window)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
-
- if (obj) {
- if (obj->logSetWindow) {
- log(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height);
- fflush(stdout);
- obj->logSetWindow = false;
- }
- }
-
- return NPERR_NO_ERROR;
-}
-
-static void executeScript(const PluginObject* obj, const char* script)
-{
- NPObject *windowScriptObject;
- browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
-
- NPString npScript;
- npScript.UTF8Characters = script;
- npScript.UTF8Length = strlen(script);
-
- NPVariant browserResult;
- browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
- browser->releasevariantvalue(&browserResult);
-}
-
-NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
-
- if (obj->returnErrorFromNewStream)
- return NPERR_GENERIC_ERROR;
-
- obj->stream = stream;
- *stype = NP_ASFILEONLY;
-
- if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)
- notifyStream(obj, stream->url, stream->headers);
-
- if (obj->onStreamLoad)
- executeScript(obj, obj->onStreamLoad);
-
- return NPERR_NO_ERROR;
-}
-
-NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
-
- if (obj->onStreamDestroy)
- executeScript(obj, obj->onStreamDestroy);
-
- return NPERR_NO_ERROR;
-}
-
-int32 NPP_WriteReady(NPP instance, NPStream *stream)
-{
- return 0;
-}
-
-int32 NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
-{
- return 0;
-}
-
-void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname)
-{
-}
-
-void NPP_Print(NPP instance, NPPrint *platformPrint)
-{
-}
-
-int16 NPP_HandleEvent(NPP instance, void *event)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- if (!obj->eventLogging)
- return 0;
-
-#ifdef WIN32
- // Below is the event handling code. Per the NPAPI spec, the events don't
- // map directly between operating systems:
- // http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/structures5.html#1000000
- NPEvent* evt = static_cast<NPEvent*>(event);
- short x = static_cast<short>(evt->lParam & 0xffff);
- short y = static_cast<short>(evt->lParam >> 16);
- switch (evt->event) {
- case WM_PAINT:
- log(instance, "updateEvt");
- break;
- case WM_LBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_RBUTTONDOWN:
- log(instance, "mouseDown at (%d, %d)", x, y);
- break;
- case WM_LBUTTONUP:
- case WM_MBUTTONUP:
- case WM_RBUTTONUP:
- log(instance, "mouseUp at (%d, %d)", x, y);
- break;
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDBLCLK:
- break;
- case WM_MOUSEMOVE:
- log(instance, "adjustCursorEvent");
- break;
- case WM_KEYUP:
- // TODO(tc): We need to convert evt->wParam from virtual-key code
- // to key code.
- log(instance, "NOTIMPLEMENTED: keyUp '%c'", ' ');
- break;
- case WM_KEYDOWN:
- // TODO(tc): We need to convert evt->wParam from virtual-key code
- // to key code.
- log(instance, "NOTIMPLEMENTED: keyDown '%c'", ' ');
- break;
- case WM_SETCURSOR:
- break;
- case WM_SETFOCUS:
- log(instance, "getFocusEvent");
- break;
- case WM_KILLFOCUS:
- log(instance, "loseFocusEvent");
- break;
- default:
- log(instance, "event %d", evt->event);
- }
-
- fflush(stdout);
-
-#elif defined(OS_LINUX)
- XEvent* evt = static_cast<XEvent*>(event);
- XButtonPressedEvent* bpress_evt = reinterpret_cast<XButtonPressedEvent*>(evt);
- XButtonReleasedEvent* brelease_evt = reinterpret_cast<XButtonReleasedEvent*>(evt);
- switch (evt->type) {
- case ButtonPress:
- log(instance, "mouseDown at (%d, %d)", bpress_evt->x, bpress_evt->y);
- break;
- case ButtonRelease:
- log(instance, "mouseUp at (%d, %d)", brelease_evt->x, brelease_evt->y);
- break;
- case KeyPress:
- // TODO: extract key code
- log(instance, "NOTIMPLEMENTED: keyDown '%c'", ' ');
- break;
- case KeyRelease:
- // TODO: extract key code
- log(instance, "NOTIMPLEMENTED: keyUp '%c'", ' ');
- break;
- case GraphicsExpose:
- log(instance, "updateEvt");
- break;
- // NPAPI events
- case FocusIn:
- log(instance, "getFocusEvent");
- break;
- case FocusOut:
- log(instance, "loseFocusEvent");
- break;
- case EnterNotify:
- case LeaveNotify:
- case MotionNotify:
- log(instance, "adjustCursorEvent");
- break;
- default:
- log(instance, "event %d", evt->type);
- }
-
- fflush(stdout);
-#else
-
-#ifdef MAC_EVENT_CODE_DISABLED_DUE_TO_ERRORS
-// This code apparently never built on Mac, but Mac was previously
-// using the Linux branch. It doesn't quite build.
-// warning: 'GlobalToLocal' is deprecated (declared at
-// .../Frameworks/QD.framework/Headers/QuickdrawAPI.h:2181)
- EventRecord* evt = static_cast<EventRecord*>(event);
- Point pt = { evt->where.v, evt->where.h };
- switch (evt->what) {
- case nullEvent:
- // these are delivered non-deterministically, don't log.
- break;
- case mouseDown:
- GlobalToLocal(&pt);
- log(instance, "mouseDown at (%d, %d)", pt.h, pt.v);
- break;
- case mouseUp:
- GlobalToLocal(&pt);
- log(instance, "mouseUp at (%d, %d)", pt.h, pt.v);
- break;
- case keyDown:
- log(instance, "keyDown '%c'", (char)(evt->message & 0xFF));
- break;
- case keyUp:
- log(instance, "keyUp '%c'", (char)(evt->message & 0xFF));
- break;
- case autoKey:
- log(instance, "autoKey '%c'", (char)(evt->message & 0xFF));
- break;
- case updateEvt:
- log(instance, "updateEvt");
- break;
- case diskEvt:
- log(instance, "diskEvt");
- break;
- case activateEvt:
- log(instance, "activateEvt");
- break;
- case osEvt:
- switch ((evt->message & 0xFF000000) >> 24) {
- case suspendResumeMessage:
- log(instance, "osEvt - %s", (evt->message & 0x1) ? "resume" : "suspend");
- break;
- case mouseMovedMessage:
- log(instance, "osEvt - mouseMoved");
- break;
- default:
- log(instance, "osEvt - %08lX", evt->message);
- }
- break;
- case kHighLevelEvent:
- log(instance, "kHighLevelEvent");
- break;
- // NPAPI events
- case getFocusEvent:
- log(instance, "getFocusEvent");
- break;
- case loseFocusEvent:
- log(instance, "loseFocusEvent");
- break;
- case adjustCursorEvent:
- log(instance, "adjustCursorEvent");
- break;
- default:
- log(instance, "event %d", evt->what);
- }
-#endif // MAC_EVENT_CODE_DISABLED_DUE_TO_ERRORS
-
-#endif
-
- return 0;
-}
-
-void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- if (obj->onURLNotify)
- executeScript(obj, obj->onURLNotify);
-
- handleCallback(obj, url, reason, notifyData);
-}
-
-NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
-{
- NPError err = NPERR_NO_ERROR;
-
- switch (variable) {
-#if defined(OS_LINUX)
- case NPPVpluginNameString:
- *((const char **)value) = "Pepper Test PlugIn";
- break;
- case NPPVpluginDescriptionString:
- *((const char **)value) = "Simple Pepper plug-in for manual testing.";
- break;
- case NPPVpluginNeedsXEmbed:
- *((NPBool *)value) = TRUE;
- break;
-#endif
- case NPPVpluginScriptableNPObject: {
- void **v = (void **)value;
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- // Return value is expected to be retained
- browser->retainobject((NPObject *)obj);
- *v = obj;
- break;
- }
- default:
- fprintf(stderr, "Unhandled variable to NPP_GetValue\n");
- err = NPERR_GENERIC_ERROR;
- break;
- }
-
- return err;
-}
-
-NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
-{
- return NPERR_GENERIC_ERROR;
-}
-
-#if defined(OS_LINUX)
-NPError NP_GetValue(NPP instance, NPPVariable variable, void *value)
-{
- return NPP_GetValue(instance, variable, value);
-}
-
-const char* NP_GetMIMEDescription(void) {
- // The layout test LayoutTests/fast/js/navigator-mimeTypes-length.html
- // asserts that the number of mimetypes handled by plugins should be
- // greater than the number of plugins. This isn't true if we're
- // the only plugin and we only handle one mimetype, so specify
- // multiple mimetypes here.
- return "pepper-application/x-pepper-test-plugin pepper test;";
-}
-#endif
diff --git a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp
index c05db65..b4e6fbe 100644
--- a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp
+++ b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp
@@ -6,6 +6,7 @@
'type': 'shared_library',
'dependencies': [
'../../../third_party/npapi/npapi.gyp:npapi',
+ '../../../skia/skia.gyp:skia',
],
'include_dirs': [
'../../..', # Root of Chrome Checkout
@@ -22,11 +23,11 @@
}]
],
'sources': [
- 'main.cpp',
- 'PluginObject.cpp',
- 'PluginObject.h',
- 'TestObject.cpp',
- 'TestObject.h',
+ 'main.cc',
+ 'plugin_object.cc',
+ 'plugin_object.h',
+ 'test_object.cc',
+ 'test_object.h',
],
}
],
diff --git a/webkit/tools/pepper_test_plugin/PluginObject.cpp b/webkit/tools/pepper_test_plugin/plugin_object.cc
index 0e21a09..ff76d5e 100644
--- a/webkit/tools/pepper_test_plugin/PluginObject.cpp
+++ b/webkit/tools/pepper_test_plugin/plugin_object.cc
@@ -23,12 +23,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "PluginObject.h"
+#include "webkit/tools/pepper_test_plugin/plugin_object.h"
-#include "TestObject.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+
+#include "webkit/tools/pepper_test_plugin/test_object.h"
+
#ifdef WIN32
#define snprintf sprintf_s
#endif
@@ -58,7 +60,7 @@ static NPClass pluginClass = {
pluginSetProperty,
};
-NPClass *getPluginClass(void)
+NPClass* GetPluginClass(void)
{
return &pluginClass;
}
@@ -201,7 +203,7 @@ static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* resul
BOOLEAN_TO_NPVARIANT(plugin->returnErrorFromNewStream, *result);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT_COUNT]) {
- INT32_TO_NPVARIANT(getTestObjectCount(), *result);
+ INT32_TO_NPVARIANT(GetTestObjectCount(), *result);
return true;
}
return false;
@@ -694,7 +696,7 @@ static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* a
return true;
}
} else if (name == pluginMethodIdentifiers[ID_TEST_CREATE_TEST_OBJECT]) {
- NPObject *testObject = browser->createobject(plugin->npp, getTestClass());
+ NPObject *testObject = browser->createobject(plugin->npp, GetTestClass());
assert(testObject->referenceCount == 1);
OBJECT_TO_NPVARIANT(testObject, *result);
return true;
@@ -820,7 +822,7 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
}
newInstance->npp = npp;
- newInstance->testObject = browser->createobject(npp, getTestClass());
+ newInstance->testObject = browser->createobject(npp, GetTestClass());
newInstance->eventLogging = FALSE;
newInstance->onStreamLoad = 0;
newInstance->onStreamDestroy = 0;
@@ -850,7 +852,8 @@ static void pluginDeallocate(NPObject* header)
free(plugin);
}
-void handleCallback(PluginObject* object, const char *url, NPReason reason, void *notifyData)
+void HandleCallback(PluginObject* object, const char *url, NPReason reason,
+ void* notifyData)
{
assert(object);
@@ -886,7 +889,7 @@ void handleCallback(PluginObject* object, const char *url, NPReason reason, void
free(strHdr);
}
-void notifyStream(PluginObject* object, const char *url, const char *headers)
+void NotifyStream(PluginObject* object, const char* url, const char* headers)
{
if (object->firstUrl == NULL) {
if (url)
@@ -901,7 +904,7 @@ void notifyStream(PluginObject* object, const char *url, const char *headers)
}
}
-void testNPRuntime(NPP npp)
+void TestNPRuntime(NPP npp)
{
NPObject* windowScriptObject;
browser->getvalue(npp, NPNVWindowNPObject, &windowScriptObject);
diff --git a/webkit/tools/pepper_test_plugin/PluginObject.h b/webkit/tools/pepper_test_plugin/plugin_object.h
index 7162954..7870589 100644
--- a/webkit/tools/pepper_test_plugin/PluginObject.h
+++ b/webkit/tools/pepper_test_plugin/plugin_object.h
@@ -23,29 +23,36 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_PLUGIN_OBJECT_H_
+#define WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_PLUGIN_OBJECT_H_
+
#include "webkit/glue/plugins/nphostapi.h"
-extern NPNetscapeFuncs *browser;
+extern NPNetscapeFuncs* browser;
+
+struct PluginObject {
+ NPObject header;
+ NPP npp;
+ NPBool eventLogging;
+ NPBool logSetWindow;
+ NPBool logDestroy;
+ NPBool returnErrorFromNewStream;
+ NPObject* testObject;
+ NPStream* stream;
+ char* onStreamLoad;
+ char* onStreamDestroy;
+ char* onURLNotify;
+ char* firstUrl;
+ char* firstHeaders;
+ char* lastUrl;
+ char* lastHeaders;
+};
-typedef struct {
- NPObject header;
- NPP npp;
- NPBool eventLogging;
- NPBool logSetWindow;
- NPBool logDestroy;
- NPBool returnErrorFromNewStream;
- NPObject* testObject;
- NPStream* stream;
- char* onStreamLoad;
- char* onStreamDestroy;
- char* onURLNotify;
- char* firstUrl;
- char* firstHeaders;
- char* lastUrl;
- char* lastHeaders;
-} PluginObject;
+extern NPClass* GetPluginClass();
+extern void HandleCallback(PluginObject* object, const char *url,
+ NPReason reason, void* notify_data);
+extern void NotifyStream(PluginObject* object, const char* url,
+ const char* headers);
+extern void TestNPRuntime(NPP npp);
-extern NPClass *getPluginClass(void);
-extern void handleCallback(PluginObject* object, const char *url, NPReason reason, void *notifyData);
-extern void notifyStream(PluginObject* object, const char *url, const char *headers);
-extern void testNPRuntime(NPP npp);
+#endif // WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_PLUGIN_OBJECT_H_
diff --git a/webkit/tools/pepper_test_plugin/TestObject.cpp b/webkit/tools/pepper_test_plugin/test_object.cc
index a839c1e..9b84d33 100644
--- a/webkit/tools/pepper_test_plugin/TestObject.cpp
+++ b/webkit/tools/pepper_test_plugin/test_object.cc
@@ -23,11 +23,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "TestObject.h"
-#include "PluginObject.h"
+#include "webkit/tools/pepper_test_plugin/test_object.h"
#include <stdlib.h>
+#include "webkit/tools/pepper_test_plugin/plugin_object.h"
+
static bool testEnumerate(NPObject*, NPIdentifier **value, uint32_t *count);
static bool testHasMethod(NPObject*, NPIdentifier name);
static bool testInvoke(NPObject* header, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result);
@@ -38,7 +39,6 @@ static NPObject *testAllocate(NPP npp, NPClass *theClass);
static void testDeallocate(NPObject*);
static bool testConstruct(NPObject*, const NPVariant* args, uint32_t argCount, NPVariant* result);
-
static NPClass testClass = {
NP_CLASS_STRUCT_VERSION,
testAllocate,
@@ -55,14 +55,15 @@ static NPClass testClass = {
testConstruct
};
-NPClass *getTestClass(void)
+NPClass* GetTestClass()
{
return &testClass;
}
int testObjectCount = 0;
-int getTestObjectCount(void) {
+int GetTestObjectCount()
+{
return testObjectCount;
}
@@ -104,7 +105,7 @@ static NPObject *testAllocate(NPP npp, NPClass *theClass)
{
TestObject *newInstance =
static_cast<TestObject*>(malloc(sizeof(TestObject)));
- newInstance->testObject = NULL;
+ newInstance->test_object = NULL;
++testObjectCount;
if (!identifiersInitialized) {
@@ -118,8 +119,8 @@ static NPObject *testAllocate(NPP npp, NPClass *theClass)
static void testDeallocate(NPObject *obj)
{
TestObject *testObject = reinterpret_cast<TestObject*>(obj);
- if (testObject->testObject)
- browser->releaseobject(testObject->testObject);
+ if (testObject->test_object)
+ browser->releaseobject(testObject->test_object);
--testObjectCount;
free(obj);
}
@@ -172,10 +173,10 @@ static bool testGetProperty(NPObject *obj, NPIdentifier name,
return true;
} else if (name == testIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
TestObject* testObject = reinterpret_cast<TestObject*>(obj);
- if (testObject->testObject == NULL)
- testObject->testObject = browser->createobject(NULL, &testClass);
- browser->retainobject(testObject->testObject);
- OBJECT_TO_NPVARIANT(testObject->testObject, *variant);
+ if (testObject->test_object == NULL)
+ testObject->test_object = browser->createobject(NULL, &testClass);
+ browser->retainobject(testObject->test_object);
+ OBJECT_TO_NPVARIANT(testObject->test_object, *variant);
return true;
} else if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) {
INT32_TO_NPVARIANT(obj->referenceCount, *variant);
diff --git a/webkit/tools/pepper_test_plugin/TestObject.h b/webkit/tools/pepper_test_plugin/test_object.h
index fba904b..787472d 100644
--- a/webkit/tools/pepper_test_plugin/TestObject.h
+++ b/webkit/tools/pepper_test_plugin/test_object.h
@@ -23,14 +23,19 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_TEST_OBJECT_H_
+#define WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_TEST_OBJECT_H_
+
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npruntime.h"
-typedef struct {
- NPObject header;
- NPObject* testObject;
-} TestObject;
+struct TestObject {
+ NPObject header;
+ NPObject* test_object;
+};
+
+NPClass* GetTestClass();
+int GetTestObjectCount();
-NPClass *getTestClass(void);
-int getTestObjectCount(void);
+#endif // WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_TEST_OBJECT_H_