2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-21 16:01:16 -07:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2011-10-10 22:50:08 -07:00
|
|
|
/* This must occur *after* layers/PLayers.h to avoid typedefs conflicts. */
|
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prtypes.h"
|
|
|
|
#include "prmem.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "prenv.h"
|
2007-07-11 16:25:45 -07:00
|
|
|
#include "prclist.h"
|
2010-03-03 21:02:55 -08:00
|
|
|
|
2011-10-04 07:06:54 -07:00
|
|
|
#include "jsfriendapi.h"
|
2010-03-03 21:02:55 -08:00
|
|
|
|
2011-05-21 06:28:54 -07:00
|
|
|
#include "nsPluginHost.h"
|
2008-09-15 05:45:01 -07:00
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
#include "nsNPAPIPluginInstance.h"
|
|
|
|
#include "nsNPAPIPluginStreamListener.h"
|
2012-06-05 06:58:39 -07:00
|
|
|
#include "nsPluginStreamListenerPeer.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIServiceManager.h"
|
2007-07-11 16:25:45 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2012-04-03 21:09:20 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsPluginsDir.h"
|
|
|
|
#include "nsPluginSafety.h"
|
|
|
|
#include "nsPluginLogging.h"
|
|
|
|
|
|
|
|
#include "nsIJSContextStack.h"
|
|
|
|
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsIDocument.h"
|
2011-09-14 09:22:27 -07:00
|
|
|
#include "nsIContent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2011-09-14 09:22:27 -07:00
|
|
|
#include "nsIUnicodeNormalizer.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDOMJSUtils.h"
|
2008-01-14 16:51:29 -08:00
|
|
|
#include "nsIPrincipal.h"
|
2010-08-15 02:10:15 -07:00
|
|
|
#include "nsWildCard.h"
|
2011-09-14 09:22:27 -07:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
|
2008-04-23 16:24:21 -07:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include <prinrval.h>
|
|
|
|
|
2011-06-25 08:25:03 -07:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2008-09-11 08:10:26 -07:00
|
|
|
#include <Carbon/Carbon.h>
|
2010-04-21 16:57:22 -07:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
#include <OpenGL/OpenGL.h>
|
2012-01-09 16:11:04 -08:00
|
|
|
#include "nsCocoaFeatures.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2008-09-11 08:10:26 -07:00
|
|
|
// needed for nppdf plugin
|
2012-06-27 17:15:32 -07:00
|
|
|
#if (MOZ_WIDGET_GTK)
|
2007-03-22 10:30:00 -07:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkx.h>
|
2012-06-27 17:15:32 -07:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "gtk2xtbin.h"
|
|
|
|
#endif
|
2012-06-27 17:15:32 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-22 06:49:26 -07:00
|
|
|
#ifdef XP_OS2
|
|
|
|
#define INCL_DOS
|
|
|
|
#define INCL_DOSERRORS
|
|
|
|
#include <os2.h>
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsJSNPRuntime.h"
|
2009-01-12 16:55:52 -08:00
|
|
|
#include "nsIHttpAuthManager.h"
|
|
|
|
#include "nsICookieService.h"
|
2012-04-23 21:49:25 -07:00
|
|
|
#include "nsILoadContext.h"
|
|
|
|
#include "nsIDocShell.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-11-19 12:58:59 -08:00
|
|
|
#include "nsNetUtil.h"
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
#include "mozilla/Mutex.h"
|
2009-10-27 12:51:12 -07:00
|
|
|
#include "mozilla/PluginLibrary.h"
|
|
|
|
using mozilla::PluginLibrary;
|
2009-07-24 15:21:07 -07:00
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
#include "mozilla/PluginPRLibrary.h"
|
|
|
|
using mozilla::PluginPRLibrary;
|
2009-07-20 12:04:52 -07:00
|
|
|
|
2009-09-08 23:31:35 -07:00
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
|
|
|
using mozilla::plugins::PluginModuleParent;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2010-06-21 13:35:49 -07:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
|
|
|
|
2011-02-19 04:16:51 -08:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <windows.h>
|
2012-07-25 07:23:26 -07:00
|
|
|
#include "nsWindowsHelpers.h"
|
2012-10-02 06:24:51 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "mozilla/a11y/Compatibility.h"
|
|
|
|
#endif
|
2011-02-19 04:16:51 -08:00
|
|
|
#endif
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-01-31 06:40:58 -08:00
|
|
|
#include <android/log.h>
|
|
|
|
#include "android_npapi.h"
|
2011-09-16 14:34:31 -07:00
|
|
|
#include "ANPBase.h"
|
|
|
|
#include "AndroidBridge.h"
|
2012-08-07 00:06:29 -07:00
|
|
|
#undef LOG
|
2011-09-16 14:34:31 -07:00
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
|
|
|
#endif
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
using namespace mozilla;
|
2010-03-25 16:45:33 -07:00
|
|
|
using namespace mozilla::plugins::parent;
|
|
|
|
|
|
|
|
// We should make this const...
|
|
|
|
static NPNetscapeFuncs sBrowserFuncs = {
|
|
|
|
sizeof(sBrowserFuncs),
|
|
|
|
(NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR,
|
|
|
|
_geturl,
|
|
|
|
_posturl,
|
|
|
|
_requestread,
|
|
|
|
_newstream,
|
|
|
|
_write,
|
|
|
|
_destroystream,
|
|
|
|
_status,
|
|
|
|
_useragent,
|
|
|
|
_memalloc,
|
|
|
|
_memfree,
|
|
|
|
_memflush,
|
|
|
|
_reloadplugins,
|
|
|
|
_getJavaEnv,
|
|
|
|
_getJavaPeer,
|
|
|
|
_geturlnotify,
|
|
|
|
_posturlnotify,
|
|
|
|
_getvalue,
|
|
|
|
_setvalue,
|
|
|
|
_invalidaterect,
|
|
|
|
_invalidateregion,
|
|
|
|
_forceredraw,
|
|
|
|
_getstringidentifier,
|
|
|
|
_getstringidentifiers,
|
|
|
|
_getintidentifier,
|
|
|
|
_identifierisstring,
|
|
|
|
_utf8fromidentifier,
|
|
|
|
_intfromidentifier,
|
|
|
|
_createobject,
|
|
|
|
_retainobject,
|
|
|
|
_releaseobject,
|
|
|
|
_invoke,
|
|
|
|
_invokeDefault,
|
|
|
|
_evaluate,
|
|
|
|
_getproperty,
|
|
|
|
_setproperty,
|
|
|
|
_removeproperty,
|
|
|
|
_hasproperty,
|
|
|
|
_hasmethod,
|
|
|
|
_releasevariantvalue,
|
|
|
|
_setexception,
|
|
|
|
_pushpopupsenabledstate,
|
|
|
|
_poppopupsenabledstate,
|
|
|
|
_enumerate,
|
|
|
|
_pluginthreadasynccall,
|
|
|
|
_construct,
|
|
|
|
_getvalueforurl,
|
|
|
|
_setvalueforurl,
|
|
|
|
_getauthenticationinfo,
|
|
|
|
_scheduletimer,
|
|
|
|
_unscheduletimer,
|
|
|
|
_popupcontextmenu,
|
2010-11-09 07:26:44 -08:00
|
|
|
_convertpoint,
|
|
|
|
NULL, // handleevent, unimplemented
|
|
|
|
NULL, // unfocusinstance, unimplemented
|
2012-02-15 19:08:41 -08:00
|
|
|
_urlredirectresponse,
|
|
|
|
_initasyncsurface,
|
|
|
|
_finalizeasyncsurface,
|
|
|
|
_setcurrentasyncsurface
|
2010-03-25 16:45:33 -07:00
|
|
|
};
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
static Mutex *sPluginThreadAsyncCallLock = nullptr;
|
2007-07-11 16:25:45 -07:00
|
|
|
static PRCList sPendingAsyncCalls = PR_INIT_STATIC_CLIST(&sPendingAsyncCalls);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// POST/GET stream type
|
|
|
|
enum eNPPStreamTypeInternal {
|
|
|
|
eNPPStreamTypeInternal_Get,
|
|
|
|
eNPPStreamTypeInternal_Post
|
|
|
|
};
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kMemoryCID, NS_MEMORY_CID);
|
|
|
|
|
2008-04-23 16:32:50 -07:00
|
|
|
// This function sends a notification using the observer service to any object
|
|
|
|
// registered to listen to the "experimental-notify-plugin-call" subject.
|
|
|
|
// Each "experimental-notify-plugin-call" notification carries with it the run
|
|
|
|
// time value in milliseconds that the call took to execute.
|
2008-04-23 16:24:21 -07:00
|
|
|
void NS_NotifyPluginCall(PRIntervalTime startTime)
|
|
|
|
{
|
|
|
|
PRIntervalTime endTime = PR_IntervalNow() - startTime;
|
2008-04-23 16:32:50 -07:00
|
|
|
nsCOMPtr<nsIObserverService> notifyUIService =
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 09:59:13 -07:00
|
|
|
mozilla::services::GetObserverService();
|
2009-05-22 15:24:50 -07:00
|
|
|
if (!notifyUIService)
|
|
|
|
return;
|
|
|
|
|
2008-04-23 16:24:21 -07:00
|
|
|
float runTimeInSeconds = float(endTime) / PR_TicksPerSecond();
|
|
|
|
nsAutoString runTimeString;
|
|
|
|
runTimeString.AppendFloat(runTimeInSeconds);
|
|
|
|
const PRUnichar* runTime = runTimeString.get();
|
2012-07-30 07:20:58 -07:00
|
|
|
notifyUIService->NotifyObservers(nullptr, "experimental-notify-plugin-call",
|
2008-04-23 16:32:50 -07:00
|
|
|
runTime);
|
2008-04-23 16:24:21 -07:00
|
|
|
}
|
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
static void CheckClassInitialized()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool initialized = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (initialized)
|
|
|
|
return;
|
|
|
|
|
2008-10-07 18:50:25 -07:00
|
|
|
if (!sPluginThreadAsyncCallLock)
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
sPluginThreadAsyncCallLock = new Mutex("nsNPAPIPlugin.sPluginThreadAsyncCallLock");
|
2007-07-11 16:25:45 -07:00
|
|
|
|
2011-09-29 23:02:59 -07:00
|
|
|
initialized = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,("NPN callbacks initialized\n"));
|
|
|
|
}
|
|
|
|
|
2011-05-11 13:23:25 -07:00
|
|
|
NS_IMPL_ISUPPORTS0(nsNPAPIPlugin)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
nsNPAPIPlugin::nsNPAPIPlugin()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-04-07 15:14:54 -07:00
|
|
|
memset((void*)&mPluginFuncs, 0, sizeof(mPluginFuncs));
|
2010-01-31 13:41:26 -08:00
|
|
|
mPluginFuncs.size = sizeof(mPluginFuncs);
|
2010-12-02 21:20:59 -08:00
|
|
|
mPluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
mLibrary = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-07-12 19:44:48 -07:00
|
|
|
nsNPAPIPlugin::~nsNPAPIPlugin()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-31 13:41:26 -08:00
|
|
|
delete mLibrary;
|
2012-07-30 07:20:58 -07:00
|
|
|
mLibrary = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-12-16 12:08:45 -08:00
|
|
|
void
|
2010-03-24 14:22:04 -07:00
|
|
|
nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
|
|
|
|
const nsAString& browserDumpID)
|
2009-12-16 12:08:45 -08:00
|
|
|
{
|
|
|
|
nsRefPtr<nsPluginHost> host = dont_AddRef(nsPluginHost::GetInst());
|
2010-03-24 14:22:04 -07:00
|
|
|
host->PluginCrashed(this, pluginDumpID, browserDumpID);
|
2009-12-16 12:08:45 -08:00
|
|
|
}
|
2009-07-24 15:21:07 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2010-09-15 21:57:13 -07:00
|
|
|
nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
|
2009-07-24 15:21:07 -07:00
|
|
|
{
|
|
|
|
if (PR_GetEnv("MOZ_DISABLE_OOP_PLUGINS")) {
|
2011-09-29 23:02:59 -07:00
|
|
|
return false;
|
2009-07-24 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
2010-10-15 09:04:39 -07:00
|
|
|
if (!aPluginTag) {
|
2011-09-29 23:02:59 -07:00
|
|
|
return false;
|
2010-10-15 09:04:39 -07:00
|
|
|
}
|
|
|
|
|
2012-10-02 06:24:51 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Certain assistive technologies don't want oop Flash, thus we have a special
|
|
|
|
// pref for them to disable oop Flash (refer to bug 785047 for details).
|
|
|
|
bool useA11yPref = false;
|
|
|
|
#endif
|
|
|
|
|
2012-07-03 14:04:45 -07:00
|
|
|
#ifdef XP_WIN
|
2012-10-02 06:24:51 -07:00
|
|
|
useA11yPref = a11y::Compatibility::IsJAWS();
|
|
|
|
|
2012-07-03 14:04:45 -07:00
|
|
|
// On Windows Vista+, we force Flash to run in OOPP mode because Adobe
|
|
|
|
// doesn't test Flash in-process and there are known stability bugs.
|
|
|
|
if (aPluginTag->mIsFlashPlugin && IsVistaOrLater()) {
|
2012-10-02 06:24:51 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
if (!useA11yPref)
|
|
|
|
return true;
|
|
|
|
#else
|
2012-07-03 14:04:45 -07:00
|
|
|
return true;
|
2012-10-02 06:24:51 -07:00
|
|
|
#endif
|
2012-07-03 14:04:45 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-03 21:09:20 -07:00
|
|
|
nsIPrefBranch* prefs = Preferences::GetRootBranch();
|
2010-01-28 07:31:53 -08:00
|
|
|
if (!prefs) {
|
2011-09-29 23:02:59 -07:00
|
|
|
return false;
|
2010-01-28 07:31:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get per-library whitelist/blacklist pref string
|
|
|
|
// "dom.ipc.plugins.enabled.filename.dll" and fall back to the default value
|
|
|
|
// of "dom.ipc.plugins.enabled"
|
2010-08-15 02:10:15 -07:00
|
|
|
// The "filename.dll" part can contain shell wildcard pattern
|
2010-01-28 07:31:53 -08:00
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefFile(aPluginTag->mFullPath.get());
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t slashPos = prefFile.RFindCharInSet("/\\");
|
2010-01-28 07:31:53 -08:00
|
|
|
if (kNotFound == slashPos)
|
2011-09-29 23:02:59 -07:00
|
|
|
return false;
|
2010-08-15 02:10:15 -07:00
|
|
|
prefFile.Cut(0, slashPos + 1);
|
|
|
|
ToLowerCase(prefFile);
|
|
|
|
|
2010-09-27 13:42:43 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#if defined(__i386__)
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefGroupKey("dom.ipc.plugins.enabled.i386.");
|
2010-09-27 13:42:43 -07:00
|
|
|
#elif defined(__x86_64__)
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefGroupKey("dom.ipc.plugins.enabled.x86_64.");
|
2010-09-27 13:42:43 -07:00
|
|
|
#elif defined(__ppc__)
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefGroupKey("dom.ipc.plugins.enabled.ppc.");
|
2010-09-27 13:42:43 -07:00
|
|
|
#endif
|
|
|
|
#else
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString prefGroupKey("dom.ipc.plugins.enabled.");
|
2010-09-27 13:42:43 -07:00
|
|
|
#endif
|
2010-08-15 02:10:15 -07:00
|
|
|
|
2012-10-02 06:24:51 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
if (useA11yPref)
|
|
|
|
prefGroupKey.AssignLiteral("dom.ipc.plugins.enabled.a11y.");
|
|
|
|
#endif
|
|
|
|
|
2010-10-15 09:04:39 -07:00
|
|
|
// Java plugins include a number of different file names,
|
|
|
|
// so use the mime type (mIsJavaPlugin) and a special pref.
|
|
|
|
if (aPluginTag->mIsJavaPlugin &&
|
2012-04-03 21:09:20 -07:00
|
|
|
!Preferences::GetBool("dom.ipc.plugins.java.enabled", true)) {
|
2011-09-29 23:02:59 -07:00
|
|
|
return false;
|
2010-10-15 09:04:39 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t prefCount;
|
2010-08-15 02:10:15 -07:00
|
|
|
char** prefNames;
|
|
|
|
nsresult rv = prefs->GetChildList(prefGroupKey.get(),
|
|
|
|
&prefCount, &prefNames);
|
2010-01-28 07:31:53 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool oopPluginsEnabled = false;
|
|
|
|
bool prefSet = false;
|
2010-08-15 02:10:15 -07:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && prefCount > 0) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t prefixLength = prefGroupKey.Length();
|
|
|
|
for (uint32_t currentPref = 0; currentPref < prefCount; currentPref++) {
|
2010-08-15 02:10:15 -07:00
|
|
|
// Get the mask
|
|
|
|
const char* maskStart = prefNames[currentPref] + prefixLength;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool match = false;
|
2010-08-15 02:10:15 -07:00
|
|
|
|
|
|
|
int valid = NS_WildCardValid(maskStart);
|
|
|
|
if (valid == INVALID_SXP) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(valid == NON_SXP) {
|
|
|
|
// mask is not a shell pattern, compare it as normal string
|
|
|
|
match = (strcmp(prefFile.get(), maskStart) == 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
match = (NS_WildCardMatch(prefFile.get(), maskStart, 0) == MATCH);
|
|
|
|
}
|
|
|
|
|
2012-04-03 21:09:20 -07:00
|
|
|
if (match && NS_SUCCEEDED(Preferences::GetBool(prefNames[currentPref],
|
|
|
|
&oopPluginsEnabled))) {
|
2011-09-29 23:02:59 -07:00
|
|
|
prefSet = true;
|
2010-08-15 02:10:15 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!prefSet) {
|
2012-04-03 21:09:20 -07:00
|
|
|
oopPluginsEnabled =
|
2010-09-27 13:42:43 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#if defined(__i386__)
|
2012-04-03 21:09:20 -07:00
|
|
|
Preferences::GetBool("dom.ipc.plugins.enabled.i386", false);
|
2010-09-27 13:42:43 -07:00
|
|
|
#elif defined(__x86_64__)
|
2012-04-03 21:09:20 -07:00
|
|
|
Preferences::GetBool("dom.ipc.plugins.enabled.x86_64", false);
|
2010-09-27 13:42:43 -07:00
|
|
|
#elif defined(__ppc__)
|
2012-04-03 21:09:20 -07:00
|
|
|
Preferences::GetBool("dom.ipc.plugins.enabled.ppc", false);
|
2010-09-27 13:42:43 -07:00
|
|
|
#endif
|
|
|
|
#else
|
2012-10-02 06:24:51 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
useA11yPref ? Preferences::GetBool("dom.ipc.plugins.enabled.a11y", false) :
|
|
|
|
#endif
|
2012-04-03 21:09:20 -07:00
|
|
|
Preferences::GetBool("dom.ipc.plugins.enabled", false);
|
2010-09-27 13:42:43 -07:00
|
|
|
#endif
|
2010-08-15 02:10:15 -07:00
|
|
|
}
|
2010-01-28 07:31:53 -08:00
|
|
|
|
|
|
|
return oopPluginsEnabled;
|
2009-07-24 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
inline PluginLibrary*
|
2010-09-15 21:57:13 -07:00
|
|
|
GetNewPluginLibrary(nsPluginTag *aPluginTag)
|
2009-07-24 15:21:07 -07:00
|
|
|
{
|
2010-09-15 21:57:13 -07:00
|
|
|
if (!aPluginTag) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-09-15 21:57:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nsNPAPIPlugin::RunPluginOOP(aPluginTag)) {
|
|
|
|
return PluginModuleParent::LoadModule(aPluginTag->mFullPath.get());
|
2009-07-24 15:21:07 -07:00
|
|
|
}
|
2010-09-15 21:57:13 -07:00
|
|
|
return new PluginPRLibrary(aPluginTag->mFullPath.get(), aPluginTag->mLibrary);
|
2009-07-24 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
// Creates an nsNPAPIPlugin object. One nsNPAPIPlugin object exists per plugin (not instance).
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
2011-02-08 14:16:07 -08:00
|
|
|
nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-15 21:57:13 -07:00
|
|
|
if (!aPluginTag) {
|
2010-08-17 17:05:48 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
CheckClassInitialized();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
nsRefPtr<nsNPAPIPlugin> plugin = new nsNPAPIPlugin();
|
|
|
|
if (!plugin)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2010-09-15 21:57:13 -07:00
|
|
|
PluginLibrary* pluginLib = GetNewPluginLibrary(aPluginTag);
|
2010-04-07 15:14:54 -07:00
|
|
|
if (!pluginLib) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
|
2010-04-07 15:14:54 -07:00
|
|
|
if (!pluginLib->HasRequiredFunctions()) {
|
|
|
|
NS_WARNING("Not all necessary functions exposed by plugin, it will not load.");
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-04-07 15:14:54 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
plugin->mLibrary = pluginLib;
|
|
|
|
pluginLib->SetPlugin(plugin);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
NPError pluginCallError;
|
|
|
|
nsresult rv;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
// Exchange NPAPI entry points.
|
|
|
|
#if defined(XP_WIN) || defined(XP_OS2)
|
|
|
|
// NP_GetEntryPoints must be called before NP_Initialize on Windows.
|
|
|
|
rv = pluginLib->NP_GetEntryPoints(&plugin->mPluginFuncs, &pluginCallError);
|
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
// NP_Initialize must be called after NP_GetEntryPoints on Windows.
|
|
|
|
rv = pluginLib->NP_Initialize(&sBrowserFuncs, &pluginCallError);
|
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-04-07 15:14:54 -07:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
// NP_Initialize must be called before NP_GetEntryPoints on Mac OS X.
|
|
|
|
// We need to match WebKit's behavior.
|
|
|
|
rv = pluginLib->NP_Initialize(&sBrowserFuncs, &pluginCallError);
|
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2008-12-15 09:29:44 -08:00
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
rv = pluginLib->NP_GetEntryPoints(&plugin->mPluginFuncs, &pluginCallError);
|
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-04-07 15:14:54 -07:00
|
|
|
}
|
2011-11-10 16:17:46 -08:00
|
|
|
#elif defined(MOZ_WIDGET_GONK)
|
2010-04-07 15:14:54 -07:00
|
|
|
#else
|
|
|
|
rv = pluginLib->NP_Initialize(&sBrowserFuncs, &plugin->mPluginFuncs, &pluginCallError);
|
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-04-07 15:14:54 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2010-04-07 15:14:54 -07:00
|
|
|
*aResult = plugin.forget().get();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
PluginLibrary*
|
|
|
|
nsNPAPIPlugin::GetLibrary()
|
|
|
|
{
|
|
|
|
return mLibrary;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPPluginFuncs*
|
|
|
|
nsNPAPIPlugin::PluginFuncs()
|
|
|
|
{
|
|
|
|
return &mPluginFuncs;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
2010-01-31 13:41:26 -08:00
|
|
|
nsNPAPIPlugin::Shutdown()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_BASIC,
|
|
|
|
("NPP Shutdown to be called: this=%p\n", this));
|
|
|
|
|
2009-10-27 12:51:12 -07:00
|
|
|
NPError shutdownError;
|
2010-01-31 13:41:26 -08:00
|
|
|
mLibrary->NP_Shutdown(&shutdownError);
|
2011-04-28 13:02:35 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-19 07:46:24 -07:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPlugin::RetainStream(NPStream *pstream, nsISupports **aRetainedPeer)
|
|
|
|
{
|
|
|
|
if (!aRetainedPeer)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*aRetainedPeer = NULL;
|
|
|
|
|
|
|
|
if (!pstream || !pstream->ndata)
|
2012-07-30 02:24:36 -07:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2011-10-19 07:46:24 -07:00
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
nsNPAPIStreamWrapper* streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
nsNPAPIPluginStreamListener* listener = streamWrapper->GetStreamListener();
|
|
|
|
if (!listener) {
|
2012-07-30 02:24:36 -07:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2012-05-17 16:54:26 -07:00
|
|
|
}
|
2011-10-19 07:46:24 -07:00
|
|
|
|
2012-06-05 06:58:39 -07:00
|
|
|
nsIStreamListener* streamListener = listener->GetStreamListenerPeer();
|
|
|
|
if (!streamListener) {
|
2012-07-30 02:24:36 -07:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2012-06-05 06:58:39 -07:00
|
|
|
}
|
2011-10-19 07:46:24 -07:00
|
|
|
|
2012-06-05 06:58:39 -07:00
|
|
|
*aRetainedPeer = streamListener;
|
2011-10-19 07:46:24 -07:00
|
|
|
NS_ADDREF(*aRetainedPeer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Create a new NPP GET or POST (given in the type argument) url
|
|
|
|
// stream that may have a notify callback
|
|
|
|
NPError
|
2008-09-15 05:45:01 -07:00
|
|
|
MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target,
|
|
|
|
eNPPStreamTypeInternal type,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool bDoNotify = false,
|
2012-07-30 07:20:58 -07:00
|
|
|
void *notifyData = nullptr, uint32_t len = 0,
|
|
|
|
const char *buf = nullptr, NPBool file = false)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!npp)
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2010-03-08 13:54:04 -08:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
|
|
|
if (!inst || !inst->IsRunning())
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2011-05-21 06:28:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHostCOM = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
|
|
|
|
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
|
|
|
|
if (!pluginHost) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
nsRefPtr<nsNPAPIPluginStreamListener> listener;
|
2010-10-11 12:41:11 -07:00
|
|
|
// Set aCallNotify here to false. If pluginHost->GetURL or PostURL fail,
|
|
|
|
// the listener's destructor will do the notification while we are about to
|
|
|
|
// return a failure code.
|
2011-01-05 11:44:21 -08:00
|
|
|
// Call SetCallNotify(true) below after we are sure we cannot return a failure
|
2010-10-11 12:41:11 -07:00
|
|
|
// code.
|
2011-01-05 11:44:21 -08:00
|
|
|
if (!target) {
|
|
|
|
inst->NewStreamListener(relativeURL, notifyData,
|
|
|
|
getter_AddRefs(listener));
|
|
|
|
if (listener) {
|
2012-05-17 16:54:26 -07:00
|
|
|
listener->SetCallNotify(false);
|
2011-01-05 11:44:21 -08:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case eNPPStreamTypeInternal_Get:
|
|
|
|
{
|
2011-04-11 13:00:30 -07:00
|
|
|
if (NS_FAILED(pluginHost->GetURL(inst, relativeURL, target, listener,
|
|
|
|
NULL, NULL, false)))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eNPPStreamTypeInternal_Post:
|
|
|
|
{
|
2011-04-11 13:00:30 -07:00
|
|
|
if (NS_FAILED(pluginHost->PostURL(inst, relativeURL, len, buf, file, target, listener, NULL, NULL, false, 0, NULL)))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2009-08-14 07:09:00 -07:00
|
|
|
NS_ERROR("how'd I get here");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-10-11 12:41:11 -07:00
|
|
|
if (listener) {
|
|
|
|
// SetCallNotify(bDoNotify) here, see comment above.
|
2012-05-17 16:54:26 -07:00
|
|
|
listener->SetCallNotify(bDoNotify);
|
2010-10-11 12:41:11 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-05-08 10:45:56 -07:00
|
|
|
#if defined(MOZ_MEMORY_WINDOWS)
|
2009-12-01 13:27:13 -08:00
|
|
|
extern "C" size_t malloc_usable_size(const void *ptr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
static char *gNPPException;
|
|
|
|
|
|
|
|
class nsPluginThreadRunnable : public nsRunnable,
|
|
|
|
public PRCList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsPluginThreadRunnable(NPP instance, PluginThreadCallback func,
|
|
|
|
void *userData);
|
|
|
|
virtual ~nsPluginThreadRunnable();
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsForInstance(NPP instance)
|
2009-12-01 13:27:13 -08:00
|
|
|
{
|
|
|
|
return (mInstance == instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Invalidate()
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
mFunc = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsValid()
|
2009-12-01 13:27:13 -08:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return (mFunc != nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
NPP mInstance;
|
|
|
|
PluginThreadCallback mFunc;
|
|
|
|
void *mUserData;
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsIDocument *
|
|
|
|
GetDocumentFromNPP(NPP npp)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(npp, nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)npp->ndata;
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(inst, nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
|
|
|
inst->GetOwner(getter_AddRefs(owner));
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(owner, nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
owner->GetDocument(getter_AddRefs(doc));
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static JSContext *
|
|
|
|
GetJSContextFromDoc(nsIDocument *doc)
|
|
|
|
{
|
|
|
|
nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(sgo, nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
nsIScriptContext *scx = sgo->GetContext();
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(scx, nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
2011-09-18 02:22:17 -07:00
|
|
|
return scx->GetNativeContext();
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static JSContext *
|
|
|
|
GetJSContextFromNPP(NPP npp)
|
|
|
|
{
|
|
|
|
nsIDocument *doc = GetDocumentFromNPP(npp);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(doc, nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
return GetJSContextFromDoc(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NPIdentifier
|
|
|
|
doGetIdentifier(JSContext *cx, const NPUTF8* name)
|
|
|
|
{
|
|
|
|
NS_ConvertUTF8toUTF16 utf16name(name);
|
|
|
|
|
|
|
|
JSString *str = ::JS_InternUCStringN(cx, (jschar *)utf16name.get(),
|
|
|
|
utf16name.Length());
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return NULL;
|
|
|
|
|
2011-05-17 12:15:12 -07:00
|
|
|
return StringToNPIdentifier(cx, str);
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
2011-05-08 10:45:56 -07:00
|
|
|
#if defined(MOZ_MEMORY_WINDOWS)
|
2009-12-01 13:27:13 -08:00
|
|
|
BOOL
|
|
|
|
InHeap(HANDLE hHeap, LPVOID lpMem)
|
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
PROCESS_HEAP_ENTRY he;
|
|
|
|
he.lpData = NULL;
|
|
|
|
while (HeapWalk(hHeap, &he) != 0) {
|
|
|
|
if (he.lpData == lpMem) {
|
|
|
|
success = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapUnlock(hHeap);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} /* anonymous namespace */
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder::NPPExceptionAutoHolder()
|
|
|
|
: mOldException(gNPPException)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
gNPPException = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder::~NPPExceptionAutoHolder()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!gNPPException, "NPP exception not properly cleared!");
|
|
|
|
|
|
|
|
gNPPException = mOldException;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginThreadRunnable::nsPluginThreadRunnable(NPP instance,
|
|
|
|
PluginThreadCallback func,
|
|
|
|
void *userData)
|
|
|
|
: mInstance(instance), mFunc(func), mUserData(userData)
|
|
|
|
{
|
|
|
|
if (!sPluginThreadAsyncCallLock) {
|
|
|
|
// Failed to create lock, not much we can do here then...
|
2012-07-30 07:20:58 -07:00
|
|
|
mFunc = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PR_INIT_CLIST(this);
|
|
|
|
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
MutexAutoLock lock(*sPluginThreadAsyncCallLock);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
2009-12-17 18:09:22 -08:00
|
|
|
if (!inst || !inst->IsRunning()) {
|
2009-12-01 13:27:13 -08:00
|
|
|
// The plugin was stopped, ignore this async call.
|
2012-07-30 07:20:58 -07:00
|
|
|
mFunc = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PR_APPEND_LINK(this, &sPendingAsyncCalls);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginThreadRunnable::~nsPluginThreadRunnable()
|
|
|
|
{
|
|
|
|
if (!sPluginThreadAsyncCallLock) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
MutexAutoLock lock(*sPluginThreadAsyncCallLock);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
PR_REMOVE_LINK(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginThreadRunnable::Run()
|
|
|
|
{
|
|
|
|
if (mFunc) {
|
|
|
|
PluginDestructionGuard guard(mInstance);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_TRY_SAFE_CALL_VOID(mFunc(mUserData), nullptr);
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OnPluginDestroy(NPP instance)
|
|
|
|
{
|
|
|
|
if (!sPluginThreadAsyncCallLock) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
MutexAutoLock lock(*sPluginThreadAsyncCallLock);
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
if (PR_CLIST_IS_EMPTY(&sPendingAsyncCalls)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginThreadRunnable *r =
|
|
|
|
(nsPluginThreadRunnable *)PR_LIST_HEAD(&sPendingAsyncCalls);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (r->IsForInstance(instance)) {
|
|
|
|
r->Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
r = (nsPluginThreadRunnable *)PR_NEXT_LINK(r);
|
|
|
|
} while (r != &sPendingAsyncCalls);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OnShutdown()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(PR_CLIST_IS_EMPTY(&sPendingAsyncCalls),
|
|
|
|
"Pending async plugin call list not cleaned up!");
|
|
|
|
|
|
|
|
if (sPluginThreadAsyncCallLock) {
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
delete sPluginThreadAsyncCallLock;
|
2009-12-01 13:27:13 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
sPluginThreadAsyncCallLock = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
AsyncCallbackAutoLock::AsyncCallbackAutoLock()
|
2009-12-01 13:27:13 -08:00
|
|
|
{
|
2011-04-06 10:28:02 -07:00
|
|
|
if (sPluginThreadAsyncCallLock) {
|
|
|
|
sPluginThreadAsyncCallLock->Lock();
|
|
|
|
}
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
AsyncCallbackAutoLock::~AsyncCallbackAutoLock()
|
2009-12-01 13:27:13 -08:00
|
|
|
{
|
2011-04-06 10:28:02 -07:00
|
|
|
if (sPluginThreadAsyncCallLock) {
|
|
|
|
sPluginThreadAsyncCallLock->Unlock();
|
|
|
|
}
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NPP NPPStack::sCurrentNPP = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
|
|
|
|
const char *
|
|
|
|
PeekException()
|
|
|
|
{
|
|
|
|
return gNPPException;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PopException()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(gNPPException, "Uh, no NPP exception to pop!");
|
|
|
|
|
|
|
|
if (gNPPException) {
|
|
|
|
free(gNPPException);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
gNPPException = nullptr;
|
2009-12-01 13:27:13 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//
|
|
|
|
// Static callbacks that get routed back through the new C++ API
|
|
|
|
//
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
namespace parent {
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_geturl(NPP npp, const char* relativeURL, const char* target)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_geturl called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_GetURL: npp=%p, target=%s, url=%s\n", (void *)npp, target,
|
|
|
|
relativeURL));
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Block Adobe Acrobat from loading URLs that are not http:, https:,
|
|
|
|
// or ftp: URLs if the given target is null.
|
2008-11-03 11:23:07 -08:00
|
|
|
if (!target && relativeURL &&
|
2007-03-22 10:30:00 -07:00
|
|
|
(strncmp(relativeURL, "http:", 5) != 0) &&
|
|
|
|
(strncmp(relativeURL, "https:", 6) != 0) &&
|
|
|
|
(strncmp(relativeURL, "ftp:", 4) != 0)) {
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-01-26 17:30:58 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
const char *name = nullptr;
|
2010-01-26 17:30:58 -08:00
|
|
|
nsRefPtr<nsPluginHost> host = dont_AddRef(nsPluginHost::GetInst());
|
|
|
|
host->GetPluginName(inst, &name);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (name && strstr(name, "Adobe") && strstr(name, "Acrobat")) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
|
|
|
eNPPStreamTypeInternal_Get);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_geturlnotify(NPP npp, const char* relativeURL, const char* target,
|
|
|
|
void* notifyData)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_geturlnotify called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_GetURLNotify: npp=%p, target=%s, notify=%p, url=%s\n", (void*)npp,
|
|
|
|
target, notifyData, relativeURL));
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
2011-09-29 23:02:59 -07:00
|
|
|
eNPPStreamTypeInternal_Get, true,
|
2008-09-15 05:45:01 -07:00
|
|
|
notifyData);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_posturlnotify(NPP npp, const char *relativeURL, const char *target,
|
2008-09-11 08:10:26 -07:00
|
|
|
uint32_t len, const char *buf, NPBool file, void *notifyData)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_posturlnotify called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2009-11-25 06:26:01 -08:00
|
|
|
if (!buf)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_PostURLNotify: npp=%p, target=%s, len=%d, file=%d, "
|
|
|
|
"notify=%p, url=%s, buf=%s\n",
|
|
|
|
(void*)npp, target, len, file, notifyData, relativeURL,
|
|
|
|
buf));
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
2011-09-29 23:02:59 -07:00
|
|
|
eNPPStreamTypeInternal_Post, true,
|
2008-09-15 05:45:01 -07:00
|
|
|
notifyData, len, buf, file);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_posturl(NPP npp, const char *relativeURL, const char *target,
|
2008-09-11 08:10:26 -07:00
|
|
|
uint32_t len, const char *buf, NPBool file)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_posturl called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_PostURL: npp=%p, target=%s, file=%d, len=%d, url=%s, "
|
|
|
|
"buf=%s\n",
|
|
|
|
(void*)npp, target, file, len, relativeURL, buf));
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
2012-07-30 07:20:58 -07:00
|
|
|
eNPPStreamTypeInternal_Post, false, nullptr,
|
2009-12-01 13:27:13 -08:00
|
|
|
len, buf, file);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_newstream(NPP npp, NPMIMEType type, const char* target, NPStream* *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_newstream called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_NewStream: npp=%p, type=%s, target=%s\n", (void*)npp,
|
|
|
|
(const char *)type, target));
|
|
|
|
|
|
|
|
NPError err = NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
if (npp && npp->ndata) {
|
2011-05-17 18:48:34 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2008-02-28 18:06:00 -08:00
|
|
|
|
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIOutputStream> stream;
|
2009-06-29 11:53:52 -07:00
|
|
|
if (NS_SUCCEEDED(inst->NewStreamFromPlugin((const char*) type, target,
|
|
|
|
getter_AddRefs(stream)))) {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsNPAPIStreamWrapper* wrapper = new nsNPAPIStreamWrapper(stream, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (wrapper) {
|
2012-05-17 16:54:26 -07:00
|
|
|
(*result) = &wrapper->mNPStream;
|
2007-03-22 10:30:00 -07:00
|
|
|
err = NPERR_NO_ERROR;
|
|
|
|
} else {
|
|
|
|
err = NPERR_OUT_OF_MEMORY_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
err = NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-09-11 08:10:26 -07:00
|
|
|
int32_t NP_CALLBACK
|
|
|
|
_write(NPP npp, NPStream *pstream, int32_t len, void *buffer)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_write called from the wrong thread\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_Write: npp=%p, url=%s, len=%d, buffer=%s\n", (void*)npp,
|
|
|
|
pstream->url, len, (char*)buffer));
|
|
|
|
|
|
|
|
// negative return indicates failure to the plugin
|
|
|
|
if (!npp)
|
|
|
|
return -1;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
nsNPAPIStreamWrapper* wrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
if (!wrapper) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return -1;
|
2012-05-17 16:54:26 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
nsIOutputStream* stream = wrapper->GetOutputStream();
|
|
|
|
if (!stream) {
|
|
|
|
return -1;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t count = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv = stream->Write((char *)buffer, len, &count);
|
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return -1;
|
2012-05-17 16:54:26 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-11 08:10:26 -07:00
|
|
|
return (int32_t)count;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_destroystream(NPP npp, NPStream *pstream, NPError reason)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_write called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_DestroyStream: npp=%p, url=%s, reason=%d\n", (void*)npp,
|
|
|
|
pstream->url, (int)reason));
|
|
|
|
|
|
|
|
if (!npp)
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
nsNPAPIStreamWrapper *streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
if (!streamWrapper) {
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-18 21:33:24 -07:00
|
|
|
nsNPAPIPluginStreamListener *listener = streamWrapper->GetStreamListener();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (listener) {
|
2012-05-18 21:33:24 -07:00
|
|
|
// This type of stream is going from the browser to the plugin. It's either the
|
|
|
|
// initial src/data stream or another stream resulting from NPN_GetURL* or
|
|
|
|
// NPN_PostURL*.
|
|
|
|
//
|
|
|
|
// Calling OnStopBinding on the listener may cause it to be deleted due to the
|
|
|
|
// releasing of its last references.
|
2012-07-30 07:20:58 -07:00
|
|
|
listener->OnStopBinding(nullptr, NS_BINDING_ABORTED);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2012-05-18 21:33:24 -07:00
|
|
|
// This type of stream (NPStream) was created via NPN_NewStream. The plugin holds
|
|
|
|
// the reference until it is to be deleted here. Deleting the wrapper will
|
|
|
|
// release the wrapped nsIOutputStream.
|
|
|
|
//
|
|
|
|
// The NPStream the plugin references should always be a sub-object of it's own
|
|
|
|
// 'ndata', which is our nsNPAPIStramWrapper. See bug 548441.
|
2012-05-17 16:54:26 -07:00
|
|
|
NS_ASSERTION((char*)streamWrapper <= (char*)pstream &&
|
2010-03-09 11:38:13 -08:00
|
|
|
((char*)pstream) + sizeof(*pstream)
|
2012-05-17 16:54:26 -07:00
|
|
|
<= ((char*)streamWrapper) + sizeof(*streamWrapper),
|
2010-03-09 11:38:13 -08:00
|
|
|
"pstream is not a subobject of wrapper");
|
2012-05-17 16:54:26 -07:00
|
|
|
delete streamWrapper;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-05-18 21:33:24 -07:00
|
|
|
// 'listener' and/or 'streamWrapper' may be invalid (deleted) at this point. Don't
|
|
|
|
// touch them again!
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_status(NPP npp, const char *message)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_status called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_Status: npp=%p, message=%s\n",
|
|
|
|
(void*)npp, message));
|
|
|
|
|
|
|
|
if (!npp || !npp->ndata) {
|
|
|
|
NS_WARNING("_status: npp or npp->ndata == 0");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
inst->ShowStatus(message);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_memfree (void *ptr)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_memfree called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemFree: ptr=%p\n", ptr));
|
|
|
|
|
|
|
|
if (ptr)
|
|
|
|
nsMemory::Free(ptr);
|
|
|
|
}
|
|
|
|
|
2008-09-11 08:10:26 -07:00
|
|
|
uint32_t NP_CALLBACK
|
|
|
|
_memflush(uint32_t size)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_memflush called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemFlush: size=%d\n", size));
|
|
|
|
|
2011-09-29 23:02:59 -07:00
|
|
|
nsMemory::HeapMinimize(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_reloadplugins(NPBool reloadPages)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_reloadplugins called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_ReloadPlugins: reloadPages=%d\n", reloadPages));
|
|
|
|
|
2009-06-25 14:06:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
if (!pluginHost)
|
2008-03-30 08:23:21 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-25 14:06:54 -07:00
|
|
|
pluginHost->ReloadPlugins(reloadPages);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_invalidaterect(NPP npp, NPRect *invalidRect)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invalidaterect called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_InvalidateRect: npp=%p, top=%d, left=%d, bottom=%d, "
|
|
|
|
"right=%d\n", (void *)npp, invalidRect->top,
|
|
|
|
invalidRect->left, invalidRect->bottom, invalidRect->right));
|
|
|
|
|
|
|
|
if (!npp || !npp->ndata) {
|
|
|
|
NS_WARNING("_invalidaterect: npp or npp->ndata == 0");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2009-09-16 18:30:26 -07:00
|
|
|
inst->InvalidateRect((NPRect *)invalidRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_invalidateregion(NPP npp, NPRegion invalidRegion)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invalidateregion called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_InvalidateRegion: npp=%p, region=%p\n", (void*)npp,
|
|
|
|
(void*)invalidRegion));
|
|
|
|
|
|
|
|
if (!npp || !npp->ndata) {
|
|
|
|
NS_WARNING("_invalidateregion: npp or npp->ndata == 0");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2009-09-16 18:30:26 -07:00
|
|
|
inst->InvalidateRegion((NPRegion)invalidRegion);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_forceredraw(NPP npp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getwindowobject(NPP npp)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getwindowobject called from the wrong thread\n"));
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-03-30 08:23:21 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
JSContext *cx = GetJSContextFromNPP(npp);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(cx, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Using ::JS_GetGlobalObject(cx) is ok here since the window we
|
|
|
|
// want to return here is the outer window, *not* the inner (since
|
|
|
|
// we don't know what the plugin will do with it).
|
|
|
|
return nsJSObjWrapper::GetNewOrUsed(npp, cx, ::JS_GetGlobalObject(cx));
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getpluginelement(NPP npp)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getpluginelement called from the wrong thread\n"));
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-03-30 08:23:21 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-10 11:11:30 -07:00
|
|
|
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(npp->ndata);
|
|
|
|
if (!inst)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
2009-09-10 11:11:30 -07:00
|
|
|
inst->GetDOMElement(getter_AddRefs(element));
|
|
|
|
|
|
|
|
if (!element)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
JSContext *cx = GetJSContextFromNPP(npp);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(cx, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(xpc, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
|
|
|
xpc->WrapNative(cx, ::JS_GetGlobalObject(cx), element,
|
|
|
|
NS_GET_IID(nsIDOMElement),
|
|
|
|
getter_AddRefs(holder));
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(holder, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
JSObject* obj = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
holder->GetJSObject(&obj);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(obj, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return nsJSObjWrapper::GetNewOrUsed(npp, cx, obj);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPIdentifier NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getstringidentifier(const NPUTF8* name)
|
|
|
|
{
|
2008-03-30 07:55:42 -07:00
|
|
|
if (!name) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifier: passed null name"));
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2008-03-30 07:55:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> stack =
|
|
|
|
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
|
|
|
if (!stack)
|
|
|
|
return NULL;
|
|
|
|
|
2012-05-05 02:00:05 -07:00
|
|
|
JSContext* cx = stack->GetSafeJSContext();
|
|
|
|
if (!cx) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NULL;
|
2012-05-05 02:00:05 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
JSAutoRequest ar(cx);
|
|
|
|
return doGetIdentifier(cx, name);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
|
|
|
NPIdentifier *identifiers)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifiers called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> stack =
|
|
|
|
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
|
|
|
if (!stack)
|
|
|
|
return;
|
|
|
|
|
2012-05-05 02:00:05 -07:00
|
|
|
JSContext* cx = stack->GetSafeJSContext();
|
|
|
|
if (!cx) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return;
|
2012-05-05 02:00:05 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
JSAutoRequest ar(cx);
|
|
|
|
|
|
|
|
for (int32_t i = 0; i < nameCount; ++i) {
|
2008-03-30 07:55:42 -07:00
|
|
|
if (names[i]) {
|
|
|
|
identifiers[i] = doGetIdentifier(cx, names[i]);
|
|
|
|
} else {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifiers: passed null name"));
|
|
|
|
identifiers[i] = NULL;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPIdentifier NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getintidentifier(int32_t intid)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2010-07-14 23:19:36 -07:00
|
|
|
return IntToNPIdentifier(intid);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPUTF8* NP_CALLBACK
|
2010-07-14 23:19:36 -07:00
|
|
|
_utf8fromidentifier(NPIdentifier id)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_utf8fromidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2010-07-14 23:19:36 -07:00
|
|
|
if (!id)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NULL;
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
if (!NPIdentifierIsString(id)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
JSString *str = NPIdentifierToString(id);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return
|
2010-12-03 00:24:17 -08:00
|
|
|
ToNewUTF8String(nsDependentString(::JS_GetInternedStringChars(str),
|
2007-03-22 10:30:00 -07:00
|
|
|
::JS_GetStringLength(str)));
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
int32_t NP_CALLBACK
|
2010-07-14 23:19:36 -07:00
|
|
|
_intfromidentifier(NPIdentifier id)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_intfromidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
if (!NPIdentifierIsInt(id)) {
|
2012-09-27 23:57:33 -07:00
|
|
|
return INT32_MIN;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
return NPIdentifierToInt(id);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2010-07-14 23:19:36 -07:00
|
|
|
_identifierisstring(NPIdentifier id)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_identifierisstring called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
return NPIdentifierIsString(id);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_createobject(NPP npp, NPClass* aClass)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_createobject called from the wrong thread\n"));
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-03-30 08:23:21 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp) {
|
|
|
|
NS_ERROR("Null npp passed to _createobject()!");
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!aClass) {
|
|
|
|
NS_ERROR("Null class passed to _createobject()!");
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
|
|
|
NPObject *npobj;
|
|
|
|
|
|
|
|
if (aClass->allocate) {
|
|
|
|
npobj = aClass->allocate(npp, aClass);
|
|
|
|
} else {
|
|
|
|
npobj = (NPObject *)PR_Malloc(sizeof(NPObject));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (npobj) {
|
|
|
|
npobj->_class = aClass;
|
|
|
|
npobj->referenceCount = 1;
|
2009-11-12 14:16:54 -08:00
|
|
|
NS_LOG_ADDREF(npobj, 1, "BrowserNPObject", sizeof(NPObject));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("Created NPObject %p, NPClass %p\n", npobj, aClass));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return npobj;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPObject* NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_retainobject(NPObject* npobj)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_retainobject called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (npobj) {
|
2011-02-05 21:27:31 -08:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2010-07-11 05:50:47 -07:00
|
|
|
int32_t refCnt =
|
|
|
|
#endif
|
2012-08-22 08:56:38 -07:00
|
|
|
PR_ATOMIC_INCREMENT((int32_t*)&npobj->referenceCount);
|
2009-11-12 14:16:54 -08:00
|
|
|
NS_LOG_ADDREF(npobj, refCnt, "BrowserNPObject", sizeof(NPObject));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return npobj;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_releaseobject(NPObject* npobj)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_releaseobject called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npobj)
|
|
|
|
return;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t refCnt = PR_ATOMIC_DECREMENT((int32_t*)&npobj->referenceCount);
|
2009-11-12 14:16:54 -08:00
|
|
|
NS_LOG_RELEASE(npobj, refCnt, "BrowserNPObject");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (refCnt == 0) {
|
2007-08-09 15:22:26 -07:00
|
|
|
nsNPObjWrapper::OnDestroy(npobj);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("Deleting NPObject %p, refcount hit 0\n", npobj));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (npobj->_class && npobj->_class->deallocate) {
|
|
|
|
npobj->_class->deallocate(npobj);
|
|
|
|
} else {
|
|
|
|
PR_Free(npobj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_invoke(NPP npp, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invoke called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->invoke)
|
|
|
|
return false;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_Invoke(npp %p, npobj %p, method %p, args %d\n", npp,
|
|
|
|
npobj, method, argCount));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return npobj->_class->invoke(npobj, method, args, argCount, result);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_invokeDefault(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invokedefault called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->invokeDefault)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_InvokeDefault(npp %p, npobj %p, args %d\n", npp,
|
|
|
|
npobj, argCount));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return npobj->_class->invokeDefault(npobj, args, argCount, result);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_evaluate called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-01-14 16:51:29 -08:00
|
|
|
nsIDocument *doc = GetDocumentFromNPP(npp);
|
|
|
|
NS_ENSURE_TRUE(doc, false);
|
|
|
|
|
|
|
|
JSContext *cx = GetJSContextFromDoc(doc);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_TRUE(cx, false);
|
|
|
|
|
2009-12-22 13:54:06 -08:00
|
|
|
nsCOMPtr<nsIScriptContext> scx = GetScriptContextFromJSContext(cx);
|
|
|
|
NS_ENSURE_TRUE(scx, false);
|
|
|
|
|
2011-01-12 10:57:06 -08:00
|
|
|
JSAutoRequest req(cx);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
JSObject *obj =
|
|
|
|
nsNPObjWrapper::GetNewOrUsed(npp, cx, npobj);
|
|
|
|
|
|
|
|
if (!obj) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-04 07:06:54 -07:00
|
|
|
obj = JS_ObjectToInnerObject(cx, obj);
|
2011-11-15 23:50:19 -08:00
|
|
|
NS_ABORT_IF_FALSE(obj,
|
|
|
|
"JS_ObjectToInnerObject should never return null with non-null input.");
|
2010-08-10 16:11:32 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Root obj and the rval (below).
|
|
|
|
jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
|
2012-01-11 00:23:09 -08:00
|
|
|
JS::AutoArrayRooter tvr(cx, ArrayLength(vec), vec);
|
2007-03-22 10:30:00 -07:00
|
|
|
jsval *rval = &vec[1];
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
// Initialize the out param to void
|
|
|
|
VOID_TO_NPVARIANT(*result);
|
|
|
|
}
|
|
|
|
|
2008-12-16 20:48:42 -08:00
|
|
|
if (!script || !script->UTF8Length || !script->UTF8Characters) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Nothing to evaluate.
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-16 20:48:42 -08:00
|
|
|
NS_ConvertUTF8toUTF16 utf16script(script->UTF8Characters,
|
|
|
|
script->UTF8Length);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-14 16:51:29 -08:00
|
|
|
nsIPrincipal *principal = doc->NodePrincipal();
|
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString specStr;
|
2008-01-14 16:51:29 -08:00
|
|
|
const char *spec;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
principal->GetURI(getter_AddRefs(uri));
|
|
|
|
|
|
|
|
if (uri) {
|
|
|
|
uri->GetSpec(specStr);
|
|
|
|
spec = specStr.get();
|
|
|
|
} else {
|
|
|
|
// No URI in a principal means it's the system principal. If the
|
|
|
|
// document URI is a chrome:// URI, pass that in as the URI of the
|
|
|
|
// script, else pass in null for the filename as there's no way to
|
|
|
|
// know where this document really came from. Passing in null here
|
|
|
|
// also means that the script gets treated by XPConnect as if it
|
|
|
|
// needs additional protection, which is what we want for unknown
|
|
|
|
// chrome code anyways.
|
|
|
|
|
|
|
|
uri = doc->GetDocumentURI();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isChrome = false;
|
2008-01-14 16:51:29 -08:00
|
|
|
|
|
|
|
if (uri && NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome) {
|
|
|
|
uri->GetSpec(specStr);
|
|
|
|
spec = specStr.get();
|
|
|
|
} else {
|
2012-07-30 07:20:58 -07:00
|
|
|
spec = nullptr;
|
2008-01-14 16:51:29 -08:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_Evaluate(npp %p, npobj %p, script <<<%s>>>) called\n",
|
2008-12-16 20:48:42 -08:00
|
|
|
npp, npobj, script->UTF8Characters));
|
2008-02-28 18:06:00 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv = scx->EvaluateStringWithValue(utf16script, obj, principal,
|
2012-07-30 07:20:58 -07:00
|
|
|
spec, 0, 0, rval, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_SUCCEEDED(rv) &&
|
|
|
|
(!result || JSValToNPVariant(npp, cx, *rval, result));
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
NPVariant *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->getProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_GetProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, property));
|
|
|
|
|
2010-11-19 12:58:59 -08:00
|
|
|
if (!npobj->_class->getProperty(npobj, property, result))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// If a Java plugin tries to get the document.URL or document.documentURI
|
|
|
|
// property from us, don't pass back a value that Java won't be able to
|
|
|
|
// understand -- one that will make the URL(String) constructor throw a
|
|
|
|
// MalformedURL exception. Passing such a value causes Java Plugin2 to
|
|
|
|
// crash (to throw a RuntimeException in Plugin2Manager.getDocumentBase()).
|
|
|
|
// Also don't pass back a value that Java is likely to mishandle.
|
|
|
|
|
|
|
|
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*) npp->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return false;
|
|
|
|
nsNPAPIPlugin* plugin = inst->GetPlugin();
|
|
|
|
if (!plugin)
|
|
|
|
return false;
|
|
|
|
nsRefPtr<nsPluginHost> host = dont_AddRef(nsPluginHost::GetInst());
|
|
|
|
nsPluginTag* pluginTag = host->TagForPlugin(plugin);
|
|
|
|
if (!pluginTag->mIsJavaPlugin)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!NPVARIANT_IS_STRING(*result))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
NPUTF8* propertyName = _utf8fromidentifier(property);
|
|
|
|
if (!propertyName)
|
|
|
|
return true;
|
|
|
|
bool notURL =
|
|
|
|
(PL_strcasecmp(propertyName, "URL") &&
|
|
|
|
PL_strcasecmp(propertyName, "documentURI"));
|
|
|
|
_memfree(propertyName);
|
|
|
|
if (notURL)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
NPObject* window_obj = _getwindowobject(npp);
|
|
|
|
if (!window_obj)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
NPVariant doc_v;
|
2012-07-30 07:20:58 -07:00
|
|
|
NPObject* document_obj = nullptr;
|
2010-11-19 12:58:59 -08:00
|
|
|
NPIdentifier doc_id = _getstringidentifier("document");
|
|
|
|
bool ok = npobj->_class->getProperty(window_obj, doc_id, &doc_v);
|
|
|
|
_releaseobject(window_obj);
|
|
|
|
if (ok) {
|
|
|
|
if (NPVARIANT_IS_OBJECT(doc_v)) {
|
|
|
|
document_obj = NPVARIANT_TO_OBJECT(doc_v);
|
|
|
|
} else {
|
|
|
|
_releasevariantvalue(&doc_v);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
_releaseobject(document_obj);
|
|
|
|
if (document_obj != npobj)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
NPString urlnp = NPVARIANT_TO_STRING(*result);
|
|
|
|
nsXPIDLCString url;
|
|
|
|
url.Assign(urlnp.UTF8Characters, urlnp.UTF8Length);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool javaCompatible = false;
|
2010-11-19 12:58:59 -08:00
|
|
|
if (NS_FAILED(NS_CheckIsJavaCompatibleURLString(url, &javaCompatible)))
|
2011-09-29 23:02:59 -07:00
|
|
|
javaCompatible = false;
|
2010-11-19 12:58:59 -08:00
|
|
|
if (javaCompatible)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// If Java won't be able to interpret the original value of document.URL or
|
|
|
|
// document.documentURI, or is likely to mishandle it, pass back something
|
|
|
|
// that Java will understand but won't be able to use to access the network,
|
|
|
|
// and for which same-origin checks will always fail.
|
|
|
|
|
|
|
|
if (inst->mFakeURL.IsVoid()) {
|
|
|
|
// Abort (do an error return) if NS_MakeRandomInvalidURLString() fails.
|
|
|
|
if (NS_FAILED(NS_MakeRandomInvalidURLString(inst->mFakeURL))) {
|
|
|
|
_releasevariantvalue(result);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_releasevariantvalue(result);
|
|
|
|
char* fakeurl = (char *) _memalloc(inst->mFakeURL.Length() + 1);
|
|
|
|
strcpy(fakeurl, inst->mFakeURL);
|
|
|
|
STRINGZ_TO_NPVARIANT(fakeurl, *result);
|
|
|
|
|
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_setproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
const NPVariant *value)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->setProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_SetProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, property));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return npobj->_class->setProperty(npobj, property, value);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_removeproperty(NPP npp, NPObject* npobj, NPIdentifier property)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_removeproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->removeProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_RemoveProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, property));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return npobj->_class->removeProperty(npobj, property);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_hasproperty(NPP npp, NPObject* npobj, NPIdentifier propertyName)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_hasproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->hasProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_HasProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, propertyName));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return npobj->_class->hasProperty(npobj, propertyName);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_hasmethod(NPP npp, NPObject* npobj, NPIdentifier methodName)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_hasmethod called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->hasMethod)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_HasMethod(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, methodName));
|
|
|
|
|
2009-01-15 12:20:10 -08:00
|
|
|
return npobj->_class->hasMethod(npobj, methodName);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
bool NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_enumerate called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class)
|
|
|
|
return false;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_Enumerate(npp %p, npobj %p) called\n", npp, npobj));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(npobj->_class) ||
|
|
|
|
!npobj->_class->enumerate) {
|
|
|
|
*identifier = 0;
|
|
|
|
*count = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
|
|
|
return npobj->_class->enumerate(npobj, identifier, count);
|
|
|
|
}
|
|
|
|
|
2007-10-09 18:24:28 -07:00
|
|
|
bool NP_CALLBACK
|
|
|
|
_construct(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_construct called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-10-09 18:24:28 -07:00
|
|
|
if (!npp || !npobj || !npobj->_class ||
|
|
|
|
!NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) ||
|
|
|
|
!npobj->_class->construct) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
|
|
|
return npobj->_class->construct(npobj, args, argCount, result);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_releasevariantvalue(NPVariant* variant)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_releasevariantvalue called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (variant->type) {
|
|
|
|
case NPVariantType_Void :
|
|
|
|
case NPVariantType_Null :
|
|
|
|
case NPVariantType_Bool :
|
|
|
|
case NPVariantType_Int32 :
|
|
|
|
case NPVariantType_Double :
|
|
|
|
break;
|
|
|
|
case NPVariantType_String :
|
|
|
|
{
|
|
|
|
const NPString *s = &NPVARIANT_TO_STRING(*variant);
|
|
|
|
|
2008-12-16 20:48:42 -08:00
|
|
|
if (s->UTF8Characters) {
|
2011-05-08 10:45:56 -07:00
|
|
|
#if defined(MOZ_MEMORY_WINDOWS)
|
2008-12-16 20:48:42 -08:00
|
|
|
if (malloc_usable_size((void *)s->UTF8Characters) != 0) {
|
|
|
|
PR_Free((void *)s->UTF8Characters);
|
2008-04-30 17:17:54 -07:00
|
|
|
} else {
|
2008-12-16 20:48:42 -08:00
|
|
|
void *p = (void *)s->UTF8Characters;
|
2008-04-30 17:17:54 -07:00
|
|
|
DWORD nheaps = 0;
|
|
|
|
nsAutoTArray<HANDLE, 50> heaps;
|
|
|
|
nheaps = GetProcessHeaps(0, heaps.Elements());
|
|
|
|
heaps.AppendElements(nheaps);
|
|
|
|
GetProcessHeaps(nheaps, heaps.Elements());
|
|
|
|
for (DWORD i = 0; i < nheaps; i++) {
|
|
|
|
if (InHeap(heaps[i], p)) {
|
|
|
|
HeapFree(heaps[i], 0, p);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2010-05-11 02:45:15 -07:00
|
|
|
NS_Free((void *)s->UTF8Characters);
|
2008-04-30 17:17:54 -07:00
|
|
|
#endif
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NPVariantType_Object:
|
|
|
|
{
|
|
|
|
NPObject *npobj = NPVARIANT_TO_OBJECT(*variant);
|
|
|
|
|
|
|
|
if (npobj)
|
|
|
|
_releaseobject(npobj);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_ERROR("Unknown NPVariant type!");
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID_TO_NPVARIANT(*variant);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_setexception(NPObject* npobj, const NPUTF8 *message)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setexception called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-30 13:15:22 -07:00
|
|
|
if (!message) return;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gNPPException) {
|
|
|
|
// If a plugin throws multiple exceptions, we'll only report the
|
|
|
|
// last one for now.
|
|
|
|
free(gNPPException);
|
|
|
|
}
|
|
|
|
|
|
|
|
gNPPException = strdup(message);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_getvalue(NPP npp, NPNVariable variable, void *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getvalue called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetValue: npp=%p, var=%d\n",
|
|
|
|
(void*)npp, (int)variable));
|
|
|
|
|
|
|
|
nsresult res;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
switch(variable) {
|
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
|
|
|
case NPNVxDisplay : {
|
2011-08-24 09:15:58 -07:00
|
|
|
#if defined(MOZ_X11)
|
2007-03-22 10:30:00 -07:00
|
|
|
if (npp) {
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool windowless = false;
|
2009-09-16 18:30:26 -07:00
|
|
|
inst->IsWindowless(&windowless);
|
2012-03-01 22:17:26 -08:00
|
|
|
// The documentation on the types for many variables in NP(N|P)_GetValue
|
|
|
|
// is vague. Often boolean values are NPBool (1 byte), but
|
|
|
|
// https://developer.mozilla.org/en/XEmbed_Extension_for_Mozilla_Plugins
|
|
|
|
// treats NPPVpluginNeedsXEmbed as PRBool (int), and
|
|
|
|
// on x86/32-bit, flash stores to this using |movl 0x1,&needsXEmbed|.
|
|
|
|
// thus we can't use NPBool for needsXEmbed, or the three bytes above
|
|
|
|
// it on the stack would get clobbered. so protect with the larger bool.
|
|
|
|
int needsXEmbed = 0;
|
2008-07-16 18:19:54 -07:00
|
|
|
if (!windowless) {
|
2012-03-01 22:17:26 -08:00
|
|
|
res = inst->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needsXEmbed);
|
2011-03-23 11:46:09 -07:00
|
|
|
// If the call returned an error code make sure we still use our default value.
|
|
|
|
if (NS_FAILED(res)) {
|
2012-03-01 22:17:26 -08:00
|
|
|
needsXEmbed = 0;
|
2011-03-23 11:46:09 -07:00
|
|
|
}
|
2008-07-16 18:19:54 -07:00
|
|
|
}
|
2012-03-01 22:17:26 -08:00
|
|
|
if (windowless || needsXEmbed) {
|
2010-06-21 13:35:49 -07:00
|
|
|
(*(Display **)result) = mozilla::DefaultXDisplay();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2010-04-20 11:49:34 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
2007-03-22 10:30:00 -07:00
|
|
|
// adobe nppdf calls XtGetApplicationNameAndClass(display,
|
|
|
|
// &instance, &class) we have to init Xt toolkit before get
|
|
|
|
// XtDisplay just call gtk_xtbin_new(w,0) once
|
|
|
|
static GtkWidget *gtkXtBinHolder = 0;
|
|
|
|
if (!gtkXtBinHolder) {
|
2009-04-06 04:30:55 -07:00
|
|
|
gtkXtBinHolder = gtk_xtbin_new(gdk_get_default_root_window(),0);
|
2007-03-22 10:30:00 -07:00
|
|
|
// it crashes on destroy, let it leak
|
|
|
|
// gtk_widget_destroy(gtkXtBinHolder);
|
|
|
|
}
|
|
|
|
(*(Display **)result) = GTK_XTBIN(gtkXtBinHolder)->xtdisplay;
|
|
|
|
return NPERR_NO_ERROR;
|
2010-04-20 11:49:34 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVxtAppContext:
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
#endif
|
|
|
|
|
2010-04-20 11:49:34 -07:00
|
|
|
#if defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_WIDGET_GTK2) \
|
|
|
|
|| defined(MOZ_WIDGET_QT)
|
2007-03-22 10:30:00 -07:00
|
|
|
case NPNVnetscapeWindow: {
|
|
|
|
if (!npp || !npp->ndata)
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
|
|
|
inst->GetOwner(getter_AddRefs(owner));
|
2012-07-20 04:16:17 -07:00
|
|
|
NS_ENSURE_TRUE(owner, NPERR_NO_ERROR);
|
2009-06-29 11:53:52 -07:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(owner->GetNetscapeWindow(result))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case NPNVjavascriptEnabledBool: {
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = false;
|
2012-04-03 21:09:20 -07:00
|
|
|
bool js = false;
|
|
|
|
res = Preferences::GetBool("javascript.enabled", &js);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
*(NPBool*)result = js;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVasdEnabledBool:
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
|
|
|
case NPNVisOfflineBool: {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool offline = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIIOService> ioservice =
|
|
|
|
do_GetService(NS_IOSERVICE_CONTRACTID, &res);
|
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
res = ioservice->GetOffline(&offline);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
*(NPBool*)result = offline;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVToolkit: {
|
2012-06-27 17:15:32 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2007-03-22 10:30:00 -07:00
|
|
|
*((NPNToolkitType*)result) = NPNVGtk2;
|
|
|
|
#endif
|
|
|
|
|
2010-04-20 11:49:34 -07:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
/* Fake toolkit so flash plugin works */
|
|
|
|
*((NPNToolkitType*)result) = NPNVGtk2;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
if (*(NPNToolkitType*)result)
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVSupportsXEmbedBool: {
|
2012-06-27 17:15:32 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = true;
|
2010-05-21 10:19:57 -07:00
|
|
|
#elif defined(MOZ_WIDGET_QT)
|
|
|
|
// Desktop Flash fail to initialize if browser does not support NPNVSupportsXEmbedBool
|
|
|
|
// even when wmode!=windowed, lets return fake support
|
|
|
|
fprintf(stderr, "Fake support for XEmbed plugins in Qt port\n");
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
#else
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVWindowNPObject: {
|
|
|
|
*(NPObject **)result = _getwindowobject(npp);
|
|
|
|
|
2009-12-01 15:08:16 -08:00
|
|
|
return *(NPObject **)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVPluginElementNPObject: {
|
|
|
|
*(NPObject **)result = _getpluginelement(npp);
|
|
|
|
|
2010-02-02 06:46:25 -08:00
|
|
|
return *(NPObject **)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-09-05 18:45:08 -07:00
|
|
|
case NPNVSupportsWindowless: {
|
2010-04-20 11:49:34 -07:00
|
|
|
#if defined(XP_WIN) || defined(XP_MACOSX) || \
|
2012-06-27 17:15:32 -07:00
|
|
|
(defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)))
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = true;
|
2007-09-05 18:45:08 -07:00
|
|
|
#else
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = false;
|
2007-09-05 18:45:08 -07:00
|
|
|
#endif
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-01-30 13:40:14 -08:00
|
|
|
case NPNVprivateModeBool: {
|
2012-04-23 21:49:25 -07:00
|
|
|
nsCOMPtr<nsIDocument> doc = GetDocumentFromNPP(npp);
|
2012-04-25 08:56:40 -07:00
|
|
|
NS_ENSURE_TRUE(doc, NPERR_GENERIC_ERROR);
|
|
|
|
nsCOMPtr<nsPIDOMWindow> domwindow = doc->GetWindow();
|
2012-04-23 21:49:25 -07:00
|
|
|
if (domwindow) {
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = domwindow->GetDocShell();
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
|
|
|
*(NPBool*)result = (NPBool)(loadContext && loadContext->UsePrivateBrowsing());
|
2009-01-30 13:40:14 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-14 09:22:27 -07:00
|
|
|
case NPNVdocumentOrigin: {
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)npp->ndata;
|
|
|
|
if (!inst) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
|
|
|
inst->GetDOMElement(getter_AddRefs(element));
|
|
|
|
if (!element) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(element));
|
|
|
|
if (!content) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPrincipal* principal = content->NodePrincipal();
|
|
|
|
|
|
|
|
nsAutoString utf16Origin;
|
|
|
|
res = nsContentUtils::GetUTFOrigin(principal, utf16Origin);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIUnicodeNormalizer> normalizer = do_GetService(NS_UNICODE_NORMALIZER_CONTRACTID);
|
|
|
|
if (!normalizer) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString normalizedUTF16Origin;
|
|
|
|
res = normalizer->NormalizeUnicodeNFKC(utf16Origin, normalizedUTF16Origin);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
*(char**)result = ToNewUTF8String(normalizedUTF16Origin);
|
|
|
|
return *(char**)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-03-26 18:07:57 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case NPNVpluginDrawingModel: {
|
|
|
|
if (npp) {
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2007-03-26 18:07:57 -07:00
|
|
|
if (inst) {
|
2009-09-16 18:30:26 -07:00
|
|
|
NPDrawingModel drawingModel;
|
2012-08-22 08:56:38 -07:00
|
|
|
inst->GetDrawingModel((int32_t*)&drawingModel);
|
2009-09-16 18:30:26 -07:00
|
|
|
*(NPDrawingModel*)result = drawingModel;
|
2007-03-26 18:07:57 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef NP_NO_QUICKDRAW
|
|
|
|
case NPNVsupportsQuickDrawBool: {
|
2012-08-30 12:10:55 -07:00
|
|
|
*(NPBool*)result = false;
|
2007-03-26 18:07:57 -07:00
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case NPNVsupportsCoreGraphicsBool: {
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = true;
|
2007-03-26 18:07:57 -07:00
|
|
|
|
2009-08-26 17:29:47 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2010-03-23 17:51:11 -07:00
|
|
|
case NPNVsupportsCoreAnimationBool: {
|
2012-01-09 16:11:04 -08:00
|
|
|
*(NPBool*)result = nsCocoaFeatures::SupportCoreAnimationPlugins();
|
2010-03-23 17:51:11 -07:00
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2010-06-08 21:11:48 -07:00
|
|
|
case NPNVsupportsInvalidatingCoreAnimationBool: {
|
2012-01-09 16:11:04 -08:00
|
|
|
*(NPBool*)result = nsCocoaFeatures::SupportCoreAnimationPlugins();
|
2010-06-08 21:11:48 -07:00
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2010-03-23 17:51:11 -07:00
|
|
|
|
2009-08-26 17:29:47 -07:00
|
|
|
#ifndef NP_NO_CARBON
|
|
|
|
case NPNVsupportsCarbonBool: {
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = true;
|
2009-08-26 17:29:47 -07:00
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
case NPNVsupportsCocoaBool: {
|
2011-09-29 23:02:59 -07:00
|
|
|
*(NPBool*)result = true;
|
2009-08-26 17:29:47 -07:00
|
|
|
|
2007-03-26 18:07:57 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2011-01-20 17:08:11 -08:00
|
|
|
|
|
|
|
case NPNVsupportsUpdatedCocoaTextInputBool: {
|
|
|
|
*(NPBool*)result = true;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2007-03-26 18:07:57 -07:00
|
|
|
#endif
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-16 14:34:31 -07:00
|
|
|
case kLogInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get log interface");
|
|
|
|
ANPLogInterfaceV0 *i = (ANPLogInterfaceV0 *) result;
|
|
|
|
InitLogInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kBitmapInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get bitmap interface");
|
|
|
|
ANPBitmapInterfaceV0 *i = (ANPBitmapInterfaceV0 *) result;
|
|
|
|
InitBitmapInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kMatrixInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get matrix interface");
|
|
|
|
ANPMatrixInterfaceV0 *i = (ANPMatrixInterfaceV0 *) result;
|
|
|
|
InitMatrixInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kPathInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get path interface");
|
|
|
|
ANPPathInterfaceV0 *i = (ANPPathInterfaceV0 *) result;
|
|
|
|
InitPathInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kTypefaceInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get typeface interface");
|
|
|
|
ANPTypefaceInterfaceV0 *i = (ANPTypefaceInterfaceV0 *) result;
|
|
|
|
InitTypeFaceInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kPaintInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get paint interface");
|
|
|
|
ANPPaintInterfaceV0 *i = (ANPPaintInterfaceV0 *) result;
|
|
|
|
InitPaintInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kCanvasInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get canvas interface");
|
|
|
|
ANPCanvasInterfaceV0 *i = (ANPCanvasInterfaceV0 *) result;
|
|
|
|
InitCanvasInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kWindowInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get window interface");
|
|
|
|
ANPWindowInterfaceV0 *i = (ANPWindowInterfaceV0 *) result;
|
|
|
|
InitWindowInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kAudioTrackInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get audio interface");
|
|
|
|
ANPAudioTrackInterfaceV0 *i = (ANPAudioTrackInterfaceV0 *) result;
|
2012-01-31 06:40:58 -08:00
|
|
|
InitAudioTrackInterfaceV0(i);
|
2011-09-16 14:34:31 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kEventInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get event interface");
|
|
|
|
ANPEventInterfaceV0 *i = (ANPEventInterfaceV0 *) result;
|
|
|
|
InitEventInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kSystemInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get system interface");
|
|
|
|
ANPSystemInterfaceV0* i = reinterpret_cast<ANPSystemInterfaceV0*>(result);
|
|
|
|
InitSystemInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kSurfaceInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get surface interface");
|
|
|
|
ANPSurfaceInterfaceV0 *i = (ANPSurfaceInterfaceV0 *) result;
|
|
|
|
InitSurfaceInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kSupportedDrawingModel_ANPGetValue: {
|
|
|
|
LOG("get supported drawing model");
|
|
|
|
uint32_t* bits = reinterpret_cast<uint32_t*>(result);
|
|
|
|
*bits = kBitmap_ANPDrawingModel && kSurface_ANPDrawingModel;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kJavaContext_ANPGetValue: {
|
|
|
|
LOG("get context");
|
2012-01-29 12:39:30 -08:00
|
|
|
JNIEnv* env = GetJNIForThread();
|
|
|
|
if (!env)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
jclass cls = env->FindClass("org/mozilla/gecko/GeckoApp");
|
|
|
|
jfieldID field = env->GetStaticFieldID(cls, "mAppContext",
|
|
|
|
"Lorg/mozilla/gecko/GeckoApp;");
|
|
|
|
jobject ret = env->GetStaticObjectField(cls, field);
|
2012-09-11 02:19:00 -07:00
|
|
|
env->DeleteLocalRef(cls);
|
2011-09-16 14:34:31 -07:00
|
|
|
int32_t* i = reinterpret_cast<int32_t*>(result);
|
|
|
|
*i = reinterpret_cast<int32_t>(ret);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2012-01-31 06:40:58 -08:00
|
|
|
|
|
|
|
case kAudioTrackInterfaceV1_ANPGetValue: {
|
|
|
|
LOG("get audio interface v1");
|
|
|
|
ANPAudioTrackInterfaceV1 *i = (ANPAudioTrackInterfaceV1 *) result;
|
|
|
|
InitAudioTrackInterfaceV1(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kNativeWindowInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get native window interface v0");
|
|
|
|
ANPNativeWindowInterfaceV0* i = (ANPNativeWindowInterfaceV0 *) result;
|
|
|
|
InitNativeWindowInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kOpenGLInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get openGL interface");
|
|
|
|
ANPOpenGLInterfaceV0 *i = (ANPOpenGLInterfaceV0*) result;
|
|
|
|
InitOpenGLInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kWindowInterfaceV1_ANPGetValue: {
|
|
|
|
LOG("get Window interface V1");
|
|
|
|
ANPWindowInterfaceV1 *i = (ANPWindowInterfaceV1 *) result;
|
|
|
|
InitWindowInterfaceV1(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kWindowInterfaceV2_ANPGetValue: {
|
|
|
|
LOG("get Window interface V2");
|
|
|
|
ANPWindowInterfaceV2 *i = (ANPWindowInterfaceV2 *) result;
|
|
|
|
InitWindowInterfaceV2(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kVideoInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get video interface");
|
|
|
|
ANPVideoInterfaceV0 *i = (ANPVideoInterfaceV0*) result;
|
|
|
|
InitVideoInterfaceV0(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kVideoInterfaceV1_ANPGetValue: {
|
|
|
|
LOG("get video interface");
|
|
|
|
ANPVideoInterfaceV1 *i = (ANPVideoInterfaceV1*) result;
|
|
|
|
InitVideoInterfaceV1(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case kSystemInterfaceV1_ANPGetValue: {
|
|
|
|
LOG("get system interface v1");
|
|
|
|
ANPSystemInterfaceV1* i = reinterpret_cast<ANPSystemInterfaceV1*>(result);
|
|
|
|
InitSystemInterfaceV1(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kSystemInterfaceV2_ANPGetValue: {
|
|
|
|
LOG("get system interface v2");
|
|
|
|
ANPSystemInterfaceV2* i = reinterpret_cast<ANPSystemInterfaceV2*>(result);
|
|
|
|
InitSystemInterfaceV2(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
#endif
|
|
|
|
|
2011-05-08 10:45:56 -07:00
|
|
|
// we no longer hand out any XPCOM objects
|
2009-11-30 02:11:20 -08:00
|
|
|
case NPNVDOMElement:
|
|
|
|
// fall through
|
|
|
|
case NPNVDOMWindow:
|
|
|
|
// fall through
|
|
|
|
case NPNVserviceManager:
|
|
|
|
// old XPCOM objects, no longer supported, but null out the out
|
|
|
|
// param to avoid crashing plugins that still try to use this.
|
2012-07-30 07:20:58 -07:00
|
|
|
*(nsISupports**)result = nullptr;
|
2009-11-30 02:11:20 -08:00
|
|
|
// fall through
|
2008-08-14 05:47:04 -07:00
|
|
|
default:
|
2011-09-16 14:34:31 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_getvalue unhandled get value: %d\n", variable));
|
2008-08-14 05:47:04 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_setvalue(NPP npp, NPPVariable variable, void *result)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setvalue called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_SetValue: npp=%p, var=%d\n",
|
|
|
|
(void*)npp, (int)variable));
|
|
|
|
|
|
|
|
if (!npp)
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-11-03 11:23:07 -08:00
|
|
|
NS_ASSERTION(inst, "null instance");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-11-03 11:23:07 -08:00
|
|
|
if (!inst)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (variable) {
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
// we should keep backward compatibility with NPAPI where the
|
2007-03-22 10:30:00 -07:00
|
|
|
// actual pointer value is checked rather than its content
|
|
|
|
// when passing booleans
|
|
|
|
case NPPVpluginWindowBool: {
|
2008-12-09 09:22:51 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// This setting doesn't apply to OS X (only to Windows and Unix/Linux).
|
|
|
|
// See https://developer.mozilla.org/En/NPN_SetValue#section_5. Return
|
|
|
|
// NPERR_NO_ERROR here to conform to other browsers' behavior on OS X
|
|
|
|
// (e.g. Safari and Opera).
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
#else
|
2012-07-30 07:20:58 -07:00
|
|
|
NPBool bWindowless = (result == nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
return inst->SetWindowless(bWindowless);
|
2008-12-09 09:22:51 -08:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
case NPPVpluginTransparentBool: {
|
2012-07-30 07:20:58 -07:00
|
|
|
NPBool bTransparent = (result != nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
return inst->SetTransparent(bTransparent);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPPVjavascriptPushCallerBool:
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIJSContextStack> contextStack =
|
|
|
|
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
NPBool bPushCaller = (result != nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (bPushCaller) {
|
2009-06-28 16:43:19 -07:00
|
|
|
JSContext *cx;
|
|
|
|
rv = inst->GetJSContext(&cx);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = contextStack->Push(cx);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2012-07-30 07:20:58 -07:00
|
|
|
rv = contextStack->Pop(nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_SUCCEEDED(rv) ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPPVpluginKeepLibraryInMemory: {
|
2012-07-30 07:20:58 -07:00
|
|
|
NPBool bCached = (result != nullptr);
|
2012-08-14 02:10:42 -07:00
|
|
|
inst->SetCached(bCached);
|
|
|
|
return NPERR_NO_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-08-04 14:17:55 -07:00
|
|
|
|
2011-04-08 12:58:04 -07:00
|
|
|
case NPPVpluginUsesDOMForCursorBool: {
|
2012-07-30 07:20:58 -07:00
|
|
|
bool useDOMForCursor = (result != nullptr);
|
2011-04-08 12:58:04 -07:00
|
|
|
return inst->SetUsesDOMForCursor(useDOMForCursor);
|
|
|
|
}
|
|
|
|
|
2012-02-15 19:24:38 -08:00
|
|
|
#ifndef MOZ_WIDGET_ANDROID
|
|
|
|
// On android, their 'drawing model' uses the same constant!
|
2007-11-13 12:02:03 -08:00
|
|
|
case NPPVpluginDrawingModel: {
|
2007-03-26 18:07:57 -07:00
|
|
|
if (inst) {
|
2009-08-12 15:32:41 -07:00
|
|
|
inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result));
|
2007-03-26 18:07:57 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2012-02-15 19:24:38 -08:00
|
|
|
#endif
|
2009-08-26 17:29:47 -07:00
|
|
|
|
2012-02-15 19:24:38 -08:00
|
|
|
#ifdef XP_MACOSX
|
2009-08-26 17:29:47 -07:00
|
|
|
case NPPVpluginEventModel: {
|
|
|
|
if (inst) {
|
|
|
|
inst->SetEventModel((NPEventModel)NS_PTR_TO_INT32(result));
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2007-03-26 18:07:57 -07:00
|
|
|
#endif
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-16 14:34:31 -07:00
|
|
|
case kRequestDrawingModel_ANPSetValue:
|
|
|
|
if (inst)
|
2012-01-17 14:45:06 -08:00
|
|
|
inst->SetANPDrawingModel(NS_PTR_TO_INT32(result));
|
2011-09-16 14:34:31 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
case kAcceptEvents_ANPSetValue:
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
default:
|
2009-03-17 14:20:24 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
NPError NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_requestread(NPStream *pstream, NPByteRange *rangeList)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_requestread called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_RequestRead: stream=%p\n",
|
|
|
|
(void*)pstream));
|
|
|
|
|
|
|
|
#ifdef PLUGIN_LOGGING
|
2012-07-30 07:20:58 -07:00
|
|
|
for(NPByteRange * range = rangeList; range != nullptr; range = range->next)
|
2007-03-22 10:30:00 -07:00
|
|
|
PR_LOG(nsPluginLogging::gNPNLog,PLUGIN_LOG_NOISY,
|
|
|
|
("%i-%i", range->offset, range->offset + range->length - 1));
|
|
|
|
|
|
|
|
PR_LOG(nsPluginLogging::gNPNLog,PLUGIN_LOG_NOISY, ("\n\n"));
|
|
|
|
PR_LogFlush();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!pstream || !rangeList || !pstream->ndata)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
nsNPAPIStreamWrapper* streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
nsNPAPIPluginStreamListener* streamlistener = streamWrapper->GetStreamListener();
|
|
|
|
if (!streamlistener) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t streamtype = NP_NORMAL;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
streamlistener->GetStreamType(&streamtype);
|
|
|
|
|
2009-09-16 18:30:26 -07:00
|
|
|
if (streamtype != NP_SEEK)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_STREAM_NOT_SEEKABLE;
|
|
|
|
|
2012-06-05 06:58:39 -07:00
|
|
|
if (!streamlistener->mStreamListenerPeer)
|
2010-02-23 18:58:27 -08:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2012-06-05 06:58:39 -07:00
|
|
|
nsresult rv = streamlistener->mStreamListenerPeer->RequestRead((NPByteRange *)rangeList);
|
2010-02-23 18:58:27 -08:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-07 08:11:35 -07:00
|
|
|
return NPERR_NO_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-07-11 14:28:12 -07:00
|
|
|
// Deprecated, only stubbed out
|
|
|
|
void* NP_CALLBACK /* OJI type: JRIEnv* */
|
2010-01-31 13:41:26 -08:00
|
|
|
_getJavaEnv()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaEnv\n"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
const char * NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_useragent(NPP npp)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_useragent called from the wrong thread\n"));
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-03-30 08:23:21 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_UserAgent: npp=%p\n", (void*)npp));
|
|
|
|
|
2011-05-21 06:28:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
|
|
|
|
if (!pluginHost) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2011-05-21 06:28:54 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-03-30 08:23:21 -07:00
|
|
|
const char *retstr;
|
2009-06-25 14:06:54 -07:00
|
|
|
nsresult rv = pluginHost->UserAgent(&retstr);
|
2008-03-30 08:23:21 -07:00
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return retstr;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void * NP_CALLBACK
|
2008-09-11 08:10:26 -07:00
|
|
|
_memalloc (uint32_t size)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,("NPN_memalloc called from the wrong thread\n"));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemAlloc: size=%d\n", size));
|
|
|
|
return nsMemory::Alloc(size);
|
|
|
|
}
|
|
|
|
|
2008-07-11 14:28:12 -07:00
|
|
|
// Deprecated, only stubbed out
|
|
|
|
void* NP_CALLBACK /* OJI type: jref */
|
2007-03-22 10:30:00 -07:00
|
|
|
_getJavaPeer(NPP npp)
|
|
|
|
{
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaPeer: npp=%p\n", (void*)npp));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_pushpopupsenabledstate(NPP npp, NPBool enabled)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_pushpopupsenabledstate called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2010-02-20 05:53:10 -08:00
|
|
|
nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : NULL;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->PushPopupsEnabledState(enabled);
|
|
|
|
}
|
|
|
|
|
2007-06-26 17:41:08 -07:00
|
|
|
void NP_CALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
_poppopupsenabledstate(NPP npp)
|
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_poppopupsenabledstate called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2010-02-20 05:53:10 -08:00
|
|
|
nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : NULL;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->PopPopupsEnabledState();
|
|
|
|
}
|
|
|
|
|
2007-07-11 16:25:45 -07:00
|
|
|
void NP_CALLBACK
|
2007-07-12 13:38:11 -07:00
|
|
|
_pluginthreadasynccall(NPP instance, PluginThreadCallback func, void *userData)
|
2007-07-11 16:25:45 -07:00
|
|
|
{
|
2008-03-30 08:23:21 -07:00
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,("NPN_pluginthreadasynccall called from the main thread\n"));
|
|
|
|
} else {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,("NPN_pluginthreadasynccall called from a non main thread\n"));
|
|
|
|
}
|
2007-07-11 16:25:45 -07:00
|
|
|
nsRefPtr<nsPluginThreadRunnable> evt =
|
|
|
|
new nsPluginThreadRunnable(instance, func, userData);
|
|
|
|
|
|
|
|
if (evt && evt->IsValid()) {
|
|
|
|
NS_DispatchToMainThread(evt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-12 16:55:52 -08:00
|
|
|
NPError NP_CALLBACK
|
|
|
|
_getvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
|
|
|
char **value, uint32_t *len)
|
|
|
|
{
|
|
|
|
if (!instance) {
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!url || !*url || !len) {
|
|
|
|
return NPERR_INVALID_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
|
|
|
|
switch (variable) {
|
|
|
|
case NPNURLVProxy:
|
|
|
|
{
|
2011-05-21 06:28:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
|
2009-06-25 14:06:54 -07:00
|
|
|
if (pluginHost && NS_SUCCEEDED(pluginHost->FindProxyForURL(url, value))) {
|
2009-01-12 16:55:52 -08:00
|
|
|
*len = *value ? PL_strlen(*value) : 0;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NPNURLVCookie:
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICookieService> cookieService =
|
|
|
|
do_GetService(NS_COOKIESERVICE_CONTRACTID);
|
|
|
|
|
|
|
|
if (!cookieService)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
// Make an nsURI from the url argument
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), nsDependentCString(url)))) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (NS_FAILED(cookieService->GetCookieString(uri, nullptr, value)) ||
|
2010-05-11 02:45:15 -07:00
|
|
|
!*value) {
|
2009-01-12 16:55:52 -08:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2010-05-11 02:45:15 -07:00
|
|
|
*len = PL_strlen(*value);
|
|
|
|
return NPERR_NO_ERROR;
|
2009-01-12 16:55:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Fall through and return an error...
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_setvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
|
|
|
const char *value, uint32_t len)
|
|
|
|
{
|
|
|
|
if (!instance) {
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!url || !*url) {
|
|
|
|
return NPERR_INVALID_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (variable) {
|
|
|
|
case NPNURLVCookie:
|
|
|
|
{
|
2009-06-13 13:16:40 -07:00
|
|
|
if (!url || !value || (0 >= len))
|
|
|
|
return NPERR_INVALID_PARAM;
|
2009-01-12 16:55:52 -08:00
|
|
|
|
2009-06-13 13:16:40 -07:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
nsCOMPtr<nsICookieService> cookieService = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uriIn;
|
2012-07-30 07:20:58 -07:00
|
|
|
rv = ioService->NewURI(nsDependentCString(url), nullptr, nullptr, getter_AddRefs(uriIn));
|
2009-06-13 13:16:40 -07:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrompt> prompt;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsPluginHost::GetPrompt(nullptr, getter_AddRefs(prompt));
|
2009-06-13 13:16:40 -07:00
|
|
|
|
|
|
|
char *cookie = (char*)value;
|
|
|
|
char c = cookie[len];
|
|
|
|
cookie[len] = '\0';
|
2012-07-30 07:20:58 -07:00
|
|
|
rv = cookieService->SetCookieString(uriIn, prompt, cookie, nullptr);
|
2009-06-13 13:16:40 -07:00
|
|
|
cookie[len] = c;
|
|
|
|
if (NS_SUCCEEDED(rv))
|
2009-01-12 16:55:52 -08:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NPNURLVProxy:
|
|
|
|
// We don't support setting proxy values, fall through...
|
|
|
|
default:
|
|
|
|
// Fall through and return an error...
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_getauthenticationinfo(NPP instance, 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)
|
|
|
|
{
|
|
|
|
if (!instance || !protocol || !host || !scheme || !realm || !username ||
|
|
|
|
!ulen || !password || !plen)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*username = nullptr;
|
|
|
|
*password = nullptr;
|
2009-01-12 16:55:52 -08:00
|
|
|
*ulen = 0;
|
|
|
|
*plen = 0;
|
|
|
|
|
|
|
|
nsDependentCString proto(protocol);
|
|
|
|
|
|
|
|
if (!proto.LowerCaseEqualsLiteral("http") &&
|
|
|
|
!proto.LowerCaseEqualsLiteral("https"))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIHttpAuthManager> authManager =
|
|
|
|
do_GetService("@mozilla.org/network/http-auth-manager;1");
|
|
|
|
if (!authManager)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
nsAutoString unused, uname16, pwd16;
|
|
|
|
if (NS_FAILED(authManager->GetAuthIdentity(proto, nsDependentCString(host),
|
|
|
|
port, nsDependentCString(scheme),
|
|
|
|
nsDependentCString(realm),
|
|
|
|
EmptyCString(), unused, uname16,
|
|
|
|
pwd16))) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ConvertUTF16toUTF8 uname8(uname16);
|
|
|
|
NS_ConvertUTF16toUTF8 pwd8(pwd16);
|
|
|
|
|
|
|
|
*username = ToNewCString(uname8);
|
|
|
|
*ulen = *username ? uname8.Length() : 0;
|
|
|
|
|
|
|
|
*password = ToNewCString(pwd8);
|
|
|
|
*plen = *password ? pwd8.Length() : 0;
|
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
uint32_t NP_CALLBACK
|
2009-12-01 13:27:13 -08:00
|
|
|
_scheduletimer(NPP instance, uint32_t interval, NPBool repeat, PluginTimerFunc timerFunc)
|
2009-07-01 08:09:49 -07:00
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return inst->ScheduleTimer(interval, repeat, timerFunc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_unscheduletimer(NPP instance, uint32_t timerID)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->UnscheduleTimer(timerID);
|
|
|
|
}
|
|
|
|
|
2009-08-26 17:29:47 -07:00
|
|
|
NPError NP_CALLBACK
|
|
|
|
_popupcontextmenu(NPP instance, NPMenu* menu)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return inst->PopUpContextMenu(menu);
|
|
|
|
}
|
|
|
|
|
2012-02-15 19:08:41 -08:00
|
|
|
NPError NP_CALLBACK
|
|
|
|
_initasyncsurface(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return inst->InitAsyncSurface(size, format, initData, surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError NP_CALLBACK
|
|
|
|
_finalizeasyncsurface(NPP instance, NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return inst->FinalizeAsyncSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NP_CALLBACK
|
|
|
|
_setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->SetCurrentAsyncSurface(surface, changed);
|
|
|
|
}
|
|
|
|
|
2009-08-26 17:29:47 -07:00
|
|
|
NPBool NP_CALLBACK
|
|
|
|
_convertpoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
2011-09-29 23:02:59 -07:00
|
|
|
return false;
|
2009-08-26 17:29:47 -07:00
|
|
|
|
|
|
|
return inst->ConvertPoint(sourceX, sourceY, sourceSpace, destX, destY, destSpace);
|
|
|
|
}
|
|
|
|
|
2011-01-05 11:44:21 -08:00
|
|
|
void NP_CALLBACK
|
|
|
|
_urlredirectresponse(NPP instance, void* notifyData, NPBool allow)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
inst->URLRedirectResponse(notifyData, allow);
|
|
|
|
}
|
|
|
|
|
2009-12-01 13:27:13 -08:00
|
|
|
} /* namespace parent */
|
|
|
|
} /* namespace plugins */
|
|
|
|
} /* namespace mozilla */
|