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_PluginInstanceChild_h
|
|
|
|
#define dom_plugins_PluginInstanceChild_h 1
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
#include "mozilla/plugins/PPluginInstanceChild.h"
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginScriptableObjectChild.h"
|
2009-12-03 00:16:14 -08:00
|
|
|
#include "mozilla/plugins/StreamNotifyChild.h"
|
2009-12-01 13:05:26 -08:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "mozilla/gfx/SharedDIBWin.h"
|
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
#include "npfunctions.h"
|
2009-09-17 15:15:12 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsTArray.h"
|
2010-01-19 19:13:24 -08:00
|
|
|
#include "ChildAsyncCall.h"
|
|
|
|
#include "ChildTimer.h"
|
2010-02-18 12:20:25 -08:00
|
|
|
#include "nsRect.h"
|
2010-02-24 13:14:13 -08:00
|
|
|
#include "nsTHashtable.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
class PBrowserStreamChild;
|
|
|
|
class BrowserStreamChild;
|
2009-09-09 15:00:14 -07:00
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
class PluginInstanceChild : public PPluginInstanceChild
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-09-21 07:51:35 -07:00
|
|
|
friend class BrowserStreamChild;
|
|
|
|
friend class PluginStreamChild;
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
#ifdef OS_WIN
|
|
|
|
friend LRESULT CALLBACK PluginWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
#endif
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
protected:
|
2009-09-30 14:36:14 -07:00
|
|
|
virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window, NPError* rv);
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2009-09-24 19:03:59 -07:00
|
|
|
virtual bool
|
|
|
|
AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv);
|
2009-09-17 16:09:20 -07:00
|
|
|
virtual bool
|
2009-09-17 15:15:12 -07:00
|
|
|
AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value,
|
|
|
|
NPError* result);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2010-01-19 19:23:35 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerNPP_SetValue_NPNVprivateModeBool(const bool& value, NPError* result);
|
|
|
|
|
2009-09-18 18:19:11 -07:00
|
|
|
virtual bool
|
2009-10-27 12:58:33 -07:00
|
|
|
AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled);
|
2009-09-18 18:19:11 -07:00
|
|
|
|
2010-01-15 12:35:57 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerNPP_Destroy(NPError* result);
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
virtual PPluginScriptableObjectChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
AllocPPluginScriptableObject();
|
2009-08-10 16:28:22 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
virtual bool
|
2009-09-22 10:31:11 -07:00
|
|
|
DeallocPPluginScriptableObject(PPluginScriptableObjectChild* aObject);
|
2009-08-10 16:28:22 -07:00
|
|
|
|
2010-03-04 13:20:14 -08:00
|
|
|
NS_OVERRIDE virtual bool
|
|
|
|
RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor);
|
2009-10-07 16:50:48 -07:00
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
virtual PBrowserStreamChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
AllocPBrowserStream(const nsCString& url,
|
|
|
|
const uint32_t& length,
|
|
|
|
const uint32_t& lastmodified,
|
2009-10-16 16:31:53 -07:00
|
|
|
PStreamNotifyChild* notifyData,
|
2009-09-22 10:31:11 -07:00
|
|
|
const nsCString& headers,
|
|
|
|
const nsCString& mimeType,
|
|
|
|
const bool& seekable,
|
|
|
|
NPError* rv,
|
|
|
|
uint16_t *stype);
|
2009-08-18 13:20:03 -07:00
|
|
|
|
2010-01-12 15:06:18 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerPBrowserStreamConstructor(
|
|
|
|
PBrowserStreamChild* aActor,
|
|
|
|
const nsCString& url,
|
|
|
|
const uint32_t& length,
|
|
|
|
const uint32_t& lastmodified,
|
|
|
|
PStreamNotifyChild* notifyData,
|
|
|
|
const nsCString& headers,
|
|
|
|
const nsCString& mimeType,
|
|
|
|
const bool& seekable,
|
|
|
|
NPError* rv,
|
|
|
|
uint16_t* stype);
|
|
|
|
|
2009-09-21 07:51:35 -07:00
|
|
|
virtual bool
|
2009-12-03 00:16:14 -08:00
|
|
|
DeallocPBrowserStream(PBrowserStreamChild* stream);
|
2009-08-18 13:20:03 -07:00
|
|
|
|
2009-09-21 07:51:35 -07:00
|
|
|
virtual PPluginStreamChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
AllocPPluginStream(const nsCString& mimeType,
|
|
|
|
const nsCString& target,
|
|
|
|
NPError* result);
|
2009-09-21 07:51:35 -07:00
|
|
|
|
|
|
|
virtual bool
|
2009-12-03 00:16:14 -08:00
|
|
|
DeallocPPluginStream(PPluginStreamChild* stream);
|
2009-09-21 07:51:35 -07:00
|
|
|
|
2009-09-08 14:22:50 -07:00
|
|
|
virtual PStreamNotifyChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
AllocPStreamNotify(const nsCString& url, const nsCString& target,
|
|
|
|
const bool& post, const nsCString& buffer,
|
|
|
|
const bool& file,
|
|
|
|
NPError* result);
|
2009-09-08 14:22:50 -07:00
|
|
|
|
2009-11-25 06:26:01 -08:00
|
|
|
NS_OVERRIDE virtual bool
|
2009-12-03 00:16:14 -08:00
|
|
|
DeallocPStreamNotify(PStreamNotifyChild* notifyData);
|
2009-09-08 14:22:50 -07:00
|
|
|
|
2010-01-26 13:40:15 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerSetPluginFocus();
|
|
|
|
|
2010-01-26 16:08:39 -08:00
|
|
|
virtual bool
|
|
|
|
AnswerUpdateWindow();
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
public:
|
2010-02-24 16:13:48 -08:00
|
|
|
PluginInstanceChild(const NPPluginFuncs* aPluginIface, const nsCString& aMimeType);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
virtual ~PluginInstanceChild();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
bool Initialize();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
NPP GetNPP()
|
|
|
|
{
|
|
|
|
return &mData;
|
|
|
|
}
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
NPError
|
2009-09-24 19:03:59 -07:00
|
|
|
NPN_GetValue(NPNVariable aVariable, void* aValue);
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_SetValue(NPPVariable aVariable, void* aValue);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginScriptableObjectChild*
|
2009-09-23 00:12:52 -07:00
|
|
|
GetActorForNPObject(NPObject* aObject);
|
2009-09-17 15:15:12 -07:00
|
|
|
|
2009-09-21 07:51:35 -07:00
|
|
|
NPError
|
|
|
|
NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
|
|
|
|
NPStream** aStream);
|
|
|
|
|
2010-01-04 13:46:34 -08:00
|
|
|
void InvalidateRect(NPRect* aInvalidRect);
|
2009-11-13 12:20:03 -08:00
|
|
|
|
2009-12-03 00:16:14 -08:00
|
|
|
bool NotifyStream(StreamNotifyChild* notifyData, NPReason reason);
|
|
|
|
|
2010-01-19 19:13:24 -08:00
|
|
|
uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func);
|
|
|
|
void UnscheduleTimer(uint32_t id);
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
private:
|
2010-02-24 13:14:13 -08:00
|
|
|
friend class PluginModuleChild;
|
|
|
|
|
2010-02-24 16:13:48 -08:00
|
|
|
// Quirks mode support for various plugin mime types
|
|
|
|
enum PluginQuirks {
|
|
|
|
QUIRK_SILVERLIGHT_WINLESS_INPUT_TRANSLATION = 1, // Win32
|
|
|
|
};
|
|
|
|
|
|
|
|
void InitQuirksModes(const nsCString& aMimeType);
|
2009-07-01 14:19:32 -07:00
|
|
|
|
2010-02-20 13:59:40 -08:00
|
|
|
NPError
|
|
|
|
InternalGetNPObjectForValue(NPNVariable aValue,
|
|
|
|
NPObject** aObject);
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
static bool RegisterWindowClass();
|
|
|
|
bool CreatePluginWindow();
|
|
|
|
void DestroyPluginWindow();
|
|
|
|
void ReparentPluginWindow(HWND hWndParent);
|
|
|
|
void SizePluginWindow(int width, int height);
|
2010-02-09 14:34:38 -08:00
|
|
|
int16_t WinlessHandleEvent(NPEvent& event);
|
|
|
|
void SetNestedInputEventHook();
|
|
|
|
void ResetNestedEventHook();
|
|
|
|
void SetNestedInputPumpHook();
|
|
|
|
void ResetPumpHooks();
|
|
|
|
void InternalCallSetNestedEventState(bool aState);
|
2009-07-01 14:19:32 -07:00
|
|
|
static LRESULT CALLBACK DummyWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK PluginWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2010-02-09 14:34:38 -08:00
|
|
|
static VOID CALLBACK PumpTimerProc(HWND hwnd,
|
|
|
|
UINT uMsg,
|
|
|
|
UINT_PTR idEvent,
|
|
|
|
DWORD dwTime);
|
|
|
|
static LRESULT CALLBACK NestedInputEventHook(int code,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK NestedInputPumpHook(int code,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2009-07-01 14:19:32 -07:00
|
|
|
#endif
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
const NPPluginFuncs* mPluginIface;
|
|
|
|
NPP_t mData;
|
|
|
|
NPWindow mWindow;
|
2010-02-24 16:13:48 -08:00
|
|
|
int mQuirks;
|
2010-01-15 12:35:57 -08:00
|
|
|
|
2010-02-20 13:59:40 -08:00
|
|
|
// Cached scriptable actors to avoid IPC churn
|
|
|
|
PluginScriptableObjectChild* mCachedWindowActor;
|
|
|
|
PluginScriptableObjectChild* mCachedElementActor;
|
|
|
|
|
2009-10-11 16:54:49 -07:00
|
|
|
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
2009-06-30 11:51:05 -07:00
|
|
|
NPSetWindowCallbackStruct mWsInfo;
|
2009-07-01 14:19:32 -07:00
|
|
|
#elif defined(OS_WIN)
|
|
|
|
HWND mPluginWindowHWND;
|
|
|
|
WNDPROC mPluginWndProc;
|
|
|
|
HWND mPluginParentHWND;
|
2010-02-09 14:34:38 -08:00
|
|
|
HHOOK mNestedEventHook;
|
|
|
|
HHOOK mNestedPumpHook;
|
|
|
|
int mNestedEventLevelDepth;
|
|
|
|
bool mNestedEventState;
|
|
|
|
HWND mCachedWinlessPluginHWND;
|
|
|
|
UINT_PTR mEventPumpTimer;
|
2010-02-18 12:20:25 -08:00
|
|
|
nsIntPoint mPluginSize;
|
2010-02-24 16:13:48 -08:00
|
|
|
nsIntPoint mPluginOffset;
|
2009-07-02 09:54:22 -07:00
|
|
|
#endif
|
2009-09-17 15:15:12 -07:00
|
|
|
|
2010-01-19 19:13:24 -08:00
|
|
|
friend class ChildAsyncCall;
|
|
|
|
nsTArray<ChildAsyncCall*> mPendingAsyncCalls;
|
2010-02-03 14:17:09 -08:00
|
|
|
nsTArray<nsAutoPtr<ChildTimer> > mTimers;
|
2010-01-19 19:13:24 -08:00
|
|
|
|
2010-02-24 13:14:13 -08:00
|
|
|
/**
|
|
|
|
* During destruction we enumerate all remaining scriptable objects and
|
|
|
|
* invalidate/delete them. Enumeration can re-enter, so maintain a
|
|
|
|
* hash separate from PluginModuleChild.mObjectMap.
|
|
|
|
*/
|
|
|
|
nsAutoPtr< nsTHashtable<DeletingObjectEntry> > mDeletingHash;
|
|
|
|
|
2009-12-01 13:05:26 -08:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
private:
|
|
|
|
// Shared dib rendering management for windowless plugins.
|
|
|
|
bool SharedSurfaceSetWindow(const NPRemoteWindow& aWindow, NPError* rv);
|
2009-12-14 16:27:25 -08:00
|
|
|
int16_t SharedSurfacePaint(NPEvent& evcopy);
|
2009-12-01 13:05:26 -08:00
|
|
|
void SharedSurfaceRelease();
|
2009-12-14 16:27:25 -08:00
|
|
|
bool AlphaExtractCacheSetup();
|
|
|
|
void AlphaExtractCacheRelease();
|
|
|
|
void UpdatePaintClipRect(RECT* aRect);
|
2009-12-01 13:05:26 -08:00
|
|
|
|
|
|
|
private:
|
2009-12-14 16:27:25 -08:00
|
|
|
enum {
|
|
|
|
RENDER_NATIVE,
|
|
|
|
RENDER_BACK_ONE,
|
|
|
|
RENDER_BACK_TWO
|
|
|
|
};
|
2009-12-01 13:05:26 -08:00
|
|
|
gfx::SharedDIBWin mSharedSurfaceDib;
|
2009-12-14 16:27:25 -08:00
|
|
|
struct {
|
|
|
|
PRUint32 doublePassEvent;
|
|
|
|
PRUint16 doublePass;
|
|
|
|
HDC hdc;
|
|
|
|
HBITMAP bmp;
|
|
|
|
} mAlphaExtract;
|
2009-12-01 13:05:26 -08:00
|
|
|
#endif // defined(OS_WIN)
|
2009-06-30 11:51:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#endif // ifndef dom_plugins_PluginInstanceChild_h
|