2009-06-30 22:51:05 +04: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
|
|
|
|
* Chris Jones <jones.chris.g@gmail.com>
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* 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-09 10:31:35 +04:00
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
2009-09-09 18:04:09 +04:00
|
|
|
#include "mozilla/plugins/BrowserStreamParent.h"
|
2009-07-02 20:54:22 +04:00
|
|
|
|
2009-09-15 00:01:31 +04:00
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
|
2009-08-11 03:28:22 +04:00
|
|
|
using mozilla::SharedLibrary;
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-09-15 00:01:31 +04:00
|
|
|
using mozilla::ipc::NPRemoteIdentifier;
|
|
|
|
|
|
|
|
using namespace mozilla::plugins;
|
|
|
|
|
|
|
|
PR_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(void*));
|
2009-08-19 00:20:03 +04:00
|
|
|
|
2009-08-11 03:28:22 +04:00
|
|
|
// HACKS
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent* PluginModuleParent::Shim::HACK_target;
|
2009-06-30 22:51:05 +04:00
|
|
|
|
|
|
|
SharedLibrary*
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::LoadModule(const char* aFilePath, PRLibrary* aLibrary)
|
2009-06-30 22:51:05 +04:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
// Block on the child process being launched and initialized.
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent* parent = new PluginModuleParent(aFilePath);
|
2009-07-20 22:14:41 +04:00
|
|
|
parent->mSubprocess.Launch();
|
2009-07-02 20:54:22 +04:00
|
|
|
parent->Open(parent->mSubprocess.GetChannel());
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-09-09 10:31:35 +04:00
|
|
|
// FIXME/cjones: leaking PluginModuleParents ...
|
2009-06-30 22:51:05 +04:00
|
|
|
return parent->mShim;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::PluginModuleParent(const char* aFilePath) :
|
2009-07-02 20:54:22 +04:00
|
|
|
mFilePath(aFilePath),
|
|
|
|
mSubprocess(aFilePath),
|
|
|
|
ALLOW_THIS_IN_INITIALIZER_LIST(mShim(new Shim(this)))
|
2009-06-30 22:51:05 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRBool ok =
|
|
|
|
#endif
|
|
|
|
mValidIdentifiers.Init();
|
|
|
|
NS_ASSERTION(ok, "Out of memory!");
|
2009-06-30 22:51:05 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::~PluginModuleParent()
|
2009-06-30 22:51:05 +04:00
|
|
|
{
|
|
|
|
_MOZ_LOG(" (closing Shim ...)");
|
|
|
|
delete mShim;
|
|
|
|
}
|
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
PPluginInstanceParent*
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::PPluginInstanceConstructor(const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const nsTArray<nsCString>& aNames,
|
|
|
|
const nsTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
2009-07-02 20:54:22 +04:00
|
|
|
{
|
2009-08-19 00:20:03 +04:00
|
|
|
NS_ERROR("Not reachable!");
|
|
|
|
return NULL;
|
2009-07-02 20:54:22 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-10 02:59:06 +04:00
|
|
|
PluginModuleParent::PPluginInstanceDestructor(PPluginInstanceParent* aActor,
|
2009-09-09 10:31:35 +04:00
|
|
|
NPError* _retval)
|
2009-07-02 20:54:22 +04:00
|
|
|
{
|
2009-07-02 01:19:32 +04:00
|
|
|
_MOZ_LOG(__FUNCTION__);
|
2009-09-09 10:31:35 +04:00
|
|
|
delete aActor;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-07-02 20:54:22 +04:00
|
|
|
}
|
|
|
|
|
2009-06-30 22:51:05 +04:00
|
|
|
void
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
|
2009-06-30 22:51:05 +04:00
|
|
|
{
|
2009-07-02 20:54:22 +04:00
|
|
|
aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
|
|
|
aFuncs->javaClass = nsnull;
|
|
|
|
|
|
|
|
// FIXME/cjones: /should/ dynamically allocate shim trampoline.
|
|
|
|
// but here we just HACK
|
|
|
|
aFuncs->newp = Shim::NPP_New;
|
2009-09-14 22:56:23 +04:00
|
|
|
aFuncs->destroy = NPP_Destroy;
|
|
|
|
aFuncs->setwindow = NPP_SetWindow;
|
|
|
|
aFuncs->newstream = NPP_NewStream;
|
|
|
|
aFuncs->destroystream = NPP_DestroyStream;
|
|
|
|
aFuncs->asfile = NPP_StreamAsFile;
|
|
|
|
aFuncs->writeready = NPP_WriteReady;
|
|
|
|
aFuncs->write = NPP_Write;
|
|
|
|
aFuncs->print = NPP_Print;
|
|
|
|
aFuncs->event = NPP_HandleEvent;
|
|
|
|
aFuncs->urlnotify = NPP_URLNotify;
|
|
|
|
aFuncs->getvalue = NPP_GetValue;
|
|
|
|
aFuncs->setvalue = NPP_SetValue;
|
2009-06-30 22:51:05 +04:00
|
|
|
}
|
|
|
|
|
2009-07-02 20:54:22 +04:00
|
|
|
#ifdef OS_LINUX
|
2009-06-30 22:51:05 +04:00
|
|
|
NPError
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::NP_Initialize(const NPNetscapeFuncs* npnIface,
|
2009-09-19 23:24:24 +04:00
|
|
|
NPPluginFuncs* nppIface)
|
2009-06-30 22:51:05 +04:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-07-02 20:54:22 +04:00
|
|
|
NPError prv;
|
2009-09-19 05:19:11 +04:00
|
|
|
if (!CallNP_Initialize(&prv))
|
2009-07-02 20:54:22 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
else if (NPERR_NO_ERROR != prv)
|
|
|
|
return prv;
|
|
|
|
|
|
|
|
SetPluginFuncs(nppIface);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NPError
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::NP_Initialize(const NPNetscapeFuncs* npnIface)
|
2009-07-02 20:54:22 +04:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
NPError prv;
|
2009-09-19 05:19:11 +04:00
|
|
|
if (!CallNP_Initialize(&prv))
|
2009-09-19 23:24:24 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2009-07-03 00:48:33 +04:00
|
|
|
return prv;
|
2009-07-02 20:54:22 +04:00
|
|
|
}
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-07-02 20:54:22 +04:00
|
|
|
NPError
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* nppIface)
|
2009-07-02 20:54:22 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(nppIface, "Null pointer!");
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-07-02 20:54:22 +04:00
|
|
|
SetPluginFuncs(nppIface);
|
2009-06-30 22:51:05 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2009-07-02 20:54:22 +04:00
|
|
|
#endif
|
2009-06-30 22:51:05 +04:00
|
|
|
|
|
|
|
NPError
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::NPP_New(NPMIMEType pluginType,
|
|
|
|
NPP instance,
|
|
|
|
uint16_t mode,
|
|
|
|
int16_t argc,
|
|
|
|
char* argn[],
|
|
|
|
char* argv[],
|
|
|
|
NPSavedData* saved)
|
2009-06-30 22:51:05 +04:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
// create the instance on the other side
|
2009-07-30 01:12:15 +04:00
|
|
|
nsTArray<nsCString> names;
|
|
|
|
nsTArray<nsCString> values;
|
2009-06-30 22:51:05 +04:00
|
|
|
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
2009-07-30 01:12:15 +04:00
|
|
|
names.AppendElement(nsDependentCString(argn[i]));
|
|
|
|
values.AppendElement(nsDependentCString(argv[i]));
|
2009-06-30 22:51:05 +04:00
|
|
|
}
|
|
|
|
|
2009-08-08 03:13:20 +04:00
|
|
|
NPError prv = NPERR_GENERIC_ERROR;
|
2009-09-09 10:31:35 +04:00
|
|
|
nsAutoPtr<PluginInstanceParent> parentInstance(
|
|
|
|
static_cast<PluginInstanceParent*>(
|
|
|
|
CallPPluginInstanceConstructor(new PluginInstanceParent(instance,
|
|
|
|
mNPNIface),
|
|
|
|
nsDependentCString(pluginType), mode,
|
|
|
|
names,values, &prv)));
|
|
|
|
printf ("[PluginModuleParent] %s: got return value %hd\n", __FUNCTION__,
|
2009-07-02 20:54:22 +04:00
|
|
|
prv);
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-07-02 20:54:22 +04:00
|
|
|
if (NPERR_NO_ERROR != prv)
|
|
|
|
return prv;
|
|
|
|
NS_ASSERTION(parentInstance,
|
|
|
|
"if there's no parentInstance, there should be an error");
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-07-02 01:19:32 +04:00
|
|
|
instance->pdata = (void*) parentInstance.forget();
|
|
|
|
return prv;
|
|
|
|
}
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-07-02 01:19:32 +04:00
|
|
|
NPError
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::NPP_Destroy(NPP instance,
|
|
|
|
NPSavedData** save)
|
2009-07-02 01:19:32 +04:00
|
|
|
{
|
|
|
|
// FIXME/cjones:
|
|
|
|
// (1) send a "destroy" message to the child
|
|
|
|
// (2) the child shuts down its instance
|
|
|
|
// (3) remove both parent and child IDs from map
|
|
|
|
// (4) free parent
|
|
|
|
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginInstanceParent* parentInstance =
|
|
|
|
static_cast<PluginInstanceParent*>(instance->pdata);
|
2009-07-02 01:19:32 +04:00
|
|
|
|
|
|
|
NPError prv;
|
2009-09-19 05:19:11 +04:00
|
|
|
if (!Shim::HACK_target->CallPPluginInstanceDestructor(parentInstance, &prv)) {
|
2009-07-02 01:19:32 +04:00
|
|
|
prv = NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
instance->pdata = nsnull;
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-07-02 20:54:22 +04:00
|
|
|
return prv;
|
2009-07-02 01:19:32 +04:00
|
|
|
}
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-09-15 00:01:31 +04:00
|
|
|
NPIdentifier
|
|
|
|
PluginModuleParent::GetValidNPIdentifier(NPRemoteIdentifier aRemoteIdentifier)
|
2009-09-14 22:56:23 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
NS_ASSERTION(mValidIdentifiers.IsInitialized(), "Not initialized!");
|
|
|
|
if (aRemoteIdentifier &&
|
|
|
|
mValidIdentifiers.GetEntry((NPIdentifier)aRemoteIdentifier)) {
|
|
|
|
return (NPIdentifier)aRemoteIdentifier;
|
|
|
|
}
|
|
|
|
return 0;
|
2009-09-14 22:56:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_NewStream(NPP instance, NPMIMEType type,
|
|
|
|
NPStream* stream, NPBool seekable,
|
|
|
|
uint16_t* stype)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_NewStream(type, stream, seekable,
|
|
|
|
stype);
|
|
|
|
}
|
|
|
|
|
2009-09-15 00:01:31 +04:00
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_SetWindow(NPP instance, NPWindow* window)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_SetWindow(window);
|
|
|
|
}
|
|
|
|
|
2009-09-14 22:56:23 +04:00
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_DestroyStream(NPP instance,
|
|
|
|
NPStream* stream,
|
|
|
|
NPReason reason)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_DestroyStream(stream, reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
PluginModuleParent::NPP_WriteReady(NPP instance,
|
|
|
|
NPStream* stream)
|
|
|
|
{
|
|
|
|
return StreamCast(instance, stream)->WriteReady();
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
PluginModuleParent::NPP_Write(NPP instance,
|
|
|
|
NPStream* stream,
|
|
|
|
int32_t offset,
|
|
|
|
int32_t len,
|
|
|
|
void* buffer)
|
|
|
|
{
|
|
|
|
return StreamCast(instance, stream)->Write(offset, len, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_StreamAsFile(NPP instance,
|
|
|
|
NPStream* stream,
|
|
|
|
const char* fname)
|
|
|
|
{
|
|
|
|
StreamCast(instance, stream)->StreamAsFile(fname);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_Print(NPP instance, NPPrint* platformPrint)
|
|
|
|
{
|
|
|
|
InstCast(instance)->NPP_Print(platformPrint);
|
|
|
|
}
|
|
|
|
|
|
|
|
int16_t
|
|
|
|
PluginModuleParent::NPP_HandleEvent(NPP instance, void* event)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_HandleEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_URLNotify(NPP instance, const char* url,
|
|
|
|
NPReason reason, void* notifyData)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_URLNotify(url, reason, notifyData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_GetValue(NPP instance,
|
|
|
|
NPPVariable variable, void *ret_value)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_GetValue(variable, ret_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_SetValue(NPP instance, NPNVariable variable,
|
|
|
|
void *value)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_SetValue(variable, value);
|
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::RecvNPN_GetStringIdentifier(const nsCString& aString,
|
|
|
|
NPRemoteIdentifier* aId)
|
2009-08-11 03:28:22 +04:00
|
|
|
{
|
2009-09-19 23:24:24 +04:00
|
|
|
if (aString.IsVoid()) {
|
|
|
|
NS_ERROR("Someone sent over a void string?!");
|
2009-09-18 05:49:04 +04:00
|
|
|
return false;
|
2009-09-19 23:24:24 +04:00
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
NPIdentifier ident = _getstringidentifier(aString.BeginReading());
|
2009-09-18 05:49:04 +04:00
|
|
|
if (!ident) {
|
|
|
|
*aId = 0;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
nsVoidPtrHashKey* newEntry = mValidIdentifiers.PutEntry(ident);
|
2009-09-19 23:24:24 +04:00
|
|
|
if (!newEntry) {
|
|
|
|
NS_ERROR("Out of memory?");
|
2009-09-18 05:49:04 +04:00
|
|
|
return false;
|
2009-09-19 23:24:24 +04:00
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
*aId = (NPRemoteIdentifier)ident;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-11 03:28:22 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::RecvNPN_GetIntIdentifier(const int32_t& aInt,
|
|
|
|
NPRemoteIdentifier* aId)
|
2009-08-11 03:28:22 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
NPIdentifier ident = _getintidentifier(aInt);
|
2009-09-18 05:49:04 +04:00
|
|
|
if (!ident) {
|
|
|
|
*aId = 0;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
nsVoidPtrHashKey* newEntry = mValidIdentifiers.PutEntry(ident);
|
2009-09-19 23:24:24 +04:00
|
|
|
if (!newEntry) {
|
|
|
|
NS_ERROR("Out of memory?");
|
2009-09-18 05:49:04 +04:00
|
|
|
return false;
|
2009-09-19 23:24:24 +04:00
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
*aId = (NPRemoteIdentifier)ident;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-11 03:28:22 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::RecvNPN_UTF8FromIdentifier(const NPRemoteIdentifier& aId,
|
2009-09-18 05:49:04 +04:00
|
|
|
NPError *err,
|
2009-09-09 10:31:35 +04:00
|
|
|
nsCString* aString)
|
2009-08-11 03:28:22 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
NPIdentifier ident = GetValidNPIdentifier(aId);
|
2009-09-18 05:49:04 +04:00
|
|
|
if (!ident) {
|
|
|
|
*err = NPERR_INVALID_PARAM;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
NPUTF8* val = _utf8fromidentifier(ident);
|
2009-09-18 05:49:04 +04:00
|
|
|
if (!val) {
|
|
|
|
*err = NPERR_INVALID_PARAM;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
aString->Assign(val);
|
2009-09-18 05:49:04 +04:00
|
|
|
*err = NPERR_NO_ERROR;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-11 03:28:22 +04:00
|
|
|
}
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::RecvNPN_IntFromIdentifier(const NPRemoteIdentifier& aId,
|
2009-09-18 05:49:04 +04:00
|
|
|
NPError* err,
|
2009-09-09 10:31:35 +04:00
|
|
|
int32_t* aInt)
|
2009-08-11 03:28:22 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
NPIdentifier ident = GetValidNPIdentifier(aId);
|
2009-09-18 05:49:04 +04:00
|
|
|
if (!ident) {
|
|
|
|
*err = NPERR_INVALID_PARAM;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
*aInt = _intfromidentifier(ident);
|
2009-09-18 05:49:04 +04:00
|
|
|
*err = NPERR_NO_ERROR;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-11 03:28:22 +04:00
|
|
|
}
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::RecvNPN_IdentifierIsString(const NPRemoteIdentifier& aId,
|
|
|
|
bool* aIsString)
|
2009-08-11 03:28:22 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
NPIdentifier ident = GetValidNPIdentifier(aId);
|
2009-09-18 05:49:04 +04:00
|
|
|
if (!ident) {
|
|
|
|
*aIsString = false;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
*aIsString = _identifierisstring(ident);
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-11 03:28:22 +04:00
|
|
|
}
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-15 00:01:31 +04:00
|
|
|
PluginModuleParent::RecvNPN_GetStringIdentifiers(const nsTArray<nsCString>& aNames,
|
2009-09-09 10:31:35 +04:00
|
|
|
nsTArray<NPRemoteIdentifier>* aIds)
|
2009-08-11 03:28:22 +04:00
|
|
|
{
|
2009-09-15 00:01:31 +04:00
|
|
|
NS_ASSERTION(aIds->IsEmpty(), "Non-empty array!");
|
|
|
|
|
|
|
|
PRUint32 count = aNames.Length();
|
2009-09-19 23:24:24 +04:00
|
|
|
if (!count) {
|
|
|
|
NS_ERROR("No names to get!");
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
nsAutoTArray<NPUTF8*, 10> buffers;
|
|
|
|
nsAutoTArray<NPIdentifier, 10> ids;
|
|
|
|
|
2009-09-19 23:24:24 +04:00
|
|
|
if (!(buffers.SetLength(count) &&
|
|
|
|
ids.SetLength(count) &&
|
|
|
|
aIds->SetCapacity(count))) {
|
|
|
|
NS_ERROR("Out of memory?");
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
|
|
|
|
for (PRUint32 index = 0; index < count; index++) {
|
|
|
|
buffers[index] = const_cast<NPUTF8*>(aNames[index].BeginReading());
|
|
|
|
NS_ASSERTION(buffers[index], "Null pointer should be impossible!");
|
|
|
|
}
|
|
|
|
|
|
|
|
_getstringidentifiers(const_cast<const NPUTF8**>(buffers.Elements()),
|
|
|
|
count, ids.Elements());
|
|
|
|
|
|
|
|
for (PRUint32 index = 0; index < count; index++) {
|
|
|
|
NPIdentifier& id = ids[index];
|
|
|
|
if (id) {
|
|
|
|
nsVoidPtrHashKey* newEntry = mValidIdentifiers.PutEntry(id);
|
2009-09-19 23:24:24 +04:00
|
|
|
if (!newEntry) {
|
|
|
|
NS_ERROR("Out of memory?");
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-15 00:01:31 +04:00
|
|
|
}
|
|
|
|
aIds->AppendElement((NPRemoteIdentifier)id);
|
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-11 03:28:22 +04:00
|
|
|
}
|
2009-08-19 00:20:03 +04:00
|
|
|
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginInstanceParent*
|
|
|
|
PluginModuleParent::InstCast(NPP instance)
|
2009-08-19 00:20:03 +04:00
|
|
|
{
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginInstanceParent* ip =
|
|
|
|
static_cast<PluginInstanceParent*>(instance->pdata);
|
|
|
|
if (instance != ip->mNPP) {
|
2009-08-19 00:20:03 +04:00
|
|
|
NS_RUNTIMEABORT("Corrupted plugin data.");
|
2009-09-09 10:31:35 +04:00
|
|
|
}
|
2009-08-19 00:20:03 +04:00
|
|
|
return ip;
|
|
|
|
}
|
|
|
|
|
2009-09-09 18:04:09 +04:00
|
|
|
BrowserStreamParent*
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginModuleParent::StreamCast(NPP instance,
|
|
|
|
NPStream* s)
|
2009-08-19 00:20:03 +04:00
|
|
|
{
|
2009-09-09 10:31:35 +04:00
|
|
|
PluginInstanceParent* ip = InstCast(instance);
|
2009-09-09 18:04:09 +04:00
|
|
|
BrowserStreamParent* sp =
|
|
|
|
static_cast<BrowserStreamParent*>(s->pdata);
|
2009-09-09 10:31:35 +04:00
|
|
|
if (sp->mNPP != ip || s != sp->mStream) {
|
2009-08-19 00:20:03 +04:00
|
|
|
NS_RUNTIMEABORT("Corrupted plugin stream data.");
|
2009-09-09 10:31:35 +04:00
|
|
|
}
|
2009-08-19 00:20:03 +04:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|