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
|
|
|
#ifndef dom_plugins_PluginModuleChild_h
|
|
|
|
#define dom_plugins_PluginModuleChild_h 1
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
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"
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2010-03-23 07:30:51 -07:00
|
|
|
#include "nsDataHashtable.h"
|
2010-01-22 07:06:13 -08:00
|
|
|
#include "nsTHashtable.h"
|
2009-09-17 15:15:12 -07:00
|
|
|
#include "nsHashKeys.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2011-06-27 10:29:06 -07:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2011-05-23 23:58:28 -07:00
|
|
|
#include "PluginInterposeOSX.h"
|
|
|
|
#endif
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
#include "mozilla/plugins/PPluginModuleChild.h"
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginInstanceChild.h"
|
2010-03-23 07:30:51 -07:00
|
|
|
#include "mozilla/plugins/PluginIdentifierChild.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
// NOTE: stolen from nsNPAPIPlugin.h
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use this macro before each exported function
|
|
|
|
* (between the return address and the function
|
|
|
|
* itself), to ensure that the function has the
|
|
|
|
* right calling conventions on OS/2.
|
|
|
|
*/
|
|
|
|
#ifdef XP_OS2
|
|
|
|
#define NP_CALLBACK _System
|
|
|
|
#else
|
|
|
|
#define NP_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (__stdcall * _name)
|
|
|
|
#elif defined(XP_OS2)
|
|
|
|
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (_System * _name)
|
|
|
|
#else
|
|
|
|
#define NS_NPAPIPLUGIN_CALLBACK(_type, _name) _type (* _name)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks, NPPluginFuncs* fCallbacks);
|
|
|
|
typedef NS_NPAPIPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
|
|
|
|
|
|
|
|
namespace mozilla {
|
2011-06-08 12:56:31 -07:00
|
|
|
namespace dom {
|
|
|
|
class PCrashReporterChild;
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
namespace plugins {
|
2009-09-17 15:15:12 -07:00
|
|
|
|
2010-06-01 20:58:00 -07:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
class NestedLoopTimer;
|
|
|
|
static const int kNestedLoopDetectorIntervalMs = 90;
|
|
|
|
#endif
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
class PluginScriptableObjectChild;
|
2010-01-22 07:06:13 -08:00
|
|
|
class PluginInstanceChild;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
class PluginModuleChild : public PPluginModuleChild
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2011-06-08 12:56:31 -07:00
|
|
|
typedef mozilla::dom::PCrashReporterChild PCrashReporterChild;
|
2009-07-02 09:54:22 -07: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);
|
|
|
|
}
|
|
|
|
|
2011-08-16 03:25:34 -07:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual bool ShouldContinueFromReplyTimeout();
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
// Implement the PPluginModuleChild interface
|
2011-01-05 11:44:21 -08:00
|
|
|
virtual bool AnswerNP_GetEntryPoints(NPError* rv);
|
2011-06-08 12:56:31 -07:00
|
|
|
virtual bool AnswerNP_Initialize(NPError* rv);
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2010-03-23 07:30:51 -07:00
|
|
|
virtual PPluginIdentifierChild*
|
|
|
|
AllocPPluginIdentifier(const nsCString& aString,
|
2011-06-14 12:49:48 -07:00
|
|
|
const int32_t& aInt,
|
|
|
|
const bool& aTemporary);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvPPluginIdentifierConstructor(PPluginIdentifierChild* actor,
|
|
|
|
const nsCString& aString,
|
|
|
|
const int32_t& aInt,
|
|
|
|
const bool& aTemporary);
|
2010-03-23 07:30:51 -07:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPPluginIdentifier(PPluginIdentifierChild* aActor);
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
virtual PPluginInstanceChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
AllocPPluginInstance(const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
2010-11-08 18:49:00 -08:00
|
|
|
const InfallibleTArray<nsCString>& aNames,
|
|
|
|
const InfallibleTArray<nsCString>& aValues,
|
2009-09-22 10:31:11 -07:00
|
|
|
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(PPluginInstanceChild* aActor);
|
2009-10-07 16:50:48 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
virtual bool
|
2009-09-17 15:15:12 -07:00
|
|
|
AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
|
|
|
|
const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
2010-11-08 18:49:00 -08:00
|
|
|
const InfallibleTArray<nsCString>& aNames,
|
|
|
|
const InfallibleTArray<nsCString>& aValues,
|
2009-09-17 15:15:12 -07:00
|
|
|
NPError* rv);
|
2009-11-03 13:37:07 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerNP_Shutdown(NPError *rv);
|
2009-09-17 15:15:12 -07:00
|
|
|
|
2011-01-05 11:44:21 -08:00
|
|
|
virtual bool
|
2011-02-08 14:16:07 -08:00
|
|
|
AnswerOptionalFunctionsSupported(bool *aURLRedirectNotify,
|
|
|
|
bool *aClearSiteData,
|
|
|
|
bool *aGetSitesWithData);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
AnswerNPP_ClearSiteData(const nsCString& aSite,
|
|
|
|
const uint64_t& aFlags,
|
|
|
|
const uint64_t& aMaxAge,
|
|
|
|
NPError* aResult);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
AnswerNPP_GetSitesWithData(InfallibleTArray<nsCString>* aResult);
|
2011-01-05 11:44:21 -08:00
|
|
|
|
2011-06-24 07:20:03 -07:00
|
|
|
virtual bool
|
|
|
|
RecvSetAudioSessionData(const nsID& aId,
|
|
|
|
const nsString& aDisplayName,
|
|
|
|
const nsString& aIconPath);
|
|
|
|
|
2011-08-16 03:25:34 -07:00
|
|
|
virtual bool
|
|
|
|
RecvSetParentHangTimeout(const uint32_t& aSeconds);
|
|
|
|
|
2011-06-08 12:56:31 -07:00
|
|
|
virtual PCrashReporterChild*
|
|
|
|
AllocPCrashReporter(mozilla::dom::NativeThreadId* id,
|
|
|
|
PRUint32* processType);
|
|
|
|
virtual bool
|
|
|
|
DeallocPCrashReporter(PCrashReporterChild* actor);
|
|
|
|
virtual bool
|
|
|
|
AnswerPCrashReporterConstructor(PCrashReporterChild* actor,
|
|
|
|
mozilla::dom::NativeThreadId* id,
|
|
|
|
PRUint32* processType);
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
virtual void
|
|
|
|
ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2011-01-05 05:48:26 -08:00
|
|
|
NS_NORETURN void QuickExit();
|
|
|
|
|
2011-05-18 04:57:08 -07:00
|
|
|
NS_OVERRIDE virtual bool
|
|
|
|
RecvProcessNativeEventsInRPCCall();
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
public:
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild();
|
|
|
|
virtual ~PluginModuleChild();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2011-04-07 17:13:59 -07:00
|
|
|
// aPluginFilename is UTF8, not native-charset!
|
2009-06-30 11:51:05 -07:00
|
|
|
bool Init(const std::string& aPluginFilename,
|
2009-10-27 14:52:37 -07:00
|
|
|
base::ProcessHandle aParentProcessHandle,
|
2009-06-30 11:51:05 -07:00
|
|
|
MessageLoop* aIOLoop,
|
|
|
|
IPC::Channel* aChannel);
|
|
|
|
|
|
|
|
void CleanUp();
|
|
|
|
|
2009-11-19 14:57:56 -08:00
|
|
|
const char* GetUserAgent();
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
static const NPNetscapeFuncs sBrowserFuncs;
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
static PluginModuleChild* current();
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
bool RegisterActorForNPObject(NPObject* aObject,
|
|
|
|
PluginScriptableObjectChild* aActor);
|
2009-09-17 15:15:12 -07:00
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
void UnregisterActorForNPObject(NPObject* aObject);
|
2009-09-17 15:15:12 -07:00
|
|
|
|
|
|
|
PluginScriptableObjectChild* GetActorForNPObject(NPObject* aObject);
|
|
|
|
|
2009-11-11 17:12:01 -08:00
|
|
|
#ifdef DEBUG
|
2010-01-15 12:35:57 -08:00
|
|
|
bool NPObjectIsRegistered(NPObject* aObject);
|
2009-11-11 17:12:01 -08:00
|
|
|
#endif
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
/**
|
|
|
|
* The child implementation of NPN_CreateObject.
|
|
|
|
*/
|
|
|
|
static NPObject* NP_CALLBACK NPN_CreateObject(NPP aNPP, NPClass* aClass);
|
|
|
|
/**
|
|
|
|
* The child implementation of NPN_RetainObject.
|
|
|
|
*/
|
|
|
|
static NPObject* NP_CALLBACK NPN_RetainObject(NPObject* aNPObj);
|
|
|
|
/**
|
|
|
|
* The child implementation of NPN_ReleaseObject.
|
|
|
|
*/
|
|
|
|
static void NP_CALLBACK NPN_ReleaseObject(NPObject* aNPObj);
|
|
|
|
|
2010-03-23 07:30:51 -07:00
|
|
|
/**
|
|
|
|
* The child implementations of NPIdentifier-related functions.
|
|
|
|
*/
|
|
|
|
static NPIdentifier NP_CALLBACK NPN_GetStringIdentifier(const NPUTF8* aName);
|
|
|
|
static void NP_CALLBACK NPN_GetStringIdentifiers(const NPUTF8** aNames,
|
|
|
|
int32_t aNameCount,
|
|
|
|
NPIdentifier* aIdentifiers);
|
|
|
|
static NPIdentifier NP_CALLBACK NPN_GetIntIdentifier(int32_t aIntId);
|
|
|
|
static bool NP_CALLBACK NPN_IdentifierIsString(NPIdentifier aIdentifier);
|
|
|
|
static NPUTF8* NP_CALLBACK NPN_UTF8FromIdentifier(NPIdentifier aIdentifier);
|
|
|
|
static int32_t NP_CALLBACK NPN_IntFromIdentifier(NPIdentifier aIdentifier);
|
|
|
|
|
2011-06-25 08:25:03 -07:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2010-07-29 15:38:32 -07:00
|
|
|
void ProcessNativeEvents();
|
2010-08-13 09:45:50 -07:00
|
|
|
|
|
|
|
void PluginShowWindow(uint32_t window_id, bool modal, CGRect r) {
|
|
|
|
SendPluginShowWindow(window_id, modal, r.origin.x, r.origin.y, r.size.width, r.size.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PluginHideWindow(uint32_t window_id) {
|
|
|
|
SendPluginHideWindow(window_id);
|
|
|
|
}
|
2011-05-23 23:58:28 -07:00
|
|
|
|
|
|
|
void SetCursor(NSCursorInfo& cursorInfo) {
|
|
|
|
SendSetCursor(cursorInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowCursor(bool show) {
|
|
|
|
SendShowCursor(show);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushCursor(NSCursorInfo& cursorInfo) {
|
|
|
|
SendPushCursor(cursorInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopCursor() {
|
|
|
|
SendPopCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetNativeCursorsSupported() {
|
|
|
|
bool supported = false;
|
|
|
|
SendGetNativeCursorsSupported(&supported);
|
|
|
|
return supported;
|
|
|
|
}
|
2010-07-29 15:38:32 -07:00
|
|
|
#endif
|
|
|
|
|
2010-12-06 16:50:47 -08:00
|
|
|
// Quirks mode support for various plugin mime types
|
|
|
|
enum PluginQuirks {
|
|
|
|
QUIRKS_NOT_INITIALIZED = 0,
|
|
|
|
// Silverlight assumes it is transparent in windowless mode. This quirk
|
|
|
|
// matches the logic in nsNPAPIPluginInstance::SetWindowless.
|
|
|
|
QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT = 1 << 0,
|
|
|
|
// Win32: Hook TrackPopupMenu api so that we can swap out parent
|
|
|
|
// hwnds. The api will fail with parents not associated with our
|
|
|
|
// child ui thread. See WinlessHandleEvent for details.
|
|
|
|
QUIRK_WINLESS_TRACKPOPUP_HOOK = 1 << 1,
|
|
|
|
// Win32: Throttle flash WM_USER+1 heart beat messages to prevent
|
|
|
|
// flooding chromium's dispatch loop, which can cause ipc traffic
|
|
|
|
// processing lag.
|
|
|
|
QUIRK_FLASH_THROTTLE_WMUSER_EVENTS = 1 << 2,
|
|
|
|
// Win32: Catch resets on our subclass by hooking SetWindowLong.
|
|
|
|
QUIRK_FLASH_HOOK_SETLONGPTR = 1 << 3,
|
2010-12-06 16:50:53 -08:00
|
|
|
// X11: Work around a bug in Flash up to 10.1 d51 at least, where
|
|
|
|
// expose event top left coordinates within the plugin-rect and
|
|
|
|
// not at the drawable origin are misinterpreted.
|
|
|
|
QUIRK_FLASH_EXPOSE_COORD_TRANSLATION = 1 << 4,
|
2010-12-06 16:50:56 -08:00
|
|
|
// Win32: Catch get window info calls on the browser and tweak the
|
|
|
|
// results so mouse input works when flash is displaying it's settings
|
|
|
|
// window.
|
2011-01-14 14:13:43 -08:00
|
|
|
QUIRK_FLASH_HOOK_GETWINDOWINFO = 1 << 5,
|
2011-02-15 21:18:02 -08:00
|
|
|
// Win: Addresses a flash bug with mouse capture and full screen
|
|
|
|
// windows.
|
2011-02-16 14:43:31 -08:00
|
|
|
QUIRK_FLASH_FIXUP_MOUSE_CAPTURE = 1 << 6,
|
2011-02-18 13:31:59 -08:00
|
|
|
// Win: QuickTime steals focus on SetWindow calls even if it's hidden.
|
|
|
|
// Avoid calling SetWindow in that case.
|
|
|
|
QUIRK_QUICKTIME_AVOID_SETWINDOW = 1 << 7,
|
2011-07-26 12:18:23 -07:00
|
|
|
// Win: Check to make sure the parent window has focus before calling
|
|
|
|
// set focus on the child. Addresses a full screen dialog prompt
|
|
|
|
// problem in Silverlight.
|
|
|
|
QUIRK_SILVERLIGHT_FOCUS_CHECK_PARENT = 1 << 8,
|
2010-12-06 16:50:47 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
int GetQuirks() { return mQuirks; }
|
2011-05-01 13:33:16 -07:00
|
|
|
|
|
|
|
private:
|
2010-12-06 16:50:47 -08:00
|
|
|
void AddQuirk(PluginQuirks quirk) {
|
|
|
|
if (mQuirks == QUIRKS_NOT_INITIALIZED)
|
|
|
|
mQuirks = 0;
|
|
|
|
mQuirks |= quirk;
|
|
|
|
}
|
|
|
|
void InitQuirksModes(const nsCString& aMimeType);
|
2009-07-02 09:54:22 -07:00
|
|
|
bool InitGraphics();
|
2011-02-16 14:43:31 -08:00
|
|
|
void DeinitGraphics();
|
2010-02-16 10:44:24 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
|
|
|
static gboolean DetectNestedEventLoop(gpointer data);
|
|
|
|
static gboolean ProcessBrowserEvents(gpointer data);
|
|
|
|
|
2010-06-01 20:58:00 -07:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void EnteredCxxStack();
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void ExitedCxxStack();
|
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
|
|
|
2010-02-16 10:44:24 -08:00
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void EnteredCxxStack();
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void ExitedCxxStack();
|
|
|
|
#endif
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
PRLibrary* mLibrary;
|
2011-04-07 17:13:59 -07:00
|
|
|
nsCString mPluginFilename; // UTF8
|
2009-11-19 14:57:56 -08:00
|
|
|
nsCString mUserAgent;
|
2010-12-06 16:50:47 -08:00
|
|
|
int mQuirks;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
// we get this from the plugin
|
2010-03-17 11:38:28 -07:00
|
|
|
NP_PLUGINSHUTDOWN mShutdownFunc;
|
|
|
|
#ifdef OS_LINUX
|
2009-06-30 11:51:05 -07:00
|
|
|
NP_PLUGINUNIXINIT mInitializeFunc;
|
2010-03-17 11:38:28 -07:00
|
|
|
#elif defined(OS_WIN) || defined(OS_MACOSX)
|
2009-07-02 09:54:22 -07:00
|
|
|
NP_PLUGININIT mInitializeFunc;
|
|
|
|
NP_GETENTRYPOINTS mGetEntryPointsFunc;
|
|
|
|
#endif
|
2010-02-16 10:44:24 -08:00
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
NPPluginFuncs mFunctions;
|
|
|
|
NPSavedData mSavedData;
|
2009-09-17 15:15:12 -07:00
|
|
|
|
2010-02-16 10:44:24 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
|
|
|
// If a plugin spins a nested glib event loop in response to a
|
|
|
|
// synchronous IPC message from the browser, the loop might break
|
|
|
|
// only after the browser responds to a request sent by the
|
|
|
|
// plugin. This can happen if a plugin uses gtk's synchronous
|
|
|
|
// copy/paste, for example. But because the browser is blocked on
|
|
|
|
// a condvar, it can't respond to the request. This situation
|
|
|
|
// isn't technically a deadlock, but the symptoms are basically
|
|
|
|
// the same from the user's perspective.
|
|
|
|
//
|
|
|
|
// We take two steps to prevent this
|
|
|
|
//
|
|
|
|
// (1) Detect nested event loops spun by the plugin. This is
|
|
|
|
// done by scheduling a glib timer event in the plugin
|
|
|
|
// process whenever the browser might block on the plugin.
|
|
|
|
// If the plugin indeed spins a nested loop, this timer event
|
|
|
|
// will fire "soon" thereafter.
|
|
|
|
//
|
|
|
|
// (2) When a nested loop is detected, deschedule the
|
|
|
|
// nested-loop-detection timer and in its place, schedule
|
|
|
|
// another timer that periodically calls back into the
|
|
|
|
// browser and spins a mini event loop. This mini event loop
|
|
|
|
// processes a handful of pending native events.
|
|
|
|
//
|
|
|
|
// Because only timer (1) or (2) (or neither) may be active at any
|
|
|
|
// point in time, we use the same member variable
|
|
|
|
// |mNestedLoopTimerId| to refer to both.
|
|
|
|
//
|
|
|
|
// When the browser no longer might be blocked on a plugin's IPC
|
|
|
|
// response, we deschedule whichever of (1) or (2) is active.
|
|
|
|
guint mNestedLoopTimerId;
|
2010-03-25 18:52:16 -07:00
|
|
|
# ifdef DEBUG
|
|
|
|
// Depth of the stack of calls to g_main_context_dispatch before any
|
|
|
|
// nested loops are run. This is 1 when IPC calls are dispatched from
|
|
|
|
// g_main_context_iteration, or 0 when dispatched directly from
|
|
|
|
// MessagePumpForUI.
|
|
|
|
int mTopLoopDepth;
|
|
|
|
# endif
|
2010-06-01 20:58:00 -07:00
|
|
|
#elif defined (MOZ_WIDGET_QT)
|
|
|
|
NestedLoopTimer *mNestedLoopTimerObject;
|
2010-02-16 10:44:24 -08:00
|
|
|
#endif
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
struct NPObjectData : public nsPtrHashKey<NPObject>
|
|
|
|
{
|
|
|
|
NPObjectData(const NPObject* key)
|
|
|
|
: nsPtrHashKey<NPObject>(key)
|
|
|
|
, instance(NULL)
|
|
|
|
, actor(NULL)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
// never NULL
|
|
|
|
PluginInstanceChild* instance;
|
|
|
|
|
|
|
|
// sometimes NULL (no actor associated with an NPObject)
|
|
|
|
PluginScriptableObjectChild* actor;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* mObjectMap contains all the currently active NPObjects (from NPN_CreateObject until the
|
|
|
|
* final release/dealloc, whether or not an actor is currently associated with the object.
|
|
|
|
*/
|
|
|
|
nsTHashtable<NPObjectData> mObjectMap;
|
|
|
|
|
2011-06-14 12:49:48 -07:00
|
|
|
friend class PluginIdentifierChild;
|
|
|
|
friend class PluginIdentifierChildString;
|
|
|
|
friend class PluginIdentifierChildInt;
|
|
|
|
nsDataHashtable<nsCStringHashKey, PluginIdentifierChildString*> mStringIdentifiers;
|
|
|
|
nsDataHashtable<nsUint32HashKey, PluginIdentifierChildInt*> mIntIdentifiers;
|
2010-03-23 07:30:51 -07:00
|
|
|
|
2010-02-24 13:14:13 -08:00
|
|
|
public: // called by PluginInstanceChild
|
2010-01-22 07:06:13 -08:00
|
|
|
/**
|
|
|
|
* Dealloc an NPObject after last-release or when the associated instance
|
2010-02-24 13:14:13 -08:00
|
|
|
* is destroyed. This function will remove the object from mObjectMap.
|
2010-01-22 07:06:13 -08:00
|
|
|
*/
|
|
|
|
static void DeallocNPObject(NPObject* o);
|
|
|
|
|
2010-02-24 13:14:13 -08:00
|
|
|
NPError NPP_Destroy(PluginInstanceChild* instance) {
|
|
|
|
return mFunctions.destroy(instance->GetNPP(), 0);
|
|
|
|
}
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
/**
|
2010-02-24 13:14:13 -08:00
|
|
|
* Fill PluginInstanceChild.mDeletingHash with all the remaining NPObjects
|
|
|
|
* associated with that instance.
|
2010-01-22 07:06:13 -08:00
|
|
|
*/
|
2010-02-24 13:14:13 -08:00
|
|
|
void FindNPObjectsForInstance(PluginInstanceChild* instance);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static PLDHashOperator CollectForInstance(NPObjectData* d, void* userArg);
|
2010-04-30 11:42:51 -07:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void EnteredCall();
|
|
|
|
NS_OVERRIDE
|
|
|
|
virtual void ExitedCall();
|
|
|
|
|
|
|
|
// Entered/ExitedCall notifications keep track of whether the plugin has
|
|
|
|
// entered a nested event loop within this RPC call.
|
2010-04-30 11:43:59 -07:00
|
|
|
struct IncallFrame
|
|
|
|
{
|
|
|
|
IncallFrame()
|
|
|
|
: _spinning(false)
|
|
|
|
, _savedNestableTasksAllowed(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool _spinning;
|
|
|
|
bool _savedNestableTasksAllowed;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsAutoTArray<IncallFrame, 8> mIncallPumpingStack;
|
2010-04-30 11:42:51 -07:00
|
|
|
|
|
|
|
static LRESULT CALLBACK NestedInputEventHook(int code,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2010-05-11 08:19:14 -07:00
|
|
|
static LRESULT CALLBACK CallWindowProcHook(int code,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
void SetEventHooks();
|
|
|
|
void ResetEventHooks();
|
2010-04-30 11:42:51 -07:00
|
|
|
HHOOK mNestedEventHook;
|
2010-05-11 08:19:14 -07:00
|
|
|
HHOOK mGlobalCallWndProcHook;
|
2010-04-30 11:42:51 -07:00
|
|
|
#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_PluginModuleChild_h
|