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 ***** */
|
|
|
|
|
2010-02-10 12:48:20 -08:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
#include <QApplication>
|
|
|
|
#endif
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginModuleChild.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2010-01-27 21:22:41 -08:00
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
2009-07-02 09:54:22 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "nsILocalFile.h"
|
|
|
|
|
2009-11-12 14:16:54 -08:00
|
|
|
#include "pratom.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsPluginsDir.h"
|
2009-12-03 00:16:28 -08:00
|
|
|
#include "nsXULAppAPI.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginInstanceChild.h"
|
2009-09-15 12:48:18 -07:00
|
|
|
#include "mozilla/plugins/StreamNotifyChild.h"
|
|
|
|
#include "mozilla/plugins/BrowserStreamChild.h"
|
2009-09-21 07:51:35 -07:00
|
|
|
#include "mozilla/plugins/PluginStreamChild.h"
|
2010-02-03 14:17:09 -08:00
|
|
|
#include "mozilla/plugins/PluginThreadChild.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
using mozilla::ipc::NPRemoteIdentifier;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-14 13:01:31 -07:00
|
|
|
using namespace mozilla::plugins;
|
|
|
|
|
|
|
|
namespace {
|
2009-09-21 19:02:15 -07:00
|
|
|
PluginModuleChild* gInstance = nsnull;
|
2010-02-10 12:48:20 -08:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
static QApplication *gQApp = nsnull;
|
|
|
|
#endif
|
2009-09-14 13:01:31 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-21 19:02:15 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::PluginModuleChild() :
|
2009-07-02 09:54:22 -07:00
|
|
|
mLibrary(0),
|
|
|
|
mInitializeFunc(0),
|
|
|
|
mShutdownFunc(0)
|
|
|
|
#ifdef OS_WIN
|
|
|
|
, mGetEntryPointsFunc(0)
|
2010-02-16 10:44:24 -08:00
|
|
|
#elif defined(MOZ_WIDGET_GTK2)
|
|
|
|
, mNestedLoopTimerId(0)
|
2009-07-02 09:54:22 -07:00
|
|
|
#endif
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(!gInstance, "Something terribly wrong here!");
|
2009-06-30 11:51:05 -07:00
|
|
|
memset(&mFunctions, 0, sizeof(mFunctions));
|
|
|
|
memset(&mSavedData, 0, sizeof(mSavedData));
|
2009-09-14 13:01:31 -07:00
|
|
|
gInstance = this;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::~PluginModuleChild()
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(gInstance == this, "Something terribly wrong here!");
|
2009-06-30 11:51:05 -07:00
|
|
|
if (mLibrary) {
|
|
|
|
PR_UnloadLibrary(mLibrary);
|
|
|
|
}
|
2010-02-10 12:48:20 -08:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
if (gQApp)
|
|
|
|
delete gQApp;
|
|
|
|
gQApp = nsnull;
|
|
|
|
#endif
|
2009-09-14 13:01:31 -07:00
|
|
|
gInstance = nsnull;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
// static
|
|
|
|
PluginModuleChild*
|
|
|
|
PluginModuleChild::current()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(gInstance, "Null instance!");
|
|
|
|
return gInstance;
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::Init(const std::string& aPluginFilename,
|
2009-10-27 14:52:37 -07:00
|
|
|
base::ProcessHandle aParentProcessHandle,
|
2009-09-08 23:31:35 -07:00
|
|
|
MessageLoop* aIOLoop,
|
|
|
|
IPC::Channel* aChannel)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
NS_ASSERTION(aChannel, "need a channel");
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
if (!mObjectMap.Init()) {
|
|
|
|
NS_WARNING("Failed to initialize object hashtable!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
if (!InitGraphics())
|
|
|
|
return false;
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
nsCString filename;
|
|
|
|
filename = aPluginFilename.c_str();
|
|
|
|
nsCOMPtr<nsILocalFile> pluginFile;
|
|
|
|
NS_NewNativeLocalFile(filename,
|
|
|
|
PR_TRUE,
|
|
|
|
getter_AddRefs(pluginFile));
|
|
|
|
|
|
|
|
PRBool exists;
|
|
|
|
pluginFile->Exists(&exists);
|
|
|
|
NS_ASSERTION(exists, "plugin file ain't there");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> pluginIfile;
|
|
|
|
pluginIfile = do_QueryInterface(pluginFile);
|
|
|
|
|
|
|
|
nsPluginFile lib(pluginIfile);
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
nsresult rv = lib.LoadPlugin(mLibrary);
|
2009-06-30 11:51:05 -07:00
|
|
|
NS_ASSERTION(NS_OK == rv, "trouble with mPluginFile");
|
|
|
|
NS_ASSERTION(mLibrary, "couldn't open shared object");
|
|
|
|
|
2009-10-27 14:52:37 -07:00
|
|
|
if (!Open(aChannel, aParentProcessHandle, aIOLoop))
|
2009-06-30 11:51:05 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
memset((void*) &mFunctions, 0, sizeof(mFunctions));
|
|
|
|
mFunctions.size = sizeof(mFunctions);
|
|
|
|
|
2009-11-03 13:37:07 -08:00
|
|
|
// TODO: use PluginPRLibrary here
|
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
|
|
|
mShutdownFunc =
|
|
|
|
(NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
|
|
|
|
|
|
|
|
// create the new plugin handler
|
|
|
|
|
|
|
|
mInitializeFunc =
|
|
|
|
(NP_PLUGINUNIXINIT) PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
|
|
|
|
NS_ASSERTION(mInitializeFunc, "couldn't find NP_Initialize()");
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#elif defined(OS_WIN)
|
|
|
|
mShutdownFunc =
|
|
|
|
(NP_PLUGINSHUTDOWN)PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
|
|
|
|
|
|
|
|
mGetEntryPointsFunc =
|
|
|
|
(NP_GETENTRYPOINTS)PR_FindSymbol(mLibrary, "NP_GetEntryPoints");
|
|
|
|
NS_ENSURE_TRUE(mGetEntryPointsFunc, false);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
mInitializeFunc =
|
|
|
|
(NP_PLUGININIT)PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
|
|
|
|
NS_ENSURE_TRUE(mInitializeFunc, false);
|
2009-11-10 18:25:10 -08:00
|
|
|
#elif defined(OS_MACOSX)
|
|
|
|
# warning IMPLEMENT ME
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#else
|
|
|
|
|
2009-11-03 13:37:07 -08:00
|
|
|
# error Please copy the initialization code from nsNPAPIPlugin.cpp
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
#endif
|
2009-07-02 09:54:22 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 22:50:44 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
2010-01-19 13:45:54 -08:00
|
|
|
typedef void (*GObjectDisposeFn)(GObject*);
|
2010-01-19 13:45:56 -08:00
|
|
|
typedef void (*GtkPlugEmbeddedFn)(GtkPlug*);
|
2010-01-19 13:45:54 -08:00
|
|
|
|
|
|
|
static GObjectDisposeFn real_gtk_plug_dispose;
|
2010-01-19 13:45:56 -08:00
|
|
|
static GtkPlugEmbeddedFn real_gtk_plug_embedded;
|
2010-01-19 13:45:54 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
undo_bogus_unref(gpointer data, GObject* object, gboolean is_last_ref) {
|
|
|
|
if (!is_last_ref) // recursion in g_object_ref
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_object_ref(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wrap_gtk_plug_dispose(GObject* object) {
|
|
|
|
// Work around Flash Player bug described in bug 538914.
|
|
|
|
//
|
|
|
|
// This function is called during gtk_widget_destroy and/or before
|
|
|
|
// the object's last reference is removed. A reference to the
|
|
|
|
// object is held during the call so the ref count should not drop
|
|
|
|
// to zero. However, Flash Player tries to destroy the GtkPlug
|
|
|
|
// using g_object_unref instead of gtk_widget_destroy. The
|
|
|
|
// reference that Flash is removing actually belongs to the
|
|
|
|
// GtkPlug. During real_gtk_plug_dispose, the GtkPlug removes its
|
|
|
|
// reference.
|
|
|
|
//
|
|
|
|
// A toggle ref is added to prevent premature deletion of the object
|
|
|
|
// caused by Flash Player's extra unref, and to detect when there are
|
|
|
|
// unexpectedly no other references.
|
|
|
|
g_object_add_toggle_ref(object, undo_bogus_unref, NULL);
|
|
|
|
(*real_gtk_plug_dispose)(object);
|
|
|
|
g_object_remove_toggle_ref(object, undo_bogus_unref, NULL);
|
|
|
|
}
|
2010-01-19 13:45:56 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
wrap_gtk_plug_embedded(GtkPlug* plug) {
|
|
|
|
GdkWindow* socket_window = plug->socket_window;
|
|
|
|
if (socket_window &&
|
|
|
|
g_object_get_data(G_OBJECT(socket_window),
|
|
|
|
"moz-existed-before-set-window")) {
|
|
|
|
// Add missing reference for
|
|
|
|
// https://bugzilla.gnome.org/show_bug.cgi?id=607061
|
|
|
|
g_object_ref(socket_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*real_gtk_plug_embedded) {
|
|
|
|
(*real_gtk_plug_embedded)(plug);
|
|
|
|
}
|
|
|
|
}
|
2010-02-16 10:44:24 -08:00
|
|
|
|
|
|
|
//
|
|
|
|
// The next four constants are knobs that can be tuned. They trade
|
|
|
|
// off potential UI lag from delayed event processing with CPU time.
|
|
|
|
//
|
|
|
|
static const gint kNestedLoopDetectorPriority = G_PRIORITY_HIGH_IDLE;
|
|
|
|
// 90ms so that we can hopefully break livelocks before the user
|
|
|
|
// notices UI lag (100ms)
|
|
|
|
static const guint kNestedLoopDetectorIntervalMs = 90;
|
|
|
|
|
|
|
|
static const gint kBrowserEventPriority = G_PRIORITY_HIGH_IDLE;
|
|
|
|
static const guint kBrowserEventIntervalMs = 10;
|
|
|
|
|
|
|
|
// static
|
|
|
|
gboolean
|
|
|
|
PluginModuleChild::DetectNestedEventLoop(gpointer data)
|
|
|
|
{
|
|
|
|
PluginModuleChild* pmc = static_cast<PluginModuleChild*>(data);
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(0 != pmc->mNestedLoopTimerId,
|
|
|
|
"callback after descheduling");
|
|
|
|
NS_ABORT_IF_FALSE(1 < g_main_depth(),
|
|
|
|
"not canceled before returning to main event loop!");
|
|
|
|
|
|
|
|
PLUGIN_LOG_DEBUG(("Detected nested glib event loop"));
|
|
|
|
|
|
|
|
// just detected a nested loop; start a timer that will
|
|
|
|
// periodically rpc-call back into the browser and process some
|
|
|
|
// events
|
|
|
|
pmc->mNestedLoopTimerId =
|
|
|
|
g_timeout_add_full(kBrowserEventPriority,
|
|
|
|
kBrowserEventIntervalMs,
|
|
|
|
PluginModuleChild::ProcessBrowserEvents,
|
|
|
|
data,
|
|
|
|
NULL);
|
|
|
|
// cancel the nested-loop detection timer
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
gboolean
|
|
|
|
PluginModuleChild::ProcessBrowserEvents(gpointer data)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(1 < g_main_depth(),
|
|
|
|
"not canceled before returning to main event loop!");
|
|
|
|
|
|
|
|
PluginModuleChild* pmc = static_cast<PluginModuleChild*>(data);
|
|
|
|
|
2010-02-16 10:44:25 -08:00
|
|
|
pmc->CallProcessSomeEvents();
|
2010-02-16 10:44:24 -08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleChild::EnteredCxxStack()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(0 == mNestedLoopTimerId,
|
|
|
|
"previous timer not descheduled");
|
|
|
|
|
|
|
|
mNestedLoopTimerId =
|
|
|
|
g_timeout_add_full(kNestedLoopDetectorPriority,
|
|
|
|
kNestedLoopDetectorIntervalMs,
|
|
|
|
PluginModuleChild::DetectNestedEventLoop,
|
|
|
|
this,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleChild::ExitedCxxStack()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(0 < mNestedLoopTimerId,
|
|
|
|
"nested loop timeout not scheduled");
|
|
|
|
|
|
|
|
g_source_remove(mNestedLoopTimerId);
|
|
|
|
mNestedLoopTimerId = 0;
|
|
|
|
}
|
|
|
|
|
2010-01-19 13:45:54 -08:00
|
|
|
#endif
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::InitGraphics()
|
2009-07-02 09:54:22 -07:00
|
|
|
{
|
2010-01-27 21:22:41 -08:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
2010-02-01 22:28:28 -08:00
|
|
|
// Work around plugins that don't interact well with GDK
|
|
|
|
// client-side windows.
|
|
|
|
PR_SetEnv("GDK_NATIVE_WINDOWS=1");
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
gtk_init(0, 0);
|
2010-01-19 13:45:54 -08:00
|
|
|
|
|
|
|
// GtkPlug is a static class so will leak anyway but this ref makes sure.
|
|
|
|
gpointer gtk_plug_class = g_type_class_ref(GTK_TYPE_PLUG);
|
2010-01-19 13:45:56 -08:00
|
|
|
|
2010-01-19 13:45:54 -08:00
|
|
|
// The dispose method is a good place to hook into the destruction process
|
|
|
|
// because the reference count should be 1 the last time dispose is
|
|
|
|
// called. (Toggle references wouldn't detect if the reference count
|
|
|
|
// might be higher.)
|
|
|
|
GObjectDisposeFn* dispose = &G_OBJECT_CLASS(gtk_plug_class)->dispose;
|
|
|
|
NS_ABORT_IF_FALSE(*dispose != wrap_gtk_plug_dispose,
|
|
|
|
"InitGraphics called twice");
|
|
|
|
real_gtk_plug_dispose = *dispose;
|
|
|
|
*dispose = wrap_gtk_plug_dispose;
|
2010-01-19 13:45:56 -08:00
|
|
|
|
|
|
|
GtkPlugEmbeddedFn* embedded = >K_PLUG_CLASS(gtk_plug_class)->embedded;
|
|
|
|
real_gtk_plug_embedded = *embedded;
|
|
|
|
*embedded = wrap_gtk_plug_embedded;
|
2010-01-28 22:50:44 -08:00
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
2010-02-10 12:48:20 -08:00
|
|
|
if (!qApp)
|
|
|
|
gQApp = new QApplication(0, NULL);
|
2009-07-02 09:54:22 -07:00
|
|
|
#else
|
|
|
|
// may not be necessary on all platforms
|
|
|
|
#endif
|
2010-02-24 14:25:16 -08:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
// Do this after initializing GDK, or GDK will install its own handler.
|
|
|
|
XRE_InstallX11ErrorHandler();
|
|
|
|
#endif
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
return true;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-11-03 13:37:07 -08:00
|
|
|
bool
|
|
|
|
PluginModuleChild::AnswerNP_Shutdown(NPError *rv)
|
|
|
|
{
|
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
// the PluginModuleParent shuts down this process after this RPC
|
|
|
|
// call pops off its stack
|
2009-11-03 13:37:07 -08:00
|
|
|
|
2009-11-09 17:30:02 -08:00
|
|
|
*rv = mShutdownFunc ? mShutdownFunc() : NPERR_NO_ERROR;
|
2009-12-03 00:16:28 -08:00
|
|
|
|
|
|
|
// weakly guard against re-entry after NP_Shutdown
|
|
|
|
memset(&mFunctions, 0, sizeof(mFunctions));
|
|
|
|
|
2009-11-03 13:37:07 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
void
|
|
|
|
PluginModuleChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
// doesn't matter why we're being destroyed; it's up to us to
|
|
|
|
// initiate (clean) shutdown
|
|
|
|
XRE_ShutdownChildProcess();
|
|
|
|
}
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
void
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::CleanUp()
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-11-19 14:57:56 -08:00
|
|
|
const char*
|
|
|
|
PluginModuleChild::GetUserAgent()
|
|
|
|
{
|
|
|
|
if (!CallNPN_UserAgent(&mUserAgent))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return NullableStringGet(mUserAgent);
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:15:12 -07:00
|
|
|
bool
|
2010-01-22 07:06:13 -08:00
|
|
|
PluginModuleChild::RegisterActorForNPObject(NPObject* aObject,
|
|
|
|
PluginScriptableObjectChild* aActor)
|
2009-09-17 15:15:12 -07:00
|
|
|
{
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
|
|
|
|
NS_ASSERTION(aObject && aActor, "Null pointer!");
|
2010-01-22 07:06:13 -08:00
|
|
|
|
|
|
|
NPObjectData* d = mObjectMap.GetEntry(aObject);
|
|
|
|
if (!d) {
|
|
|
|
NS_ERROR("NPObject not in object table");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->actor = aActor;
|
|
|
|
return true;
|
2009-09-17 15:15:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-22 07:06:13 -08:00
|
|
|
PluginModuleChild::UnregisterActorForNPObject(NPObject* aObject)
|
2009-09-17 15:15:12 -07:00
|
|
|
{
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
|
|
|
|
NS_ASSERTION(aObject, "Null pointer!");
|
2010-01-22 07:06:13 -08:00
|
|
|
|
|
|
|
mObjectMap.GetEntry(aObject)->actor = NULL;
|
2009-09-17 15:15:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
PluginScriptableObjectChild*
|
|
|
|
PluginModuleChild::GetActorForNPObject(NPObject* aObject)
|
|
|
|
{
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-17 15:15:12 -07:00
|
|
|
NS_ASSERTION(mObjectMap.IsInitialized(), "Not initialized!");
|
|
|
|
NS_ASSERTION(aObject, "Null pointer!");
|
2009-11-12 14:16:54 -08:00
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
NPObjectData* d = mObjectMap.GetEntry(aObject);
|
|
|
|
if (!d) {
|
|
|
|
NS_ERROR("Plugin using object not created with NPN_CreateObject?");
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-11-12 14:16:54 -08:00
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
return d->actor;
|
2009-11-12 14:16:54 -08:00
|
|
|
}
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
#ifdef DEBUG
|
2010-01-15 12:35:57 -08:00
|
|
|
bool
|
|
|
|
PluginModuleChild::NPObjectIsRegistered(NPObject* aObject)
|
|
|
|
{
|
2010-01-22 07:06:13 -08:00
|
|
|
return !!mObjectMap.GetEntry(aObject);
|
2009-11-11 17:12:01 -08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// FIXME/cjones: just getting this out of the way for the moment ...
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
namespace child {
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_requestread(NPStream *pstream, NPByteRange *rangeList);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_geturlnotify(NPP aNPP, const char* relativeURL, const char* target,
|
|
|
|
void* notifyData);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_getvalue(NPP aNPP, NPNVariable variable, void *r_value);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_setvalue(NPP aNPP, NPPVariable variable, void *r_value);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_geturl(NPP aNPP, const char* relativeURL, const char* target);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_posturlnotify(NPP aNPP, const char* relativeURL, const char *target,
|
|
|
|
uint32_t len, const char *buf, NPBool file, void* notifyData);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_posturl(NPP aNPP, const char* relativeURL, const char *target, uint32_t len,
|
|
|
|
const char *buf, NPBool file);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_newstream(NPP aNPP, NPMIMEType type, const char* window, NPStream** pstream);
|
|
|
|
|
|
|
|
static int32_t NP_CALLBACK
|
|
|
|
_write(NPP aNPP, NPStream *pstream, int32_t len, void *buffer);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_destroystream(NPP aNPP, NPStream *pstream, NPError reason);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_status(NPP aNPP, const char *message);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_memfree (void *ptr);
|
|
|
|
|
|
|
|
static uint32_t NP_CALLBACK
|
|
|
|
_memflush(uint32_t size);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_reloadplugins(NPBool reloadPages);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_invalidaterect(NPP aNPP, NPRect *invalidRect);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_invalidateregion(NPP aNPP, NPRegion invalidRegion);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_forceredraw(NPP aNPP);
|
|
|
|
|
|
|
|
static const char* NP_CALLBACK
|
|
|
|
_useragent(NPP aNPP);
|
|
|
|
|
|
|
|
static void* NP_CALLBACK
|
|
|
|
_memalloc (uint32_t size);
|
|
|
|
|
|
|
|
// Deprecated entry points for the old Java plugin.
|
|
|
|
static void* NP_CALLBACK /* OJI type: JRIEnv* */
|
|
|
|
_getjavaenv(void);
|
|
|
|
|
|
|
|
// Deprecated entry points for the old Java plugin.
|
|
|
|
static void* NP_CALLBACK /* OJI type: jref */
|
|
|
|
_getjavapeer(NPP aNPP);
|
|
|
|
|
|
|
|
static NPIdentifier NP_CALLBACK
|
|
|
|
_getstringidentifier(const NPUTF8* name);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
|
|
|
NPIdentifier *identifiers);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_identifierisstring(NPIdentifier identifiers);
|
|
|
|
|
|
|
|
static NPIdentifier NP_CALLBACK
|
|
|
|
_getintidentifier(int32_t intid);
|
|
|
|
|
|
|
|
static NPUTF8* NP_CALLBACK
|
|
|
|
_utf8fromidentifier(NPIdentifier identifier);
|
|
|
|
|
|
|
|
static int32_t NP_CALLBACK
|
|
|
|
_intfromidentifier(NPIdentifier identifier);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_invoke(NPP aNPP, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_invokedefault(NPP aNPP, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_evaluate(NPP aNPP, NPObject* npobj, NPString *script, NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_getproperty(NPP aNPP, NPObject* npobj, NPIdentifier property,
|
|
|
|
NPVariant *result);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_setproperty(NPP aNPP, NPObject* npobj, NPIdentifier property,
|
|
|
|
const NPVariant *value);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_removeproperty(NPP aNPP, NPObject* npobj, NPIdentifier property);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_hasproperty(NPP aNPP, NPObject* npobj, NPIdentifier propertyName);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_hasmethod(NPP aNPP, NPObject* npobj, NPIdentifier methodName);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_enumerate(NPP aNPP, NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_construct(NPP aNPP, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_releasevariantvalue(NPVariant *variant);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_setexception(NPObject* npobj, const NPUTF8 *message);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_pushpopupsenabledstate(NPP aNPP, NPBool enabled);
|
|
|
|
|
|
|
|
static bool NP_CALLBACK
|
|
|
|
_poppopupsenabledstate(NPP aNPP);
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_pluginthreadasynccall(NPP instance, PluginThreadCallback func,
|
|
|
|
void *userData);
|
|
|
|
|
2009-09-29 11:50:11 -07:00
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_getvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
|
|
|
char **value, uint32_t *len);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
|
|
|
const char *value, uint32_t len);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_getauthenticationinfo(NPP npp, const char *protocol,
|
|
|
|
const char *host, int32_t port,
|
|
|
|
const char *scheme, const char *realm,
|
|
|
|
char **username, uint32_t *ulen,
|
|
|
|
char **password, uint32_t *plen);
|
|
|
|
|
|
|
|
static uint32_t NP_CALLBACK
|
|
|
|
_scheduletimer(NPP instance, uint32_t interval, NPBool repeat,
|
|
|
|
void (*timerFunc)(NPP npp, uint32_t timerID));
|
|
|
|
|
|
|
|
static void NP_CALLBACK
|
|
|
|
_unscheduletimer(NPP instance, uint32_t timerID);
|
|
|
|
|
|
|
|
static NPError NP_CALLBACK
|
|
|
|
_popupcontextmenu(NPP instance, NPMenu* menu);
|
|
|
|
|
|
|
|
static NPBool NP_CALLBACK
|
|
|
|
_convertpoint(NPP instance,
|
|
|
|
double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
|
|
|
|
double *destX, double *destY, NPCoordinateSpace destSpace);
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
} /* namespace child */
|
|
|
|
} /* namespace plugins */
|
|
|
|
} /* namespace mozilla */
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
const NPNetscapeFuncs PluginModuleChild::sBrowserFuncs = {
|
2009-06-30 11:51:05 -07:00
|
|
|
sizeof(sBrowserFuncs),
|
|
|
|
(NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR,
|
2009-12-01 13:27:13 -08:00
|
|
|
mozilla::plugins::child::_geturl,
|
|
|
|
mozilla::plugins::child::_posturl,
|
|
|
|
mozilla::plugins::child::_requestread,
|
|
|
|
mozilla::plugins::child::_newstream,
|
|
|
|
mozilla::plugins::child::_write,
|
|
|
|
mozilla::plugins::child::_destroystream,
|
|
|
|
mozilla::plugins::child::_status,
|
|
|
|
mozilla::plugins::child::_useragent,
|
|
|
|
mozilla::plugins::child::_memalloc,
|
|
|
|
mozilla::plugins::child::_memfree,
|
|
|
|
mozilla::plugins::child::_memflush,
|
|
|
|
mozilla::plugins::child::_reloadplugins,
|
|
|
|
mozilla::plugins::child::_getjavaenv,
|
|
|
|
mozilla::plugins::child::_getjavapeer,
|
|
|
|
mozilla::plugins::child::_geturlnotify,
|
|
|
|
mozilla::plugins::child::_posturlnotify,
|
|
|
|
mozilla::plugins::child::_getvalue,
|
|
|
|
mozilla::plugins::child::_setvalue,
|
|
|
|
mozilla::plugins::child::_invalidaterect,
|
|
|
|
mozilla::plugins::child::_invalidateregion,
|
|
|
|
mozilla::plugins::child::_forceredraw,
|
|
|
|
mozilla::plugins::child::_getstringidentifier,
|
|
|
|
mozilla::plugins::child::_getstringidentifiers,
|
|
|
|
mozilla::plugins::child::_getintidentifier,
|
|
|
|
mozilla::plugins::child::_identifierisstring,
|
|
|
|
mozilla::plugins::child::_utf8fromidentifier,
|
|
|
|
mozilla::plugins::child::_intfromidentifier,
|
2010-01-22 07:06:13 -08:00
|
|
|
PluginModuleChild::NPN_CreateObject,
|
|
|
|
PluginModuleChild::NPN_RetainObject,
|
|
|
|
PluginModuleChild::NPN_ReleaseObject,
|
2009-12-01 13:27:13 -08:00
|
|
|
mozilla::plugins::child::_invoke,
|
|
|
|
mozilla::plugins::child::_invokedefault,
|
|
|
|
mozilla::plugins::child::_evaluate,
|
|
|
|
mozilla::plugins::child::_getproperty,
|
|
|
|
mozilla::plugins::child::_setproperty,
|
|
|
|
mozilla::plugins::child::_removeproperty,
|
|
|
|
mozilla::plugins::child::_hasproperty,
|
|
|
|
mozilla::plugins::child::_hasmethod,
|
|
|
|
mozilla::plugins::child::_releasevariantvalue,
|
|
|
|
mozilla::plugins::child::_setexception,
|
|
|
|
mozilla::plugins::child::_pushpopupsenabledstate,
|
|
|
|
mozilla::plugins::child::_poppopupsenabledstate,
|
|
|
|
mozilla::plugins::child::_enumerate,
|
|
|
|
mozilla::plugins::child::_pluginthreadasynccall,
|
|
|
|
mozilla::plugins::child::_construct,
|
|
|
|
mozilla::plugins::child::_getvalueforurl,
|
|
|
|
mozilla::plugins::child::_setvalueforurl,
|
|
|
|
mozilla::plugins::child::_getauthenticationinfo,
|
|
|
|
mozilla::plugins::child::_scheduletimer,
|
|
|
|
mozilla::plugins::child::_unscheduletimer,
|
|
|
|
mozilla::plugins::child::_popupcontextmenu,
|
|
|
|
mozilla::plugins::child::_convertpoint
|
2009-06-30 11:51:05 -07:00
|
|
|
};
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
PluginInstanceChild*
|
2009-06-30 11:51:05 -07:00
|
|
|
InstCast(NPP aNPP)
|
|
|
|
{
|
2009-10-08 00:54:16 -07:00
|
|
|
NS_ABORT_IF_FALSE(!!(aNPP->ndata), "nil instance");
|
2009-09-15 12:48:18 -07:00
|
|
|
return static_cast<PluginInstanceChild*>(aNPP->ndata);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
namespace child {
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
NPError NP_CALLBACK
|
2009-09-22 14:06:00 -07:00
|
|
|
_requestread(NPStream* aStream,
|
2009-06-30 11:51:05 -07:00
|
|
|
NPByteRange* aRangeList)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-22 14:06:00 -07:00
|
|
|
BrowserStreamChild* bs =
|
|
|
|
static_cast<BrowserStreamChild*>(static_cast<AStream*>(aStream->ndata));
|
|
|
|
bs->EnsureCorrectStream(aStream);
|
|
|
|
return bs->NPN_RequestRead(aRangeList);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_geturlnotify(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget,
|
|
|
|
void* aNotifyData)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-15 12:48:18 -07:00
|
|
|
|
2009-09-21 19:02:15 -07:00
|
|
|
nsCString url = NullableString(aRelativeURL);
|
2009-11-25 06:26:01 -08:00
|
|
|
StreamNotifyChild* sn = new StreamNotifyChild(url);
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
NPError err;
|
|
|
|
InstCast(aNPP)->CallPStreamNotifyConstructor(
|
2009-11-25 06:26:01 -08:00
|
|
|
sn, url, NullableString(aTarget), false, nsCString(), false, &err);
|
|
|
|
|
|
|
|
if (NPERR_NO_ERROR == err) {
|
|
|
|
// If NPN_PostURLNotify fails, the parent will immediately send us
|
|
|
|
// a PStreamNotifyDestructor, which should not call NPP_URLNotify.
|
|
|
|
sn->SetValid(aNotifyData);
|
|
|
|
}
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_getvalue(NPP aNPP,
|
|
|
|
NPNVariable aVariable,
|
|
|
|
void* aValue)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
switch (aVariable) {
|
2010-02-03 14:17:41 -08:00
|
|
|
// Copied from nsNPAPIPlugin.cpp
|
|
|
|
case NPNVToolkit:
|
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
|
|
|
*static_cast<NPNToolkitType*>(aValue) = NPNVGtk2;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
#endif
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
case NPNVjavascriptEnabledBool: // Intentional fall-through
|
|
|
|
case NPNVasdEnabledBool: // Intentional fall-through
|
|
|
|
case NPNVisOfflineBool: // Intentional fall-through
|
|
|
|
case NPNVSupportsXEmbedBool: // Intentional fall-through
|
|
|
|
case NPNVSupportsWindowless: // Intentional fall-through
|
|
|
|
case NPNVprivateModeBool: {
|
|
|
|
NPError result;
|
|
|
|
bool value;
|
|
|
|
PluginModuleChild::current()->
|
|
|
|
CallNPN_GetValue_WithBoolReturn(aVariable, &result, &value);
|
|
|
|
*(NPBool*)aValue = value ? true : false;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
if (aNPP) {
|
|
|
|
return InstCast(aNPP)->NPN_GetValue(aVariable, aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_WARNING("Null NPP!");
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTREACHED("Shouldn't get here!");
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_setvalue(NPP aNPP,
|
|
|
|
NPPVariable aVariable,
|
|
|
|
void* aValue)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-24 19:03:59 -07:00
|
|
|
return InstCast(aNPP)->NPN_SetValue(aVariable, aValue);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_geturl(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
NPError err;
|
2009-09-21 19:02:15 -07:00
|
|
|
InstCast(aNPP)->CallNPN_GetURL(NullableString(aRelativeURL),
|
|
|
|
NullableString(aTarget), &err);
|
2009-09-15 12:48:18 -07:00
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_posturlnotify(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget,
|
|
|
|
uint32_t aLength,
|
|
|
|
const char* aBuffer,
|
|
|
|
NPBool aIsFile,
|
|
|
|
void* aNotifyData)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-15 12:48:18 -07:00
|
|
|
|
2009-11-25 06:26:01 -08:00
|
|
|
if (!aBuffer)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
2009-09-21 19:02:15 -07:00
|
|
|
nsCString url = NullableString(aRelativeURL);
|
2009-11-25 06:26:01 -08:00
|
|
|
StreamNotifyChild* sn = new StreamNotifyChild(url);
|
2009-10-08 23:24:46 -07:00
|
|
|
|
2009-11-25 06:26:01 -08:00
|
|
|
NPError err;
|
|
|
|
InstCast(aNPP)->CallPStreamNotifyConstructor(
|
|
|
|
sn, url, NullableString(aTarget), true,
|
|
|
|
nsCString(aBuffer, aLength), aIsFile, &err);
|
2009-10-08 23:24:46 -07:00
|
|
|
|
2009-11-25 06:26:01 -08:00
|
|
|
if (NPERR_NO_ERROR == err) {
|
|
|
|
// If NPN_PostURLNotify fails, the parent will immediately send us
|
|
|
|
// a PStreamNotifyDestructor, which should not call NPP_URLNotify.
|
|
|
|
sn->SetValid(aNotifyData);
|
|
|
|
}
|
2009-10-08 23:24:46 -07:00
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_posturl(NPP aNPP,
|
|
|
|
const char* aRelativeURL,
|
|
|
|
const char* aTarget,
|
|
|
|
uint32_t aLength,
|
|
|
|
const char* aBuffer,
|
|
|
|
NPBool aIsFile)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
NPError err;
|
2009-09-21 19:02:15 -07:00
|
|
|
// FIXME what should happen when |aBuffer| is null?
|
|
|
|
InstCast(aNPP)->CallNPN_PostURL(NullableString(aRelativeURL),
|
|
|
|
NullableString(aTarget),
|
2009-09-15 12:48:18 -07:00
|
|
|
nsDependentCString(aBuffer, aLength),
|
|
|
|
aIsFile, &err);
|
|
|
|
return err;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_newstream(NPP aNPP,
|
|
|
|
NPMIMEType aMIMEType,
|
|
|
|
const char* aWindow,
|
|
|
|
NPStream** aStream)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-21 07:51:35 -07:00
|
|
|
return InstCast(aNPP)->NPN_NewStream(aMIMEType, aWindow, aStream);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t NP_CALLBACK
|
|
|
|
_write(NPP aNPP,
|
|
|
|
NPStream* aStream,
|
|
|
|
int32_t aLength,
|
|
|
|
void* aBuffer)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-21 07:51:35 -07:00
|
|
|
PluginStreamChild* ps =
|
|
|
|
static_cast<PluginStreamChild*>(static_cast<AStream*>(aStream->ndata));
|
|
|
|
ps->EnsureCorrectInstance(InstCast(aNPP));
|
|
|
|
ps->EnsureCorrectStream(aStream);
|
|
|
|
return ps->NPN_Write(aLength, aBuffer);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_destroystream(NPP aNPP,
|
2009-09-15 12:48:18 -07:00
|
|
|
NPStream* aStream,
|
2009-06-30 11:51:05 -07:00
|
|
|
NPError aReason)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-09-15 12:48:18 -07:00
|
|
|
PluginInstanceChild* p = InstCast(aNPP);
|
2009-09-21 07:51:35 -07:00
|
|
|
AStream* s = static_cast<AStream*>(aStream->ndata);
|
|
|
|
if (s->IsBrowserStream()) {
|
|
|
|
BrowserStreamChild* bs = static_cast<BrowserStreamChild*>(s);
|
|
|
|
bs->EnsureCorrectInstance(p);
|
2010-03-06 13:02:31 -08:00
|
|
|
bs->NPN_DestroyStream(aReason);
|
2009-09-21 07:51:35 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
PluginStreamChild* ps = static_cast<PluginStreamChild*>(s);
|
|
|
|
ps->EnsureCorrectInstance(p);
|
2009-12-03 00:16:14 -08:00
|
|
|
PPluginStreamChild::Call__delete__(ps, aReason, false);
|
2009-09-21 07:51:35 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_status(NPP aNPP,
|
|
|
|
const char* aMessage)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_memfree(void* aPtr)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
NS_Free(aPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t NP_CALLBACK
|
|
|
|
_memflush(uint32_t aSize)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_reloadplugins(NPBool aReloadPages)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_invalidaterect(NPP aNPP,
|
|
|
|
NPRect* aInvalidRect)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2010-02-24 16:19:51 -08:00
|
|
|
// NULL check for nspluginwrapper (bug 548434)
|
|
|
|
if (aNPP) {
|
|
|
|
InstCast(aNPP)->InvalidateRect(aInvalidRect);
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_invalidateregion(NPP aNPP,
|
|
|
|
NPRegion aInvalidRegion)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-30 21:09:21 -07:00
|
|
|
// Not implemented in Mozilla.
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_forceredraw(NPP aNPP)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* NP_CALLBACK
|
|
|
|
_useragent(NPP aNPP)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-11-19 14:57:56 -08:00
|
|
|
return PluginModuleChild::current()->GetUserAgent();
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void* NP_CALLBACK
|
|
|
|
_memalloc(uint32_t aSize)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
return NS_Alloc(aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deprecated entry points for the old Java plugin.
|
|
|
|
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
|
|
|
_getjavaenv(void)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* NP_CALLBACK /* OJI type: jref */
|
|
|
|
_getjavapeer(NPP aNPP)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPIdentifier NP_CALLBACK
|
|
|
|
_getstringidentifier(const NPUTF8* aName)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2010-02-24 13:34:17 -08:00
|
|
|
NPRemoteIdentifier ident = 0;
|
|
|
|
if (aName)
|
|
|
|
PluginModuleChild::current()->
|
|
|
|
SendNPN_GetStringIdentifier(nsDependentCString(aName), &ident);
|
2009-09-14 13:01:31 -07:00
|
|
|
return (NPIdentifier)ident;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_getstringidentifiers(const NPUTF8** aNames,
|
|
|
|
int32_t aNameCount,
|
|
|
|
NPIdentifier* aIdentifiers)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
if (!(aNames && aNameCount > 0 && aIdentifiers)) {
|
|
|
|
NS_RUNTIMEABORT("Bad input! Headed for a crash!");
|
|
|
|
}
|
|
|
|
|
2010-02-24 13:34:17 -08:00
|
|
|
// Initialize to zero in case of errors later
|
|
|
|
for (int32_t index = 0; index < aNameCount; ++index)
|
|
|
|
aIdentifiers[index] = 0;
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2010-02-24 13:34:17 -08:00
|
|
|
nsTArray<nsCString> names;
|
|
|
|
nsTArray<NPRemoteIdentifier> ids;
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2010-02-24 13:34:17 -08:00
|
|
|
names.SetLength(aNameCount);
|
|
|
|
for (int32_t index = 0; index < aNameCount; ++index) {
|
|
|
|
if (aNames[index]) {
|
|
|
|
names[index] = nsDependentCString(aNames[index]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
names[index].SetIsVoid(true);
|
2009-09-14 13:01:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-24 13:34:17 -08:00
|
|
|
PluginModuleChild::current()->
|
|
|
|
SendNPN_GetStringIdentifiers(names, &ids);
|
|
|
|
|
|
|
|
for (int32_t index = 0; index < ids.Length(); ++index)
|
|
|
|
aIdentifiers[index] = (NPIdentifier)ids[index];
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_identifierisstring(NPIdentifier aIdentifier)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
bool isString;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_IdentifierIsString((NPRemoteIdentifier)aIdentifier,
|
|
|
|
&isString)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
isString = false;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
return isString;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPIdentifier NP_CALLBACK
|
|
|
|
_getintidentifier(int32_t aIntId)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
NPRemoteIdentifier ident;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_GetIntIdentifier(aIntId, &ident)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
ident = 0;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
|
|
|
return (NPIdentifier)ident;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPUTF8* NP_CALLBACK
|
|
|
|
_utf8fromidentifier(NPIdentifier aIdentifier)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
NPError err;
|
2009-09-14 13:01:31 -07:00
|
|
|
nsCAutoString val;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_UTF8FromIdentifier((NPRemoteIdentifier)aIdentifier,
|
|
|
|
&err, &val)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
return (NPERR_NO_ERROR == err) ? strdup(val.get()) : 0;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t NP_CALLBACK
|
|
|
|
_intfromidentifier(NPIdentifier aIdentifier)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
NPError err;
|
2009-09-14 13:01:31 -07:00
|
|
|
int32_t val;
|
2009-09-19 12:24:24 -07:00
|
|
|
if (!PluginModuleChild::current()->
|
|
|
|
SendNPN_IntFromIdentifier((NPRemoteIdentifier)aIdentifier,
|
|
|
|
&err, &val)) {
|
|
|
|
NS_WARNING("Failed to send message!");
|
|
|
|
return -1;
|
|
|
|
}
|
2009-09-14 13:01:31 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
// -1 for consistency
|
|
|
|
return (NPERR_NO_ERROR == err) ? val : -1;
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_invoke(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aMethod,
|
|
|
|
const NPVariant* aArgs,
|
|
|
|
uint32_t aArgCount,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->invoke)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->invoke(aNPObj, aMethod, aArgs, aArgCount, aResult);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_invokedefault(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
const NPVariant* aArgs,
|
|
|
|
uint32_t aArgCount,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->invokeDefault)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->invokeDefault(aNPObj, aArgs, aArgCount, aResult);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_evaluate(NPP aNPP,
|
2009-10-13 10:54:41 -07:00
|
|
|
NPObject* aObject,
|
2009-06-30 11:51:05 -07:00
|
|
|
NPString* aScript,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-10-13 10:54:41 -07:00
|
|
|
if (!(aNPP && aObject && aScript && aResult)) {
|
|
|
|
NS_ERROR("Bad arguments!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginScriptableObjectChild* actor =
|
|
|
|
InstCast(aNPP)->GetActorForNPObject(aObject);
|
|
|
|
if (!actor) {
|
|
|
|
NS_ERROR("Failed to create actor?!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return actor->Evaluate(aScript, aResult);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_getproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->getProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->getProperty(aNPObj, aPropertyName, aResult);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_setproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName,
|
|
|
|
const NPVariant* aValue)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->setProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->setProperty(aNPObj, aPropertyName, aValue);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_removeproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->removeProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->removeProperty(aNPObj, aPropertyName);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_hasproperty(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aPropertyName)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->hasProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->hasProperty(aNPObj, aPropertyName);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_hasmethod(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier aMethodName)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class || !aNPObj->_class->hasMethod)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return aNPObj->_class->hasMethod(aNPObj, aMethodName);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_enumerate(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
NPIdentifier** aIdentifiers,
|
|
|
|
uint32_t* aCount)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(aNPObj->_class) ||
|
|
|
|
!aNPObj->_class->enumerate) {
|
|
|
|
*aIdentifiers = 0;
|
|
|
|
*aCount = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aNPObj->_class->enumerate(aNPObj, aIdentifiers, aCount);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_construct(NPP aNPP,
|
|
|
|
NPObject* aNPObj,
|
|
|
|
const NPVariant* aArgs,
|
|
|
|
uint32_t aArgCount,
|
|
|
|
NPVariant* aResult)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
|
|
|
|
if (!aNPP || !aNPObj || !aNPObj->_class ||
|
|
|
|
!NP_CLASS_STRUCT_VERSION_HAS_CTOR(aNPObj->_class) ||
|
|
|
|
!aNPObj->_class->construct) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aNPObj->_class->construct(aNPObj, aArgs, aArgCount, aResult);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_releasevariantvalue(NPVariant* aVariant)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
|
|
|
|
2009-10-07 16:50:48 -07:00
|
|
|
if (NPVARIANT_IS_STRING(*aVariant)) {
|
|
|
|
NPString str = NPVARIANT_TO_STRING(*aVariant);
|
|
|
|
free(const_cast<NPUTF8*>(str.UTF8Characters));
|
|
|
|
}
|
|
|
|
else if (NPVARIANT_IS_OBJECT(*aVariant)) {
|
|
|
|
NPObject* object = NPVARIANT_TO_OBJECT(*aVariant);
|
|
|
|
if (object) {
|
2010-01-22 07:06:13 -08:00
|
|
|
PluginModuleChild::NPN_ReleaseObject(object);
|
2009-10-07 16:50:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
VOID_TO_NPVARIANT(*aVariant);
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_setexception(NPObject* aNPObj,
|
|
|
|
const NPUTF8* aMessage)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
NS_NOTYETIMPLEMENTED("Implement me!");
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_pushpopupsenabledstate(NPP aNPP,
|
|
|
|
NPBool aEnabled)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-13 10:54:41 -07:00
|
|
|
bool retval;
|
|
|
|
if (InstCast(aNPP)->CallNPN_PushPopupsEnabledState(aEnabled ? true : false,
|
|
|
|
&retval)) {
|
|
|
|
return retval;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NP_CALLBACK
|
|
|
|
_poppopupsenabledstate(NPP aNPP)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-13 10:54:41 -07:00
|
|
|
bool retval;
|
|
|
|
if (InstCast(aNPP)->CallNPN_PopPopupsEnabledState(&retval)) {
|
|
|
|
return retval;
|
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_pluginthreadasynccall(NPP aNPP,
|
|
|
|
PluginThreadCallback aFunc,
|
|
|
|
void* aUserData)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-12-16 14:27:18 -08:00
|
|
|
if (!aFunc)
|
|
|
|
return;
|
|
|
|
|
2010-02-03 14:17:09 -08:00
|
|
|
PluginThreadChild::current()->message_loop()
|
|
|
|
->PostTask(FROM_HERE, new ChildAsyncCall(InstCast(aNPP), aFunc,
|
|
|
|
aUserData));
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
2009-09-29 11:50:11 -07:00
|
|
|
NPError NP_CALLBACK
|
|
|
|
_getvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
|
|
|
char **value, uint32_t *len)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2010-01-15 08:26:46 -08:00
|
|
|
|
|
|
|
if (!url)
|
|
|
|
return NPERR_INVALID_URL;
|
|
|
|
|
|
|
|
if (!npp || !value || !len)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
|
|
|
switch (variable) {
|
|
|
|
case NPNURLVCookie:
|
|
|
|
case NPNURLVProxy:
|
|
|
|
nsCString v;
|
|
|
|
NPError result;
|
|
|
|
InstCast(npp)->
|
|
|
|
CallNPN_GetValueForURL(variable, nsCString(url), &v, &result);
|
|
|
|
if (NPERR_NO_ERROR == result) {
|
|
|
|
*value = ToNewCString(v);
|
|
|
|
*len = v.Length();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_INVALID_PARAM;
|
2009-09-29 11:50:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_setvalueforurl(NPP npp, NPNURLVariable variable, const char *url,
|
|
|
|
const char *value, uint32_t len)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2010-01-15 08:26:46 -08:00
|
|
|
|
|
|
|
if (!value)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
|
|
|
if (!url)
|
|
|
|
return NPERR_INVALID_URL;
|
|
|
|
|
|
|
|
switch (variable) {
|
|
|
|
case NPNURLVCookie:
|
|
|
|
case NPNURLVProxy:
|
|
|
|
NPError result;
|
|
|
|
InstCast(npp)->CallNPN_SetValueForURL(variable, nsCString(url),
|
|
|
|
nsDependentCString(value, len),
|
|
|
|
&result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_INVALID_PARAM;
|
2009-09-29 11:50:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_getauthenticationinfo(NPP npp, const char *protocol,
|
|
|
|
const char *host, int32_t port,
|
|
|
|
const char *scheme, const char *realm,
|
|
|
|
char **username, uint32_t *ulen,
|
|
|
|
char **password, uint32_t *plen)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2010-01-15 08:26:46 -08:00
|
|
|
|
|
|
|
if (!protocol || !host || !scheme || !realm || !username || !ulen ||
|
|
|
|
!password || !plen)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
|
|
|
nsCString u;
|
|
|
|
nsCString p;
|
|
|
|
NPError result;
|
|
|
|
InstCast(npp)->
|
|
|
|
CallNPN_GetAuthenticationInfo(nsDependentCString(protocol),
|
|
|
|
nsDependentCString(host),
|
|
|
|
port,
|
|
|
|
nsDependentCString(scheme),
|
|
|
|
nsDependentCString(realm),
|
|
|
|
&u, &p, &result);
|
|
|
|
if (NPERR_NO_ERROR == result) {
|
|
|
|
*username = ToNewCString(u);
|
|
|
|
*ulen = u.Length();
|
|
|
|
*password = ToNewCString(p);
|
|
|
|
*plen = p.Length();
|
|
|
|
}
|
|
|
|
return result;
|
2009-09-29 11:50:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t NP_CALLBACK
|
2010-01-19 19:13:24 -08:00
|
|
|
_scheduletimer(NPP npp, uint32_t interval, NPBool repeat,
|
2009-09-29 11:50:11 -07:00
|
|
|
void (*timerFunc)(NPP npp, uint32_t timerID))
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2010-01-19 19:13:24 -08:00
|
|
|
|
|
|
|
return InstCast(npp)->ScheduleTimer(interval, repeat, timerFunc);
|
2009-09-29 11:50:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
2010-01-19 19:13:24 -08:00
|
|
|
_unscheduletimer(NPP npp, uint32_t timerID)
|
2009-09-29 11:50:11 -07:00
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2010-01-19 19:13:24 -08:00
|
|
|
InstCast(npp)->UnscheduleTimer(timerID);
|
2009-09-29 11:50:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_popupcontextmenu(NPP instance, NPMenu* menu)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
NS_NOTYETIMPLEMENTED("Implement me!");
|
2009-09-29 11:50:11 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPBool NP_CALLBACK
|
|
|
|
_convertpoint(NPP instance,
|
|
|
|
double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
|
|
|
|
double *destX, double *destY, NPCoordinateSpace destSpace)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-10-07 16:50:48 -07:00
|
|
|
NS_NOTYETIMPLEMENTED("Implement me!");
|
2009-09-29 11:50:11 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
} /* namespace child */
|
|
|
|
} /* namespace plugins */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-09-29 11:50:11 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-08 23:31:35 -07:00
|
|
|
PluginModuleChild::AnswerNP_Initialize(NPError* _retval)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
#if defined(OS_LINUX)
|
2009-07-02 13:48:33 -07:00
|
|
|
*_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
#elif defined(OS_WIN)
|
|
|
|
nsresult rv = mGetEntryPointsFunc(&mFunctions);
|
2009-09-17 16:09:20 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-02 09:54:22 -07:00
|
|
|
|
|
|
|
NS_ASSERTION(HIBYTE(mFunctions.version) >= NP_VERSION_MAJOR,
|
|
|
|
"callback version is less than NP version");
|
|
|
|
|
2009-07-02 13:48:33 -07:00
|
|
|
*_retval = mInitializeFunc(&sBrowserFuncs);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-11-10 18:25:10 -08:00
|
|
|
#elif defined(OS_MACOSX)
|
|
|
|
# warning IMPLEMENT ME
|
|
|
|
return false;
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#else
|
|
|
|
# error Please implement me for your platform
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PPluginInstanceChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const nsTArray<nsCString>& aNames,
|
|
|
|
const nsTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
nsAutoPtr<PluginInstanceChild> childInstance(
|
2010-02-24 16:13:48 -08:00
|
|
|
new PluginInstanceChild(&mFunctions, aMimeType));
|
2009-07-01 14:19:32 -07:00
|
|
|
if (!childInstance->Initialize()) {
|
|
|
|
*rv = NPERR_GENERIC_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-17 15:15:12 -07:00
|
|
|
return childInstance.forget();
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-17 15:15:12 -07:00
|
|
|
PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
|
|
|
|
const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const nsTArray<nsCString>& aNames,
|
|
|
|
const nsTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-09-17 15:15:12 -07:00
|
|
|
|
|
|
|
PluginInstanceChild* childInstance =
|
|
|
|
reinterpret_cast<PluginInstanceChild*>(aActor);
|
|
|
|
NS_ASSERTION(childInstance, "Null actor!");
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
// unpack the arguments into a C format
|
2009-07-29 14:12:15 -07:00
|
|
|
int argc = aNames.Length();
|
|
|
|
NS_ASSERTION(argc == (int) aValues.Length(),
|
2009-06-30 11:51:05 -07:00
|
|
|
"argn.length != argv.length");
|
|
|
|
|
2009-07-29 14:12:15 -07:00
|
|
|
nsAutoArrayPtr<char*> argn(new char*[1 + argc]);
|
|
|
|
nsAutoArrayPtr<char*> argv(new char*[1 + argc]);
|
2009-06-30 11:51:05 -07:00
|
|
|
argn[argc] = 0;
|
|
|
|
argv[argc] = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
2009-09-21 19:02:15 -07:00
|
|
|
argn[i] = const_cast<char*>(NullableStringGet(aNames[i]));
|
|
|
|
argv[i] = const_cast<char*>(NullableStringGet(aValues[i]));
|
2009-06-30 11:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPP npp = childInstance->GetNPP();
|
|
|
|
|
|
|
|
// FIXME/cjones: use SAFE_CALL stuff
|
2009-09-21 19:02:15 -07:00
|
|
|
*rv = mFunctions.newp((char*)NullableStringGet(aMimeType),
|
2009-07-02 09:54:22 -07:00
|
|
|
npp,
|
|
|
|
aMode,
|
|
|
|
argc,
|
|
|
|
argn,
|
|
|
|
argv,
|
|
|
|
0);
|
|
|
|
if (NPERR_NO_ERROR != *rv) {
|
2009-09-17 18:49:04 -07:00
|
|
|
return false;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-09-17 18:49:04 -07:00
|
|
|
return true;
|
2009-07-02 09:54:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-12-03 00:16:14 -08:00
|
|
|
PluginModuleChild::DeallocPPluginInstance(PPluginInstanceChild* aActor)
|
2009-07-02 09:54:22 -07:00
|
|
|
{
|
2009-12-18 14:22:51 -08:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-08 12:11:13 -07:00
|
|
|
AssertPluginThread();
|
2009-07-01 14:19:32 -07:00
|
|
|
|
2009-10-07 16:50:48 -07:00
|
|
|
delete aActor;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
NPObject* NP_CALLBACK
|
|
|
|
PluginModuleChild::NPN_CreateObject(NPP aNPP, NPClass* aClass)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
|
|
|
AssertPluginThread();
|
|
|
|
|
|
|
|
PluginInstanceChild* i = InstCast(aNPP);
|
2010-02-24 13:14:13 -08:00
|
|
|
if (i->mDeletingHash) {
|
|
|
|
NS_ERROR("Plugin used NPP after NPP_Destroy");
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-22 07:06:13 -08:00
|
|
|
|
|
|
|
NPObject* newObject;
|
|
|
|
if (aClass && aClass->allocate) {
|
|
|
|
newObject = aClass->allocate(aNPP, aClass);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newObject = reinterpret_cast<NPObject*>(child::_memalloc(sizeof(NPObject)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newObject) {
|
|
|
|
newObject->_class = aClass;
|
|
|
|
newObject->referenceCount = 1;
|
|
|
|
NS_LOG_ADDREF(newObject, 1, "NPObject", sizeof(NPObject));
|
|
|
|
}
|
|
|
|
|
|
|
|
NPObjectData* d = static_cast<PluginModuleChild*>(i->Manager())
|
|
|
|
->mObjectMap.PutEntry(newObject);
|
|
|
|
NS_ASSERTION(!d->instance, "New NPObject already mapped?");
|
|
|
|
d->instance = i;
|
|
|
|
|
|
|
|
return newObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPObject* NP_CALLBACK
|
|
|
|
PluginModuleChild::NPN_RetainObject(NPObject* aNPObj)
|
|
|
|
{
|
|
|
|
AssertPluginThread();
|
|
|
|
|
|
|
|
int32_t refCnt = PR_AtomicIncrement((PRInt32*)&aNPObj->referenceCount);
|
|
|
|
NS_LOG_ADDREF(aNPObj, refCnt, "NPObject", sizeof(NPObject));
|
|
|
|
|
|
|
|
return aNPObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
PluginModuleChild::NPN_ReleaseObject(NPObject* aNPObj)
|
|
|
|
{
|
|
|
|
AssertPluginThread();
|
|
|
|
|
2010-02-24 13:14:13 -08:00
|
|
|
NPObjectData* d = current()->mObjectMap.GetEntry(aNPObj);
|
|
|
|
if (!d) {
|
|
|
|
NS_ERROR("Releasing object not in mObjectMap?");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeletingObjectEntry* doe = NULL;
|
|
|
|
if (d->instance->mDeletingHash) {
|
|
|
|
doe = d->instance->mDeletingHash->GetEntry(aNPObj);
|
|
|
|
if (!doe) {
|
|
|
|
NS_ERROR("An object for a destroyed instance isn't in the instance deletion hash");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (doe->mDeleted)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-22 07:06:13 -08:00
|
|
|
int32_t refCnt = PR_AtomicDecrement((PRInt32*)&aNPObj->referenceCount);
|
|
|
|
NS_LOG_RELEASE(aNPObj, refCnt, "NPObject");
|
|
|
|
|
|
|
|
if (refCnt == 0) {
|
|
|
|
DeallocNPObject(aNPObj);
|
2010-02-24 13:14:13 -08:00
|
|
|
if (doe)
|
|
|
|
doe->mDeleted = true;
|
2010-01-22 07:06:13 -08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleChild::DeallocNPObject(NPObject* aNPObj)
|
|
|
|
{
|
|
|
|
if (aNPObj->_class && aNPObj->_class->deallocate) {
|
|
|
|
aNPObj->_class->deallocate(aNPObj);
|
|
|
|
} else {
|
|
|
|
child::_memfree(aNPObj);
|
|
|
|
}
|
2010-02-24 13:14:13 -08:00
|
|
|
|
|
|
|
NPObjectData* d = current()->mObjectMap.GetEntry(aNPObj);
|
|
|
|
if (d->actor)
|
|
|
|
d->actor->NPObjectDestroyed();
|
|
|
|
|
|
|
|
current()->mObjectMap.RemoveEntry(aNPObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleChild::FindNPObjectsForInstance(PluginInstanceChild* instance)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(instance->mDeletingHash, "filling null mDeletingHash?");
|
|
|
|
mObjectMap.EnumerateEntries(CollectForInstance, instance);
|
2010-01-22 07:06:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
PLDHashOperator
|
2010-02-24 13:14:13 -08:00
|
|
|
PluginModuleChild::CollectForInstance(NPObjectData* d, void* userArg)
|
2010-01-22 07:06:13 -08:00
|
|
|
{
|
2010-02-24 13:14:13 -08:00
|
|
|
PluginInstanceChild* instance = static_cast<PluginInstanceChild*>(userArg);
|
|
|
|
if (d->instance == instance) {
|
2010-01-22 07:06:13 -08:00
|
|
|
NPObject* o = d->GetKey();
|
2010-02-24 13:14:13 -08:00
|
|
|
instance->mDeletingHash->PutEntry(o);
|
2010-01-22 07:06:13 -08:00
|
|
|
}
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|