Fix for Bug# 1771. Re-ordered the calling into the plugin entry point. Initialize()
for 4x plugin now happens in CreatePlugin(). git-svn-id: svn://10.0.0.236/trunk@16021 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -59,7 +59,7 @@ ns4xPlugin::CheckClassInitialized(void)
|
||||
CALLBACKS.memflush = NewNPN_MemFlushProc(_memflush);
|
||||
CALLBACKS.reloadplugins = NewNPN_ReloadPluginsProc(_reloadplugins);
|
||||
CALLBACKS.getJavaEnv = NewNPN_GetJavaEnvProc(_getJavaEnv);
|
||||
// CALLBACKS.getJavaPeer = NewNPN_GetJavaPeerProc(_getJavaPeer);
|
||||
CALLBACKS.getJavaPeer = NewNPN_GetJavaPeerProc(_getJavaPeer);
|
||||
CALLBACKS.geturlnotify = NewNPN_GetURLNotifyProc(_geturlnotify);
|
||||
CALLBACKS.posturlnotify = NewNPN_PostURLNotifyProc(_posturlnotify);
|
||||
CALLBACKS.getvalue = NewNPN_GetValueProc(_getvalue);
|
||||
@@ -74,13 +74,12 @@ ns4xPlugin::CheckClassInitialized(void)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, NP_PLUGININIT aInit)
|
||||
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
memcpy((void*) &fCallbacks, (void*) callbacks, sizeof(fCallbacks));
|
||||
fShutdownEntry = aShutdown;
|
||||
fInitialize = aInit;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +143,8 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIMallocIID, NS_IMALLOC_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Static factory method.
|
||||
@@ -151,10 +152,11 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
|
||||
|
||||
nsresult
|
||||
ns4xPlugin::CreatePlugin(PRLibrary *library,
|
||||
nsIPlugin **result)
|
||||
nsIPlugin **result, nsISupports* browserInterfaces)
|
||||
{
|
||||
CheckClassInitialized();
|
||||
|
||||
// XXX this only applies on Windows
|
||||
NP_GETENTRYPOINTS pfnGetEntryPoints =
|
||||
(NP_GETENTRYPOINTS)PR_FindSymbol(library, "NP_GetEntryPoints");
|
||||
|
||||
@@ -177,11 +179,25 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
|
||||
NP_PLUGINSHUTDOWN pfnShutdown =
|
||||
(NP_PLUGINSHUTDOWN)PR_FindSymbol(library, "NP_Shutdown");
|
||||
|
||||
// create the new plugin handler
|
||||
*result = new ns4xPlugin(&callbacks, pfnShutdown);
|
||||
|
||||
NS_ADDREF(*result);
|
||||
|
||||
if (*result == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// we must init here because the plugin may call NPN functions
|
||||
// when we call into the NP_Initialize entry point - NPN functions
|
||||
// require that mBrowserManager be set up
|
||||
(*result)->Initialize(browserInterfaces);
|
||||
|
||||
// the NP_Initialize entry point was misnamed as NP_PluginInit,
|
||||
// early in plugin project development. Its correct name is
|
||||
// documented now, and new developers expect it to work. However,
|
||||
// I don't want to break the plugins already in the field, so
|
||||
// we'll accept either name
|
||||
|
||||
NP_PLUGININIT pfnInitialize =
|
||||
(NP_PLUGININIT)PR_FindSymbol(library, "NP_Initialize");
|
||||
|
||||
@@ -193,12 +209,8 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
|
||||
if (pfnInitialize == NULL)
|
||||
return NS_ERROR_UNEXPECTED; // XXX Right error?
|
||||
|
||||
*result = new ns4xPlugin(&callbacks, pfnShutdown, pfnInitialize);
|
||||
|
||||
NS_ADDREF(*result);
|
||||
|
||||
if (*result == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (pfnInitialize(&(ns4xPlugin::CALLBACKS)) != NS_OK)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -238,24 +250,20 @@ nsresult ns4xPlugin :: LockFactory(PRBool aLock)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIMallocIID, NS_IMALLOC_IID);
|
||||
|
||||
nsresult
|
||||
ns4xPlugin::Initialize(nsISupports* browserInterfaces)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull == mPluginManager)
|
||||
rv = browserInterfaces->QueryInterface(kIPluginManagerIID, (void **)&mPluginManager);
|
||||
// set up the connections to the plugin manager
|
||||
if (nsnull == mPluginManager)
|
||||
if((rv = browserInterfaces->QueryInterface(kIPluginManagerIID, (void **)&mPluginManager)) != NS_OK)
|
||||
return rv;
|
||||
if (nsnull == mMalloc)
|
||||
if((rv = browserInterfaces->QueryInterface(kIMallocIID, (void **)&mMalloc)) != NS_OK)
|
||||
return rv;
|
||||
|
||||
if (nsnull == mMalloc)
|
||||
rv = browserInterfaces->QueryInterface(kIMallocIID, (void **)&mMalloc);
|
||||
|
||||
if (fInitialize(&ns4xPlugin::CALLBACKS) != NS_OK)
|
||||
rv = NS_ERROR_UNEXPECTED; // XXX shoudl convert the 4.x error...
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -744,22 +752,21 @@ ns4xPlugin::_memalloc (uint32 size)
|
||||
return mMalloc->Alloc(size);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
|
||||
#ifdef JAVA
|
||||
java_lang_Class* NP_EXPORT
|
||||
ns4xPlugin::_getJavaClass(void* handle)
|
||||
{
|
||||
// Is this just a generic call into the Java VM?
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
jref NP_EXPORT
|
||||
ns4xPlugin::_getJavaPeer(NPP npp)
|
||||
{
|
||||
#if 0
|
||||
NPIPluginInstancePeer* peer = (NPIPluginInstancePeer*) npp->ndata;
|
||||
PR_ASSERT(peer != NULL);
|
||||
if (peer == NULL)
|
||||
@@ -775,7 +782,7 @@ ns4xPlugin::_getJavaPeer(NPP npp)
|
||||
lcPeer->Release();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ typedef NPError (PLUGIN_ENTRYPOINT_CALL_TYPE *NP_PLUGINSHUTDOWN)();
|
||||
class ns4xPlugin : public nsILiveConnectPlugin
|
||||
{
|
||||
public:
|
||||
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, NP_PLUGININIT aInit);
|
||||
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown);
|
||||
~ns4xPlugin(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -106,7 +106,8 @@ public:
|
||||
*/
|
||||
static nsresult
|
||||
CreatePlugin(PRLibrary *library,
|
||||
nsIPlugin **result);
|
||||
nsIPlugin **result,
|
||||
nsISupports* browserInterfaces);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -202,11 +203,14 @@ protected:
|
||||
static JRIEnv* NP_EXPORT
|
||||
_getJavaEnv(void);
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
|
||||
static jref NP_EXPORT
|
||||
_getJavaPeer(NPP npp);
|
||||
|
||||
static java_lang_Class* NP_EXPORT
|
||||
_getJavaClass(void* handle);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC) && !defined(powerc)
|
||||
@@ -219,7 +223,6 @@ protected:
|
||||
*/
|
||||
NPPluginFuncs fCallbacks;
|
||||
|
||||
NP_PLUGININIT fInitialize;
|
||||
NP_PLUGINSHUTDOWN fShutdownEntry;
|
||||
|
||||
/**
|
||||
|
||||
@@ -862,7 +862,8 @@ printf("plugin manager2 processnextevent called\n");
|
||||
|
||||
nsresult nsPluginHostImpl :: Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsISupports *object;
|
||||
|
||||
// rv = nsMalloc::Create(nsnull, kIMallocIID, (void **)&mMalloc);
|
||||
@@ -875,7 +876,6 @@ nsresult nsPluginHostImpl :: Init(void)
|
||||
rv = object->QueryInterface(kIMallocIID, (void **)&mMalloc);
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1377,13 +1377,16 @@ printf("loaded plugin %s for mime type %s\n", plugins->mName, aMimeType);
|
||||
|
||||
if (plugins->mFlags & NS_PLUGIN_FLAG_OLDSCHOOL)
|
||||
{
|
||||
nsresult rv = ns4xPlugin::CreatePlugin(plugins->mLibrary, (nsIPlugin **)&plugins->mEntryPoint);
|
||||
// we have to load an old 4x style plugin
|
||||
nsresult rv = ns4xPlugin::CreatePlugin(plugins->mLibrary, (nsIPlugin **)&plugins->mEntryPoint,
|
||||
(nsISupports*)(nsIPluginManager*) this);
|
||||
#ifdef NS_DEBUG
|
||||
printf("result of creating plugin adapter: %d\n", rv);
|
||||
printf("result of creating plugin adapter: %d\n", rv);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have to load a new 5x style plugin
|
||||
nsFactoryProc fact = (nsFactoryProc)PR_FindSymbol(plugins->mLibrary, "NSGetFactory");
|
||||
|
||||
if (nsnull != fact)
|
||||
@@ -1396,10 +1399,11 @@ printf("result of creating plugin adapter: %d\n", rv);
|
||||
NS_RELEASE(factory);
|
||||
}
|
||||
}
|
||||
// we only need to call this for 5x style plugins - CreatePlugin() handles this for
|
||||
// 4x style plugins
|
||||
if (nsnull != plugins->mEntryPoint)
|
||||
plugins->mEntryPoint->Initialize((nsISupports *)(nsIPluginManager *)this);
|
||||
}
|
||||
|
||||
if (nsnull != plugins->mEntryPoint)
|
||||
plugins->mEntryPoint->Initialize((nsISupports *)(nsIPluginManager *)this);
|
||||
}
|
||||
|
||||
if (nsnull != plugins->mEntryPoint)
|
||||
|
||||
Reference in New Issue
Block a user