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
|
|
|
#ifndef dom_plugins_PluginModuleParent_h
|
|
|
|
#define dom_plugins_PluginModuleParent_h 1
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "prlink.h"
|
|
|
|
|
|
|
|
#include "npapi.h"
|
|
|
|
#include "npfunctions.h"
|
|
|
|
|
|
|
|
#include "base/string_util.h"
|
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
#include "mozilla/PluginLibrary.h"
|
2009-09-09 15:59:06 -07:00
|
|
|
#include "mozilla/plugins/PPluginModuleParent.h"
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginInstanceParent.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "mozilla/plugins/PluginProcessParent.h"
|
2010-03-23 07:30:51 -07:00
|
|
|
#include "mozilla/plugins/PluginIdentifierParent.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2010-03-23 07:30:51 -07:00
|
|
|
#include "nsDataHashtable.h"
|
2009-09-14 13:01:31 -07:00
|
|
|
#include "nsHashKeys.h"
|
2010-01-13 17:20:00 -08:00
|
|
|
#include "nsIFileStreams.h"
|
2010-04-20 07:52:19 -07:00
|
|
|
#include "nsTObserverArray.h"
|
2009-07-01 14:19:32 -07:00
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-12-03 00:16:14 -08:00
|
|
|
class BrowserStreamParent;
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
/**
|
2009-09-08 23:31:35 -07:00
|
|
|
* PluginModuleParent
|
2009-06-30 11:51:05 -07:00
|
|
|
*
|
|
|
|
* This class implements the NPP API from the perspective of the rest
|
|
|
|
* of Gecko, forwarding NPP calls along to the child process that is
|
|
|
|
* actually running the plugin.
|
|
|
|
*
|
|
|
|
* This class /also/ implements a version of the NPN API, because the
|
|
|
|
* child process needs to make these calls back into Gecko proper.
|
|
|
|
* This class is responsible for "actually" making those function calls.
|
|
|
|
*/
|
2009-10-27 12:51:12 -07:00
|
|
|
class PluginModuleParent : public PPluginModuleParent, PluginLibrary
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
private:
|
2009-10-27 12:51:12 -07:00
|
|
|
typedef mozilla::PluginLibrary PluginLibrary;
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
protected:
|
2010-03-23 07:30:51 -07:00
|
|
|
|
|
|
|
virtual PPluginIdentifierParent*
|
|
|
|
AllocPPluginIdentifier(const nsCString& aString,
|
|
|
|
const int32_t& aInt);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPPluginIdentifier(PPluginIdentifierParent* aActor);
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PPluginInstanceParent*
|
2009-09-22 10:31:11 -07:00
|
|
|
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-09-17 16:09:20 -07:00
|
|
|
virtual bool
|
2009-12-03 00:16:14 -08:00
|
|
|
DeallocPPluginInstance(PPluginInstanceParent* aActor);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
public:
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleParent(const char* aFilePath);
|
2009-12-11 12:48:37 -08:00
|
|
|
virtual ~PluginModuleParent();
|
2009-12-04 10:24:57 -08:00
|
|
|
|
2009-12-16 12:08:45 -08:00
|
|
|
NS_OVERRIDE virtual void SetPlugin(nsNPAPIPlugin* plugin)
|
|
|
|
{
|
|
|
|
mPlugin = plugin;
|
|
|
|
}
|
|
|
|
|
2009-12-03 12:31:52 -08:00
|
|
|
NS_OVERRIDE virtual void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
/**
|
|
|
|
* LoadModule
|
|
|
|
*
|
2009-10-27 12:51:12 -07:00
|
|
|
* This may or may not launch a plugin child process,
|
2009-06-30 11:51:05 -07:00
|
|
|
* and may or may not be very expensive.
|
|
|
|
*/
|
2009-10-27 12:51:12 -07:00
|
|
|
static PluginLibrary* LoadModule(const char* aFilePath);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2010-02-11 12:32:18 -08:00
|
|
|
const NPNetscapeFuncs* GetNetscapeFuncs() {
|
|
|
|
return mNPNIface;
|
|
|
|
}
|
|
|
|
|
2010-04-28 08:01:09 -07:00
|
|
|
PluginProcessParent* Process() const { return mSubprocess; }
|
2010-02-11 13:22:44 -08:00
|
|
|
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
|
|
|
|
|
2010-03-07 12:16:02 -08:00
|
|
|
bool OkToCleanup() const {
|
|
|
|
return !IsOnCxxStack();
|
|
|
|
}
|
|
|
|
|
2010-03-23 07:30:51 -07:00
|
|
|
PPluginIdentifierParent*
|
|
|
|
GetIdentifierForNPIdentifier(NPIdentifier aIdentifier);
|
|
|
|
|
2010-04-20 07:52:19 -07:00
|
|
|
#ifdef OS_MACOSX
|
|
|
|
void AddToRefreshTimer(PluginInstanceParent *aInstance);
|
|
|
|
void RemoveFromRefreshTimer(PluginInstanceParent *aInstance);
|
|
|
|
#endif
|
|
|
|
|
2010-02-11 12:32:18 -08:00
|
|
|
protected:
|
2010-03-10 23:35:31 -08:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
|
|
|
MediateRPCRace(const Message& parent, const Message& child)
|
|
|
|
{
|
|
|
|
return MediateRace(parent, child);
|
|
|
|
}
|
|
|
|
|
2010-03-26 13:07:37 -07:00
|
|
|
virtual bool RecvXXX_HACK_FIXME_cjones(Shmem& mem) { NS_RUNTIMEABORT("not reached"); return false; }
|
|
|
|
|
2010-02-11 12:32:18 -08:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool ShouldContinueFromReplyTimeout();
|
|
|
|
|
2009-10-08 00:54:16 -07:00
|
|
|
virtual bool
|
|
|
|
AnswerNPN_UserAgent(nsCString* userAgent);
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
|
|
|
|
NPError* aError,
|
|
|
|
bool* aBoolVal);
|
|
|
|
|
2010-02-16 10:44:25 -08:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool AnswerProcessSomeEvents();
|
|
|
|
|
2010-04-30 11:42:51 -07:00
|
|
|
NS_OVERRIDE virtual bool
|
|
|
|
RecvProcessNativeEventsInRPCCall();
|
|
|
|
|
2010-02-24 14:25:16 -08:00
|
|
|
virtual bool
|
|
|
|
RecvAppendNotesToCrashReport(const nsCString& aNotes);
|
|
|
|
|
2010-08-13 09:45:50 -07:00
|
|
|
NS_OVERRIDE virtual bool
|
|
|
|
RecvPluginShowWindow(const uint32_t& aWindowId, const bool& aModal,
|
|
|
|
const int32_t& aX, const int32_t& aY,
|
|
|
|
const size_t& aWidth, const size_t& aHeight);
|
|
|
|
|
|
|
|
NS_OVERRIDE virtual bool
|
|
|
|
RecvPluginHideWindow(const uint32_t& aWindowId);
|
|
|
|
|
2009-09-23 00:12:52 -07:00
|
|
|
static PluginInstanceParent* InstCast(NPP instance);
|
|
|
|
static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
private:
|
2009-07-02 09:54:22 -07:00
|
|
|
void SetPluginFuncs(NPPluginFuncs* aFuncs);
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
// Implement the module-level functions from NPAPI; these are
|
|
|
|
// normally resolved directly from the DSO.
|
2009-07-02 09:54:22 -07:00
|
|
|
#ifdef OS_LINUX
|
2009-06-30 11:51:05 -07:00
|
|
|
NPError NP_Initialize(const NPNetscapeFuncs* npnIface,
|
|
|
|
NPPluginFuncs* nppIface);
|
2009-07-02 09:54:22 -07:00
|
|
|
#else
|
|
|
|
NPError NP_Initialize(const NPNetscapeFuncs* npnIface);
|
|
|
|
NPError NP_GetEntryPoints(NPPluginFuncs* nppIface);
|
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
// NPP-like API that Gecko calls are trampolined into. These
|
|
|
|
// messages then get forwarded along to the plugin instance,
|
|
|
|
// and then eventually the child process.
|
|
|
|
|
2009-09-14 11:56:23 -07:00
|
|
|
static NPError NPP_Destroy(NPP instance, NPSavedData** save);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-14 11:56:23 -07:00
|
|
|
static NPError NPP_SetWindow(NPP instance, NPWindow* window);
|
|
|
|
static NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
|
|
|
|
NPBool seekable, uint16_t* stype);
|
2009-08-18 13:20:03 -07:00
|
|
|
static NPError NPP_DestroyStream(NPP instance,
|
|
|
|
NPStream* stream, NPReason reason);
|
|
|
|
static int32_t NPP_WriteReady(NPP instance, NPStream* stream);
|
|
|
|
static int32_t NPP_Write(NPP instance, NPStream* stream,
|
|
|
|
int32_t offset, int32_t len, void* buffer);
|
|
|
|
static void NPP_StreamAsFile(NPP instance,
|
|
|
|
NPStream* stream, const char* fname);
|
2009-09-14 11:56:23 -07:00
|
|
|
static void NPP_Print(NPP instance, NPPrint* platformPrint);
|
|
|
|
static int16_t NPP_HandleEvent(NPP instance, void* event);
|
|
|
|
static void NPP_URLNotify(NPP instance, const char* url,
|
|
|
|
NPReason reason, void* notifyData);
|
|
|
|
static NPError NPP_GetValue(NPP instance,
|
|
|
|
NPPVariable variable, void *ret_value);
|
|
|
|
static NPError NPP_SetValue(NPP instance, NPNVariable variable,
|
|
|
|
void *value);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
virtual bool HasRequiredFunctions();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
|
|
|
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);
|
2009-07-02 09:54:22 -07:00
|
|
|
#else
|
2009-10-27 12:51:12 -07:00
|
|
|
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);
|
2009-07-02 09:54:22 -07:00
|
|
|
#endif
|
2009-10-27 12:51:12 -07:00
|
|
|
virtual nsresult NP_Shutdown(NPError* error);
|
2010-01-29 12:18:50 -08:00
|
|
|
virtual nsresult NP_GetMIMEDescription(const char** mimeDesc);
|
2009-10-27 12:51:12 -07:00
|
|
|
virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
|
|
|
|
void *aValue, NPError* error);
|
2009-12-23 13:12:00 -08:00
|
|
|
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2)
|
2009-10-27 12:51:12 -07:00
|
|
|
virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error);
|
|
|
|
#endif
|
|
|
|
virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
|
|
|
|
uint16_t mode, int16_t argc, char* argn[],
|
|
|
|
char* argv[], NPSavedData* saved,
|
|
|
|
NPError* error);
|
|
|
|
private:
|
2010-03-24 14:22:03 -07:00
|
|
|
void WritePluginExtraDataForMinidump(const nsAString& id);
|
|
|
|
void WriteExtraDataForHang();
|
2010-02-11 12:32:18 -08:00
|
|
|
void CleanupFromTimeout();
|
|
|
|
static int TimeoutChanged(const char* aPref, void* aModule);
|
2010-03-07 12:16:02 -08:00
|
|
|
void NotifyPluginCrashed();
|
2010-02-11 12:32:18 -08:00
|
|
|
|
2010-02-24 14:25:16 -08:00
|
|
|
nsCString mCrashNotes;
|
2009-11-09 14:56:55 -08:00
|
|
|
PluginProcessParent* mSubprocess;
|
2010-03-30 17:24:47 -07:00
|
|
|
// the plugin thread in mSubprocess
|
|
|
|
NativeThreadId mPluginThread;
|
2009-12-03 12:31:52 -08:00
|
|
|
bool mShutdown;
|
2009-10-27 12:51:12 -07:00
|
|
|
const NPNetscapeFuncs* mNPNIface;
|
2010-03-23 07:30:51 -07:00
|
|
|
nsDataHashtable<nsVoidPtrHashKey, PluginIdentifierParent*> mIdentifiers;
|
2009-12-16 12:08:45 -08:00
|
|
|
nsNPAPIPlugin* mPlugin;
|
2010-01-13 17:20:00 -08:00
|
|
|
time_t mProcessStartTime;
|
2010-03-24 14:22:03 -07:00
|
|
|
ScopedRunnableMethodFactory<PluginModuleParent> mTaskFactory;
|
|
|
|
nsString mPluginDumpID;
|
|
|
|
nsString mBrowserDumpID;
|
|
|
|
nsString mHangID;
|
2010-04-20 07:52:19 -07:00
|
|
|
|
|
|
|
#ifdef OS_MACOSX
|
|
|
|
void CAUpdate();
|
|
|
|
base::RepeatingTimer<PluginModuleParent> mCATimer;
|
|
|
|
nsTObserverArray<PluginInstanceParent*> mCATimerTargets;
|
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#endif // ifndef dom_plugins_PluginModuleParent_h
|