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 "PluginInstanceChild.h"
|
2009-09-17 15:15:12 -07:00
|
|
|
#include "PluginModuleChild.h"
|
2009-09-09 07:04:09 -07:00
|
|
|
#include "BrowserStreamChild.h"
|
2009-09-21 07:51:35 -07:00
|
|
|
#include "PluginStreamChild.h"
|
2009-09-08 14:22:50 -07:00
|
|
|
#include "StreamNotifyChild.h"
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
using namespace mozilla::plugins;
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
#if defined(OS_LINUX)
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include "gtk2xtbin.h"
|
2009-07-01 14:19:32 -07:00
|
|
|
|
|
|
|
#elif defined(OS_WIN)
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-08-10 16:28:22 -07:00
|
|
|
namespace {
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
static const char*
|
|
|
|
NPNVariableToString(NPNVariable aVar)
|
|
|
|
{
|
|
|
|
#define VARSTR(v_) case v_: return #v_
|
|
|
|
|
|
|
|
switch(aVar) {
|
|
|
|
VARSTR(NPNVxDisplay);
|
|
|
|
VARSTR(NPNVxtAppContext);
|
|
|
|
VARSTR(NPNVnetscapeWindow);
|
|
|
|
VARSTR(NPNVjavascriptEnabledBool);
|
|
|
|
VARSTR(NPNVasdEnabledBool);
|
|
|
|
VARSTR(NPNVisOfflineBool);
|
|
|
|
|
|
|
|
VARSTR(NPNVserviceManager);
|
|
|
|
VARSTR(NPNVDOMElement);
|
|
|
|
VARSTR(NPNVDOMWindow);
|
|
|
|
VARSTR(NPNVToolkit);
|
|
|
|
VARSTR(NPNVSupportsXEmbedBool);
|
|
|
|
|
|
|
|
VARSTR(NPNVWindowNPObject);
|
|
|
|
|
|
|
|
VARSTR(NPNVPluginElementNPObject);
|
|
|
|
|
|
|
|
VARSTR(NPNVSupportsWindowless);
|
|
|
|
|
|
|
|
VARSTR(NPNVprivateModeBool);
|
|
|
|
|
|
|
|
default: return "???";
|
|
|
|
}
|
|
|
|
#undef VARSTR
|
|
|
|
}
|
|
|
|
|
2009-08-10 16:28:22 -07:00
|
|
|
} /* anonymous namespace */
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::~PluginInstanceChild()
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
DestroyPluginWindow();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
NPError
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
|
|
|
|
void* aValue)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-09-08 23:31:35 -07:00
|
|
|
printf ("[PluginInstanceChild] NPN_GetValue(%s)\n",
|
2009-06-30 11:51:05 -07:00
|
|
|
NPNVariableToString(aVar));
|
|
|
|
|
|
|
|
switch(aVar) {
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
case NPNVSupportsWindowless:
|
2009-07-01 14:19:32 -07:00
|
|
|
// FIXME/cjones report true here and use XComposite + child
|
2009-07-02 09:54:22 -07:00
|
|
|
// surface to implement windowless plugins
|
2009-07-01 14:19:32 -07:00
|
|
|
*((NPBool*)aValue) = false;
|
2009-07-02 09:54:22 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
|
|
|
#if defined(OS_LINUX)
|
2009-06-30 11:51:05 -07:00
|
|
|
case NPNVSupportsXEmbedBool:
|
2009-07-01 14:19:32 -07:00
|
|
|
*((NPBool*)aValue) = true;
|
2009-06-30 11:51:05 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
|
|
|
case NPNVToolkit:
|
|
|
|
*((NPNToolkitType*)aValue) = NPNVGtk2;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#elif defined(OS_WIN)
|
|
|
|
case NPNVToolkit:
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
#endif
|
2009-09-15 13:33:24 -07:00
|
|
|
case NPNVjavascriptEnabledBool: {
|
|
|
|
bool v = false;
|
|
|
|
NPError result;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!CallNPN_GetValue_NPNVjavascriptEnabledBool(&v, &result)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2009-09-15 13:33:24 -07:00
|
|
|
*static_cast<NPBool*>(aValue) = v;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVisOfflineBool: {
|
|
|
|
bool v = false;
|
|
|
|
NPError result;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!CallNPN_GetValue_NPNVisOfflineBool(&v, &result)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2009-09-15 13:33:24 -07:00
|
|
|
*static_cast<NPBool*>(aValue) = v;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVprivateModeBool: {
|
|
|
|
bool v = false;
|
|
|
|
NPError result;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!CallNPN_GetValue_NPNVprivateModeBool(&v, &result)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2009-09-15 13:33:24 -07:00
|
|
|
*static_cast<NPBool*>(aValue) = v;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
default:
|
|
|
|
printf(" unhandled var %s\n", NPNVariableToString(aVar));
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginInstanceChild::AnswerNPP_GetValue_NPPVpluginScriptableNPObject(
|
|
|
|
PPluginScriptableObjectChild** value,
|
|
|
|
NPError* result)
|
2009-07-02 09:54:22 -07:00
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
|
|
|
|
NPObject* object;
|
|
|
|
*result = mPluginIface->getvalue(GetNPP(), NPPVpluginScriptableNPObject,
|
|
|
|
&object);
|
|
|
|
if (*result != NPERR_NO_ERROR) {
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-09-17 15:15:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
PluginScriptableObjectChild* actor = CreateActorForNPObject(object);
|
|
|
|
if (!actor) {
|
|
|
|
PluginModuleChild::sBrowserFuncs.releaseobject(object);
|
|
|
|
*result = NPERR_GENERIC_ERROR;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-09-17 15:15:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
PluginModuleChild::sBrowserFuncs.releaseobject(object);
|
|
|
|
*value = actor;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-18 18:19:11 -07:00
|
|
|
bool
|
|
|
|
PluginInstanceChild::AnswerNPP_HandleEvent(const NPEvent& event,
|
|
|
|
int16_t* handled)
|
|
|
|
{
|
|
|
|
// plugins might be fooling with these, make a copy
|
|
|
|
NPEvent evcopy = event;
|
|
|
|
*handled = mPluginIface->event(&mData, reinterpret_cast<void*>(&evcopy));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::AnswerNPP_SetWindow(const NPWindow& aWindow,
|
|
|
|
NPError* rv)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-09-08 23:31:35 -07:00
|
|
|
printf("[PluginInstanceChild] NPP_SetWindow(%lx, %d, %d)\n",
|
2009-07-02 09:54:22 -07:00
|
|
|
reinterpret_cast<unsigned long>(aWindow.window),
|
|
|
|
aWindow.width, aWindow.height);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#if defined(OS_LINUX)
|
2009-06-30 11:51:05 -07:00
|
|
|
// XXX/cjones: the minimum info is sent over IPC to allow this
|
2009-07-02 09:54:22 -07:00
|
|
|
// code to determine the rest. this code is possibly wrong on
|
2009-06-30 11:51:05 -07:00
|
|
|
// some systems, in some conditions
|
|
|
|
|
2009-08-11 22:41:55 -07:00
|
|
|
GdkNativeWindow handle = reinterpret_cast<uintptr_t>(aWindow.window);
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
mWindow.window = (void*) handle;
|
2009-07-02 09:54:22 -07:00
|
|
|
mWindow.width = aWindow.width;
|
|
|
|
mWindow.height = aWindow.height;
|
2009-06-30 11:51:05 -07:00
|
|
|
mWindow.type = NPWindowTypeWindow;
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
mWsInfo.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
// FIXME/cjones: the code below is correct, but apparently to get
|
|
|
|
// a valid GdkWindow*, one needs to create the gtk_plug. but if we
|
|
|
|
// do that, then the plugin can't plug in to plug. a hacky solution
|
|
|
|
// may be to create the plug, then create another socket within that
|
|
|
|
// plug. yuck.
|
|
|
|
#if 0
|
2009-06-30 11:51:05 -07:00
|
|
|
mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow);
|
2009-07-02 09:54:22 -07:00
|
|
|
mWsInfo.colormap =
|
|
|
|
GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow));
|
2009-06-30 11:51:05 -07:00
|
|
|
GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow);
|
|
|
|
mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual);
|
|
|
|
mWsInfo.depth = gdkVisual->depth;
|
2009-07-02 09:54:22 -07:00
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
mWindow.ws_info = (void*) &mWsInfo;
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
*rv = mPluginIface->setwindow(&mData, &mWindow);
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#elif defined(OS_WIN)
|
2009-07-01 14:19:32 -07:00
|
|
|
ReparentPluginWindow((HWND)aWindow.window);
|
|
|
|
SizePluginWindow(aWindow.width, aWindow.height);
|
|
|
|
|
|
|
|
mWindow.window = (void*)mPluginWindowHWND;
|
2009-07-02 09:54:22 -07:00
|
|
|
mWindow.width = aWindow.width;
|
|
|
|
mWindow.height = aWindow.height;
|
|
|
|
mWindow.type = NPWindowTypeWindow;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
*rv = mPluginIface->setwindow(&mData, &mWindow);
|
|
|
|
if (*rv == NPERR_NO_ERROR) {
|
|
|
|
WNDPROC wndProc = reinterpret_cast<WNDPROC>(
|
|
|
|
GetWindowLongPtr(mPluginWindowHWND, GWLP_WNDPROC));
|
|
|
|
if (wndProc != PluginWindowProc) {
|
|
|
|
mPluginWndProc = reinterpret_cast<WNDPROC>(
|
|
|
|
SetWindowLongPtr(mPluginWindowHWND, GWLP_WNDPROC,
|
|
|
|
reinterpret_cast<LONG>(PluginWindowProc)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#else
|
|
|
|
# error Implement me for your OS
|
|
|
|
#endif
|
2009-07-02 09:54:22 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-07-01 14:19:32 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::Initialize()
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
if (!CreatePluginWindow())
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
|
|
|
|
static const TCHAR kWindowClassName[] = TEXT("GeckoPluginWindow");
|
2009-09-08 23:31:35 -07:00
|
|
|
static const TCHAR kPluginInstanceChildProperty[] = TEXT("PluginInstanceChildProperty");
|
2009-07-01 14:19:32 -07:00
|
|
|
|
|
|
|
// static
|
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::RegisterWindowClass()
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
static bool alreadyRegistered = false;
|
|
|
|
if (alreadyRegistered)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
alreadyRegistered = true;
|
|
|
|
|
|
|
|
WNDCLASSEX wcex;
|
|
|
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wcex.style = CS_DBLCLKS;
|
|
|
|
wcex.lpfnWndProc = DummyWindowProc;
|
|
|
|
wcex.cbClsExtra = 0;
|
|
|
|
wcex.cbWndExtra = 0;
|
|
|
|
wcex.hInstance = GetModuleHandle(NULL);
|
|
|
|
wcex.hIcon = 0;
|
|
|
|
wcex.hCursor = 0;
|
2009-07-02 13:48:33 -07:00
|
|
|
wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
|
2009-07-01 14:19:32 -07:00
|
|
|
wcex.lpszMenuName = 0;
|
|
|
|
wcex.lpszClassName = kWindowClassName;
|
|
|
|
wcex.hIconSm = 0;
|
|
|
|
|
|
|
|
return RegisterClassEx(&wcex) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::CreatePluginWindow()
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
if (!RegisterWindowClass())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!mPluginWindowHWND) {
|
|
|
|
mPluginWindowHWND =
|
|
|
|
CreateWindowEx(WS_EX_LEFT | WS_EX_LTRREADING |
|
|
|
|
WS_EX_NOPARENTNOTIFY | // XXXbent Get rid of this!
|
|
|
|
WS_EX_RIGHTSCROLLBAR,
|
|
|
|
kWindowClassName, 0,
|
|
|
|
WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0,
|
|
|
|
0, 0, NULL, 0, GetModuleHandle(NULL), 0);
|
|
|
|
if (!mPluginWindowHWND)
|
|
|
|
return false;
|
2009-09-08 23:31:35 -07:00
|
|
|
if (!SetProp(mPluginWindowHWND, kPluginInstanceChildProperty, this))
|
2009-07-01 14:19:32 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Apparently some plugins require an ASCII WndProc.
|
|
|
|
SetWindowLongPtrA(mPluginWindowHWND, GWLP_WNDPROC,
|
|
|
|
reinterpret_cast<LONG>(DefWindowProcA));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::DestroyPluginWindow()
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
if (mPluginWindowHWND) {
|
|
|
|
// Unsubclass the window.
|
|
|
|
WNDPROC wndProc = reinterpret_cast<WNDPROC>(
|
|
|
|
GetWindowLongPtr(mPluginWindowHWND, GWLP_WNDPROC));
|
|
|
|
if (wndProc == PluginWindowProc) {
|
|
|
|
NS_ASSERTION(mPluginWndProc, "Should have old proc here!");
|
|
|
|
SetWindowLongPtr(mPluginWindowHWND, GWLP_WNDPROC,
|
|
|
|
reinterpret_cast<LONG>(mPluginWndProc));
|
|
|
|
mPluginWndProc = 0;
|
|
|
|
}
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
RemoveProp(mPluginWindowHWND, kPluginInstanceChildProperty);
|
2009-07-01 14:19:32 -07:00
|
|
|
DestroyWindow(mPluginWindowHWND);
|
|
|
|
mPluginWindowHWND = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::ReparentPluginWindow(HWND hWndParent)
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
if (hWndParent != mPluginParentHWND && IsWindow(hWndParent)) {
|
|
|
|
LONG style = GetWindowLongPtr(mPluginWindowHWND, GWL_STYLE);
|
|
|
|
style |= WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
|
|
|
SetWindowLongPtr(mPluginWindowHWND, GWL_STYLE, style);
|
|
|
|
SetParent(mPluginWindowHWND, hWndParent);
|
|
|
|
ShowWindow(mPluginWindowHWND, SW_SHOWNA);
|
|
|
|
}
|
|
|
|
mPluginParentHWND = hWndParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::SizePluginWindow(int width,
|
|
|
|
int height)
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
if (mPluginWindowHWND) {
|
|
|
|
SetWindowPos(mPluginWindowHWND, NULL, 0, 0, width, height,
|
|
|
|
SWP_NOZORDER | SWP_NOREPOSITION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// See chromium's webplugin_delegate_impl.cc for explanation of this function.
|
|
|
|
// static
|
|
|
|
LRESULT CALLBACK
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::DummyWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
|
|
|
return CallWindowProc(DefWindowProc, hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
LRESULT CALLBACK
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild::PluginWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2009-07-01 14:19:32 -07:00
|
|
|
{
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginInstanceChild* self = reinterpret_cast<PluginInstanceChild*>(
|
|
|
|
GetProp(hWnd, kPluginInstanceChildProperty));
|
2009-07-01 14:19:32 -07:00
|
|
|
if (!self) {
|
|
|
|
NS_NOTREACHED("Badness!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(self->mPluginWindowHWND == hWnd, "Wrong window!");
|
|
|
|
|
|
|
|
LRESULT res = CallWindowProc(self->mPluginWndProc, hWnd, message, wParam,
|
|
|
|
lParam);
|
|
|
|
|
|
|
|
if (message == WM_CLOSE)
|
|
|
|
self->DestroyPluginWindow();
|
|
|
|
|
|
|
|
if (message == WM_NCDESTROY)
|
2009-09-08 23:31:35 -07:00
|
|
|
RemoveProp(hWnd, kPluginInstanceChildProperty);
|
2009-07-01 14:19:32 -07:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OS_WIN
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PPluginScriptableObjectChild*
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginInstanceChild::PPluginScriptableObjectConstructor()
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
nsAutoPtr<PluginScriptableObjectChild>* object =
|
|
|
|
mScriptableObjects.AppendElement();
|
|
|
|
NS_ENSURE_TRUE(object, nsnull);
|
|
|
|
|
|
|
|
*object = new PluginScriptableObjectChild();
|
|
|
|
NS_ENSURE_TRUE(*object, nsnull);
|
|
|
|
|
|
|
|
return object->get();
|
2009-08-10 16:28:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginInstanceChild::PPluginScriptableObjectDestructor(PPluginScriptableObjectChild* aObject)
|
2009-08-10 16:28:22 -07:00
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginScriptableObjectChild* object =
|
|
|
|
reinterpret_cast<PluginScriptableObjectChild*>(aObject);
|
|
|
|
|
|
|
|
PRUint32 count = mScriptableObjects.Length();
|
|
|
|
for (PRUint32 index = 0; index < count; index++) {
|
|
|
|
if (mScriptableObjects[index] == object) {
|
|
|
|
mScriptableObjects.RemoveElementAt(index);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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-09 15:59:06 -07:00
|
|
|
PBrowserStreamChild*
|
2009-09-09 07:04:09 -07:00
|
|
|
PluginInstanceChild::PBrowserStreamConstructor(const nsCString& url,
|
|
|
|
const uint32_t& length,
|
|
|
|
const uint32_t& lastmodified,
|
2009-09-08 14:22:50 -07:00
|
|
|
const PStreamNotifyChild* notifyData,
|
2009-09-09 07:04:09 -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-09 07:04:09 -07:00
|
|
|
return new BrowserStreamChild(this, url, length, lastmodified, headers,
|
|
|
|
mimeType, seekable, rv, stype);
|
2009-08-18 13:20:03 -07:00
|
|
|
}
|
|
|
|
|
2009-09-21 07:51:35 -07:00
|
|
|
bool
|
|
|
|
PluginInstanceChild::AnswerPBrowserStreamDestructor(PBrowserStreamChild* stream,
|
|
|
|
const NPError& reason,
|
|
|
|
const bool& artificial)
|
|
|
|
{
|
|
|
|
if (!artificial)
|
|
|
|
static_cast<BrowserStreamChild*>(stream)->NPP_DestroyStream(reason);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-09 15:59:06 -07:00
|
|
|
PluginInstanceChild::PBrowserStreamDestructor(PBrowserStreamChild* stream,
|
2009-09-09 07:04:09 -07:00
|
|
|
const NPError& reason,
|
|
|
|
const bool& artificial)
|
2009-08-18 13:20:03 -07:00
|
|
|
{
|
|
|
|
delete stream;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-18 13:20:03 -07:00
|
|
|
}
|
|
|
|
|
2009-09-21 07:51:35 -07:00
|
|
|
PPluginStreamChild*
|
|
|
|
PluginInstanceChild::PPluginStreamConstructor(const nsCString& mimeType,
|
|
|
|
const nsCString& target,
|
|
|
|
NPError* result)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("not callable");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginInstanceChild::AnswerPPluginStreamDestructor(PPluginStreamChild* stream,
|
|
|
|
const NPReason& reason,
|
|
|
|
const bool& artificial)
|
|
|
|
{
|
|
|
|
if (!artificial) {
|
|
|
|
static_cast<PluginStreamChild*>(stream)->NPP_DestroyStream(reason);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginInstanceChild::PPluginStreamDestructor(PPluginStreamChild* stream,
|
|
|
|
const NPError& reason,
|
|
|
|
const bool& artificial)
|
|
|
|
{
|
|
|
|
delete stream;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-08 14:22:50 -07:00
|
|
|
PStreamNotifyChild*
|
|
|
|
PluginInstanceChild::PStreamNotifyConstructor(const nsCString& url,
|
|
|
|
const nsCString& target,
|
|
|
|
const bool& post,
|
|
|
|
const nsCString& buffer,
|
|
|
|
const bool& file,
|
|
|
|
NPError* result)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 14:22:50 -07:00
|
|
|
PluginInstanceChild::PStreamNotifyDestructor(PStreamNotifyChild* notifyData,
|
|
|
|
const NPReason& reason)
|
|
|
|
{
|
|
|
|
StreamNotifyChild* sn = static_cast<StreamNotifyChild*>(notifyData);
|
|
|
|
mPluginIface->urlnotify(&mData, sn->mURL.get(), reason, sn->mClosure);
|
|
|
|
delete sn;
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-09-08 14:22:50 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginScriptableObjectChild*
|
|
|
|
PluginInstanceChild::CreateActorForNPObject(NPObject* aObject)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aObject, "Null pointer!");
|
|
|
|
|
|
|
|
PluginScriptableObjectChild* actor =
|
|
|
|
reinterpret_cast<PluginScriptableObjectChild*>(
|
|
|
|
CallPPluginScriptableObjectConstructor());
|
|
|
|
NS_ENSURE_TRUE(actor, nsnull);
|
|
|
|
|
|
|
|
actor->Initialize(this, aObject);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool ok =
|
|
|
|
#endif
|
|
|
|
PluginModuleChild::current()->RegisterNPObject(aObject, actor);
|
|
|
|
NS_ASSERTION(ok, "Out of memory?");
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
}
|
2009-09-21 07:51:35 -07:00
|
|
|
|
|
|
|
NPError
|
|
|
|
PluginInstanceChild::NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
|
|
|
|
NPStream** aStream)
|
|
|
|
{
|
|
|
|
PluginStreamChild* ps = new PluginStreamChild(this);
|
|
|
|
|
|
|
|
NPError result;
|
|
|
|
CallPPluginStreamConstructor(ps, nsDependentCString(aMIMEType),
|
|
|
|
nsDependentCString(aWindow), &result);
|
|
|
|
if (NPERR_NO_ERROR != result) {
|
|
|
|
*aStream = NULL;
|
|
|
|
CallPPluginStreamDestructor(ps, NPERR_GENERIC_ERROR, true);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aStream = &ps->mStream;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|