зеркало из https://github.com/mozilla/gecko-dev.git
For 73856, adding simple scriptability to the old style plugins, sr=vidur, ra=av
This commit is contained in:
Родитель
7fb2cbef9a
Коммит
4343179a46
|
@ -418,7 +418,7 @@ ns4xPluginInstance :: IsStarted(void)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS1(ns4xPluginInstance, nsIPluginInstance)
|
||||
NS_IMPL_ISUPPORTS2(ns4xPluginInstance, nsIPluginInstance, nsIScriptablePlugin)
|
||||
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
||||
|
@ -728,7 +728,10 @@ NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* hand
|
|||
NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
||||
void *value)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if(!mStarted)
|
||||
return NS_OK;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
|
||||
switch (variable)
|
||||
{
|
||||
|
@ -741,30 +744,38 @@ NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
|||
break;
|
||||
|
||||
default:
|
||||
rv = NS_ERROR_FAILURE; //XXX this is bad
|
||||
if(fCallbacks->getvalue)
|
||||
{
|
||||
NS_TRY_SAFE_CALL_RETURN(res,
|
||||
CallNPP_GetValueProc(fCallbacks->getvalue,
|
||||
&fNPP,
|
||||
(NPPVariable)variable,
|
||||
value),
|
||||
fLibrary);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance::GetNPP(NPP* aNPP)
|
||||
{
|
||||
if(aNPP != nsnull)
|
||||
*aNPP = &fNPP;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(aNPP != nsnull)
|
||||
*aNPP = &fNPP;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance::GetCallbacks(const NPPluginFuncs ** aCallbacks)
|
||||
{
|
||||
if(aCallbacks != nsnull)
|
||||
*aCallbacks = fCallbacks;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(aCallbacks != nsnull)
|
||||
*aCallbacks = fCallbacks;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance :: SetWindowless(PRBool aWindowless)
|
||||
|
@ -779,5 +790,22 @@ nsresult ns4xPluginInstance :: SetTransparent(PRBool aTransparent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsQIResult scriptablePeer; */
|
||||
NS_IMETHODIMP ns4xPluginInstance :: GetScriptablePeer(void * *aScriptablePeer)
|
||||
{
|
||||
if (!aScriptablePeer)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aScriptablePeer = nsnull;
|
||||
return GetValue(nsPluginInstanceVariable_ScriptableInstance, aScriptablePeer);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr scriptableInterface; */
|
||||
NS_IMETHODIMP ns4xPluginInstance :: GetScriptableInterface(nsIID * *aScriptableInterface)
|
||||
{
|
||||
if (!aScriptableInterface)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aScriptableInterface = nsnull;
|
||||
return GetValue(nsPluginInstanceVariable_ScriptableIID, (void*)aScriptableInterface);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "npupp.h"
|
||||
#include "jri.h"
|
||||
#include "prlink.h" // for PRLibrary
|
||||
#include "nsIScriptablePlugin.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -42,7 +43,8 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ns4xPluginInstance : public nsIPluginInstance
|
||||
class ns4xPluginInstance : public nsIPluginInstance,
|
||||
public nsIScriptablePlugin
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -77,6 +79,13 @@ public:
|
|||
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIScriptablePlugin methods
|
||||
|
||||
NS_IMETHOD GetScriptablePeer(void * *aScriptablePeer);
|
||||
|
||||
NS_IMETHOD GetScriptableInterface(nsIID * *aScriptableInterface);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ns4xPluginInstance-specific methods
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsIScriptablePlugin.h"
|
||||
|
||||
#if MOZ_NEW_CACHE
|
||||
#include "nsICachingChannel.h"
|
||||
|
@ -313,6 +313,7 @@ nsActivePlugin::nsActivePlugin(nsCOMPtr<nsIPlugin> aPlugin,
|
|||
aInstance->GetPeer(&mPeer);
|
||||
NS_ADDREF(aInstance);
|
||||
}
|
||||
mXPConnected = PR_FALSE;
|
||||
mDefaultPlugin = aDefaultPlugin;
|
||||
mStopped = PR_FALSE;
|
||||
mllStopTime = LL_ZERO;
|
||||
|
@ -1728,13 +1729,14 @@ nsPluginHostImpl::~nsPluginHostImpl()
|
|||
Destroy();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS6(nsPluginHostImpl,
|
||||
NS_IMPL_ISUPPORTS7(nsPluginHostImpl,
|
||||
nsIPluginManager,
|
||||
nsIPluginManager2,
|
||||
nsIPluginHost,
|
||||
nsIFileUtilities,
|
||||
nsICookieStorage,
|
||||
nsIObserver);
|
||||
nsIObserver,
|
||||
nsPIPluginHost);
|
||||
|
||||
NS_METHOD
|
||||
nsPluginHostImpl::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
|
@ -4142,13 +4144,19 @@ nsPluginHostImpl::StopPluginInstance(nsIPluginInstance* aInstance)
|
|||
if (!doCache || oldSchool)
|
||||
{
|
||||
PRBool lastInstance = PR_FALSE;
|
||||
PRBool xpConnected = plugin->mXPConnected;
|
||||
|
||||
mActivePluginList.remove(plugin, &lastInstance);
|
||||
|
||||
// and if this is the last instance we should unload the library
|
||||
// and if this was the last instance we should unload the library
|
||||
// and clear mEntryPoint and mLibrary member of the pluginTag
|
||||
if(lastInstance)
|
||||
{
|
||||
pluginTag->mEntryPoint = nsnull;
|
||||
|
||||
if(xpConnected)
|
||||
pluginTag->mCanUnloadLibrary = PR_FALSE;
|
||||
|
||||
if ((nsnull != pluginTag->mLibrary) && pluginTag->mCanUnloadLibrary)
|
||||
{
|
||||
PR_UnloadLibrary(pluginTag->mLibrary);
|
||||
|
@ -4355,6 +4363,18 @@ NS_IMETHODIMP nsPluginHostImpl::Observe(nsISupports *aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance,
|
||||
PRBool aScriptable)
|
||||
{
|
||||
nsActivePlugin * p = mActivePluginList.find(aPluginInstance.get());
|
||||
if(p == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
p->mXPConnected = aScriptable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsIPluginManager2.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsPIPluginHost.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prlink.h"
|
||||
|
@ -87,6 +88,7 @@ struct nsActivePlugin
|
|||
PRBool mStopped;
|
||||
PRTime mllStopTime;
|
||||
PRBool mDefaultPlugin;
|
||||
PRBool mXPConnected;
|
||||
|
||||
nsActivePlugin(nsCOMPtr<nsIPlugin> aPlugin,
|
||||
nsIPluginInstance* aInstance,
|
||||
|
@ -144,7 +146,8 @@ class nsPluginHostImpl : public nsIPluginManager2,
|
|||
public nsIPluginHost,
|
||||
public nsIFileUtilities,
|
||||
public nsICookieStorage,
|
||||
public nsIObserver
|
||||
public nsIObserver,
|
||||
public nsPIPluginHost
|
||||
{
|
||||
public:
|
||||
nsPluginHostImpl();
|
||||
|
@ -327,6 +330,10 @@ public:
|
|||
NS_IMETHOD
|
||||
Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData);
|
||||
|
||||
// Methods from nsPIPluginHost
|
||||
NS_IMETHOD
|
||||
SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance, PRBool aScriptable);
|
||||
|
||||
/* Called by GetURL and PostURL */
|
||||
|
||||
NS_IMETHOD
|
||||
|
|
|
@ -418,7 +418,7 @@ ns4xPluginInstance :: IsStarted(void)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS1(ns4xPluginInstance, nsIPluginInstance)
|
||||
NS_IMPL_ISUPPORTS2(ns4xPluginInstance, nsIPluginInstance, nsIScriptablePlugin)
|
||||
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
||||
|
@ -728,7 +728,10 @@ NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* hand
|
|||
NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
||||
void *value)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if(!mStarted)
|
||||
return NS_OK;
|
||||
|
||||
nsresult res = NS_OK;
|
||||
|
||||
switch (variable)
|
||||
{
|
||||
|
@ -741,30 +744,38 @@ NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
|||
break;
|
||||
|
||||
default:
|
||||
rv = NS_ERROR_FAILURE; //XXX this is bad
|
||||
if(fCallbacks->getvalue)
|
||||
{
|
||||
NS_TRY_SAFE_CALL_RETURN(res,
|
||||
CallNPP_GetValueProc(fCallbacks->getvalue,
|
||||
&fNPP,
|
||||
(NPPVariable)variable,
|
||||
value),
|
||||
fLibrary);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance::GetNPP(NPP* aNPP)
|
||||
{
|
||||
if(aNPP != nsnull)
|
||||
*aNPP = &fNPP;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(aNPP != nsnull)
|
||||
*aNPP = &fNPP;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance::GetCallbacks(const NPPluginFuncs ** aCallbacks)
|
||||
{
|
||||
if(aCallbacks != nsnull)
|
||||
*aCallbacks = fCallbacks;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(aCallbacks != nsnull)
|
||||
*aCallbacks = fCallbacks;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ns4xPluginInstance :: SetWindowless(PRBool aWindowless)
|
||||
|
@ -779,5 +790,22 @@ nsresult ns4xPluginInstance :: SetTransparent(PRBool aTransparent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsQIResult scriptablePeer; */
|
||||
NS_IMETHODIMP ns4xPluginInstance :: GetScriptablePeer(void * *aScriptablePeer)
|
||||
{
|
||||
if (!aScriptablePeer)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aScriptablePeer = nsnull;
|
||||
return GetValue(nsPluginInstanceVariable_ScriptableInstance, aScriptablePeer);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr scriptableInterface; */
|
||||
NS_IMETHODIMP ns4xPluginInstance :: GetScriptableInterface(nsIID * *aScriptableInterface)
|
||||
{
|
||||
if (!aScriptableInterface)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aScriptableInterface = nsnull;
|
||||
return GetValue(nsPluginInstanceVariable_ScriptableIID, (void*)aScriptableInterface);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "npupp.h"
|
||||
#include "jri.h"
|
||||
#include "prlink.h" // for PRLibrary
|
||||
#include "nsIScriptablePlugin.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -42,7 +43,8 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ns4xPluginInstance : public nsIPluginInstance
|
||||
class ns4xPluginInstance : public nsIPluginInstance,
|
||||
public nsIScriptablePlugin
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -77,6 +79,13 @@ public:
|
|||
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIScriptablePlugin methods
|
||||
|
||||
NS_IMETHOD GetScriptablePeer(void * *aScriptablePeer);
|
||||
|
||||
NS_IMETHOD GetScriptableInterface(nsIID * *aScriptableInterface);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ns4xPluginInstance-specific methods
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsIScriptablePlugin.h"
|
||||
|
||||
#if MOZ_NEW_CACHE
|
||||
#include "nsICachingChannel.h"
|
||||
|
@ -313,6 +313,7 @@ nsActivePlugin::nsActivePlugin(nsCOMPtr<nsIPlugin> aPlugin,
|
|||
aInstance->GetPeer(&mPeer);
|
||||
NS_ADDREF(aInstance);
|
||||
}
|
||||
mXPConnected = PR_FALSE;
|
||||
mDefaultPlugin = aDefaultPlugin;
|
||||
mStopped = PR_FALSE;
|
||||
mllStopTime = LL_ZERO;
|
||||
|
@ -1728,13 +1729,14 @@ nsPluginHostImpl::~nsPluginHostImpl()
|
|||
Destroy();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS6(nsPluginHostImpl,
|
||||
NS_IMPL_ISUPPORTS7(nsPluginHostImpl,
|
||||
nsIPluginManager,
|
||||
nsIPluginManager2,
|
||||
nsIPluginHost,
|
||||
nsIFileUtilities,
|
||||
nsICookieStorage,
|
||||
nsIObserver);
|
||||
nsIObserver,
|
||||
nsPIPluginHost);
|
||||
|
||||
NS_METHOD
|
||||
nsPluginHostImpl::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
|
@ -4142,13 +4144,19 @@ nsPluginHostImpl::StopPluginInstance(nsIPluginInstance* aInstance)
|
|||
if (!doCache || oldSchool)
|
||||
{
|
||||
PRBool lastInstance = PR_FALSE;
|
||||
PRBool xpConnected = plugin->mXPConnected;
|
||||
|
||||
mActivePluginList.remove(plugin, &lastInstance);
|
||||
|
||||
// and if this is the last instance we should unload the library
|
||||
// and if this was the last instance we should unload the library
|
||||
// and clear mEntryPoint and mLibrary member of the pluginTag
|
||||
if(lastInstance)
|
||||
{
|
||||
pluginTag->mEntryPoint = nsnull;
|
||||
|
||||
if(xpConnected)
|
||||
pluginTag->mCanUnloadLibrary = PR_FALSE;
|
||||
|
||||
if ((nsnull != pluginTag->mLibrary) && pluginTag->mCanUnloadLibrary)
|
||||
{
|
||||
PR_UnloadLibrary(pluginTag->mLibrary);
|
||||
|
@ -4355,6 +4363,18 @@ NS_IMETHODIMP nsPluginHostImpl::Observe(nsISupports *aSubject,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance,
|
||||
PRBool aScriptable)
|
||||
{
|
||||
nsActivePlugin * p = mActivePluginList.find(aPluginInstance.get());
|
||||
if(p == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
p->mXPConnected = aScriptable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsIPluginManager2.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsPIPluginHost.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prlink.h"
|
||||
|
@ -87,6 +88,7 @@ struct nsActivePlugin
|
|||
PRBool mStopped;
|
||||
PRTime mllStopTime;
|
||||
PRBool mDefaultPlugin;
|
||||
PRBool mXPConnected;
|
||||
|
||||
nsActivePlugin(nsCOMPtr<nsIPlugin> aPlugin,
|
||||
nsIPluginInstance* aInstance,
|
||||
|
@ -144,7 +146,8 @@ class nsPluginHostImpl : public nsIPluginManager2,
|
|||
public nsIPluginHost,
|
||||
public nsIFileUtilities,
|
||||
public nsICookieStorage,
|
||||
public nsIObserver
|
||||
public nsIObserver,
|
||||
public nsPIPluginHost
|
||||
{
|
||||
public:
|
||||
nsPluginHostImpl();
|
||||
|
@ -327,6 +330,10 @@ public:
|
|||
NS_IMETHOD
|
||||
Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData);
|
||||
|
||||
// Methods from nsPIPluginHost
|
||||
NS_IMETHOD
|
||||
SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance, PRBool aScriptable);
|
||||
|
||||
/* Called by GetURL and PostURL */
|
||||
|
||||
NS_IMETHOD
|
||||
|
|
Загрузка…
Ссылка в новой задаче