зеркало из https://github.com/mozilla/gecko-dev.git
Clean up a bunch of things in nsNPAPIPlugin. b=543339
This commit is contained in:
Родитель
bd5f0b64ba
Коммит
c1b32a0fc9
|
@ -83,9 +83,6 @@ typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCal
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
|
||||||
#ifdef XP_MACOSX
|
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownProcPtr* unloadProcPtr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace plugins {
|
namespace plugins {
|
||||||
|
|
|
@ -109,6 +109,7 @@ using mozilla::PluginPRLibrary;
|
||||||
using mozilla::plugins::PluginModuleParent;
|
using mozilla::plugins::PluginModuleParent;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static NPNetscapeFuncs sBrowserFuncs;
|
||||||
static PRLock *sPluginThreadAsyncCallLock = nsnull;
|
static PRLock *sPluginThreadAsyncCallLock = nsnull;
|
||||||
static PRCList sPendingAsyncCalls = PR_INIT_STATIC_CLIST(&sPendingAsyncCalls);
|
static PRCList sPendingAsyncCalls = PR_INIT_STATIC_CLIST(&sPendingAsyncCalls);
|
||||||
|
|
||||||
|
@ -142,10 +143,8 @@ void NS_NotifyPluginCall(PRIntervalTime startTime)
|
||||||
runTime);
|
runTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
NPNetscapeFuncs nsNPAPIPlugin::CALLBACKS;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNPAPIPlugin::CheckClassInitialized(void)
|
nsNPAPIPlugin::CheckClassInitialized()
|
||||||
{
|
{
|
||||||
static PRBool initialized = PR_FALSE;
|
static PRBool initialized = PR_FALSE;
|
||||||
|
|
||||||
|
@ -153,62 +152,60 @@ nsNPAPIPlugin::CheckClassInitialized(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// XXX It'd be nice to make this const and initialize it statically...
|
// XXX It'd be nice to make this const and initialize it statically...
|
||||||
CALLBACKS.size = sizeof(CALLBACKS);
|
sBrowserFuncs.size = sizeof(sBrowserFuncs);
|
||||||
CALLBACKS.version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
sBrowserFuncs.version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
|
||||||
CALLBACKS.geturl = ((NPN_GetURLProcPtr)_geturl);
|
sBrowserFuncs.geturl = ((NPN_GetURLProcPtr)_geturl);
|
||||||
CALLBACKS.posturl = ((NPN_PostURLProcPtr)_posturl);
|
sBrowserFuncs.posturl = ((NPN_PostURLProcPtr)_posturl);
|
||||||
CALLBACKS.requestread = ((NPN_RequestReadProcPtr)_requestread);
|
sBrowserFuncs.requestread = ((NPN_RequestReadProcPtr)_requestread);
|
||||||
CALLBACKS.newstream = ((NPN_NewStreamProcPtr)_newstream);
|
sBrowserFuncs.newstream = ((NPN_NewStreamProcPtr)_newstream);
|
||||||
CALLBACKS.write = ((NPN_WriteProcPtr)_write);
|
sBrowserFuncs.write = ((NPN_WriteProcPtr)_write);
|
||||||
CALLBACKS.destroystream = ((NPN_DestroyStreamProcPtr)_destroystream);
|
sBrowserFuncs.destroystream = ((NPN_DestroyStreamProcPtr)_destroystream);
|
||||||
CALLBACKS.status = ((NPN_StatusProcPtr)_status);
|
sBrowserFuncs.status = ((NPN_StatusProcPtr)_status);
|
||||||
CALLBACKS.uagent = ((NPN_UserAgentProcPtr)_useragent);
|
sBrowserFuncs.uagent = ((NPN_UserAgentProcPtr)_useragent);
|
||||||
CALLBACKS.memalloc = ((NPN_MemAllocProcPtr)_memalloc);
|
sBrowserFuncs.memalloc = ((NPN_MemAllocProcPtr)_memalloc);
|
||||||
CALLBACKS.memfree = ((NPN_MemFreeProcPtr)_memfree);
|
sBrowserFuncs.memfree = ((NPN_MemFreeProcPtr)_memfree);
|
||||||
CALLBACKS.memflush = ((NPN_MemFlushProcPtr)_memflush);
|
sBrowserFuncs.memflush = ((NPN_MemFlushProcPtr)_memflush);
|
||||||
CALLBACKS.reloadplugins = ((NPN_ReloadPluginsProcPtr)_reloadplugins);
|
sBrowserFuncs.reloadplugins = ((NPN_ReloadPluginsProcPtr)_reloadplugins);
|
||||||
|
sBrowserFuncs.getJavaEnv = ((NPN_GetJavaEnvProcPtr)_getJavaEnv);
|
||||||
// Deprecated API callbacks.
|
sBrowserFuncs.getJavaPeer = ((NPN_GetJavaPeerProcPtr)_getJavaPeer);
|
||||||
CALLBACKS.getJavaEnv = ((NPN_GetJavaEnvProcPtr)_getJavaEnv);
|
sBrowserFuncs.geturlnotify = ((NPN_GetURLNotifyProcPtr)_geturlnotify);
|
||||||
CALLBACKS.getJavaPeer = ((NPN_GetJavaPeerProcPtr)_getJavaPeer);
|
sBrowserFuncs.posturlnotify = ((NPN_PostURLNotifyProcPtr)_posturlnotify);
|
||||||
CALLBACKS.geturlnotify = ((NPN_GetURLNotifyProcPtr)_geturlnotify);
|
sBrowserFuncs.getvalue = ((NPN_GetValueProcPtr)_getvalue);
|
||||||
CALLBACKS.posturlnotify = ((NPN_PostURLNotifyProcPtr)_posturlnotify);
|
sBrowserFuncs.setvalue = ((NPN_SetValueProcPtr)_setvalue);
|
||||||
CALLBACKS.getvalue = ((NPN_GetValueProcPtr)_getvalue);
|
sBrowserFuncs.invalidaterect = ((NPN_InvalidateRectProcPtr)_invalidaterect);
|
||||||
CALLBACKS.setvalue = ((NPN_SetValueProcPtr)_setvalue);
|
sBrowserFuncs.invalidateregion = ((NPN_InvalidateRegionProcPtr)_invalidateregion);
|
||||||
CALLBACKS.invalidaterect = ((NPN_InvalidateRectProcPtr)_invalidaterect);
|
sBrowserFuncs.forceredraw = ((NPN_ForceRedrawProcPtr)_forceredraw);
|
||||||
CALLBACKS.invalidateregion = ((NPN_InvalidateRegionProcPtr)_invalidateregion);
|
sBrowserFuncs.getstringidentifier = ((NPN_GetStringIdentifierProcPtr)_getstringidentifier);
|
||||||
CALLBACKS.forceredraw = ((NPN_ForceRedrawProcPtr)_forceredraw);
|
sBrowserFuncs.getstringidentifiers = ((NPN_GetStringIdentifiersProcPtr)_getstringidentifiers);
|
||||||
CALLBACKS.getstringidentifier = ((NPN_GetStringIdentifierProcPtr)_getstringidentifier);
|
sBrowserFuncs.getintidentifier = ((NPN_GetIntIdentifierProcPtr)_getintidentifier);
|
||||||
CALLBACKS.getstringidentifiers = ((NPN_GetStringIdentifiersProcPtr)_getstringidentifiers);
|
sBrowserFuncs.identifierisstring = ((NPN_IdentifierIsStringProcPtr)_identifierisstring);
|
||||||
CALLBACKS.getintidentifier = ((NPN_GetIntIdentifierProcPtr)_getintidentifier);
|
sBrowserFuncs.utf8fromidentifier = ((NPN_UTF8FromIdentifierProcPtr)_utf8fromidentifier);
|
||||||
CALLBACKS.identifierisstring = ((NPN_IdentifierIsStringProcPtr)_identifierisstring);
|
sBrowserFuncs.intfromidentifier = ((NPN_IntFromIdentifierProcPtr)_intfromidentifier);
|
||||||
CALLBACKS.utf8fromidentifier = ((NPN_UTF8FromIdentifierProcPtr)_utf8fromidentifier);
|
sBrowserFuncs.createobject = ((NPN_CreateObjectProcPtr)_createobject);
|
||||||
CALLBACKS.intfromidentifier = ((NPN_IntFromIdentifierProcPtr)_intfromidentifier);
|
sBrowserFuncs.retainobject = ((NPN_RetainObjectProcPtr)_retainobject);
|
||||||
CALLBACKS.createobject = ((NPN_CreateObjectProcPtr)_createobject);
|
sBrowserFuncs.releaseobject = ((NPN_ReleaseObjectProcPtr)_releaseobject);
|
||||||
CALLBACKS.retainobject = ((NPN_RetainObjectProcPtr)_retainobject);
|
sBrowserFuncs.invoke = ((NPN_InvokeProcPtr)_invoke);
|
||||||
CALLBACKS.releaseobject = ((NPN_ReleaseObjectProcPtr)_releaseobject);
|
sBrowserFuncs.invokeDefault = ((NPN_InvokeDefaultProcPtr)_invokeDefault);
|
||||||
CALLBACKS.invoke = ((NPN_InvokeProcPtr)_invoke);
|
sBrowserFuncs.evaluate = ((NPN_EvaluateProcPtr)_evaluate);
|
||||||
CALLBACKS.invokeDefault = ((NPN_InvokeDefaultProcPtr)_invokeDefault);
|
sBrowserFuncs.getproperty = ((NPN_GetPropertyProcPtr)_getproperty);
|
||||||
CALLBACKS.evaluate = ((NPN_EvaluateProcPtr)_evaluate);
|
sBrowserFuncs.setproperty = ((NPN_SetPropertyProcPtr)_setproperty);
|
||||||
CALLBACKS.getproperty = ((NPN_GetPropertyProcPtr)_getproperty);
|
sBrowserFuncs.removeproperty = ((NPN_RemovePropertyProcPtr)_removeproperty);
|
||||||
CALLBACKS.setproperty = ((NPN_SetPropertyProcPtr)_setproperty);
|
sBrowserFuncs.hasproperty = ((NPN_HasPropertyProcPtr)_hasproperty);
|
||||||
CALLBACKS.removeproperty = ((NPN_RemovePropertyProcPtr)_removeproperty);
|
sBrowserFuncs.hasmethod = ((NPN_HasMethodProcPtr)_hasmethod);
|
||||||
CALLBACKS.hasproperty = ((NPN_HasPropertyProcPtr)_hasproperty);
|
sBrowserFuncs.enumerate = ((NPN_EnumerateProcPtr)_enumerate);
|
||||||
CALLBACKS.hasmethod = ((NPN_HasMethodProcPtr)_hasmethod);
|
sBrowserFuncs.construct = ((NPN_ConstructProcPtr)_construct);
|
||||||
CALLBACKS.enumerate = ((NPN_EnumerateProcPtr)_enumerate);
|
sBrowserFuncs.releasevariantvalue = ((NPN_ReleaseVariantValueProcPtr)_releasevariantvalue);
|
||||||
CALLBACKS.construct = ((NPN_ConstructProcPtr)_construct);
|
sBrowserFuncs.setexception = ((NPN_SetExceptionProcPtr)_setexception);
|
||||||
CALLBACKS.releasevariantvalue = ((NPN_ReleaseVariantValueProcPtr)_releasevariantvalue);
|
sBrowserFuncs.pushpopupsenabledstate = ((NPN_PushPopupsEnabledStateProcPtr)_pushpopupsenabledstate);
|
||||||
CALLBACKS.setexception = ((NPN_SetExceptionProcPtr)_setexception);
|
sBrowserFuncs.poppopupsenabledstate = ((NPN_PopPopupsEnabledStateProcPtr)_poppopupsenabledstate);
|
||||||
CALLBACKS.pushpopupsenabledstate = ((NPN_PushPopupsEnabledStateProcPtr)_pushpopupsenabledstate);
|
sBrowserFuncs.pluginthreadasynccall = ((NPN_PluginThreadAsyncCallProcPtr)_pluginthreadasynccall);
|
||||||
CALLBACKS.poppopupsenabledstate = ((NPN_PopPopupsEnabledStateProcPtr)_poppopupsenabledstate);
|
sBrowserFuncs.getvalueforurl = ((NPN_GetValueForURLPtr)_getvalueforurl);
|
||||||
CALLBACKS.pluginthreadasynccall = ((NPN_PluginThreadAsyncCallProcPtr)_pluginthreadasynccall);
|
sBrowserFuncs.setvalueforurl = ((NPN_SetValueForURLPtr)_setvalueforurl);
|
||||||
CALLBACKS.getvalueforurl = ((NPN_GetValueForURLPtr)_getvalueforurl);
|
sBrowserFuncs.getauthenticationinfo = ((NPN_GetAuthenticationInfoPtr)_getauthenticationinfo);
|
||||||
CALLBACKS.setvalueforurl = ((NPN_SetValueForURLPtr)_setvalueforurl);
|
sBrowserFuncs.scheduletimer = ((NPN_ScheduleTimerPtr)_scheduletimer);
|
||||||
CALLBACKS.getauthenticationinfo = ((NPN_GetAuthenticationInfoPtr)_getauthenticationinfo);
|
sBrowserFuncs.unscheduletimer = ((NPN_UnscheduleTimerPtr)_unscheduletimer);
|
||||||
CALLBACKS.scheduletimer = ((NPN_ScheduleTimerPtr)_scheduletimer);
|
sBrowserFuncs.popupcontextmenu = ((NPN_PopUpContextMenuPtr)_popupcontextmenu);
|
||||||
CALLBACKS.unscheduletimer = ((NPN_UnscheduleTimerPtr)_unscheduletimer);
|
sBrowserFuncs.convertpoint = ((NPN_ConvertPointPtr)_convertpoint);
|
||||||
CALLBACKS.popupcontextmenu = ((NPN_PopUpContextMenuPtr)_popupcontextmenu);
|
|
||||||
CALLBACKS.convertpoint = ((NPN_ConvertPointPtr)_convertpoint);
|
|
||||||
|
|
||||||
if (!sPluginThreadAsyncCallLock)
|
if (!sPluginThreadAsyncCallLock)
|
||||||
sPluginThreadAsyncCallLock = nsAutoLock::NewLock("sPluginThreadAsyncCallLock");
|
sPluginThreadAsyncCallLock = nsAutoLock::NewLock("sPluginThreadAsyncCallLock");
|
||||||
|
@ -223,22 +220,23 @@ NS_IMPL_ISUPPORTS1(nsNPAPIPlugin, nsIPlugin)
|
||||||
nsNPAPIPlugin::nsNPAPIPlugin(NPPluginFuncs* callbacks,
|
nsNPAPIPlugin::nsNPAPIPlugin(NPPluginFuncs* callbacks,
|
||||||
PluginLibrary* aLibrary)
|
PluginLibrary* aLibrary)
|
||||||
{
|
{
|
||||||
memset((void*) &fCallbacks, 0, sizeof(fCallbacks));
|
memset((void*) &mPluginFuncs, 0, sizeof(mPluginFuncs));
|
||||||
|
|
||||||
fCallbacks.size = sizeof(fCallbacks);
|
mPluginFuncs.size = sizeof(mPluginFuncs);
|
||||||
fLibrary = nsnull;
|
mLibrary = nsnull;
|
||||||
mIsDefaultPlugin = PR_FALSE;
|
mIsDefaultPlugin = PR_FALSE;
|
||||||
|
|
||||||
#if defined(XP_WIN) || defined(XP_OS2)
|
#if defined(XP_WIN) || defined(XP_OS2)
|
||||||
// On Windows (and Mac) we need to keep a direct reference to the
|
// On Windows and OS/2 we need to keep a direct reference to
|
||||||
// fCallbacks and NOT just copy the struct. See Bugzilla 85334
|
// the plugin's function struct, we can't just copy it. See
|
||||||
|
// Mozilla bug 85334.
|
||||||
|
|
||||||
NPError gepError;
|
NPError gepError;
|
||||||
nsresult gepResult = aLibrary->NP_GetEntryPoints(&fCallbacks, &gepError);
|
nsresult gepResult = aLibrary->NP_GetEntryPoints(&mPluginFuncs, &gepError);
|
||||||
if (gepResult != NS_OK || gepError != NPERR_NO_ERROR)
|
if (gepResult != NS_OK || gepError != NPERR_NO_ERROR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NS_ASSERTION(HIBYTE(fCallbacks.version) >= NP_VERSION_MAJOR,
|
NS_ASSERTION(HIBYTE(mPluginFuncs.version) >= NP_VERSION_MAJOR,
|
||||||
"callback version is less than NP version");
|
"callback version is less than NP version");
|
||||||
|
|
||||||
#elif defined(XP_MACOSX)
|
#elif defined(XP_MACOSX)
|
||||||
|
@ -254,7 +252,7 @@ nsNPAPIPlugin::nsNPAPIPlugin(NPPluginFuncs* callbacks,
|
||||||
// we call NP_Initialize before getting function pointers to match
|
// we call NP_Initialize before getting function pointers to match
|
||||||
// WebKit's behavior. They implemented this first on Mac OS X.
|
// WebKit's behavior. They implemented this first on Mac OS X.
|
||||||
NPError initError;
|
NPError initError;
|
||||||
nsresult initResult = aLibrary->NP_Initialize(&(nsNPAPIPlugin::CALLBACKS), &initError);
|
nsresult initResult = aLibrary->NP_Initialize(&(sBrowserFuncs), &initError);
|
||||||
if (initResult != NS_OK || initError != NPERR_NO_ERROR)
|
if (initResult != NS_OK || initError != NPERR_NO_ERROR)
|
||||||
return;
|
return;
|
||||||
NPError gepError;
|
NPError gepError;
|
||||||
|
@ -262,34 +260,34 @@ nsNPAPIPlugin::nsNPAPIPlugin(NPPluginFuncs* callbacks,
|
||||||
if (gepResult != NS_OK || gepError != NPERR_NO_ERROR)
|
if (gepResult != NS_OK || gepError != NPERR_NO_ERROR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fCallbacks.version = np_callbacks.version;
|
mPluginFuncs.version = np_callbacks.version;
|
||||||
fCallbacks.newp = (NPP_NewProcPtr)np_callbacks.newp;
|
mPluginFuncs.newp = (NPP_NewProcPtr)np_callbacks.newp;
|
||||||
fCallbacks.destroy = (NPP_DestroyProcPtr)np_callbacks.destroy;
|
mPluginFuncs.destroy = (NPP_DestroyProcPtr)np_callbacks.destroy;
|
||||||
fCallbacks.setwindow = (NPP_SetWindowProcPtr)np_callbacks.setwindow;
|
mPluginFuncs.setwindow = (NPP_SetWindowProcPtr)np_callbacks.setwindow;
|
||||||
fCallbacks.newstream = (NPP_NewStreamProcPtr)np_callbacks.newstream;
|
mPluginFuncs.newstream = (NPP_NewStreamProcPtr)np_callbacks.newstream;
|
||||||
fCallbacks.destroystream = (NPP_DestroyStreamProcPtr)np_callbacks.destroystream;
|
mPluginFuncs.destroystream = (NPP_DestroyStreamProcPtr)np_callbacks.destroystream;
|
||||||
fCallbacks.asfile = (NPP_StreamAsFileProcPtr)np_callbacks.asfile;
|
mPluginFuncs.asfile = (NPP_StreamAsFileProcPtr)np_callbacks.asfile;
|
||||||
fCallbacks.writeready = (NPP_WriteReadyProcPtr)np_callbacks.writeready;
|
mPluginFuncs.writeready = (NPP_WriteReadyProcPtr)np_callbacks.writeready;
|
||||||
fCallbacks.write = (NPP_WriteProcPtr)np_callbacks.write;
|
mPluginFuncs.write = (NPP_WriteProcPtr)np_callbacks.write;
|
||||||
fCallbacks.print = (NPP_PrintProcPtr)np_callbacks.print;
|
mPluginFuncs.print = (NPP_PrintProcPtr)np_callbacks.print;
|
||||||
fCallbacks.event = (NPP_HandleEventProcPtr)np_callbacks.event;
|
mPluginFuncs.event = (NPP_HandleEventProcPtr)np_callbacks.event;
|
||||||
fCallbacks.urlnotify = (NPP_URLNotifyProcPtr)np_callbacks.urlnotify;
|
mPluginFuncs.urlnotify = (NPP_URLNotifyProcPtr)np_callbacks.urlnotify;
|
||||||
fCallbacks.getvalue = (NPP_GetValueProcPtr)np_callbacks.getvalue;
|
mPluginFuncs.getvalue = (NPP_GetValueProcPtr)np_callbacks.getvalue;
|
||||||
fCallbacks.setvalue = (NPP_SetValueProcPtr)np_callbacks.setvalue;
|
mPluginFuncs.setvalue = (NPP_SetValueProcPtr)np_callbacks.setvalue;
|
||||||
#else // for everyone else
|
#else // for everyone else
|
||||||
memcpy((void*) &fCallbacks, (void*) callbacks, sizeof(fCallbacks));
|
memcpy((void*) &mPluginFuncs, (void*) callbacks, sizeof(mPluginFuncs));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fLibrary = aLibrary;
|
mLibrary = aLibrary;
|
||||||
fLibrary->SetPlugin(this);
|
mLibrary->SetPlugin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsNPAPIPlugin::~nsNPAPIPlugin()
|
nsNPAPIPlugin::~nsNPAPIPlugin()
|
||||||
{
|
{
|
||||||
// reset the callbacks list
|
// reset the callbacks list
|
||||||
memset((void*) &fCallbacks, 0, sizeof(fCallbacks));
|
memset((void*) &mPluginFuncs, 0, sizeof(mPluginFuncs));
|
||||||
delete fLibrary;
|
delete mLibrary;
|
||||||
fLibrary = NULL;
|
mLibrary = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,7 +295,7 @@ nsNPAPIPlugin::~nsNPAPIPlugin()
|
||||||
void
|
void
|
||||||
nsNPAPIPlugin::SetPluginRefNum(short aRefNum)
|
nsNPAPIPlugin::SetPluginRefNum(short aRefNum)
|
||||||
{
|
{
|
||||||
fPluginRefNum = aRefNum;
|
mPluginRefNum = aRefNum;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -420,14 +418,14 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
|
||||||
plptr->Initialize();
|
plptr->Initialize();
|
||||||
|
|
||||||
NPError initError;
|
NPError initError;
|
||||||
nsresult initResult = pluginLib->NP_Initialize(&(nsNPAPIPlugin::CALLBACKS),&callbacks, &initError);
|
nsresult initResult = pluginLib->NP_Initialize(&(sBrowserFuncs),&callbacks, &initError);
|
||||||
if (initResult != NS_OK || initError != NPERR_NO_ERROR) {
|
if (initResult != NS_OK || initError != NPERR_NO_ERROR) {
|
||||||
NS_RELEASE(*aResult);
|
NS_RELEASE(*aResult);
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now copy function table back to nsNPAPIPlugin instance
|
// now copy function table back to nsNPAPIPlugin instance
|
||||||
memcpy((void*) &(plptr->fCallbacks), (void*)&callbacks, sizeof(callbacks));
|
memcpy((void*) &(plptr->mPluginFuncs), (void*)&callbacks, sizeof(callbacks));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
|
@ -452,7 +450,7 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
|
||||||
}
|
}
|
||||||
|
|
||||||
NPError initError;
|
NPError initError;
|
||||||
nsresult initResult = pluginLib->NP_Initialize(&(nsNPAPIPlugin::CALLBACKS), &initError);
|
nsresult initResult = pluginLib->NP_Initialize(&(sBrowserFuncs), &initError);
|
||||||
if (initResult != NS_OK || initError != NPERR_NO_ERROR)
|
if (initResult != NS_OK || initError != NPERR_NO_ERROR)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -524,7 +522,7 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
|
||||||
bChangedDir = TRUE;
|
bChangedDir = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = pfnInitialize(&(nsNPAPIPlugin::CALLBACKS));
|
nsresult rv = pfnInitialize(&(sBrowserFuncs));
|
||||||
|
|
||||||
if (bChangedDisk) {
|
if (bChangedDisk) {
|
||||||
rc= DosSetDefaultDisk(origDiskNum);
|
rc= DosSetDefaultDisk(origDiskNum);
|
||||||
|
@ -544,14 +542,12 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
short appRefNum = ::CurResFile();
|
short appRefNum = ::CurResFile();
|
||||||
short pluginRefNum;
|
short pluginRefNum;
|
||||||
#endif
|
|
||||||
|
|
||||||
nsCOMPtr<nsILocalFile> pluginPath;
|
nsCOMPtr<nsILocalFile> pluginPath;
|
||||||
NS_NewNativeLocalFile(nsDependentCString(aFilePath), PR_TRUE,
|
NS_NewNativeLocalFile(nsDependentCString(aFilePath), PR_TRUE,
|
||||||
getter_AddRefs(pluginPath));
|
getter_AddRefs(pluginPath));
|
||||||
nsPluginFile pluginFile(pluginPath);
|
nsPluginFile pluginFile(pluginPath);
|
||||||
|
|
||||||
#ifndef __LP64__
|
|
||||||
pluginRefNum = pluginFile.OpenPluginResource();
|
pluginRefNum = pluginFile.OpenPluginResource();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -610,11 +606,11 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
|
||||||
if (!pfnInitialize)
|
if (!pfnInitialize)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
if (pfnInitialize(&(nsNPAPIPlugin::CALLBACKS),&callbacks) != NS_OK)
|
if (pfnInitialize(&(sBrowserFuncs),&callbacks) != NS_OK)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// now copy function table back to nsNPAPIPlugin instance
|
// now copy function table back to nsNPAPIPlugin instance
|
||||||
memcpy((void*) &(plptr->fCallbacks), (void*)&callbacks, sizeof(callbacks));
|
memcpy((void*) &(plptr->mPluginFuncs), (void*)&callbacks, sizeof(callbacks));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -628,7 +624,7 @@ nsNPAPIPlugin::CreatePluginInstance(nsIPluginInstance **aResult)
|
||||||
|
|
||||||
*aResult = NULL;
|
*aResult = NULL;
|
||||||
|
|
||||||
nsRefPtr<nsNPAPIPluginInstance> inst = new nsNPAPIPluginInstance(this, &fCallbacks, fLibrary);
|
nsRefPtr<nsNPAPIPluginInstance> inst = new nsNPAPIPluginInstance(this, &mPluginFuncs, mLibrary);
|
||||||
if (!inst)
|
if (!inst)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -638,24 +634,24 @@ nsNPAPIPlugin::CreatePluginInstance(nsIPluginInstance **aResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsNPAPIPlugin::Initialize(void)
|
nsNPAPIPlugin::Initialize()
|
||||||
{
|
{
|
||||||
if (!fLibrary)
|
if (!mLibrary)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsNPAPIPlugin::Shutdown(void)
|
nsNPAPIPlugin::Shutdown()
|
||||||
{
|
{
|
||||||
NPP_PLUGIN_LOG(PLUGIN_LOG_BASIC,
|
NPP_PLUGIN_LOG(PLUGIN_LOG_BASIC,
|
||||||
("NPP Shutdown to be called: this=%p\n", this));
|
("NPP Shutdown to be called: this=%p\n", this));
|
||||||
|
|
||||||
NPError shutdownError;
|
NPError shutdownError;
|
||||||
fLibrary->NP_Shutdown(&shutdownError);
|
mLibrary->NP_Shutdown(&shutdownError);
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
if (shutdownError == NS_OK && fPluginRefNum > 0)
|
if (shutdownError == NS_OK && mPluginRefNum > 0)
|
||||||
::CloseResFile(fPluginRefNum);
|
::CloseResFile(mPluginRefNum);
|
||||||
#endif
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -663,7 +659,7 @@ nsNPAPIPlugin::Shutdown(void)
|
||||||
nsresult
|
nsresult
|
||||||
nsNPAPIPlugin::GetMIMEDescription(const char* *resultingDesc)
|
nsNPAPIPlugin::GetMIMEDescription(const char* *resultingDesc)
|
||||||
{
|
{
|
||||||
nsresult gmdResult = fLibrary->NP_GetMIMEDescription(resultingDesc);
|
nsresult gmdResult = mLibrary->NP_GetMIMEDescription(resultingDesc);
|
||||||
if (gmdResult != NS_OK) {
|
if (gmdResult != NS_OK) {
|
||||||
return gmdResult;
|
return gmdResult;
|
||||||
}
|
}
|
||||||
|
@ -678,7 +674,7 @@ nsNPAPIPlugin::GetValue(NPPVariable variable, void *value)
|
||||||
("nsNPAPIPlugin::GetValue called: this=%p, variable=%d\n", this, variable));
|
("nsNPAPIPlugin::GetValue called: this=%p, variable=%d\n", this, variable));
|
||||||
|
|
||||||
NPError gvError;
|
NPError gvError;
|
||||||
fLibrary->NP_GetValue(nsnull, variable, value, &gvError);
|
mLibrary->NP_GetValue(nsnull, variable, value, &gvError);
|
||||||
|
|
||||||
return gvError;
|
return gvError;
|
||||||
}
|
}
|
||||||
|
@ -756,7 +752,7 @@ public:
|
||||||
~nsNPAPIStreamWrapper();
|
~nsNPAPIStreamWrapper();
|
||||||
|
|
||||||
void GetStream(nsIOutputStream* &result);
|
void GetStream(nsIOutputStream* &result);
|
||||||
NPStream* GetNPStream(void) { return &fNPStream; }
|
NPStream* GetNPStream() { return &fNPStream; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsPluginThreadRunnable : public nsRunnable,
|
class nsPluginThreadRunnable : public nsRunnable,
|
||||||
|
@ -879,7 +875,7 @@ nsNPAPIStreamWrapper::nsNPAPIStreamWrapper(nsIOutputStream* stream)
|
||||||
fNPStream.ndata = (void*) this;
|
fNPStream.ndata = (void*) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsNPAPIStreamWrapper::~nsNPAPIStreamWrapper(void)
|
nsNPAPIStreamWrapper::~nsNPAPIStreamWrapper()
|
||||||
{
|
{
|
||||||
fStream->Close();
|
fStream->Close();
|
||||||
NS_IF_RELEASE(fStream);
|
NS_IF_RELEASE(fStream);
|
||||||
|
@ -2399,7 +2395,7 @@ _requestread(NPStream *pstream, NPByteRange *rangeList)
|
||||||
|
|
||||||
// Deprecated, only stubbed out
|
// Deprecated, only stubbed out
|
||||||
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
||||||
_getJavaEnv(void)
|
_getJavaEnv()
|
||||||
{
|
{
|
||||||
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaEnv\n"));
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaEnv\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -68,10 +68,7 @@
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) ();
|
||||||
#ifdef XP_MACOSX
|
|
||||||
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownProcPtr* unloadProcPtr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class nsNPAPIPlugin : public nsIPlugin
|
class nsNPAPIPlugin : public nsIPlugin
|
||||||
{
|
{
|
||||||
|
@ -104,21 +101,17 @@ public:
|
||||||
PRBool IsDefaultPlugin();
|
PRBool IsDefaultPlugin();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Ensures that the static CALLBACKS is properly initialized
|
// Ensures that the static browser functions are properly initialized
|
||||||
static void CheckClassInitialized(void);
|
static void CheckClassInitialized();
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
short fPluginRefNum;
|
short mPluginRefNum;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The plugin-side callbacks that the browser calls. One set of
|
// The plugin-side callbacks that the browser calls. One set of
|
||||||
// plugin callbacks for each plugin.
|
// plugin callbacks for each plugin.
|
||||||
NPPluginFuncs fCallbacks;
|
NPPluginFuncs mPluginFuncs;
|
||||||
PluginLibrary* fLibrary;
|
PluginLibrary* mLibrary;
|
||||||
PRLibrary* fPRLibrary;
|
|
||||||
|
|
||||||
// Browser-side callbacks that the plugin calls.
|
|
||||||
static NPNetscapeFuncs CALLBACKS;
|
|
||||||
|
|
||||||
PRBool mIsDefaultPlugin;
|
PRBool mIsDefaultPlugin;
|
||||||
};
|
};
|
||||||
|
@ -305,7 +298,7 @@ _memalloc (uint32_t size);
|
||||||
|
|
||||||
// Deprecated entry points for the old Java plugin.
|
// Deprecated entry points for the old Java plugin.
|
||||||
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
||||||
_getJavaEnv(void);
|
_getJavaEnv();
|
||||||
|
|
||||||
void* NP_CALLBACK /* OJI type: jref */
|
void* NP_CALLBACK /* OJI type: jref */
|
||||||
_getJavaPeer(NPP npp);
|
_getJavaPeer(NPP npp);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче