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"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
#undef _MOZ_LOG
|
2009-09-08 23:31:35 -07:00
|
|
|
#define _MOZ_LOG(s) printf("[PluginInstanceChild] %s\n", s)
|
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-12-03 00:16:14 -08:00
|
|
|
virtual bool Answer__delete__(NPError* rv);
|
|
|
|
|
2009-09-24 19:03:59 -07:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
AnswerNPP_GetValue_NPPVpluginWindow(bool* windowed, NPError* rv);
|
|
|
|
virtual bool
|
|
|
|
AnswerNPP_GetValue_NPPVpluginTransparent(bool* transparent, NPError* rv);
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2009-10-07 16:50:48 -07:00
|
|
|
virtual bool
|
|
|
|
AnswerPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor);
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
public:
|
2009-10-11 16:54:49 -07:00
|
|
|
PluginInstanceChild(const NPPluginFuncs* aPluginIface);
|
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-10-07 16:50:48 -07:00
|
|
|
void Destroy();
|
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);
|
|
|
|
|
2009-11-13 13:19:33 -08:00
|
|
|
// Return true if you want to send the notification to the parent process
|
|
|
|
// also.
|
|
|
|
bool
|
2009-11-13 12:20:03 -08:00
|
|
|
InternalInvalidateRect(NPRect* aInvalidRect);
|
|
|
|
|
2009-12-03 00:16:14 -08:00
|
|
|
bool NotifyStream(StreamNotifyChild* notifyData, NPReason reason);
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
private:
|
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);
|
|
|
|
static LRESULT CALLBACK DummyWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK PluginWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
const NPPluginFuncs* mPluginIface;
|
|
|
|
NPP_t mData;
|
|
|
|
NPWindow mWindow;
|
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;
|
2009-07-02 09:54:22 -07:00
|
|
|
#endif
|
2009-09-17 15:15:12 -07:00
|
|
|
|
|
|
|
nsTArray<nsAutoPtr<PluginScriptableObjectChild> > mScriptableObjects;
|
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
|