2009-06-30 11:51:05 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: sw=4 ts=4 et :
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Plugin App.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Ben Turner <bent.mozilla@gmail.com>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Chris Jones <jones.chris.g@gmail.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginModuleChild.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#ifdef OS_LINUX
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "nsILocalFile.h"
|
|
|
|
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsPluginsDir.h"
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginInstanceChild.h"
|
2009-09-15 12:48:18 -07:00
|
|
|
#include "mozilla/plugins/StreamNotifyChild.h"
|
|
|
|
#include "mozilla/plugins/BrowserStreamChild.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
using mozilla::ipc::NPRemoteIdentifier;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
using namespace mozilla::plugins;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
PluginModuleChild* gInstance = nsnull;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::PluginModuleChild() :
|
2009-07-02 09:54:22 -07:00
|
|
|
mLibrary(0),
|
|
|
|
mInitializeFunc(0),
|
|
|
|
mShutdownFunc(0)
|
|
|
|
#ifdef OS_WIN
|
|
|
|
, mGetEntryPointsFunc(0)
|
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
// ,mNextInstanceId(0)
|
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(!gInstance, "Something terribly wrong here!");
|
2009-06-30 11:51:05 -07:00
|
|
|
memset(&mFunctions, 0, sizeof(mFunctions));
|
|
|
|
memset(&mSavedData, 0, sizeof(mSavedData));
|
2009-09-14 13:01:31 -07:00
|
|
|
gInstance = this;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::~PluginModuleChild()
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(gInstance == this, "Something terribly wrong here!");
|
2009-06-30 11:51:05 -07:00
|
|
|
if (mLibrary) {
|
|
|
|
PR_UnloadLibrary(mLibrary);
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
gInstance = nsnull;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
// static
|
|
|
|
PluginModuleChild*
|
|
|
|
PluginModuleChild::current()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(gInstance, "Null instance!");
|
|
|
|
return gInstance;
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::Init(const std::string& aPluginFilename,
|
|
|
|
MessageLoop* aIOLoop,
|
|
|
|
IPC::Channel* aChannel)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
NS_ASSERTION(aChannel, "need a channel");
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
if (!mObjectMap.Init()) {
|
|
|
|
NS_WARNING("Failed to initialize object hashtable!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
if (!InitGraphics())
|
|
|
|
return false;
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
nsCString filename;
|
|
|
|
filename = aPluginFilename.c_str();
|
|
|
|
nsCOMPtr<nsILocalFile> pluginFile;
|
|
|
|
NS_NewNativeLocalFile(filename,
|
|
|
|
PR_TRUE,
|
|
|
|
getter_AddRefs(pluginFile));
|
|
|
|
|
|
|
|
PRBool exists;
|
|
|
|
pluginFile->Exists(&exists);
|
|
|
|
NS_ASSERTION(exists, "plugin file ain't there");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> pluginIfile;
|
|
|
|
pluginIfile = do_QueryInterface(pluginFile);
|
|
|
|
|
|
|
|
nsPluginFile lib(pluginIfile);
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
nsresult rv = lib.LoadPlugin(mLibrary);
|
2009-06-30 11:51:05 -07:00
|
|
|
NS_ASSERTION(NS_OK == rv, "trouble with mPluginFile");
|
|
|
|
NS_ASSERTION(mLibrary, "couldn't open shared object");
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
if (!Open(aChannel, aIOLoop))
|
2009-06-30 11:51:05 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
memset((void*) &mFunctions, 0, sizeof(mFunctions));
|
|
|
|
mFunctions.size = sizeof(mFunctions);
|
|
|
|
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#if defined(OS_LINUX)
|
2009-06-30 11:51:05 -07:00
|
|
|
mShutdownFunc =
|
|
|
|
(NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
|
|
|
|
|
|
|
|
// create the new plugin handler
|
|
|
|
|
|
|
|
mInitializeFunc =
|
|
|
|
(NP_PLUGINUNIXINIT) PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
|
|
|
|
NS_ASSERTION(mInitializeFunc, "couldn't find NP_Initialize()");
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#elif defined(OS_WIN)
|
|
|
|
mShutdownFunc =
|
|
|
|
(NP_PLUGINSHUTDOWN)PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
|
|
|
|
|
|
|
|
mGetEntryPointsFunc =
|
|
|
|
(NP_GETENTRYPOINTS)PR_FindSymbol(mLibrary, "NP_GetEntryPoints");
|
|
|
|
NS_ENSURE_TRUE(mGetEntryPointsFunc, false);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
mInitializeFunc =
|
|
|
|
(NP_PLUGININIT)PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
|
|
|
|
NS_ENSURE_TRUE(mInitializeFunc, false);
|
2009-06-30 11:51:05 -07:00
|
|
|
#else
|
|
|
|
|
|
|
|
#error Please copy the initialization code from nsNPAPIPlugin.cpp
|
|
|
|
|
|
|
|
#endif
|
2009-07-02 09:54:22 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::InitGraphics()
|
2009-07-02 09:54:22 -07:00
|
|
|
{
|
|
|
|
// FIXME/cjones: is this the place for this?
|
|
|
|
#if defined(OS_LINUX)
|
|
|
|
gtk_init(0, 0);
|
|
|
|
#else
|
|
|
|
// may not be necessary on all platforms
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::CleanUp()
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
// FIXME/cjones: destroy all instances
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
bool
|
|
|
|
PluginModuleChild::RegisterNPObject(NPObject* aObject,
|
|
|
|
PluginScriptableObjectChild* aActor)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
|
|
|
|
NS_ASSERTION(aObject && aActor, "Null pointer!");
|
|
|
|
NS_ASSERTION(!mObjectMap.Get(aObject, nsnull),
|
|
|
|
"Reregistering the same object!");
|
|
|
|
return !!mObjectMap.Put(aObject, aActor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleChild::UnregisterNPObject(NPObject* aObject)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
|
|
|
|
NS_ASSERTION(aObject, "Null pointer!");
|
|
|
|
NS_ASSERTION(mObjectMap.Get(aObject, nsnull),
|
|
|
|
"Unregistering an object that was never added!");
|
|
|
|
mObjectMap.Remove(aObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginScriptableObjectChild*
|
|
|
|
PluginModuleChild::GetActorForNPObject(NPObject* aObject)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
|
|
|
|
NS_ASSERTION(aObject, "Null pointer!");
|
|
|
|
PluginScriptableObjectChild* actor;
|
|
|
|
return mObjectMap.Get(aObject, &actor) ? actor : nsnull;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// FIXME/cjones: just getting this out of the way for the moment ...
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
typedef void (*PluginThreadCallback)(void*);
|
|
|
|
|
|
|
|
PR_BEGIN_EXTERN_C
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_requestread(NPStream *pstream, NPByteRange *rangeList);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_geturlnotify(NPP aNPP, const char* relativeURL, const char* target,
|
|
|
|
void* notifyData);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_getvalue(NPP aNPP, NPNVariable variable, void *r_value);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_setvalue(NPP aNPP, NPPVariable variable, void *r_value);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_geturl(NPP aNPP, const char* relativeURL, const char* target);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_posturlnotify(NPP aNPP, const char* relativeURL, const char *target,
|
|
|
|
uint32_t len, const char *buf, NPBool file, void* notifyData);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_posturl(NPP aNPP, const char* relativeURL, const char *target, uint32_t len,
|
|
|
|
const char *buf, NPBool file);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_newstream(NPP aNPP, NPMIMEType type, const char* window, NPStream** pstream);
|
|
|
|
|
|
|
|
static int32_t NP_CALLBACK
|
|
|
|
_write(NPP aNPP, NPStream *pstream, int32_t len, void *buffer);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_destroystream(NPP aNPP, NPStream *pstream, NPError reason);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_status(NPP aNPP, const char *message);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_memfree (void *ptr);
|
|
|
|
|
|
|
|
static uint32_t NP_CALLBACK
|
|
|
|
_memflush(uint32_t size);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_reloadplugins(NPBool reloadPages);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_invalidaterect(NPP aNPP, NPRect *invalidRect);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_invalidateregion(NPP aNPP, NPRegion invalidRegion);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_forceredraw(NPP aNPP);
|
|
|
|
|
|
|
|
static const char* NP_CALLBACK
|
|
|
|
_useragent(NPP aNPP);
|
|
|
|
|
|
|
|
static void* NP_CALLBACK
|
|
|
|
_memalloc (uint32_t size);
|
|
|
|
|
|
|
|
// Deprecated entry points for the old Java plugin.
|
|
|
|
static void* NP_CALLBACK /* OJI type: JRIEnv* */
|
|
|
|
_getjavaenv(void);
|
|
|
|
|
|
|
|
// Deprecated entry points for the old Java plugin.
|
|
|
|
static void* NP_CALLBACK /* OJI type: jref */
|
|
|
|
_getjavapeer(NPP aNPP);
|
|
|
|
|
|
|
|
static NPIdentifier NP_CALLBACK
|
|
|
|
_getstringidentifier(const NPUTF8* name);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
|
|
|
NPIdentifier *identifiers);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_identifierisstring(NPIdentifier identifiers);
|
|
|
|
|
|
|
|
static NPIdentifier NP_CALLBACK
|
|
|
|
_getintidentifier(int32_t intid);
|
|
|
|
|
|
|
|
static NPUTF8* NP_CALLBACK
|
|
|
|
_utf8fromidentifier(NPIdentifier identifier);
|
|
|
|
|
|
|
|
static int32_t NP_CALLBACK
|
|
|
|
_intfromidentifier(NPIdentifier identifier);
|
|
|
|
|
|
|
|
static NPObject* NP_CALLBACK
|
|
|
|
_createobject(NPP aNPP, NPClass* aClass);
|
|
|
|
|
|
|
|
static NPObject* NP_CALLBACK
|
|
|
|
_retainobject(NPObject* npobj);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_releaseobject(NPObject* npobj);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_invoke(NPP aNPP, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_invokedefault(NPP aNPP, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_evaluate(NPP aNPP, NPObject* npobj, NPString *script, NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_getproperty(NPP aNPP, NPObject* npobj, NPIdentifier property,
|
|
|
|
NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_setproperty(NPP aNPP, NPObject* npobj, NPIdentifier property,
|
|
|
|
const NPVariant *value);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_removeproperty(NPP aNPP, NPObject* npobj, NPIdentifier property);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_hasproperty(NPP aNPP, NPObject* npobj, NPIdentifier propertyName);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_hasmethod(NPP aNPP, NPObject* npobj, NPIdentifier methodName);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_enumerate(NPP aNPP, NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_construct(NPP aNPP, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
|
|
|
#if NP_VERSION_MINOR > 19
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_releasevariantvalue(NPVariant *variant);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_setexception(NPObject* npobj, const NPUTF8 *message);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_pushpopupsenabledstate(NPP aNPP, NPBool enabled);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_poppopupsenabledstate(NPP aNPP);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_pluginthreadasynccall(NPP instance, PluginThreadCallback func,
|
|
|
|
void *userData);
|
|
|
|
|
|
|
|
#endif /* NP_VERSION_MINOR > 19 */
|
|
|
|
|
|
|
|
PR_END_EXTERN_C
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
const NPNetscapeFuncs PluginModuleChild::sBrowserFuncs = {
|
2009-06-30 11:51:05 -07:00
|
|
|
sizeof(sBrowserFuncs),
|
|
|
|
(NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR,
|
|
|
|
_geturl,
|
|
|
|
_posturl,
|
|
|
|
_requestread,
|
|
|
|
_newstream,
|
|
|
|
_write,
|
|
|
|
_destroystream,
|
|
|
|
_status,
|
|
|
|
_useragent,
|
|
|
|
_memalloc,
|
|
|
|
_memfree,
|
|
|
|
_memflush,
|
|
|
|
_reloadplugins,
|
|
|
|
_getjavaenv,
|
|
|
|
_getjavapeer,
|
|
|
|
_geturlnotify,
|
|
|
|
_posturlnotify,
|
|
|
|
_getvalue,
|
|
|
|
_setvalue,
|
|
|
|
_invalidaterect,
|
|
|
|
_invalidateregion,
|
|
|
|
_forceredraw,
|
|
|
|
_getstringidentifier,
|
|
|
|
_getstringidentifiers,
|
|
|
|
_getintidentifier,
|
|
|
|
_identifierisstring,
|
|
|
|
_utf8fromidentifier,
|
|
|
|
_intfromidentifier,
|
|
|
|
_createobject,
|
|
|
|
_retainobject,
|
|
|
|
_releaseobject,
|
|
|
|
_invoke,
|
|
|
|
_invokedefault,
|
|
|
|
_evaluate,
|
|
|
|
_getproperty,
|
|
|
|
_setproperty,
|
|
|
|
_removeproperty,
|
|
|
|
_hasproperty,
|
|
|
|
_hasmethod
|
|
|
|
#if NP_VERSION_MINOR > 19
|
|
|
|
, _releasevariantvalue
|
|
|
|
, _setexception
|
|
|
|
, _pushpopupsenabledstate
|
|
|
|
, _poppopupsenabledstate
|
|
|
|
, _enumerate
|
|
|
|
, _pluginthreadasynccall
|
|
|
|
, _construct
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
PluginInstanceChild*
|
2009-06-30 11:51:05 -07:00
|
|
|
InstCast(NPP aNPP)
|
|
|
|
{
|
2009-09-15 12:48:18 -07:00
|
|
|
return static_cast<PluginInstanceChild*>(aNPP->ndata);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_requestread(NPStream* aSstream,
|
|
|
|
NPByteRange* aRangeList)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_geturlnotify(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget,
|
|
|
|
void* aNotifyData)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-15 12:48:18 -07:00
|
|
|
|
|
|
|
const nsDependentCString url(aRelativeURL);
|
|
|
|
NPError err;
|
|
|
|
InstCast(aNPP)->CallPStreamNotifyConstructor(
|
|
|
|
new StreamNotifyChild(url, aNotifyData),
|
|
|
|
url, nsDependentCString(aTarget), false, nsCString(), false, &err);
|
|
|
|
// TODO: what if this fails?
|
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_getvalue(NPP aNPP,
|
|
|
|
NPNVariable aVariable,
|
|
|
|
void* aValue)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-15 12:48:18 -07:00
|
|
|
return InstCast(aNPP)->NPN_GetValue(aVariable, aValue);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_setvalue(NPP aNPP,
|
|
|
|
NPPVariable aVariable,
|
|
|
|
void* aValue)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_geturl(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-15 12:48:18 -07:00
|
|
|
NPError err;
|
|
|
|
InstCast(aNPP)->CallNPN_GetURL(nsDependentCString(aRelativeURL),
|
|
|
|
nsDependentCString(aTarget), &err);
|
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_posturlnotify(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget,
|
|
|
|
uint32_t aLength,
|
|
|
|
const char* aBuffer,
|
|
|
|
NPBool aIsFile,
|
|
|
|
void* aNotifyData)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-15 12:48:18 -07:00
|
|
|
|
|
|
|
const nsDependentCString url(aRelativeURL);
|
|
|
|
NPError err;
|
|
|
|
InstCast(aNPP)->CallPStreamNotifyConstructor(
|
|
|
|
new StreamNotifyChild(url, aNotifyData),
|
|
|
|
url, nsDependentCString(aTarget), true,
|
|
|
|
nsDependentCString(aBuffer, aLength), aIsFile, &err);
|
|
|
|
// TODO: what if this fails?
|
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_posturl(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget,
|
|
|
|
uint32_t aLength,
|
|
|
|
const char* aBuffer,
|
|
|
|
NPBool aIsFile)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-15 12:48:18 -07:00
|
|
|
NPError err;
|
|
|
|
InstCast(aNPP)->CallNPN_PostURL(nsDependentCString(aRelativeURL),
|
|
|
|
nsDependentCString(aTarget),
|
|
|
|
nsDependentCString(aBuffer, aLength),
|
|
|
|
aIsFile, &err);
|
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_newstream(NPP aNPP,
|
|
|
|
NPMIMEType aMIMEType,
|
|
|
|
const char* aWindow,
|
|
|
|
NPStream** aStream)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t NP_CALLBACK
|
|
|
|
_write(NPP aNPP,
|
|
|
|
NPStream* aStream,
|
|
|
|
int32_t aLength,
|
|
|
|
void* aBuffer)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_destroystream(NPP aNPP,
|
2009-09-15 12:48:18 -07:00
|
|
|
NPStream* aStream,
|
2009-06-30 11:51:05 -07:00
|
|
|
NPError aReason)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-15 12:48:18 -07:00
|
|
|
BrowserStreamChild* bs = static_cast<BrowserStreamChild*>(aStream->ndata);
|
|
|
|
PluginInstanceChild* p = InstCast(aNPP);
|
|
|
|
bs->EnsureCorrectInstance(p);
|
|
|
|
|
|
|
|
p->CallPBrowserStreamDestructor(bs, aReason, false);
|
2009-06-30 11:51:05 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_status(NPP aNPP,
|
|
|
|
const char* aMessage)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_memfree(void* aPtr)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
NS_Free(aPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t NP_CALLBACK
|
|
|
|
_memflush(uint32_t aSize)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_reloadplugins(NPBool aReloadPages)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_invalidaterect(NPP aNPP,
|
|
|
|
NPRect* aInvalidRect)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_invalidateregion(NPP aNPP,
|
|
|
|
NPRegion aInvalidRegion)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_forceredraw(NPP aNPP)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* NP_CALLBACK
|
|
|
|
_useragent(NPP aNPP)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
// FIXME/cjones: go back to the parent for this
|
|
|
|
|
|
|
|
return "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2a1pre) Gecko/20090611 Minefield/3.6a1pre";
|
|
|
|
}
|
|
|
|
|
|
|
|
void* NP_CALLBACK
|
|
|
|
_memalloc(uint32_t aSize)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return NS_Alloc(aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deprecated entry points for the old Java plugin.
|
|
|
|
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
|
|
|
_getjavaenv(void)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* NP_CALLBACK /* OJI type: jref */
|
|
|
|
_getjavapeer(NPP aNPP)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPIdentifier NP_CALLBACK
|
|
|
|
_getstringidentifier(const NPUTF8* aName)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
NPRemoteIdentifier ident;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_GetStringIdentifier(nsDependentCString(aName), &ident)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
ident = 0;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
return (NPIdentifier)ident;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_getstringidentifiers(const NPUTF8** aNames,
|
|
|
|
int32_t aNameCount,
|
|
|
|
NPIdentifier* aIdentifiers)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
if (!(aNames && aNameCount > 0 && aIdentifiers)) {
|
|
|
|
NS_RUNTIMEABORT("Bad input! Headed for a crash!");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoTArray<nsCString, 10> names;
|
|
|
|
nsAutoTArray<NPRemoteIdentifier, 10> ids;
|
|
|
|
|
2009-09-19 12:24:24 -07:00
|
|
|
if (names.SetCapacity(aNameCount)) {
|
2009-09-14 13:01:31 -07:00
|
|
|
for (int32_t index = 0; index < aNameCount; index++) {
|
|
|
|
names.AppendElement(nsDependentCString(aNames[index]));
|
|
|
|
}
|
|
|
|
NS_ASSERTION(names.Length() == aNameCount, "Should equal here!");
|
|
|
|
|
2009-09-19 12:24:24 -07:00
|
|
|
if (PluginModuleChild::current()->
|
|
|
|
SendNPN_GetStringIdentifiers(names, &ids)) {
|
2009-09-14 13:01:31 -07:00
|
|
|
NS_ASSERTION(ids.Length() == aNameCount, "Bad length!");
|
|
|
|
|
|
|
|
for (int32_t index = 0; index < aNameCount; index++) {
|
|
|
|
aIdentifiers[index] = (NPIdentifier)ids[index];
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2009-09-19 12:24:24 -07:00
|
|
|
NS_WARNING("Failed to send message!");
|
2009-09-14 13:01:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Something must have failed above.
|
|
|
|
for (int32_t index = 0; index < aNameCount; index++) {
|
|
|
|
aIdentifiers[index] = 0;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_identifierisstring(NPIdentifier aIdentifier)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
bool isString;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_IdentifierIsString((NPRemoteIdentifier)aIdentifier,
|
|
|
|
&isString)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
isString = false;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
return isString;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPIdentifier NP_CALLBACK
|
|
|
|
_getintidentifier(int32_t aIntId)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
NPRemoteIdentifier ident;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_GetIntIdentifier(aIntId, &ident)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
ident = 0;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
return (NPIdentifier)ident;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPUTF8* NP_CALLBACK
|
|
|
|
_utf8fromidentifier(NPIdentifier aIdentifier)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
NPError err;
|
2009-09-14 13:01:31 -07:00
|
|
|
nsCAutoString val;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_UTF8FromIdentifier((NPRemoteIdentifier)aIdentifier,
|
|
|
|
&err, &val)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
return (NPERR_NO_ERROR == err) ? strdup(val.get()) : 0;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t NP_CALLBACK
|
|
|
|
_intfromidentifier(NPIdentifier aIdentifier)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
NPError err;
|
2009-09-14 13:01:31 -07:00
|
|
|
int32_t val;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_IntFromIdentifier((NPRemoteIdentifier)aIdentifier,
|
|
|
|
&err, &val)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
return -1;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
// -1 for consistency
|
|
|
|
return (NPERR_NO_ERROR == err) ? val : -1;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPObject* NP_CALLBACK
|
|
|
|
_createobject(NPP aNPP,
|
|
|
|
NPClass* aClass)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
NPObject* newObject;
|
|
|
|
if (aClass && aClass->allocate) {
|
|
|
|
newObject = aClass->allocate(aNPP, aClass);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
2009-09-17 15:15:12 -07:00
|
|
|
else {
|
|
|
|
newObject = reinterpret_cast<NPObject*>(_memalloc(sizeof(NPObject)));
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
if (newObject) {
|
|
|
|
newObject->_class = aClass;
|
|
|
|
newObject->referenceCount = 1;
|
|
|
|
}
|
|
|
|
return newObject;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPObject* NP_CALLBACK
|
|
|
|
_retainobject(NPObject* aNPObj)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-17 15:15:12 -07:00
|
|
|
++aNPObj->referenceCount;
|
2009-06-30 11:51:05 -07:00
|
|
|
return aNPObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_releaseobject(NPObject* aNPObj)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
if (--aNPObj->referenceCount == 0) {
|
|
|
|
if (aNPObj->_class && aNPObj->_class->deallocate) {
|
|
|
|
aNPObj->_class->deallocate(aNPObj);
|
|
|
|
} else {
|
2009-09-17 15:15:12 -07:00
|
|
|
_memfree(aNPObj);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_invoke(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aMethod,
|
|
|
|
const NPVariant* aArgs,
|
|
|
|
uint32_t aArgCount,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_invokedefault(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
const NPVariant* aArgs,
|
|
|
|
uint32_t aArgCount,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_evaluate(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPString* aScript,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_getproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_setproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName,
|
|
|
|
const NPVariant* aValue)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_removeproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_hasproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_hasmethod(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aMethodName)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_enumerate(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier** aIdentifiers,
|
|
|
|
uint32_t* aCount)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_construct(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
const NPVariant* aArgs,
|
|
|
|
uint32_t aArgCount,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if NP_VERSION_MINOR > 19
|
|
|
|
void NP_CALLBACK
|
|
|
|
_releasevariantvalue(NPVariant* aVariant)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_setexception(NPObject* aNPObj,
|
|
|
|
const NPUTF8* aMessage)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_pushpopupsenabledstate(NPP aNPP,
|
|
|
|
NPBool aEnabled)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_poppopupsenabledstate(NPP aNPP)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_pluginthreadasynccall(NPP aNPP,
|
|
|
|
PluginThreadCallback aFunc,
|
|
|
|
void* aUserData)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NP_VERSION_MINOR > 19 */
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::AnswerNP_Initialize(NPError* _retval)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#if defined(OS_LINUX)
|
2009-07-02 13:48:33 -07:00
|
|
|
*_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
#elif defined(OS_WIN)
|
|
|
|
nsresult rv = mGetEntryPointsFunc(&mFunctions);
|
2009-09-17 16:09:20 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
NS_ASSERTION(HIBYTE(mFunctions.version) >= NP_VERSION_MAJOR,
|
|
|
|
"callback version is less than NP version");
|
|
|
|
|
2009-07-02 13:48:33 -07:00
|
|
|
*_retval = mInitializeFunc(&sBrowserFuncs);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-06-30 11:51:05 -07:00
|
|
|
#else
|
|
|
|
# error Please implement me for your platform
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PPluginInstanceChild*
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::PPluginInstanceConstructor(const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const nsTArray<nsCString>& aNames,
|
|
|
|
const nsTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
nsAutoPtr<PluginInstanceChild> childInstance(
|
|
|
|
new PluginInstanceChild(&mFunctions));
|
2009-07-01 14:19:32 -07:00
|
|
|
if (!childInstance->Initialize()) {
|
|
|
|
*rv = NPERR_GENERIC_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-17 15:15:12 -07:00
|
|
|
return childInstance.forget();
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
|
|
|
|
const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const nsTArray<nsCString>& aNames,
|
|
|
|
const nsTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
PluginInstanceChild* childInstance =
|
|
|
|
reinterpret_cast<PluginInstanceChild*>(aActor);
|
|
|
|
NS_ASSERTION(childInstance, "Null actor!");
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
// unpack the arguments into a C format
|
2009-07-29 14:12:15 -07:00
|
|
|
int argc = aNames.Length();
|
|
|
|
NS_ASSERTION(argc == (int) aValues.Length(),
|
2009-06-30 11:51:05 -07:00
|
|
|
"argn.length != argv.length");
|
|
|
|
|
2009-07-29 14:12:15 -07:00
|
|
|
nsAutoArrayPtr<char*> argn(new char*[1 + argc]);
|
|
|
|
nsAutoArrayPtr<char*> argv(new char*[1 + argc]);
|
2009-06-30 11:51:05 -07:00
|
|
|
argn[argc] = 0;
|
|
|
|
argv[argc] = 0;
|
|
|
|
|
|
|
|
printf ("(plugin args: ");
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
2009-07-29 14:12:15 -07:00
|
|
|
argn[i] = const_cast<char*>(aNames[i].get());
|
|
|
|
argv[i] = const_cast<char*>(aValues[i].get());
|
2009-06-30 11:51:05 -07:00
|
|
|
printf("%s=%s, ", argn[i], argv[i]);
|
|
|
|
}
|
|
|
|
printf(")\n");
|
|
|
|
|
|
|
|
NPP npp = childInstance->GetNPP();
|
|
|
|
|
|
|
|
// FIXME/cjones: use SAFE_CALL stuff
|
2009-07-29 14:12:15 -07:00
|
|
|
*rv = mFunctions.newp((char*)aMimeType.get(),
|
2009-07-02 09:54:22 -07:00
|
|
|
npp,
|
|
|
|
aMode,
|
|
|
|
argc,
|
|
|
|
argn,
|
|
|
|
argv,
|
|
|
|
0);
|
|
|
|
if (NPERR_NO_ERROR != *rv) {
|
2009-09-17 18:49:04 -07:00
|
|
|
return false;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
printf ("[PluginModuleChild] %s: returning %hd\n", __FUNCTION__, *rv);
|
2009-09-17 18:49:04 -07:00
|
|
|
return true;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-09 15:59:06 -07:00
|
|
|
PluginModuleChild::PPluginInstanceDestructor(PPluginInstanceChild* actor,
|
2009-09-08 23:31:35 -07:00
|
|
|
NPError* rv)
|
2009-07-02 09:54:22 -07:00
|
|
|
{
|
2009-07-01 14:19:32 -07:00
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild* inst = static_cast<PluginInstanceChild*>(actor);
|
2009-07-01 14:19:32 -07:00
|
|
|
*rv = mFunctions.destroy(inst->GetNPP(), 0);
|
|
|
|
delete actor;
|
|
|
|
inst->GetNPP()->ndata = 0;
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|