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
|
|
|
|
* 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-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
2009-09-09 07:04:09 -07:00
|
|
|
#include "mozilla/plugins/BrowserStreamParent.h"
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
using mozilla::PluginLibrary;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
using mozilla::ipc::NPRemoteIdentifier;
|
|
|
|
|
|
|
|
using namespace mozilla::plugins;
|
|
|
|
|
|
|
|
PR_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(void*));
|
2009-08-18 13:20:03 -07:00
|
|
|
|
2009-11-09 14:56:55 -08:00
|
|
|
// static
|
2009-10-27 12:51:12 -07:00
|
|
|
PluginLibrary*
|
|
|
|
PluginModuleParent::LoadModule(const char* aFilePath)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
// Block on the child process being launched and initialized.
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent* parent = new PluginModuleParent(aFilePath);
|
2009-11-09 14:56:55 -08:00
|
|
|
parent->mSubprocess->Launch();
|
|
|
|
parent->Open(parent->mSubprocess->GetChannel(),
|
|
|
|
parent->mSubprocess->GetChildProcessHandle());
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
return parent;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 14:56:55 -08:00
|
|
|
PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-11-09 14:56:55 -08:00
|
|
|
mSubprocess = new PluginProcessParent(aFilePath);
|
|
|
|
NS_ASSERTION(mSubprocess, "Out of memory!");
|
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRBool ok =
|
|
|
|
#endif
|
|
|
|
mValidIdentifiers.Init();
|
|
|
|
NS_ASSERTION(ok, "Out of memory!");
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::~PluginModuleParent()
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-11-09 14:56:55 -08:00
|
|
|
if (mSubprocess) {
|
|
|
|
mSubprocess->Delete();
|
|
|
|
mSubprocess = nsnull;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PPluginInstanceParent*
|
2009-09-22 10:31:11 -07:00
|
|
|
PluginModuleParent::AllocPPluginInstance(const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const nsTArray<nsCString>& aNames,
|
|
|
|
const nsTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
2009-07-02 09:54:22 -07:00
|
|
|
{
|
2009-08-18 13:20:03 -07:00
|
|
|
NS_ERROR("Not reachable!");
|
|
|
|
return NULL;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-22 10:31:11 -07:00
|
|
|
PluginModuleParent::DeallocPPluginInstance(PPluginInstanceParent* aActor,
|
|
|
|
NPError* _retval)
|
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
|
|
|
delete aActor;
|
2009-10-07 16:50:48 -07:00
|
|
|
*_retval = NPERR_NO_ERROR;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
void
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-07-02 09:54:22 -07:00
|
|
|
aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
|
|
|
aFuncs->javaClass = nsnull;
|
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
aFuncs->newp = nsnull; // Gecko should always call this through a PluginLibrary object
|
2009-09-14 11:56:23 -07: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 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
NPError
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::NPP_Destroy(NPP instance,
|
|
|
|
NPSavedData** save)
|
2009-07-01 14:19:32 -07: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-08 23:31:35 -07:00
|
|
|
PluginInstanceParent* parentInstance =
|
|
|
|
static_cast<PluginInstanceParent*>(instance->pdata);
|
2009-07-01 14:19:32 -07:00
|
|
|
|
2009-10-07 16:50:48 -07:00
|
|
|
parentInstance->Destroy();
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
NPError prv;
|
2009-10-27 12:51:12 -07:00
|
|
|
if (!parentInstance->Module()->CallPPluginInstanceDestructor(parentInstance, &prv)) {
|
2009-07-01 14:19:32 -07:00
|
|
|
prv = NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
instance->pdata = nsnull;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
return prv;
|
2009-10-27 12:51:12 -07:00
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-23 00:12:52 -07:00
|
|
|
bool
|
|
|
|
PluginModuleParent::EnsureValidNPIdentifier(NPIdentifier aIdentifier)
|
|
|
|
{
|
|
|
|
if (!mValidIdentifiers.GetEntry(aIdentifier)) {
|
|
|
|
nsVoidPtrHashKey* newEntry = mValidIdentifiers.PutEntry(aIdentifier);
|
|
|
|
if (!newEntry) {
|
|
|
|
NS_ERROR("Out of memory?");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
NPIdentifier
|
|
|
|
PluginModuleParent::GetValidNPIdentifier(NPRemoteIdentifier aRemoteIdentifier)
|
2009-09-14 11:56:23 -07:00
|
|
|
{
|
2009-09-14 13:01:31 -07:00
|
|
|
NS_ASSERTION(mValidIdentifiers.IsInitialized(), "Not initialized!");
|
|
|
|
if (aRemoteIdentifier &&
|
|
|
|
mValidIdentifiers.GetEntry((NPIdentifier)aRemoteIdentifier)) {
|
|
|
|
return (NPIdentifier)aRemoteIdentifier;
|
|
|
|
}
|
|
|
|
return 0;
|
2009-09-14 11:56:23 -07: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-14 13:01:31 -07:00
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_SetWindow(NPP instance, NPWindow* window)
|
|
|
|
{
|
|
|
|
return InstCast(instance)->NPP_SetWindow(window);
|
|
|
|
}
|
|
|
|
|
2009-09-14 11:56:23 -07: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-10-08 00:54:16 -07:00
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerNPN_UserAgent(nsCString* userAgent)
|
|
|
|
{
|
|
|
|
NPP_t dummy = { 0, 0 };
|
|
|
|
*userAgent = NullableString(mNPNIface->uagent(&dummy));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::RecvNPN_GetStringIdentifier(const nsCString& aString,
|
|
|
|
NPRemoteIdentifier* aId)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-19 12:24:24 -07:00
|
|
|
if (aString.IsVoid()) {
|
|
|
|
NS_ERROR("Someone sent over a void string?!");
|
2009-09-17 18:49:04 -07:00
|
|
|
return false;
|
2009-09-19 12:24:24 -07:00
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
NPIdentifier ident = _getstringidentifier(aString.BeginReading());
|
2009-09-17 18:49:04 -07:00
|
|
|
if (!ident) {
|
|
|
|
*aId = 0;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-23 00:12:52 -07:00
|
|
|
if (!EnsureValidNPIdentifier(ident)) {
|
2009-09-19 12:24:24 -07:00
|
|
|
NS_ERROR("Out of memory?");
|
2009-09-17 18:49:04 -07:00
|
|
|
return false;
|
2009-09-19 12:24:24 -07:00
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
*aId = (NPRemoteIdentifier)ident;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::RecvNPN_GetIntIdentifier(const int32_t& aInt,
|
|
|
|
NPRemoteIdentifier* aId)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-14 13:01:31 -07:00
|
|
|
NPIdentifier ident = _getintidentifier(aInt);
|
2009-09-17 18:49:04 -07:00
|
|
|
if (!ident) {
|
|
|
|
*aId = 0;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-23 00:12:52 -07:00
|
|
|
if (!EnsureValidNPIdentifier(ident)) {
|
2009-09-19 12:24:24 -07:00
|
|
|
NS_ERROR("Out of memory?");
|
2009-09-17 18:49:04 -07:00
|
|
|
return false;
|
2009-09-19 12:24:24 -07:00
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
*aId = (NPRemoteIdentifier)ident;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::RecvNPN_UTF8FromIdentifier(const NPRemoteIdentifier& aId,
|
2009-09-17 18:49:04 -07:00
|
|
|
NPError *err,
|
2009-09-08 23:31:35 -07:00
|
|
|
nsCString* aString)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-14 13:01:31 -07:00
|
|
|
NPIdentifier ident = GetValidNPIdentifier(aId);
|
2009-09-17 18:49:04 -07:00
|
|
|
if (!ident) {
|
|
|
|
*err = NPERR_INVALID_PARAM;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
NPUTF8* val = _utf8fromidentifier(ident);
|
2009-09-17 18:49:04 -07:00
|
|
|
if (!val) {
|
|
|
|
*err = NPERR_INVALID_PARAM;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
aString->Assign(val);
|
2009-09-17 18:49:04 -07:00
|
|
|
*err = NPERR_NO_ERROR;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::RecvNPN_IntFromIdentifier(const NPRemoteIdentifier& aId,
|
2009-09-17 18:49:04 -07:00
|
|
|
NPError* err,
|
2009-09-08 23:31:35 -07:00
|
|
|
int32_t* aInt)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-14 13:01:31 -07:00
|
|
|
NPIdentifier ident = GetValidNPIdentifier(aId);
|
2009-09-17 18:49:04 -07:00
|
|
|
if (!ident) {
|
|
|
|
*err = NPERR_INVALID_PARAM;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
*aInt = _intfromidentifier(ident);
|
2009-09-17 18:49:04 -07:00
|
|
|
*err = NPERR_NO_ERROR;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::RecvNPN_IdentifierIsString(const NPRemoteIdentifier& aId,
|
|
|
|
bool* aIsString)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-14 13:01:31 -07:00
|
|
|
NPIdentifier ident = GetValidNPIdentifier(aId);
|
2009-09-17 18:49:04 -07:00
|
|
|
if (!ident) {
|
|
|
|
*aIsString = false;
|
|
|
|
return true;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
*aIsString = _identifierisstring(ident);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-14 13:01:31 -07:00
|
|
|
PluginModuleParent::RecvNPN_GetStringIdentifiers(const nsTArray<nsCString>& aNames,
|
2009-09-08 23:31:35 -07:00
|
|
|
nsTArray<NPRemoteIdentifier>* aIds)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-14 13:01:31 -07:00
|
|
|
NS_ASSERTION(aIds->IsEmpty(), "Non-empty array!");
|
|
|
|
|
|
|
|
PRUint32 count = aNames.Length();
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!count) {
|
|
|
|
NS_ERROR("No names to get!");
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
nsAutoTArray<NPUTF8*, 10> buffers;
|
|
|
|
nsAutoTArray<NPIdentifier, 10> ids;
|
|
|
|
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!(buffers.SetLength(count) &&
|
|
|
|
ids.SetLength(count) &&
|
|
|
|
aIds->SetCapacity(count))) {
|
|
|
|
NS_ERROR("Out of memory?");
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-14 13:01:31 -07: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) {
|
2009-09-23 00:12:52 -07:00
|
|
|
if (!EnsureValidNPIdentifier(id)) {
|
2009-09-19 12:24:24 -07:00
|
|
|
NS_ERROR("Out of memory?");
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
}
|
|
|
|
aIds->AppendElement((NPRemoteIdentifier)id);
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
2009-08-18 13:20:03 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceParent*
|
|
|
|
PluginModuleParent::InstCast(NPP instance)
|
2009-08-18 13:20:03 -07:00
|
|
|
{
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceParent* ip =
|
|
|
|
static_cast<PluginInstanceParent*>(instance->pdata);
|
|
|
|
if (instance != ip->mNPP) {
|
2009-08-18 13:20:03 -07:00
|
|
|
NS_RUNTIMEABORT("Corrupted plugin data.");
|
2009-09-08 23:31:35 -07:00
|
|
|
}
|
2009-08-18 13:20:03 -07:00
|
|
|
return ip;
|
|
|
|
}
|
|
|
|
|
2009-09-09 07:04:09 -07:00
|
|
|
BrowserStreamParent*
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent::StreamCast(NPP instance,
|
|
|
|
NPStream* s)
|
2009-08-18 13:20:03 -07:00
|
|
|
{
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceParent* ip = InstCast(instance);
|
2009-09-09 07:04:09 -07:00
|
|
|
BrowserStreamParent* sp =
|
2009-09-21 07:51:35 -07:00
|
|
|
static_cast<BrowserStreamParent*>(static_cast<AStream*>(s->pdata));
|
2009-09-08 23:31:35 -07:00
|
|
|
if (sp->mNPP != ip || s != sp->mStream) {
|
2009-08-18 13:20:03 -07:00
|
|
|
NS_RUNTIMEABORT("Corrupted plugin stream data.");
|
2009-09-08 23:31:35 -07:00
|
|
|
}
|
2009-08-18 13:20:03 -07:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
bool
|
|
|
|
PluginModuleParent::HasRequiredFunctions()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
mNPNIface = bFuncs;
|
|
|
|
|
|
|
|
if (!CallNP_Initialize(error)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
else if (*error != NPERR_NO_ERROR) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPluginFuncs(pFuncs);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
mNPNIface = bFuncs;
|
|
|
|
|
|
|
|
if (!CallNP_Initialize(error))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_Shutdown(NPError* error)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
2009-11-03 13:37:07 -08:00
|
|
|
// FIXME/cjones: should all sub-actors be dead by now?
|
2009-10-27 12:51:12 -07:00
|
|
|
|
2009-11-03 13:37:07 -08:00
|
|
|
bool ok = CallNP_Shutdown(error);
|
|
|
|
Close();
|
|
|
|
|
|
|
|
return ok ? NS_OK : NS_ERROR_FAILURE;
|
2009-10-27 12:51:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_GetMIMEDescription(char** mimeDesc)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
*mimeDesc = (char*)"application/x-foobar";
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_GetValue(void *future, NPPVariable aVariable,
|
|
|
|
void *aValue, NPError* error)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
//TODO: implement this correctly
|
|
|
|
printf("[%s] Not yet implemented\n", __FUNCTION__);
|
|
|
|
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(XP_WIN) || defined(XP_MACOSX)
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(pFuncs, "Null pointer!");
|
|
|
|
|
|
|
|
SetPluginFuncs(pFuncs);
|
|
|
|
*error = NPERR_NO_ERROR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
|
|
|
|
uint16_t mode, int16_t argc, char* argn[],
|
|
|
|
char* argv[], NPSavedData* saved,
|
|
|
|
NPError* error)
|
|
|
|
{
|
|
|
|
_MOZ_LOG(__FUNCTION__);
|
|
|
|
|
|
|
|
// create the instance on the other side
|
|
|
|
nsTArray<nsCString> names;
|
|
|
|
nsTArray<nsCString> values;
|
|
|
|
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
|
|
|
names.AppendElement(NullableString(argn[i]));
|
|
|
|
values.AppendElement(NullableString(argv[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoPtr<PluginInstanceParent> parentInstance(
|
|
|
|
new PluginInstanceParent(this, instance, mNPNIface));
|
|
|
|
|
|
|
|
instance->pdata = parentInstance.get();
|
|
|
|
|
|
|
|
if (!CallPPluginInstanceConstructor(parentInstance,
|
|
|
|
nsDependentCString(pluginType), mode,
|
|
|
|
names,values, error))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
printf ("[PluginModuleParent] %s: got return value %hd\n", __FUNCTION__,
|
|
|
|
*error);
|
|
|
|
|
|
|
|
if (*error == NPERR_NO_ERROR)
|
|
|
|
parentInstance.forget();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|