2008-09-09 08:43:21 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2009-01-12 19:06:21 -08:00
|
|
|
*
|
|
|
|
* Copyright (c) 2008, Mozilla Corporation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* * Neither the name of the Mozilla Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-09-09 08:43:21 -07:00
|
|
|
* Contributor(s):
|
|
|
|
* Dave Townsend <dtownsend@oxymoronical.com>
|
2009-01-12 19:06:21 -08:00
|
|
|
* Josh Aas <josh@mozilla.com>
|
|
|
|
*
|
2008-09-09 08:43:21 -07:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#include "nptest.h"
|
|
|
|
#include "nptest_utils.h"
|
|
|
|
#include "nptest_platform.h"
|
2008-09-09 08:43:21 -07:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-01-14 05:11:08 -08:00
|
|
|
#include <stdio.h>
|
2009-09-18 07:08:08 -07:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
2008-12-19 01:10:09 -08:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#define PLUGIN_NAME "Test Plug-in"
|
|
|
|
#define PLUGIN_DESCRIPTION "Plug-in for testing purposes."
|
|
|
|
#define PLUGIN_VERSION "1.0.0.0"
|
2008-12-19 01:10:09 -08:00
|
|
|
|
2009-04-05 17:04:02 -07:00
|
|
|
#define ARRAY_LENGTH(a) (sizeof(a)/sizeof(a[0]))
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
//
|
|
|
|
// static data
|
|
|
|
//
|
|
|
|
|
|
|
|
static NPNetscapeFuncs* sBrowserFuncs = NULL;
|
|
|
|
static NPClass sNPClass;
|
|
|
|
|
|
|
|
//
|
|
|
|
// identifiers
|
|
|
|
//
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
typedef bool (* ScriptableFunction)
|
|
|
|
(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
|
2009-04-10 17:15:42 -07:00
|
|
|
static bool setUndefinedValueTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-03-31 18:07:19 -07:00
|
|
|
static bool identifierToStringTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-07-01 08:09:49 -07:00
|
|
|
static bool timerTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-03-31 18:07:19 -07:00
|
|
|
static bool queryPrivateModeState(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool lastReportedPrivateModeState(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool hasWidget(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-04-05 17:04:02 -07:00
|
|
|
static bool getEdge(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool getClipRegionRectCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool getClipRegionRectEdge(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-05-07 18:32:32 -07:00
|
|
|
static bool startWatchingInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool getInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool stopWatchingInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-07-01 08:09:49 -07:00
|
|
|
static bool unscheduleAllTimers(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-08-04 18:36:37 -07:00
|
|
|
static bool getLastMouseX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
static bool getLastMouseY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
2009-01-12 19:06:21 -08:00
|
|
|
|
2009-04-05 17:04:02 -07:00
|
|
|
static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
2009-04-10 17:15:42 -07:00
|
|
|
"setUndefinedValueTest",
|
2009-01-12 19:06:21 -08:00
|
|
|
"identifierToStringTest",
|
2009-07-01 08:09:49 -07:00
|
|
|
"timerTest",
|
2009-01-30 13:40:14 -08:00
|
|
|
"queryPrivateModeState",
|
|
|
|
"lastReportedPrivateModeState",
|
2009-03-31 18:07:19 -07:00
|
|
|
"hasWidget",
|
2009-04-05 17:04:02 -07:00
|
|
|
"getEdge",
|
|
|
|
"getClipRegionRectCount",
|
|
|
|
"getClipRegionRectEdge",
|
2009-05-07 18:32:32 -07:00
|
|
|
"startWatchingInstanceCount",
|
|
|
|
"getInstanceCount",
|
|
|
|
"stopWatchingInstanceCount",
|
2009-07-01 08:09:49 -07:00
|
|
|
"unscheduleAllTimers",
|
2009-08-04 18:36:37 -07:00
|
|
|
"getLastMouseX",
|
|
|
|
"getLastMouseY",
|
2009-03-31 18:07:19 -07:00
|
|
|
};
|
2009-04-05 17:04:02 -07:00
|
|
|
static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
|
|
|
|
static const ScriptableFunction sPluginMethodFunctions[ARRAY_LENGTH(sPluginMethodIdentifierNames)] = {
|
2009-04-10 17:15:42 -07:00
|
|
|
setUndefinedValueTest,
|
2009-03-31 18:07:19 -07:00
|
|
|
identifierToStringTest,
|
2009-07-01 08:09:49 -07:00
|
|
|
timerTest,
|
2009-03-31 18:07:19 -07:00
|
|
|
queryPrivateModeState,
|
|
|
|
lastReportedPrivateModeState,
|
|
|
|
hasWidget,
|
2009-04-05 17:04:02 -07:00
|
|
|
getEdge,
|
|
|
|
getClipRegionRectCount,
|
|
|
|
getClipRegionRectEdge,
|
2009-05-07 18:32:32 -07:00
|
|
|
startWatchingInstanceCount,
|
|
|
|
getInstanceCount,
|
|
|
|
stopWatchingInstanceCount,
|
2009-07-01 08:09:49 -07:00
|
|
|
unscheduleAllTimers,
|
2009-08-04 18:36:37 -07:00
|
|
|
getLastMouseX,
|
|
|
|
getLastMouseY,
|
2009-01-12 19:06:21 -08:00
|
|
|
};
|
|
|
|
|
2009-09-18 07:08:08 -07:00
|
|
|
static char* NPN_GetURLNotifyCookie = "NPN_GetURLNotify_Cookie";
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
static bool sIdentifiersInitialized = false;
|
|
|
|
|
2009-05-07 18:32:32 -07:00
|
|
|
/**
|
|
|
|
* Incremented for every startWatchingInstanceCount.
|
|
|
|
*/
|
|
|
|
static int32_t sCurrentInstanceCountWatchGeneration = 0;
|
|
|
|
/**
|
|
|
|
* Tracks the number of instances created or destroyed since the last
|
|
|
|
* startWatchingInstanceCount.
|
|
|
|
*/
|
|
|
|
static int32_t sInstanceCount = 0;
|
|
|
|
/**
|
|
|
|
* True when we've had a startWatchingInstanceCount with no corresponding
|
|
|
|
* stopWatchingInstanceCount.
|
|
|
|
*/
|
|
|
|
static bool sWatchingInstanceCount = false;
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
static void initializeIdentifiers()
|
|
|
|
{
|
|
|
|
if (!sIdentifiersInitialized) {
|
2009-04-05 17:04:02 -07:00
|
|
|
NPN_GetStringIdentifiers(sPluginMethodIdentifierNames,
|
|
|
|
ARRAY_LENGTH(sPluginMethodIdentifierNames), sPluginMethodIdentifiers);
|
2009-01-12 19:06:21 -08:00
|
|
|
sIdentifiersInitialized = true;
|
|
|
|
}
|
2008-12-16 07:27:32 -08:00
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
static void clearIdentifiers()
|
|
|
|
{
|
2009-04-05 17:04:02 -07:00
|
|
|
memset(sPluginMethodIdentifiers, 0,
|
|
|
|
ARRAY_LENGTH(sPluginMethodIdentifiers) * sizeof(NPIdentifier));
|
2009-01-12 19:06:21 -08:00
|
|
|
sIdentifiersInitialized = false;
|
|
|
|
}
|
|
|
|
|
2009-09-18 07:08:08 -07:00
|
|
|
static void addRange(InstanceData* instanceData, const char* range)
|
|
|
|
{
|
|
|
|
char rangestr[16];
|
|
|
|
strncpy(rangestr, range, sizeof(rangestr));
|
|
|
|
const char* str1 = strtok(rangestr, ",");
|
|
|
|
const char* str2 = str1 ? strtok(NULL, ",") : NULL;
|
|
|
|
if (str1 && str2) {
|
|
|
|
TestRange* byterange = new TestRange;
|
|
|
|
byterange->offset = atoi(str1);
|
|
|
|
byterange->length = atoi(str2);
|
|
|
|
byterange->waiting = true;
|
|
|
|
byterange->next = instanceData->testrange;
|
|
|
|
instanceData->testrange = byterange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sendBufferToFrame(NPP instance)
|
|
|
|
{
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
string outbuf = "data:text/html,";
|
|
|
|
const char* buf = reinterpret_cast<char *>(instanceData->streamBuf);
|
|
|
|
int32_t bufsize = instanceData->streamBufSize;
|
|
|
|
if (instanceData->streamMode == NP_ASFILE ||
|
|
|
|
instanceData->streamMode == NP_ASFILEONLY) {
|
|
|
|
buf = reinterpret_cast<char *>(instanceData->fileBuf);
|
|
|
|
bufsize = instanceData->fileBufSize;
|
|
|
|
}
|
|
|
|
if (instanceData->err.str().length() > 0) {
|
|
|
|
buf = instanceData->err.str().c_str();
|
|
|
|
bufsize = strlen(buf);
|
|
|
|
}
|
|
|
|
if (bufsize > 0) {
|
|
|
|
outbuf.append(buf);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outbuf.append("Error: no data in buffer");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert CRLF to LF, and escape most other non-alphanumeric chars.
|
|
|
|
for (int i = 0; i < outbuf.length(); i++) {
|
|
|
|
if (outbuf[i] == '\n') {
|
|
|
|
outbuf.replace(i, 1, "%0a");
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
else if (outbuf[i] == '\r') {
|
|
|
|
outbuf.replace(i, 1, "");
|
|
|
|
i -= 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int ascii = outbuf[i];
|
|
|
|
if (!((ascii >= ',' && ascii <= ';') ||
|
|
|
|
(ascii >= 'A' && ascii <= 'Z') ||
|
|
|
|
(ascii >= 'a' && ascii <= 'z'))) {
|
|
|
|
char hex[8];
|
|
|
|
sprintf(hex, "%%%x", ascii);
|
|
|
|
outbuf.replace(i, 1, hex);
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NPError err = NPN_GetURL(instance, outbuf.c_str(),
|
|
|
|
instanceData->frame.c_str());
|
|
|
|
if (err != NPERR_NO_ERROR) {
|
|
|
|
instanceData->err << "NPN_GetURL returned " << err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
//
|
|
|
|
// function signatures
|
|
|
|
//
|
|
|
|
|
|
|
|
NPObject* scriptableAllocate(NPP npp, NPClass* aClass);
|
|
|
|
void scriptableDeallocate(NPObject* npobj);
|
|
|
|
void scriptableInvalidate(NPObject* npobj);
|
|
|
|
bool scriptableHasMethod(NPObject* npobj, NPIdentifier name);
|
|
|
|
bool scriptableInvoke(NPObject* npobj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
bool scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
bool scriptableHasProperty(NPObject* npobj, NPIdentifier name);
|
|
|
|
bool scriptableGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result);
|
|
|
|
bool scriptableSetProperty(NPObject* npobj, NPIdentifier name, const NPVariant* value);
|
|
|
|
bool scriptableRemoveProperty(NPObject* npobj, NPIdentifier name);
|
|
|
|
bool scriptableEnumerate(NPObject* npobj, NPIdentifier** identifier, uint32_t* count);
|
|
|
|
bool scriptableConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
|
|
|
|
|
|
|
//
|
|
|
|
// npapi plugin functions
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifdef XP_UNIX
|
2008-12-19 02:30:53 -08:00
|
|
|
NP_EXPORT(char*)
|
2009-01-12 19:06:21 -08:00
|
|
|
NP_GetPluginVersion()
|
|
|
|
{
|
|
|
|
return PLUGIN_VERSION;
|
2008-12-18 21:47:08 -08:00
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
#endif
|
2008-12-18 21:47:08 -08:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#if defined(XP_UNIX)
|
|
|
|
NP_EXPORT(char*) NP_GetMIMEDescription()
|
2009-03-26 16:47:43 -07:00
|
|
|
#elif defined(XP_WIN) || defined(XP_OS2)
|
2009-01-12 19:06:21 -08:00
|
|
|
char* NP_GetMIMEDescription()
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return "application/x-test:tst:Test mimetype";
|
2008-12-19 01:10:09 -08:00
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#ifdef XP_UNIX
|
2008-12-19 02:30:53 -08:00
|
|
|
NP_EXPORT(NPError)
|
2009-01-12 19:06:21 -08:00
|
|
|
NP_GetValue(void* future, NPPVariable aVariable, void* aValue) {
|
|
|
|
switch (aVariable) {
|
|
|
|
case NPPVpluginNameString:
|
|
|
|
*((char**)aValue) = PLUGIN_NAME;
|
|
|
|
break;
|
|
|
|
case NPPVpluginDescriptionString:
|
|
|
|
*((char**)aValue) = PLUGIN_DESCRIPTION;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void fillPluginFunctionTable(NPPluginFuncs* pFuncs)
|
|
|
|
{
|
|
|
|
pFuncs->version = 11;
|
|
|
|
pFuncs->size = sizeof(*pFuncs);
|
|
|
|
pFuncs->newp = NPP_New;
|
|
|
|
pFuncs->destroy = NPP_Destroy;
|
|
|
|
pFuncs->setwindow = NPP_SetWindow;
|
|
|
|
pFuncs->newstream = NPP_NewStream;
|
|
|
|
pFuncs->destroystream = NPP_DestroyStream;
|
|
|
|
pFuncs->asfile = NPP_StreamAsFile;
|
|
|
|
pFuncs->writeready = NPP_WriteReady;
|
|
|
|
pFuncs->write = NPP_Write;
|
|
|
|
pFuncs->print = NPP_Print;
|
|
|
|
pFuncs->event = NPP_HandleEvent;
|
|
|
|
pFuncs->urlnotify = NPP_URLNotify;
|
|
|
|
pFuncs->getvalue = NPP_GetValue;
|
|
|
|
pFuncs->setvalue = NPP_SetValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs)
|
2009-03-26 16:47:43 -07:00
|
|
|
#elif defined(XP_WIN) || defined(XP_OS2)
|
2009-01-12 19:06:21 -08:00
|
|
|
NPError OSCALL NP_Initialize(NPNetscapeFuncs* bFuncs)
|
|
|
|
#elif defined(XP_UNIX)
|
|
|
|
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
sBrowserFuncs = bFuncs;
|
|
|
|
|
|
|
|
initializeIdentifiers();
|
|
|
|
|
|
|
|
memset(&sNPClass, 0, sizeof(NPClass));
|
|
|
|
sNPClass.structVersion = NP_CLASS_STRUCT_VERSION;
|
|
|
|
sNPClass.allocate = (NPAllocateFunctionPtr)scriptableAllocate;
|
|
|
|
sNPClass.deallocate = (NPDeallocateFunctionPtr)scriptableDeallocate;
|
|
|
|
sNPClass.invalidate = (NPInvalidateFunctionPtr)scriptableInvalidate;
|
|
|
|
sNPClass.hasMethod = (NPHasMethodFunctionPtr)scriptableHasMethod;
|
|
|
|
sNPClass.invoke = (NPInvokeFunctionPtr)scriptableInvoke;
|
|
|
|
sNPClass.invokeDefault = (NPInvokeDefaultFunctionPtr)scriptableInvokeDefault;
|
|
|
|
sNPClass.hasProperty = (NPHasPropertyFunctionPtr)scriptableHasProperty;
|
|
|
|
sNPClass.getProperty = (NPGetPropertyFunctionPtr)scriptableGetProperty;
|
|
|
|
sNPClass.setProperty = (NPSetPropertyFunctionPtr)scriptableSetProperty;
|
|
|
|
sNPClass.removeProperty = (NPRemovePropertyFunctionPtr)scriptableRemoveProperty;
|
|
|
|
sNPClass.enumerate = (NPEnumerationFunctionPtr)scriptableEnumerate;
|
|
|
|
sNPClass.construct = (NPConstructFunctionPtr)scriptableConstruct;
|
|
|
|
|
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
|
|
|
fillPluginFunctionTable(pFuncs);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
2008-12-19 01:10:09 -08:00
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
2009-03-26 16:47:43 -07:00
|
|
|
#elif defined(XP_WIN) || defined(XP_OS2)
|
2009-01-12 19:06:21 -08:00
|
|
|
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
|
|
|
|
#endif
|
2009-03-26 16:47:43 -07:00
|
|
|
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(XP_OS2)
|
2009-01-12 19:06:21 -08:00
|
|
|
{
|
|
|
|
fillPluginFunctionTable(pFuncs);
|
|
|
|
return NPERR_NO_ERROR;
|
2008-12-19 01:10:09 -08:00
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
#endif
|
2008-12-19 01:10:09 -08:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
#if defined(XP_UNIX)
|
|
|
|
NP_EXPORT(NPError) NP_Shutdown()
|
2009-03-26 16:47:43 -07:00
|
|
|
#elif defined(XP_WIN) || defined(XP_OS2)
|
2009-01-12 19:06:21 -08:00
|
|
|
NPError OSCALL NP_Shutdown()
|
2008-12-19 02:30:53 -08:00
|
|
|
#endif
|
2009-01-12 19:06:21 -08:00
|
|
|
{
|
|
|
|
clearIdentifiers();
|
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
|
|
|
|
{
|
2009-03-31 18:07:19 -07:00
|
|
|
// Make sure we can render this plugin
|
|
|
|
NPBool browserSupportsWindowless = false;
|
|
|
|
NPN_GetValue(instance, NPNVSupportsWindowless, &browserSupportsWindowless);
|
|
|
|
if (!browserSupportsWindowless && !pluginSupportsWindowMode()) {
|
|
|
|
printf("Windowless mode not supported by the browser, windowed mode not supported by the plugin!\n");
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
|
|
|
|
// set up our our instance data
|
2009-09-18 07:08:08 -07:00
|
|
|
InstanceData* instanceData = new InstanceData;
|
2009-01-12 19:06:21 -08:00
|
|
|
if (!instanceData)
|
|
|
|
return NPERR_OUT_OF_MEMORY_ERROR;
|
|
|
|
instanceData->npp = instance;
|
2009-09-18 07:08:08 -07:00
|
|
|
instanceData->streamMode = NP_ASFILEONLY;
|
2009-09-24 15:23:35 -07:00
|
|
|
instanceData->testFunction = FUNCTION_NONE;
|
2009-09-18 07:08:08 -07:00
|
|
|
instanceData->streamChunkSize = 1024;
|
|
|
|
instanceData->streamBuf = NULL;
|
|
|
|
instanceData->streamBufSize = 0;
|
2009-09-24 15:23:35 -07:00
|
|
|
instanceData->fileBuf = NULL;
|
|
|
|
instanceData->fileBufSize = 0;
|
2009-09-18 07:08:08 -07:00
|
|
|
instanceData->testrange = NULL;
|
|
|
|
instanceData->hasWidget = false;
|
|
|
|
memset(&instanceData->window, 0, sizeof(instanceData->window));
|
2009-01-12 19:06:21 -08:00
|
|
|
instance->pdata = instanceData;
|
|
|
|
|
|
|
|
TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
|
|
|
|
if (!scriptableObject) {
|
|
|
|
printf("NPN_CreateObject failed to create an object, can't create a plugin instance\n");
|
2009-03-31 18:07:19 -07:00
|
|
|
free(instanceData);
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
NPN_RetainObject(scriptableObject);
|
|
|
|
scriptableObject->npp = instance;
|
2009-01-16 12:03:24 -08:00
|
|
|
scriptableObject->drawMode = DM_DEFAULT;
|
|
|
|
scriptableObject->drawColor = 0;
|
2009-03-31 18:07:19 -07:00
|
|
|
instanceData->scriptableObject = scriptableObject;
|
2009-01-16 12:03:24 -08:00
|
|
|
|
2009-05-07 18:32:32 -07:00
|
|
|
instanceData->instanceCountWatchGeneration = sCurrentInstanceCountWatchGeneration;
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
bool requestWindow = false;
|
2009-01-16 12:03:24 -08:00
|
|
|
// handle extra params
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
if (strcmp(argn[i], "drawmode") == 0) {
|
|
|
|
if (strcmp(argv[i], "solid") == 0)
|
|
|
|
scriptableObject->drawMode = DM_SOLID_COLOR;
|
|
|
|
}
|
|
|
|
else if (strcmp(argn[i], "color") == 0) {
|
|
|
|
scriptableObject->drawColor = parseHexColor(argv[i]);
|
|
|
|
}
|
2009-03-31 18:07:19 -07:00
|
|
|
else if (strcmp(argn[i], "wmode") == 0) {
|
|
|
|
if (strcmp(argv[i], "window") == 0) {
|
|
|
|
requestWindow = true;
|
|
|
|
}
|
2009-09-18 07:08:08 -07:00
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "streammode") == 0) {
|
|
|
|
if (strcmp(argv[i], "normal") == 0) {
|
|
|
|
instanceData->streamMode = NP_NORMAL;
|
|
|
|
}
|
|
|
|
else if ((strcmp(argv[i], "asfile") == 0) &&
|
|
|
|
strlen(argv[i]) == strlen("asfile")) {
|
|
|
|
instanceData->streamMode = NP_ASFILE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "asfileonly") == 0) {
|
|
|
|
instanceData->streamMode = NP_ASFILEONLY;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "seek") == 0) {
|
|
|
|
instanceData->streamMode = NP_SEEK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "streamchunksize") == 0) {
|
|
|
|
instanceData->streamChunkSize = atoi(argv[i]);
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "geturl") == 0) {
|
|
|
|
instanceData->testUrl = argv[i];
|
|
|
|
instanceData->testFunction = FUNCTION_NPP_GETURL;
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "posturl") == 0) {
|
|
|
|
instanceData->testUrl = argv[i];
|
|
|
|
instanceData->testFunction = FUNCTION_NPP_POSTURL;
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "geturlnotify") == 0) {
|
|
|
|
instanceData->testUrl = argv[i];
|
|
|
|
instanceData->testFunction = FUNCTION_NPP_GETURLNOTIFY;
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "postmode") == 0) {
|
|
|
|
if (strcmp(argv[i], "frame") == 0) {
|
|
|
|
instanceData->postMode = POSTMODE_FRAME;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "stream") == 0) {
|
|
|
|
instanceData->postMode = POSTMODE_STREAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "frame") == 0) {
|
|
|
|
instanceData->frame = argv[i];
|
|
|
|
}
|
|
|
|
if (strcmp(argn[i], "range") == 0) {
|
|
|
|
string range = argv[i];
|
|
|
|
int16_t semicolon = range.find(';');
|
|
|
|
while (semicolon != string::npos) {
|
|
|
|
addRange(instanceData, range.substr(0, semicolon).c_str());
|
|
|
|
if (semicolon == range.length()) {
|
|
|
|
range = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
range = range.substr(semicolon + 1);
|
|
|
|
semicolon = range.find(';');
|
|
|
|
}
|
|
|
|
if (range.length()) addRange(instanceData, range.c_str());
|
2009-03-31 18:07:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!browserSupportsWindowless || !pluginSupportsWindowlessMode()) {
|
|
|
|
requestWindow = true;
|
|
|
|
} else if (!pluginSupportsWindowMode()) {
|
|
|
|
requestWindow = false;
|
|
|
|
}
|
|
|
|
if (requestWindow) {
|
|
|
|
instanceData->hasWidget = true;
|
|
|
|
} else {
|
|
|
|
// NPPVpluginWindowBool should default to true, so we may as well
|
|
|
|
// test that by not setting it in the window case
|
|
|
|
NPN_SetValue(instance, NPPVpluginWindowBool, (void*)false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scriptableObject->drawMode == DM_SOLID_COLOR &&
|
|
|
|
(scriptableObject->drawColor & 0xFF000000) != 0xFF000000) {
|
|
|
|
NPN_SetValue(instance, NPPVpluginTransparentBool, (void*)true);
|
2009-01-16 12:03:24 -08:00
|
|
|
}
|
|
|
|
|
2009-01-30 13:40:14 -08:00
|
|
|
instanceData->lastReportedPrivateModeState = false;
|
2009-08-04 18:36:37 -07:00
|
|
|
instanceData->lastMouseX = instanceData->lastMouseY = -1;
|
2009-01-30 13:40:14 -08:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
// do platform-specific initialization
|
|
|
|
NPError err = pluginInstanceInit(instanceData);
|
2009-03-31 18:07:19 -07:00
|
|
|
if (err != NPERR_NO_ERROR) {
|
|
|
|
NPN_ReleaseObject(scriptableObject);
|
|
|
|
free(instanceData);
|
2009-01-12 19:06:21 -08:00
|
|
|
return err;
|
2009-03-31 18:07:19 -07:00
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
|
2009-09-10 11:11:30 -07:00
|
|
|
NPVariant variantTrue;
|
|
|
|
BOOLEAN_TO_NPVARIANT(true, variantTrue);
|
|
|
|
|
|
|
|
// Set a property on NPNVPluginElementNPObject
|
|
|
|
NPObject* o = NULL;
|
|
|
|
err = NPN_GetValue(instance, NPNVPluginElementNPObject, &o);
|
|
|
|
if (err == NPERR_NO_ERROR) {
|
|
|
|
NPN_SetProperty(instance, o,
|
|
|
|
NPN_GetStringIdentifier("pluginFoundElement"), &variantTrue);
|
|
|
|
NPN_ReleaseObject(o);
|
|
|
|
o = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set a property on NPNVWindowNPObject
|
|
|
|
err = NPN_GetValue(instance, NPNVWindowNPObject, &o);
|
|
|
|
if (err == NPERR_NO_ERROR) {
|
|
|
|
NPN_SetProperty(instance, o,
|
|
|
|
NPN_GetStringIdentifier("pluginFoundWindow"), &variantTrue);
|
|
|
|
NPN_ReleaseObject(o);
|
|
|
|
o = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-07 18:32:32 -07:00
|
|
|
++sInstanceCount;
|
2009-09-18 07:08:08 -07:00
|
|
|
|
|
|
|
if (instanceData->testFunction == FUNCTION_NPP_GETURL) {
|
|
|
|
NPError err = NPN_GetURL(instance, instanceData->testUrl.c_str(), NULL);
|
|
|
|
if (err != NPERR_NO_ERROR) {
|
|
|
|
instanceData->err << "NPN_GetURL returned " << err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (instanceData->testFunction == FUNCTION_NPP_GETURLNOTIFY) {
|
|
|
|
NPError err = NPN_GetURLNotify(instance, instanceData->testUrl.c_str(),
|
|
|
|
NULL, (void *)NPN_GetURLNotifyCookie);
|
|
|
|
if (err != NPERR_NO_ERROR) {
|
|
|
|
instanceData->err << "NPN_GetURLNotify returned " << err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_Destroy(NPP instance, NPSavedData** save)
|
|
|
|
{
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
2009-09-18 07:08:08 -07:00
|
|
|
|
|
|
|
if (instanceData->streamBuf) {
|
|
|
|
free(instanceData->streamBuf);
|
|
|
|
}
|
2009-09-24 15:23:35 -07:00
|
|
|
if (instanceData->fileBuf) {
|
|
|
|
free(instanceData->fileBuf);
|
|
|
|
}
|
2009-09-18 07:08:08 -07:00
|
|
|
|
|
|
|
TestRange* currentrange = instanceData->testrange;
|
|
|
|
TestRange* nextrange;
|
|
|
|
while (currentrange != NULL) {
|
|
|
|
nextrange = reinterpret_cast<TestRange*>(currentrange->next);
|
|
|
|
delete currentrange;
|
|
|
|
currentrange = nextrange;
|
|
|
|
}
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
pluginInstanceShutdown(instanceData);
|
2009-01-12 19:06:21 -08:00
|
|
|
NPN_ReleaseObject(instanceData->scriptableObject);
|
2009-05-07 18:32:32 -07:00
|
|
|
|
|
|
|
if (sCurrentInstanceCountWatchGeneration == instanceData->instanceCountWatchGeneration) {
|
|
|
|
--sInstanceCount;
|
|
|
|
}
|
2009-09-18 07:08:08 -07:00
|
|
|
delete instanceData;
|
2009-05-07 18:32:32 -07:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_SetWindow(NPP instance, NPWindow* window)
|
|
|
|
{
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
2009-03-31 18:07:19 -07:00
|
|
|
void* oldWindow = instanceData->window.window;
|
2009-04-05 17:04:02 -07:00
|
|
|
pluginDoSetWindow(instanceData, window);
|
2009-03-31 18:07:19 -07:00
|
|
|
if (instanceData->hasWidget && oldWindow != instanceData->window.window) {
|
|
|
|
pluginWidgetInit(instanceData, oldWindow);
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
|
|
|
|
{
|
2009-09-18 07:08:08 -07:00
|
|
|
printf("NPP_NewStream\n");
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
*stype = instanceData->streamMode;
|
|
|
|
|
|
|
|
if (instanceData->streamBufSize) {
|
|
|
|
free(instanceData->streamBuf);
|
|
|
|
instanceData->streamBufSize = 0;
|
|
|
|
if (instanceData->testFunction == FUNCTION_NPP_POSTURL &&
|
|
|
|
instanceData->postMode == POSTMODE_STREAM) {
|
|
|
|
instanceData->testFunction = FUNCTION_NPP_GETURL;
|
|
|
|
}
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
|
|
|
|
{
|
2009-09-18 07:08:08 -07:00
|
|
|
printf("NPP_DestroyStream\n");
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
if (instanceData->streamMode == NP_ASFILE) {
|
|
|
|
if (strcmp(reinterpret_cast<char *>(instanceData->fileBuf),
|
|
|
|
reinterpret_cast<char *>(instanceData->streamBuf)) != 0) {
|
|
|
|
instanceData->err <<
|
|
|
|
"Error: data passed to NPP_Write and NPP_StreamAsFile differed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (instanceData->frame.length() > 0 &&
|
2009-09-24 15:23:35 -07:00
|
|
|
instanceData->testFunction != FUNCTION_NPP_GETURLNOTIFY &&
|
|
|
|
instanceData->testFunction != FUNCTION_NPP_POSTURL) {
|
2009-09-18 07:08:08 -07:00
|
|
|
sendBufferToFrame(instance);
|
|
|
|
}
|
|
|
|
if (instanceData->testFunction == FUNCTION_NPP_POSTURL) {
|
|
|
|
NPError err = NPN_PostURL(instance, instanceData->testUrl.c_str(),
|
|
|
|
instanceData->postMode == POSTMODE_FRAME ? instanceData->frame.c_str() : NULL,
|
|
|
|
instanceData->streamBufSize,
|
|
|
|
reinterpret_cast<char *>(instanceData->streamBuf), false);
|
|
|
|
if (err != NPERR_NO_ERROR)
|
|
|
|
instanceData->err << "Error: NPN_PostURL returned error value " << err;
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
NPP_WriteReady(NPP instance, NPStream* stream)
|
|
|
|
{
|
2009-09-18 07:08:08 -07:00
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
return instanceData->streamChunkSize;
|
2009-01-12 19:06:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
|
|
|
|
{
|
2009-09-18 07:08:08 -07:00
|
|
|
printf("NPP_Write, offset=%d, len=%d, end=%d\n", offset, len, stream->end);
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
|
|
|
|
// If the complete stream has been written, and we're doing a seek test,
|
|
|
|
// then call NPN_RequestRead.
|
|
|
|
if (instanceData->streamMode == NP_SEEK &&
|
|
|
|
stream->end != 0 &&
|
|
|
|
stream->end == (instanceData->streamBufSize + len)) {
|
|
|
|
// prevent recursion
|
|
|
|
instanceData->streamMode = NP_NORMAL;
|
|
|
|
|
|
|
|
if (instanceData->testrange != NULL) {
|
|
|
|
NPError err = NPN_RequestRead(stream, instanceData->testrange);
|
|
|
|
if (err != NPERR_NO_ERROR) {
|
|
|
|
instanceData->err << "NPN_RequestRead returned error %d" << err;
|
|
|
|
}
|
|
|
|
printf("called NPN_RequestRead, return %d\n", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char* streamBuf = reinterpret_cast<char *>(instanceData->streamBuf);
|
|
|
|
if (offset + len <= instanceData->streamBufSize) {
|
|
|
|
if (memcmp(buffer, streamBuf + offset, len)) {
|
|
|
|
instanceData->err <<
|
|
|
|
"Error: data written from NPN_RequestRead doesn't match";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("data matches!\n");
|
|
|
|
}
|
|
|
|
TestRange* range = instanceData->testrange;
|
|
|
|
bool stillwaiting = false;
|
|
|
|
while(range != NULL) {
|
|
|
|
if (offset == range->offset &&
|
|
|
|
len == range->length) {
|
|
|
|
range->waiting = false;
|
|
|
|
}
|
|
|
|
if (range->waiting) stillwaiting = true;
|
|
|
|
range = reinterpret_cast<TestRange*>(range->next);
|
|
|
|
}
|
|
|
|
if (!stillwaiting) {
|
|
|
|
NPError err = NPN_DestroyStream(instance, stream, NPRES_DONE);
|
|
|
|
if (err != NPERR_NO_ERROR) {
|
|
|
|
instanceData->err << "Error: NPN_DestroyStream returned " << err;
|
|
|
|
}
|
|
|
|
if (instanceData->frame.length() > 0) {
|
|
|
|
sendBufferToFrame(instance);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (instanceData->streamBufSize == 0) {
|
|
|
|
instanceData->streamBuf = malloc(len + 1);
|
|
|
|
streamBuf = reinterpret_cast<char *>(instanceData->streamBuf);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
instanceData->streamBuf =
|
|
|
|
realloc(reinterpret_cast<char *>(instanceData->streamBuf),
|
|
|
|
instanceData->streamBufSize + len + 1);
|
|
|
|
streamBuf = reinterpret_cast<char *>(instanceData->streamBuf);
|
|
|
|
}
|
|
|
|
memcpy(streamBuf + instanceData->streamBufSize, buffer, len);
|
|
|
|
instanceData->streamBufSize = instanceData->streamBufSize + len;
|
|
|
|
streamBuf[instanceData->streamBufSize] = '\0';
|
|
|
|
}
|
|
|
|
return len;
|
2009-01-12 19:06:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
|
|
|
|
{
|
2009-09-18 07:08:08 -07:00
|
|
|
printf("NPP_StreamAsFile, file=%s\n", fname);
|
2009-09-24 15:23:35 -07:00
|
|
|
size_t size;
|
2009-09-18 07:08:08 -07:00
|
|
|
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
|
|
|
|
if (!fname)
|
|
|
|
return;
|
|
|
|
|
2009-09-24 15:23:35 -07:00
|
|
|
FILE *file = fopen(fname, "rb");
|
|
|
|
if (file) {
|
|
|
|
fseek(file, 0, SEEK_END);
|
|
|
|
size = ftell(file);
|
2009-09-18 07:08:08 -07:00
|
|
|
instanceData->fileBuf = malloc((int32_t)size + 1);
|
|
|
|
char* buf = reinterpret_cast<char *>(instanceData->fileBuf);
|
2009-09-24 15:23:35 -07:00
|
|
|
fseek(file, 0, SEEK_SET);
|
|
|
|
fread(instanceData->fileBuf, 1, size, file);
|
|
|
|
fclose(file);
|
2009-09-18 07:08:08 -07:00
|
|
|
buf[size] = '\0';
|
|
|
|
instanceData->fileBufSize = (int32_t)size;
|
|
|
|
}
|
2009-09-24 15:23:35 -07:00
|
|
|
else {
|
|
|
|
printf("Unable to open file\n");
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPP_Print(NPP instance, NPPrint* platformPrint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int16_t
|
|
|
|
NPP_HandleEvent(NPP instance, void* event)
|
|
|
|
{
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
return pluginHandleEvent(instanceData, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
|
|
|
{
|
2009-09-18 07:08:08 -07:00
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
|
|
|
printf("NPP_URLNotify called\n");
|
|
|
|
if (strcmp((char*)notifyData, NPN_GetURLNotifyCookie) != 0) {
|
|
|
|
printf("ERROR! NPP_URLNotify called with wrong cookie\n");
|
|
|
|
instanceData->err << "Error: NPP_URLNotify called with wrong cookie";
|
|
|
|
}
|
|
|
|
if (instanceData->frame.length() > 0) {
|
|
|
|
sendBufferToFrame(instance);
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_GetValue(NPP instance, NPPVariable variable, void* value)
|
|
|
|
{
|
2009-03-31 18:07:19 -07:00
|
|
|
InstanceData* instanceData = (InstanceData*)instance->pdata;
|
2009-01-12 19:06:21 -08:00
|
|
|
if (variable == NPPVpluginScriptableNPObject) {
|
2009-03-31 18:07:19 -07:00
|
|
|
NPObject* object = instanceData->scriptableObject;
|
2009-01-12 19:06:21 -08:00
|
|
|
NPN_RetainObject(object);
|
|
|
|
*((NPObject**)value) = object;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2009-03-31 18:07:19 -07:00
|
|
|
if (variable == NPPVpluginNeedsXEmbed) {
|
|
|
|
// Only relevant for X plugins
|
|
|
|
*(NPBool*)value = instanceData->hasWidget;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPP_SetValue(NPP instance, NPNVariable variable, void* value)
|
|
|
|
{
|
2009-01-30 13:40:14 -08:00
|
|
|
if (variable == NPNVprivateModeBool) {
|
|
|
|
InstanceData* instanceData = (InstanceData*)(instance->pdata);
|
2009-04-05 17:04:02 -07:00
|
|
|
instanceData->lastReportedPrivateModeState = bool(*static_cast<NPBool*>(value));
|
2009-01-30 13:40:14 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// npapi browser functions
|
|
|
|
//
|
|
|
|
|
|
|
|
bool
|
|
|
|
NPN_SetProperty(NPP instance, NPObject* obj, NPIdentifier propertyName, const NPVariant* value)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->setproperty(instance, obj, propertyName, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPIdentifier
|
|
|
|
NPN_GetIntIdentifier(int32_t intid)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->getintidentifier(intid);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPIdentifier
|
|
|
|
NPN_GetStringIdentifier(const NPUTF8* name)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->getstringidentifier(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->getstringidentifiers(names, nameCount, identifiers);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPUTF8*
|
|
|
|
NPN_UTF8FromIdentifier(NPIdentifier identifier)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->utf8fromidentifier(identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
NPN_IntFromIdentifier(NPIdentifier identifier)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->intfromidentifier(identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_GetValue(NPP instance, NPNVariable variable, void* value)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->getvalue(instance, variable, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_SetValue(NPP instance, NPPVariable variable, void* value)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->setvalue(instance, variable, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
NPN_HasProperty(NPP instance, NPObject* obj, NPIdentifier propertyName)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->hasproperty(instance, obj, propertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPObject*
|
|
|
|
NPN_CreateObject(NPP instance, NPClass* aClass)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->createobject(instance, aClass);
|
|
|
|
}
|
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
bool
|
|
|
|
NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->invoke(npp, obj, methodName, args, argCount, result);
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
const char*
|
|
|
|
NPN_UserAgent(NPP instance)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->uagent(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPObject*
|
|
|
|
NPN_RetainObject(NPObject* obj)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->retainobject(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPN_ReleaseObject(NPObject* obj)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->releaseobject(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
|
|
|
NPN_MemAlloc(uint32_t size)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->memalloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPN_MemFree(void* ptr)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->memfree(ptr);
|
|
|
|
}
|
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
uint32_t
|
|
|
|
NPN_ScheduleTimer(NPP instance, uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID))
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->scheduletimer(instance, interval, repeat, timerFunc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPN_UnscheduleTimer(NPP instance, uint32_t timerID)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->unscheduletimer(instance, timerID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NPN_ReleaseVariantValue(NPVariant *variant)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->releasevariantvalue(variant);
|
|
|
|
}
|
|
|
|
|
2009-09-18 07:08:08 -07:00
|
|
|
NPError
|
|
|
|
NPN_GetURLNotify(NPP instance, const char* url, const char* target, void* notifyData)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->geturlnotify(instance, url, target, notifyData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_GetURL(NPP instance, const char* url, const char* target)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->geturl(instance, url, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->requestread(stream, rangeList);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_PostURLNotify(NPP instance, const char* url,
|
|
|
|
const char* target, uint32_t len,
|
|
|
|
const char* buf, NPBool file, void* notifyData)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->posturlnotify(instance, url, target, len, buf, file, notifyData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_PostURL(NPP instance, const char *url,
|
|
|
|
const char *target, uint32_t len,
|
|
|
|
const char *buf, NPBool file)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->posturl(instance, url, target, len, buf, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
|
|
|
{
|
|
|
|
return sBrowserFuncs->destroystream(instance, stream, reason);
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
//
|
|
|
|
// npruntime object functions
|
|
|
|
//
|
|
|
|
|
|
|
|
NPObject*
|
|
|
|
scriptableAllocate(NPP npp, NPClass* aClass)
|
|
|
|
{
|
|
|
|
TestNPObject* object = (TestNPObject*)NPN_MemAlloc(sizeof(TestNPObject));
|
|
|
|
if (!object)
|
|
|
|
return NULL;
|
|
|
|
memset(object, 0, sizeof(TestNPObject));
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
scriptableDeallocate(NPObject* npobj)
|
|
|
|
{
|
|
|
|
NPN_MemFree(npobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
scriptableInvalidate(NPObject* npobj)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableHasMethod(NPObject* npobj, NPIdentifier name)
|
|
|
|
{
|
2009-04-05 17:04:02 -07:00
|
|
|
for (int i = 0; i < int(ARRAY_LENGTH(sPluginMethodIdentifiers)); i++) {
|
2009-01-12 19:06:21 -08:00
|
|
|
if (name == sPluginMethodIdentifiers[i])
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableInvoke(NPObject* npobj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
2009-04-05 17:04:02 -07:00
|
|
|
for (int i = 0; i < int(ARRAY_LENGTH(sPluginMethodIdentifiers)); i++) {
|
2009-03-31 18:07:19 -07:00
|
|
|
if (name == sPluginMethodIdentifiers[i])
|
|
|
|
return sPluginMethodFunctions[i](npobj, args, argCount, result);
|
|
|
|
}
|
2009-01-12 19:06:21 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableInvokeDefault(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableHasProperty(NPObject* npobj, NPIdentifier name)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableSetProperty(NPObject* npobj, NPIdentifier name, const NPVariant* value)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableRemoveProperty(NPObject* npobj, NPIdentifier name)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableEnumerate(NPObject* npobj, NPIdentifier** identifier, uint32_t* count)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
scriptableConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// test functions
|
|
|
|
//
|
|
|
|
|
2009-04-10 17:15:42 -07:00
|
|
|
static bool
|
|
|
|
setUndefinedValueTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
|
|
|
NPError err = NPN_SetValue(npp, (NPPVariable)0x0, 0x0);
|
|
|
|
BOOLEAN_TO_NPVARIANT((err == NPERR_NO_ERROR), *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
static bool
|
2009-01-30 13:40:14 -08:00
|
|
|
identifierToStringTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
2009-01-12 19:06:21 -08:00
|
|
|
{
|
|
|
|
if (argCount != 1)
|
|
|
|
return false;
|
|
|
|
NPIdentifier identifier = variantToIdentifier(args[0]);
|
|
|
|
if (!identifier)
|
|
|
|
return false;
|
2009-04-05 17:04:02 -07:00
|
|
|
|
2009-01-12 19:06:21 -08:00
|
|
|
NPUTF8* utf8String = NPN_UTF8FromIdentifier(identifier);
|
|
|
|
if (!utf8String)
|
|
|
|
return false;
|
|
|
|
STRINGZ_TO_NPVARIANT(utf8String, *result);
|
|
|
|
return true;
|
|
|
|
}
|
2009-01-30 13:40:14 -08:00
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
static void timerCallback(NPP npp, uint32_t timerID)
|
|
|
|
{
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
|
|
|
|
|
|
|
NPObject* windowObject;
|
|
|
|
NPN_GetValue(npp, NPNVWindowNPObject, &windowObject);
|
|
|
|
if (!windowObject)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NPVariant rval;
|
|
|
|
if (timerID == id->timerID1)
|
|
|
|
NPN_Invoke(npp, windowObject, NPN_GetStringIdentifier("shortTimerFired"), NULL, 0, &rval);
|
|
|
|
else if (timerID == id->timerID2)
|
|
|
|
NPN_Invoke(npp, windowObject, NPN_GetStringIdentifier("longTimerFired"), NULL, 0, &rval);
|
|
|
|
|
|
|
|
NPN_ReleaseObject(windowObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
timerTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
|
|
|
|
|
|
|
NPObject* windowObject;
|
|
|
|
NPN_GetValue(npp, NPNVWindowNPObject, &windowObject);
|
|
|
|
if (!windowObject)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
id->timerID1 = NPN_ScheduleTimer(npp, 50, false, timerCallback);
|
|
|
|
id->timerID2 = NPN_ScheduleTimer(npp, 150, true, timerCallback);
|
|
|
|
|
|
|
|
NPVariant rval;
|
|
|
|
NPVariant uniqueIDArgs[1];
|
|
|
|
BOOLEAN_TO_NPVARIANT((id->timerID1 != id->timerID2), uniqueIDArgs[0]);
|
|
|
|
NPN_Invoke(npp, windowObject, NPN_GetStringIdentifier("uniqueID"), uniqueIDArgs, 1, &rval);
|
|
|
|
NPN_ReleaseVariantValue(&uniqueIDArgs[0]);
|
|
|
|
|
|
|
|
NPN_ReleaseObject(windowObject);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
static bool
|
2009-01-30 13:40:14 -08:00
|
|
|
queryPrivateModeState(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
2009-04-05 17:04:02 -07:00
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
|
2009-01-30 13:40:14 -08:00
|
|
|
NPBool pms = false;
|
|
|
|
NPN_GetValue(static_cast<TestNPObject*>(npobj)->npp, NPNVprivateModeBool, &pms);
|
|
|
|
BOOLEAN_TO_NPVARIANT(pms, *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
static bool
|
2009-01-30 13:40:14 -08:00
|
|
|
lastReportedPrivateModeState(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
2009-04-05 17:04:02 -07:00
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
|
2009-01-30 13:40:14 -08:00
|
|
|
InstanceData* id = static_cast<InstanceData*>(static_cast<TestNPObject*>(npobj)->npp->pdata);
|
2009-03-31 18:07:19 -07:00
|
|
|
BOOLEAN_TO_NPVARIANT(id->lastReportedPrivateModeState, *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
hasWidget(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
2009-04-05 17:04:02 -07:00
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
|
2009-03-31 18:07:19 -07:00
|
|
|
InstanceData* id = static_cast<InstanceData*>(static_cast<TestNPObject*>(npobj)->npp->pdata);
|
|
|
|
BOOLEAN_TO_NPVARIANT(id->hasWidget, *result);
|
2009-01-30 13:40:14 -08:00
|
|
|
return true;
|
|
|
|
}
|
2009-04-05 17:04:02 -07:00
|
|
|
|
|
|
|
static bool
|
|
|
|
getEdge(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 1)
|
|
|
|
return false;
|
|
|
|
if (!NPVARIANT_IS_INT32(args[0]))
|
|
|
|
return false;
|
|
|
|
int32_t edge = NPVARIANT_TO_INT32(args[0]);
|
|
|
|
if (edge < EDGE_LEFT || edge > EDGE_BOTTOM)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(static_cast<TestNPObject*>(npobj)->npp->pdata);
|
|
|
|
int32_t r = pluginGetEdge(id, RectEdge(edge));
|
|
|
|
if (r == NPTEST_INT32_ERROR)
|
|
|
|
return false;
|
|
|
|
INT32_TO_NPVARIANT(r, *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
getClipRegionRectCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(static_cast<TestNPObject*>(npobj)->npp->pdata);
|
|
|
|
int32_t r = pluginGetClipRegionRectCount(id);
|
|
|
|
if (r == NPTEST_INT32_ERROR)
|
|
|
|
return false;
|
|
|
|
INT32_TO_NPVARIANT(r, *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
getClipRegionRectEdge(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 2)
|
|
|
|
return false;
|
|
|
|
if (!NPVARIANT_IS_INT32(args[0]))
|
|
|
|
return false;
|
|
|
|
int32_t rectIndex = NPVARIANT_TO_INT32(args[0]);
|
|
|
|
if (rectIndex < 0)
|
|
|
|
return false;
|
|
|
|
if (!NPVARIANT_IS_INT32(args[1]))
|
|
|
|
return false;
|
|
|
|
int32_t edge = NPVARIANT_TO_INT32(args[1]);
|
|
|
|
if (edge < EDGE_LEFT || edge > EDGE_BOTTOM)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(static_cast<TestNPObject*>(npobj)->npp->pdata);
|
|
|
|
int32_t r = pluginGetClipRegionRectEdge(id, rectIndex, RectEdge(edge));
|
|
|
|
if (r == NPTEST_INT32_ERROR)
|
|
|
|
return false;
|
|
|
|
INT32_TO_NPVARIANT(r, *result);
|
|
|
|
return true;
|
|
|
|
}
|
2009-05-07 18:32:32 -07:00
|
|
|
|
|
|
|
static bool
|
|
|
|
startWatchingInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
if (sWatchingInstanceCount)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sWatchingInstanceCount = true;
|
|
|
|
sInstanceCount = 0;
|
|
|
|
++sCurrentInstanceCountWatchGeneration;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
getInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
if (!sWatchingInstanceCount)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
INT32_TO_NPVARIANT(sInstanceCount, *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
stopWatchingInstanceCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
if (!sWatchingInstanceCount)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sWatchingInstanceCount = false;
|
|
|
|
return true;
|
|
|
|
}
|
2009-07-01 08:09:49 -07:00
|
|
|
|
|
|
|
static bool
|
|
|
|
unscheduleAllTimers(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
|
|
|
|
|
|
|
NPN_UnscheduleTimer(npp, id->timerID1);
|
|
|
|
id->timerID1 = 0;
|
|
|
|
NPN_UnscheduleTimer(npp, id->timerID2);
|
|
|
|
id->timerID2 = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-08-04 18:36:37 -07:00
|
|
|
|
|
|
|
static bool
|
|
|
|
getLastMouseX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
|
|
|
INT32_TO_NPVARIANT(id->lastMouseX, *result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
getLastMouseY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
|
|
|
{
|
|
|
|
if (argCount != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
|
|
|
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
|
|
|
INT32_TO_NPVARIANT(id->lastMouseY, *result);
|
|
|
|
return true;
|
|
|
|
}
|