checkpoint_basic_scriptability

git-svn-id: svn://10.0.0.236/trunk@241972 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2007-12-21 20:19:57 +00:00
parent 5ea884ad2f
commit 70f5f4a32c
10 changed files with 63 additions and 17 deletions

View File

@@ -60,7 +60,7 @@ CPPSRCS = nsScriptablePeer.cpp \
npAPInsIInputStreamShim.cpp \
$(NULL)
XPIDLSRCS = nsISimplePlugin.idl
XPIDLSRCS = nsIPluglet.idl
SHARED_LIBRARY_LIBS = $(PLUGIN_SDK_OBJDIR)/samples/common/$(LIB_PREFIX)plugingate_s.$(LIB_SUFFIX) ../src/$(LIB_PREFIX)pluglet.$(LIB_SUFFIX) $(XPCOM_LIBS) $(NSPR_LIBS)

View File

@@ -55,7 +55,7 @@
#include "prlog.h"
static PRLogModuleInfo* log = NULL;
PRLogModuleInfo* log = NULL; // declared in nppluglet.h
// service manager which will give the access to all public browser services
// we will use memory service as an illustration
@@ -353,7 +353,7 @@ NS_IMETHODIMP nsPluginInstance::HasPlugletForMimeType(const char *aMimeType,
nsresult rv = NS_ERROR_FAILURE;
*outResult = PR_FALSE;
nsCOMPtr<nsIPlugin> plugletEngine = nsnull;
nsIID scriptableIID = NS_ISIMPLEPLUGIN_IID;
nsIID scriptableIID = NS_IPLUGLET_IID;
if (!mPluglet) {
plugletEngine = do_GetService(PLUGLETENGINE_ContractID, &rv);
@@ -428,7 +428,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
switch (aVariable) {
case NPPVpluginScriptableInstance: {
// addref happens in getter, so we don't addref here
nsISimplePlugin * scriptablePeer = getScriptablePeer();
nsIPluglet * scriptablePeer = getScriptablePeer();
if (scriptablePeer) {
*(nsISupports **)aValue = scriptablePeer;
} else
@@ -437,7 +437,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
break;
case NPPVpluginScriptableIID: {
static nsIID scriptableIID = NS_ISIMPLEPLUGIN_IID;
static nsIID scriptableIID = NS_IPLUGLET_IID;
nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
if (ptr) {
*ptr = scriptableIID;

View File

@@ -43,6 +43,9 @@
#include "nsCOMPtr.h"
#include "nsIPluginInstance.h"
#include "prlog.h"
extern PRLogModuleInfo *log; // defined in nppluglet.cpp
class nsPluginInstance : public nsPluginInstanceBase
{
public:

View File

@@ -39,6 +39,9 @@
#include "nsISupports.idl"
[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
interface nsISimplePlugin : nsISupports {
interface nsIPluglet : nsISupports {
boolean hasPlugletForMimeType(in string aMimeType);
void callPlugletMethod(in string methodName,
in PRUint32 inArgc,
[array, size_is(inArgc)] in string inArgv);
};

View File

@@ -47,7 +47,7 @@
//
#include "nppluglet.h"
static NS_DEFINE_IID(kISimplePluginIID, NS_ISIMPLEPLUGIN_IID);
static NS_DEFINE_IID(kIPlugletIID, NS_IPLUGLET_IID);
static NS_DEFINE_IID(kIClassInfoIID, NS_ICLASSINFO_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@@ -86,8 +86,8 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
if(!aInstancePtr)
return NS_ERROR_NULL_POINTER;
if(aIID.Equals(kISimplePluginIID)) {
*aInstancePtr = static_cast<nsISimplePlugin*>(this);
if(aIID.Equals(kIPlugletIID)) {
*aInstancePtr = static_cast<nsIPluglet*>(this);
AddRef();
return NS_OK;
}
@@ -99,7 +99,7 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
}
if(aIID.Equals(kISupportsIID)) {
*aInstancePtr = static_cast<nsISupports*>((static_cast<nsISimplePlugin*>(this)));
*aInstancePtr = static_cast<nsISupports*>((static_cast<nsIPluglet*>(this)));
AddRef();
return NS_OK;
}
@@ -132,3 +132,12 @@ NS_IMETHODIMP nsScriptablePeer::HasPlugletForMimeType(const char *aMimeType, PRB
}
NS_IMETHODIMP nsScriptablePeer::CallPlugletMethod(const char *methodName,
PRUint32 inArgc, const char **inArgv)
{
nsresult rv = NS_OK;
PR_LOG(log, PR_LOG_DEBUG,
("nppluglet CallPlugletMethod: methodName: %s\n", methodName));
return rv;
}

View File

@@ -45,7 +45,7 @@
#ifndef __nsScriptablePeer_h__
#define __nsScriptablePeer_h__
#include "nsISimplePlugin.h"
#include "nsIPluglet.h"
#include "nsIClassInfo.h"
class nsPluginInstance;
@@ -78,7 +78,7 @@ class nsClassInfoMixin : public nsIClassInfo
{return NS_ERROR_NOT_IMPLEMENTED;}
};
class nsScriptablePeer : public nsISimplePlugin,
class nsScriptablePeer : public nsIPluglet,
public nsClassInfoMixin
{
public:
@@ -96,7 +96,7 @@ protected:
public:
// native methods callable from JavaScript
NS_DECL_NSISIMPLEPLUGIN
NS_DECL_NSIPLUGLET
void SetInstance(nsPluginInstance* plugin);