2004-04-11 09:33:17 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2009-10-22 03:01:16 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2013-04-24 22:42:40 +04:00
|
|
|
/* This must occur *after* layers/PLayerTransaction.h to avoid typedefs conflicts. */
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2013-07-12 00:21:45 +04:00
|
|
|
#include "pratom.h"
|
2004-07-12 19:53:22 +04:00
|
|
|
#include "prmem.h"
|
2009-06-30 22:51:05 +04:00
|
|
|
#include "prenv.h"
|
2007-07-12 03:25:45 +04:00
|
|
|
#include "prclist.h"
|
2010-03-04 08:02:55 +03:00
|
|
|
|
2011-10-04 18:06:54 +04:00
|
|
|
#include "jsfriendapi.h"
|
2010-03-04 08:02:55 +03:00
|
|
|
|
2011-05-21 17:28:54 +04:00
|
|
|
#include "nsPluginHost.h"
|
2008-09-15 16:45:01 +04:00
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
#include "nsNPAPIPluginInstance.h"
|
|
|
|
#include "nsNPAPIPluginStreamListener.h"
|
2012-06-05 17:58:39 +04:00
|
|
|
#include "nsPluginStreamListenerPeer.h"
|
1999-07-08 00:18:27 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2007-07-12 03:25:45 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2012-04-04 08:09:20 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-10-03 06:43:18 +04:00
|
|
|
#include "nsPluginInstanceOwner.h"
|
2001-10-16 07:35:52 +04:00
|
|
|
|
1999-07-08 00:18:27 +04:00
|
|
|
#include "nsPluginsDir.h"
|
2001-08-16 06:59:03 +04:00
|
|
|
#include "nsPluginLogging.h"
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2002-10-05 06:57:21 +04:00
|
|
|
#include "nsIDOMElement.h"
|
2005-11-29 02:56:44 +03:00
|
|
|
#include "nsPIDOMWindow.h"
|
2013-05-23 01:42:44 +04:00
|
|
|
#include "nsGlobalWindow.h"
|
2002-10-05 06:57:21 +04:00
|
|
|
#include "nsIDocument.h"
|
2011-09-14 20:22:27 +04:00
|
|
|
#include "nsIContent.h"
|
2016-10-03 15:43:47 +03:00
|
|
|
#include "nsIIDNService.h"
|
2002-10-05 06:57:21 +04:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
2004-07-12 19:53:22 +04:00
|
|
|
#include "nsIScriptContext.h"
|
2006-06-13 07:07:47 +04:00
|
|
|
#include "nsDOMJSUtils.h"
|
2008-01-15 03:51:29 +03:00
|
|
|
#include "nsIPrincipal.h"
|
2010-08-15 13:10:15 +04:00
|
|
|
#include "nsWildCard.h"
|
2011-09-14 20:22:27 +04:00
|
|
|
#include "nsContentUtils.h"
|
2014-06-26 15:08:49 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2014-12-12 21:24:24 +03:00
|
|
|
#include "nsIXULRuntime.h"
|
2004-07-12 19:53:22 +04:00
|
|
|
#include "nsIXPConnect.h"
|
2002-10-05 06:57:21 +04:00
|
|
|
|
2008-04-24 03:24:21 +04:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include <prinrval.h>
|
|
|
|
|
2011-06-25 19:25:03 +04:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2008-09-11 19:10:26 +04:00
|
|
|
#include <Carbon/Carbon.h>
|
2010-04-22 03:57:22 +04:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
#include <OpenGL/OpenGL.h>
|
2012-01-10 04:11:04 +04:00
|
|
|
#include "nsCocoaFeatures.h"
|
2014-12-11 17:44:07 +03:00
|
|
|
#include "PluginUtilsOSX.h"
|
1999-07-08 00:18:27 +04:00
|
|
|
#endif
|
|
|
|
|
2008-09-11 19:10:26 +04:00
|
|
|
// needed for nppdf plugin
|
2012-06-28 04:15:32 +04:00
|
|
|
#if (MOZ_WIDGET_GTK)
|
2002-09-03 18:45:02 +04:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkx.h>
|
2012-06-28 04:15:32 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2002-09-03 18:45:02 +04:00
|
|
|
#include "gtk2xtbin.h"
|
|
|
|
#endif
|
2012-06-28 04:15:32 +04:00
|
|
|
#endif
|
2002-09-03 18:45:02 +04:00
|
|
|
|
2014-03-09 22:35:52 +04:00
|
|
|
#include "nsJSUtils.h"
|
2004-07-12 19:53:22 +04:00
|
|
|
#include "nsJSNPRuntime.h"
|
2009-01-13 03:55:52 +03:00
|
|
|
#include "nsIHttpAuthManager.h"
|
|
|
|
#include "nsICookieService.h"
|
2012-04-24 08:49:25 +04:00
|
|
|
#include "nsILoadContext.h"
|
|
|
|
#include "nsIDocShell.h"
|
2002-09-03 18:45:02 +04:00
|
|
|
|
2010-11-19 23:58:59 +03:00
|
|
|
#include "nsNetUtil.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsNetCID.h"
|
2010-11-19 23:58:59 +03: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-04-01 08:29:02 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2009-10-27 22:51:12 +03:00
|
|
|
#include "mozilla/PluginLibrary.h"
|
|
|
|
using mozilla::PluginLibrary;
|
2009-07-25 02:21:07 +04:00
|
|
|
|
2009-10-27 22:51:12 +03:00
|
|
|
#include "mozilla/PluginPRLibrary.h"
|
|
|
|
using mozilla::PluginPRLibrary;
|
2009-07-20 23:04:52 +04:00
|
|
|
|
2009-09-09 10:31:35 +04:00
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
2014-10-29 18:05:36 +03:00
|
|
|
using mozilla::plugins::PluginModuleChromeParent;
|
|
|
|
using mozilla::plugins::PluginModuleContentParent;
|
2009-06-30 22:51:05 +04:00
|
|
|
|
2010-06-22 00:35:49 +04:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
|
|
|
|
2011-02-19 15:16:51 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <windows.h>
|
2013-10-18 22:14:31 +04:00
|
|
|
#include "mozilla/WindowsVersion.h"
|
2012-10-02 17:24:51 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "mozilla/a11y/Compatibility.h"
|
|
|
|
#endif
|
2011-02-19 15:16:51 +03:00
|
|
|
#endif
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-01-31 18:40:58 +04:00
|
|
|
#include <android/log.h>
|
|
|
|
#include "android_npapi.h"
|
2011-09-17 01:34:31 +04:00
|
|
|
#include "ANPBase.h"
|
2016-07-21 20:49:04 +03:00
|
|
|
#include "GeneratedJNIWrappers.h"
|
2012-08-07 11:06:29 +04:00
|
|
|
#undef LOG
|
2011-09-17 01:34:31 +04:00
|
|
|
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
|
|
|
|
#endif
|
|
|
|
|
2015-07-29 00:09:48 +03:00
|
|
|
#include "nsIAudioChannelAgent.h"
|
2016-05-03 04:52:44 +03:00
|
|
|
#include "AudioChannelService.h"
|
2015-07-29 00:09:48 +03: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-04-01 08:29:02 +04:00
|
|
|
using namespace mozilla;
|
2010-03-26 02:45:33 +03: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 18:26:44 +03:00
|
|
|
_convertpoint,
|
2013-10-24 00:34:30 +04:00
|
|
|
nullptr, // handleevent, unimplemented
|
|
|
|
nullptr, // unfocusinstance, unimplemented
|
2015-12-02 22:31:16 +03:00
|
|
|
_urlredirectresponse,
|
|
|
|
_initasyncsurface,
|
|
|
|
_finalizeasyncsurface,
|
|
|
|
_setcurrentasyncsurface
|
2010-03-26 02:45:33 +03:00
|
|
|
};
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
static Mutex *sPluginThreadAsyncCallLock = nullptr;
|
2007-07-12 03:25:45 +04:00
|
|
|
static PRCList sPendingAsyncCalls = PR_INIT_STATIC_CLIST(&sPendingAsyncCalls);
|
|
|
|
|
2002-03-13 07:24:45 +03:00
|
|
|
// POST/GET stream type
|
|
|
|
enum eNPPStreamTypeInternal {
|
|
|
|
eNPPStreamTypeInternal_Get,
|
|
|
|
eNPPStreamTypeInternal_Post
|
|
|
|
};
|
|
|
|
|
2016-10-15 03:03:05 +03:00
|
|
|
void NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState)
|
2012-12-07 03:58:14 +04:00
|
|
|
{
|
2013-02-27 15:50:27 +04:00
|
|
|
nsNPAPIPluginInstance::BeginPluginCall(aReentryState);
|
2012-12-07 03:58:14 +04:00
|
|
|
}
|
|
|
|
|
2016-10-15 03:03:05 +03:00
|
|
|
void NS_NotifyPluginCall(NSPluginCallReentry aReentryState)
|
2008-04-24 03:24:21 +04:00
|
|
|
{
|
2013-02-27 15:50:27 +04:00
|
|
|
nsNPAPIPluginInstance::EndPluginCall(aReentryState);
|
2008-04-24 03:24:21 +04:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
static void CheckClassInitialized()
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool initialized = false;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2001-08-16 06:59:03 +04:00
|
|
|
if (initialized)
|
|
|
|
return;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-10-08 05:50:25 +04: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-04-01 08:29:02 +04:00
|
|
|
sPluginThreadAsyncCallLock = new Mutex("nsNPAPIPlugin.sPluginThreadAsyncCallLock");
|
2007-07-12 03:25:45 +04:00
|
|
|
|
2011-09-30 10:02:59 +04:00
|
|
|
initialized = true;
|
2001-08-16 06:59:03 +04:00
|
|
|
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,("NPN callbacks initialized\n"));
|
2001-02-14 00:48:26 +03:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2011-05-12 00:23:25 +04:00
|
|
|
NS_IMPL_ISUPPORTS0(nsNPAPIPlugin)
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
nsNPAPIPlugin::nsNPAPIPlugin()
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2010-04-08 02:14:54 +04:00
|
|
|
memset((void*)&mPluginFuncs, 0, sizeof(mPluginFuncs));
|
2010-02-01 00:41:26 +03:00
|
|
|
mPluginFuncs.size = sizeof(mPluginFuncs);
|
2010-12-03 08:20:59 +03:00
|
|
|
mPluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
2002-11-06 04:24:57 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mLibrary = nullptr;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2009-07-13 06:44:48 +04:00
|
|
|
nsNPAPIPlugin::~nsNPAPIPlugin()
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2010-02-01 00:41:26 +03:00
|
|
|
delete mLibrary;
|
2012-07-30 18:20:58 +04:00
|
|
|
mLibrary = nullptr;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2009-12-16 23:08:45 +03:00
|
|
|
void
|
2010-03-25 00:22:04 +03:00
|
|
|
nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
|
|
|
|
const nsAString& browserDumpID)
|
2009-12-16 23:08:45 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
2010-03-25 00:22:04 +03:00
|
|
|
host->PluginCrashed(this, pluginDumpID, browserDumpID);
|
2009-12-16 23:08:45 +03:00
|
|
|
}
|
2009-07-25 02:21:07 +04:00
|
|
|
|
2015-08-31 23:51:19 +03:00
|
|
|
bool
|
|
|
|
nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
return false;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-10-27 22:51:12 +03:00
|
|
|
inline PluginLibrary*
|
2010-09-16 08:57:13 +04:00
|
|
|
GetNewPluginLibrary(nsPluginTag *aPluginTag)
|
2009-07-25 02:21:07 +04:00
|
|
|
{
|
2016-01-15 13:38:03 +03:00
|
|
|
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
|
|
|
|
2010-09-16 08:57:13 +04:00
|
|
|
if (!aPluginTag) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-09-16 08:57:13 +04:00
|
|
|
}
|
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2015-09-01 02:04:25 +03:00
|
|
|
return PluginModuleContentParent::LoadModule(aPluginTag->mId, aPluginTag);
|
2014-10-29 18:05:36 +03:00
|
|
|
}
|
|
|
|
|
2015-08-31 23:51:19 +03:00
|
|
|
if (nsNPAPIPlugin::RunPluginOOP(aPluginTag)) {
|
|
|
|
return PluginModuleChromeParent::LoadModule(aPluginTag->mFullPath.get(), aPluginTag->mId, aPluginTag);
|
|
|
|
}
|
|
|
|
return new PluginPRLibrary(aPluginTag->mFullPath.get(), aPluginTag->mLibrary);
|
2009-07-25 02:21:07 +04:00
|
|
|
}
|
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
// Creates an nsNPAPIPlugin object. One nsNPAPIPlugin object exists per plugin (not instance).
|
1999-07-08 00:18:27 +04:00
|
|
|
nsresult
|
2011-02-09 01:16:07 +03:00
|
|
|
nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2016-01-15 13:38:03 +03:00
|
|
|
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2010-09-16 08:57:13 +04:00
|
|
|
if (!aPluginTag) {
|
2010-08-18 04:05:48 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
CheckClassInitialized();
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPlugin> plugin = new nsNPAPIPlugin();
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2010-09-16 08:57:13 +04:00
|
|
|
PluginLibrary* pluginLib = GetNewPluginLibrary(aPluginTag);
|
2010-04-08 02:14:54 +04:00
|
|
|
if (!pluginLib) {
|
2002-03-26 06:04:37 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
|
2010-04-08 02:14:54 +04:00
|
|
|
if (!pluginLib->HasRequiredFunctions()) {
|
|
|
|
NS_WARNING("Not all necessary functions exposed by plugin, it will not load.");
|
2014-02-26 03:55:07 +04:00
|
|
|
delete pluginLib;
|
2001-08-16 06:59:03 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-04-08 02:14:54 +04:00
|
|
|
#endif
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
plugin->mLibrary = pluginLib;
|
|
|
|
pluginLib->SetPlugin(plugin);
|
2002-04-03 03:36:06 +04:00
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
// Exchange NPAPI entry points.
|
2014-02-11 02:57:01 +04:00
|
|
|
#if defined(XP_WIN)
|
2010-04-08 02:14:54 +04:00
|
|
|
// NP_GetEntryPoints must be called before NP_Initialize on Windows.
|
2014-11-27 02:13:49 +03:00
|
|
|
NPError pluginCallError;
|
|
|
|
nsresult rv = pluginLib->NP_GetEntryPoints(&plugin->mPluginFuncs, &pluginCallError);
|
2010-04-08 02:14:54 +04:00
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2002-04-03 03:36:06 +04:00
|
|
|
}
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2010-04-08 02:14:54 +04: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;
|
2002-04-03 03:36:06 +04:00
|
|
|
}
|
2010-04-08 02:14:54 +04:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
// NP_Initialize must be called before NP_GetEntryPoints on Mac OS X.
|
|
|
|
// We need to match WebKit's behavior.
|
2014-11-27 02:13:49 +03:00
|
|
|
NPError pluginCallError;
|
|
|
|
nsresult rv = pluginLib->NP_Initialize(&sBrowserFuncs, &pluginCallError);
|
2010-04-08 02:14:54 +04:00
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
2001-07-03 05:56:28 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2008-12-15 20:29:44 +03:00
|
|
|
|
2010-04-08 02:14:54 +04:00
|
|
|
rv = pluginLib->NP_GetEntryPoints(&plugin->mPluginFuncs, &pluginCallError);
|
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
2001-08-16 06:59:03 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-04-08 02:14:54 +04:00
|
|
|
}
|
2011-11-11 04:17:46 +04:00
|
|
|
#elif defined(MOZ_WIDGET_GONK)
|
2010-04-08 02:14:54 +04:00
|
|
|
#else
|
2014-11-27 02:13:49 +03:00
|
|
|
NPError pluginCallError;
|
|
|
|
nsresult rv = pluginLib->NP_Initialize(&sBrowserFuncs, &plugin->mPluginFuncs, &pluginCallError);
|
2010-04-08 02:14:54 +04:00
|
|
|
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
|
2001-08-16 06:59:03 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-04-08 02:14:54 +04:00
|
|
|
}
|
2001-06-29 11:24:12 +04:00
|
|
|
#endif
|
|
|
|
|
2014-03-15 23:00:15 +04:00
|
|
|
plugin.forget(aResult);
|
2001-08-16 06:59:03 +04:00
|
|
|
return NS_OK;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2010-07-20 06:11:26 +04:00
|
|
|
PluginLibrary*
|
|
|
|
nsNPAPIPlugin::GetLibrary()
|
|
|
|
{
|
|
|
|
return mLibrary;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPPluginFuncs*
|
|
|
|
nsNPAPIPlugin::PluginFuncs()
|
|
|
|
{
|
|
|
|
return &mPluginFuncs;
|
|
|
|
}
|
|
|
|
|
1999-07-08 00:18:27 +04:00
|
|
|
nsresult
|
2010-02-01 00:41:26 +03:00
|
|
|
nsNPAPIPlugin::Shutdown()
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2005-03-23 03:34:39 +03:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_BASIC,
|
|
|
|
("NPP Shutdown to be called: this=%p\n", this));
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2009-10-27 22:51:12 +03:00
|
|
|
NPError shutdownError;
|
2010-02-01 00:41:26 +03:00
|
|
|
mLibrary->NP_Shutdown(&shutdownError);
|
2011-04-29 00:02:35 +04:00
|
|
|
|
1999-07-08 00:18:27 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-19 18:46:24 +04:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPlugin::RetainStream(NPStream *pstream, nsISupports **aRetainedPeer)
|
|
|
|
{
|
|
|
|
if (!aRetainedPeer)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2013-10-24 00:34:30 +04:00
|
|
|
*aRetainedPeer = nullptr;
|
2011-10-19 18:46:24 +04:00
|
|
|
|
|
|
|
if (!pstream || !pstream->ndata)
|
2012-07-30 13:24:36 +04:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2011-10-19 18:46:24 +04:00
|
|
|
|
2012-05-18 03:54:26 +04:00
|
|
|
nsNPAPIStreamWrapper* streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
nsNPAPIPluginStreamListener* listener = streamWrapper->GetStreamListener();
|
|
|
|
if (!listener) {
|
2012-07-30 13:24:36 +04:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2012-05-18 03:54:26 +04:00
|
|
|
}
|
2011-10-19 18:46:24 +04:00
|
|
|
|
2012-06-05 17:58:39 +04:00
|
|
|
nsIStreamListener* streamListener = listener->GetStreamListenerPeer();
|
|
|
|
if (!streamListener) {
|
2012-07-30 13:24:36 +04:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2012-06-05 17:58:39 +04:00
|
|
|
}
|
2011-10-19 18:46:24 +04:00
|
|
|
|
2012-06-05 17:58:39 +04:00
|
|
|
*aRetainedPeer = streamListener;
|
2011-10-19 18:46:24 +04:00
|
|
|
NS_ADDREF(*aRetainedPeer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-03-23 03:34:39 +03: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 16:45:01 +04:00
|
|
|
MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target,
|
|
|
|
eNPPStreamTypeInternal type,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool bDoNotify = false,
|
2012-07-30 18:20:58 +04:00
|
|
|
void *notifyData = nullptr, uint32_t len = 0,
|
|
|
|
const char *buf = nullptr, NPBool file = false)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2005-03-23 03:34:39 +03:00
|
|
|
if (!npp)
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2010-03-09 00:54:04 +03:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
|
|
|
if (!inst || !inst->IsRunning())
|
2000-06-14 03:16:05 +04:00
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2011-05-21 17:28:54 +04:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHostCOM = do_GetService(MOZ_PLUGIN_HOST_CONTRACTID);
|
|
|
|
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
|
|
|
|
if (!pluginHost) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginStreamListener> listener;
|
2010-10-11 23:41:11 +04: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.
|
2014-04-01 16:29:25 +04:00
|
|
|
// Call SetCallNotify(true) below after we are sure we cannot return a failure
|
2010-10-11 23:41:11 +04:00
|
|
|
// code.
|
2011-01-05 22:44:21 +03:00
|
|
|
if (!target) {
|
|
|
|
inst->NewStreamListener(relativeURL, notifyData,
|
|
|
|
getter_AddRefs(listener));
|
|
|
|
if (listener) {
|
2012-05-18 03:54:26 +04:00
|
|
|
listener->SetCallNotify(false);
|
2011-01-05 22:44:21 +03:00
|
|
|
}
|
|
|
|
}
|
2002-03-13 07:24:45 +03:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case eNPPStreamTypeInternal_Get:
|
|
|
|
{
|
2011-04-12 00:00:30 +04:00
|
|
|
if (NS_FAILED(pluginHost->GetURL(inst, relativeURL, target, listener,
|
2013-10-24 00:34:30 +04:00
|
|
|
nullptr, nullptr, false)))
|
2002-03-13 07:24:45 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eNPPStreamTypeInternal_Post:
|
|
|
|
{
|
2013-10-24 00:34:30 +04:00
|
|
|
if (NS_FAILED(pluginHost->PostURL(inst, relativeURL, len, buf, file,
|
|
|
|
target, listener, nullptr, nullptr,
|
|
|
|
false, 0, nullptr)))
|
2002-03-13 07:24:45 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2009-08-14 18:09:00 +04:00
|
|
|
NS_ERROR("how'd I get here");
|
2002-03-13 07:24:45 +03:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2010-10-11 23:41:11 +04:00
|
|
|
if (listener) {
|
|
|
|
// SetCallNotify(bDoNotify) here, see comment above.
|
2012-05-18 03:54:26 +04:00
|
|
|
listener->SetCallNotify(bDoNotify);
|
2010-10-11 23:41:11 +04:00
|
|
|
}
|
|
|
|
|
2002-03-13 07:24:45 +03:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2000-06-14 03:16:05 +04:00
|
|
|
|
2011-05-08 21:45:56 +04:00
|
|
|
#if defined(MOZ_MEMORY_WINDOWS)
|
2009-12-02 00:27:13 +03:00
|
|
|
extern "C" size_t malloc_usable_size(const void *ptr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
static char *gNPPException;
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsPluginThreadRunnable : public Runnable,
|
2009-12-02 00:27:13 +03:00
|
|
|
public PRCList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsPluginThreadRunnable(NPP instance, PluginThreadCallback func,
|
|
|
|
void *userData);
|
2016-11-15 14:09:07 +03:00
|
|
|
~nsPluginThreadRunnable() override;
|
2009-12-02 00:27:13 +03:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2009-12-02 00:27:13 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsForInstance(NPP instance)
|
2009-12-02 00:27:13 +03:00
|
|
|
{
|
|
|
|
return (mInstance == instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Invalidate()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mFunc = nullptr;
|
2009-12-02 00:27:13 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsValid()
|
2009-12-02 00:27:13 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return (mFunc != nullptr);
|
2009-12-02 00:27:13 +03:00
|
|
|
}
|
|
|
|
|
2014-04-01 16:29:25 +04:00
|
|
|
private:
|
2009-12-02 00:27:13 +03:00
|
|
|
NPP mInstance;
|
|
|
|
PluginThreadCallback mFunc;
|
|
|
|
void *mUserData;
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsIDocument *
|
|
|
|
GetDocumentFromNPP(NPP npp)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(npp, nullptr);
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)npp->ndata;
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(inst, nullptr);
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(owner, nullptr);
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
owner->GetDocument(getter_AddRefs(doc));
|
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NPIdentifier
|
|
|
|
doGetIdentifier(JSContext *cx, const NPUTF8* name)
|
|
|
|
{
|
|
|
|
NS_ConvertUTF8toUTF16 utf16name(name);
|
|
|
|
|
2015-06-30 17:58:31 +03:00
|
|
|
JSString *str = ::JS_AtomizeAndPinUCStringN(cx, utf16name.get(), utf16name.Length());
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
if (!str)
|
2013-10-24 00:34:30 +04:00
|
|
|
return nullptr;
|
2009-12-02 00:27:13 +03:00
|
|
|
|
2011-05-17 23:15:12 +04:00
|
|
|
return StringToNPIdentifier(cx, str);
|
2009-12-02 00:27:13 +03:00
|
|
|
}
|
|
|
|
|
2011-05-08 21:45:56 +04:00
|
|
|
#if defined(MOZ_MEMORY_WINDOWS)
|
2009-12-02 00:27:13 +03:00
|
|
|
BOOL
|
|
|
|
InHeap(HANDLE hHeap, LPVOID lpMem)
|
|
|
|
{
|
|
|
|
BOOL success = FALSE;
|
|
|
|
PROCESS_HEAP_ENTRY he;
|
2013-10-24 00:34:30 +04:00
|
|
|
he.lpData = nullptr;
|
2009-12-02 00:27:13 +03:00
|
|
|
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 18:20:58 +04:00
|
|
|
gNPPException = nullptr;
|
2009-12-02 00:27:13 +03: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 18:20:58 +04:00
|
|
|
mFunc = nullptr;
|
2009-12-02 00:27:13 +03: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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(*sPluginThreadAsyncCallLock);
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
2009-12-18 05:09:22 +03:00
|
|
|
if (!inst || !inst->IsRunning()) {
|
2009-12-02 00:27:13 +03:00
|
|
|
// The plugin was stopped, ignore this async call.
|
2012-07-30 18:20:58 +04:00
|
|
|
mFunc = nullptr;
|
2009-12-02 00:27:13 +03: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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(*sPluginThreadAsyncCallLock);
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
PR_REMOVE_LINK(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginThreadRunnable::Run()
|
|
|
|
{
|
|
|
|
if (mFunc) {
|
|
|
|
PluginDestructionGuard guard(mInstance);
|
|
|
|
|
2013-02-27 15:50:27 +04:00
|
|
|
NS_TRY_SAFE_CALL_VOID(mFunc(mUserData), nullptr,
|
2013-07-29 23:44:32 +04:00
|
|
|
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
2009-12-02 00:27:13 +03: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-04-01 08:29:02 +04:00
|
|
|
MutexAutoLock lock(*sPluginThreadAsyncCallLock);
|
2009-12-02 00:27:13 +03: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-04-01 08:29:02 +04:00
|
|
|
delete sPluginThreadAsyncCallLock;
|
2009-12-02 00:27:13 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
sPluginThreadAsyncCallLock = nullptr;
|
2009-12-02 00:27:13 +03: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-04-01 08:29:02 +04:00
|
|
|
AsyncCallbackAutoLock::AsyncCallbackAutoLock()
|
2009-12-02 00:27:13 +03:00
|
|
|
{
|
2011-04-06 21:28:02 +04:00
|
|
|
if (sPluginThreadAsyncCallLock) {
|
|
|
|
sPluginThreadAsyncCallLock->Lock();
|
|
|
|
}
|
2009-12-02 00:27:13 +03: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-04-01 08:29:02 +04:00
|
|
|
AsyncCallbackAutoLock::~AsyncCallbackAutoLock()
|
2009-12-02 00:27:13 +03:00
|
|
|
{
|
2011-04-06 21:28:02 +04:00
|
|
|
if (sPluginThreadAsyncCallLock) {
|
|
|
|
sPluginThreadAsyncCallLock->Unlock();
|
|
|
|
}
|
2009-12-02 00:27:13 +03:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NPP NPPStack::sCurrentNPP = nullptr;
|
2009-12-02 00:27:13 +03:00
|
|
|
|
|
|
|
const char *
|
|
|
|
PeekException()
|
|
|
|
{
|
|
|
|
return gNPPException;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PopException()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(gNPPException, "Uh, no NPP exception to pop!");
|
|
|
|
|
|
|
|
if (gNPPException) {
|
|
|
|
free(gNPPException);
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
gNPPException = nullptr;
|
2009-12-02 00:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-13 07:24:45 +03:00
|
|
|
//
|
|
|
|
// Static callbacks that get routed back through the new C++ API
|
|
|
|
//
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2009-12-02 00:27:13 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
namespace parent {
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2002-03-13 07:24:45 +03:00
|
|
|
_geturl(NPP npp, const char* relativeURL, const char* target)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_geturl called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
2002-03-13 07:24:45 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_GetURL: npp=%p, target=%s, url=%s\n", (void *)npp, target,
|
|
|
|
relativeURL));
|
2000-06-14 03:16:05 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
|
|
|
eNPPStreamTypeInternal_Get);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2005-03-23 03:34:39 +03:00
|
|
|
_geturlnotify(NPP npp, const char* relativeURL, const char* target,
|
|
|
|
void* notifyData)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_geturlnotify called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
2005-03-23 03:37:58 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_GetURLNotify: npp=%p, target=%s, notify=%p, url=%s\n", (void*)npp,
|
|
|
|
target, notifyData, relativeURL));
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
2011-09-30 10:02:59 +04:00
|
|
|
eNPPStreamTypeInternal_Get, true,
|
2008-09-15 16:45:01 +04:00
|
|
|
notifyData);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2001-09-08 05:04:03 +04:00
|
|
|
_posturlnotify(NPP npp, const char *relativeURL, const char *target,
|
2008-09-11 19:10:26 +04:00
|
|
|
uint32_t len, const char *buf, NPBool file, void *notifyData)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04: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 17:26:01 +03:00
|
|
|
if (!buf)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("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-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
2011-09-30 10:02:59 +04:00
|
|
|
eNPPStreamTypeInternal_Post, true,
|
2008-09-15 16:45:01 +04:00
|
|
|
notifyData, len, buf, file);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2001-09-08 05:04:03 +04:00
|
|
|
_posturl(NPP npp, const char *relativeURL, const char *target,
|
2008-09-11 19:10:26 +04:00
|
|
|
uint32_t len, const char *buf, NPBool file)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_posturl called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_PostURL: npp=%p, target=%s, file=%d, len=%d, url=%s, "
|
|
|
|
"buf=%s\n",
|
|
|
|
(void*)npp, target, file, len, relativeURL, buf));
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2009-12-02 00:27:13 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
|
|
|
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
|
2012-07-30 18:20:58 +04:00
|
|
|
eNPPStreamTypeInternal_Post, false, nullptr,
|
2009-12-02 00:27:13 +03:00
|
|
|
len, buf, file);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2005-03-23 03:14:13 +03:00
|
|
|
_newstream(NPP npp, NPMIMEType type, const char* target, NPStream* *result)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_newstream called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_NewStream: npp=%p, type=%s, target=%s\n", (void*)npp,
|
|
|
|
(const char *)type, target));
|
2001-05-23 02:32:45 +04:00
|
|
|
|
2002-09-19 00:21:47 +04:00
|
|
|
NPError err = NPERR_INVALID_INSTANCE_ERROR;
|
2005-03-23 03:34:39 +03:00
|
|
|
if (npp && npp->ndata) {
|
2011-05-18 05:48:34 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2008-02-29 05:06:00 +03:00
|
|
|
|
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2002-09-19 00:21:47 +04:00
|
|
|
nsCOMPtr<nsIOutputStream> stream;
|
2009-06-29 22:53:52 +04:00
|
|
|
if (NS_SUCCEEDED(inst->NewStreamFromPlugin((const char*) type, target,
|
|
|
|
getter_AddRefs(stream)))) {
|
2016-11-14 12:35:58 +03:00
|
|
|
auto* wrapper = new nsNPAPIStreamWrapper(stream, nullptr);
|
2002-09-19 00:21:47 +04:00
|
|
|
if (wrapper) {
|
2012-05-18 03:54:26 +04:00
|
|
|
(*result) = &wrapper->mNPStream;
|
2002-09-19 00:21:47 +04:00
|
|
|
err = NPERR_NO_ERROR;
|
|
|
|
} else {
|
|
|
|
err = NPERR_OUT_OF_MEMORY_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
err = NPERR_GENERIC_ERROR;
|
2001-08-16 06:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2002-09-19 00:21:47 +04:00
|
|
|
return err;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
int32_t
|
2008-09-11 19:10:26 +04:00
|
|
|
_write(NPP npp, NPStream *pstream, int32_t len, void *buffer)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_write called from the wrong thread\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_Write: npp=%p, url=%s, len=%d, buffer=%s\n", (void*)npp,
|
|
|
|
pstream->url, len, (char*)buffer));
|
2001-05-23 02:32:45 +04:00
|
|
|
|
2001-08-16 06:59:03 +04:00
|
|
|
// negative return indicates failure to the plugin
|
2005-03-23 03:34:39 +03:00
|
|
|
if (!npp)
|
2001-08-16 06:59:03 +04:00
|
|
|
return -1;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2012-05-18 03:54:26 +04:00
|
|
|
nsNPAPIStreamWrapper* wrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
if (!wrapper) {
|
2001-08-16 06:59:03 +04:00
|
|
|
return -1;
|
2012-05-18 03:54:26 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2012-05-18 03:54:26 +04:00
|
|
|
nsIOutputStream* stream = wrapper->GetOutputStream();
|
|
|
|
if (!stream) {
|
|
|
|
return -1;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = 0;
|
1999-07-08 00:18:27 +04:00
|
|
|
nsresult rv = stream->Write((char *)buffer, len, &count);
|
|
|
|
|
2012-05-18 03:54:26 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2001-08-16 06:59:03 +04:00
|
|
|
return -1;
|
2012-05-18 03:54:26 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-09-11 19:10:26 +04:00
|
|
|
return (int32_t)count;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2000-11-14 00:40:27 +03:00
|
|
|
_destroystream(NPP npp, NPStream *pstream, NPError reason)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
2015-07-17 10:17:09 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_destroystream called from the wrong thread\n"));
|
2008-03-30 19:23:21 +04:00
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2004-04-11 09:33:17 +04:00
|
|
|
("NPN_DestroyStream: npp=%p, url=%s, reason=%d\n", (void*)npp,
|
|
|
|
pstream->url, (int)reason));
|
2001-05-23 02:32:45 +04:00
|
|
|
|
2004-04-11 09:33:17 +04:00
|
|
|
if (!npp)
|
2001-08-16 06:59:03 +04:00
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2012-05-18 03:54:26 +04:00
|
|
|
nsNPAPIStreamWrapper *streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
if (!streamWrapper) {
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2012-05-19 08:33:24 +04:00
|
|
|
nsNPAPIPluginStreamListener *listener = streamWrapper->GetStreamListener();
|
2004-04-11 09:33:17 +04:00
|
|
|
if (listener) {
|
2012-05-19 08:33:24 +04: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 18:20:58 +04:00
|
|
|
listener->OnStopBinding(nullptr, NS_BINDING_ABORTED);
|
2004-04-11 09:33:17 +04:00
|
|
|
} else {
|
2012-05-19 08:33:24 +04: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.
|
2014-04-01 16:29:25 +04:00
|
|
|
//
|
2015-06-14 08:50:03 +03:00
|
|
|
// The NPStream the plugin references should always be a sub-object of its own
|
2012-05-19 08:33:24 +04:00
|
|
|
// 'ndata', which is our nsNPAPIStramWrapper. See bug 548441.
|
2014-04-01 16:29:25 +04:00
|
|
|
NS_ASSERTION((char*)streamWrapper <= (char*)pstream &&
|
2010-03-09 22:38:13 +03:00
|
|
|
((char*)pstream) + sizeof(*pstream)
|
2012-05-18 03:54:26 +04:00
|
|
|
<= ((char*)streamWrapper) + sizeof(*streamWrapper),
|
2010-03-09 22:38:13 +03:00
|
|
|
"pstream is not a subobject of wrapper");
|
2012-05-18 03:54:26 +04:00
|
|
|
delete streamWrapper;
|
2001-08-16 06:59:03 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2012-05-19 08:33:24 +04:00
|
|
|
// 'listener' and/or 'streamWrapper' may be invalid (deleted) at this point. Don't
|
|
|
|
// touch them again!
|
|
|
|
|
1999-07-08 00:18:27 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2000-11-14 00:40:27 +03:00
|
|
|
_status(NPP npp, const char *message)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2015-06-14 08:50:03 +03:00
|
|
|
// NPN_Status is no longer supported.
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2000-11-14 00:40:27 +03:00
|
|
|
_memfree (void *ptr)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_memfree called from the wrong thread\n"));
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemFree: ptr=%p\n", ptr));
|
|
|
|
|
2005-03-23 03:34:39 +03:00
|
|
|
if (ptr)
|
2015-03-27 03:01:12 +03:00
|
|
|
free(ptr);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
uint32_t
|
2008-09-11 19:10:26 +04:00
|
|
|
_memflush(uint32_t size)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_memflush called from the wrong thread\n"));
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemFlush: size=%d\n", size));
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2011-09-30 10:02:59 +04:00
|
|
|
nsMemory::HeapMinimize(true);
|
2001-08-16 06:59:03 +04:00
|
|
|
return 0;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2000-11-14 00:40:27 +03:00
|
|
|
_reloadplugins(NPBool reloadPages)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_reloadplugins called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2005-03-23 03:34:39 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPN_ReloadPlugins: reloadPages=%d\n", reloadPages));
|
2000-06-14 03:16:05 +04:00
|
|
|
|
2009-06-26 01:06:54 +04:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
if (!pluginHost)
|
2008-03-30 19:23:21 +04:00
|
|
|
return;
|
2000-06-14 03:16:05 +04:00
|
|
|
|
2013-04-24 00:02:12 +04:00
|
|
|
pluginHost->ReloadPlugins();
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2000-11-14 00:40:27 +03:00
|
|
|
_invalidaterect(NPP npp, NPRect *invalidRect)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invalidaterect called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_InvalidateRect: npp=%p, top=%d, left=%d, bottom=%d, "
|
|
|
|
"right=%d\n", (void *)npp, invalidRect->top,
|
|
|
|
invalidRect->left, invalidRect->bottom, invalidRect->right));
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2005-03-23 03:34:39 +03:00
|
|
|
if (!npp || !npp->ndata) {
|
2002-09-19 00:21:47 +04:00
|
|
|
NS_WARNING("_invalidaterect: npp or npp->ndata == 0");
|
2001-08-16 06:59:03 +04:00
|
|
|
return;
|
2002-09-19 00:21:47 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2011-05-18 05:48:34 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2009-09-17 05:30:26 +04:00
|
|
|
inst->InvalidateRect((NPRect *)invalidRect);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2000-11-14 00:40:27 +03:00
|
|
|
_invalidateregion(NPP npp, NPRegion invalidRegion)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invalidateregion called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2005-03-23 03:34:39 +03:00
|
|
|
("NPN_InvalidateRegion: npp=%p, region=%p\n", (void*)npp,
|
|
|
|
(void*)invalidRegion));
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2005-03-23 03:34:39 +03:00
|
|
|
if (!npp || !npp->ndata) {
|
2002-09-19 00:21:47 +04:00
|
|
|
NS_WARNING("_invalidateregion: npp or npp->ndata == 0");
|
2001-08-16 06:59:03 +04:00
|
|
|
return;
|
2002-09-19 00:21:47 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2011-05-18 05:48:34 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2009-09-17 05:30:26 +04:00
|
|
|
inst->InvalidateRegion((NPRegion)invalidRegion);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2000-11-14 00:40:27 +03:00
|
|
|
_forceredraw(NPP npp)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPObject*
|
2004-07-12 19:53:22 +04:00
|
|
|
_getwindowobject(NPP npp)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getwindowobject called from the wrong thread\n"));
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-03-30 19:23:21 +04:00
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2013-05-23 01:42:44 +04:00
|
|
|
// The window want to return here is the outer window, *not* the inner (since
|
2005-08-12 08:11:00 +04:00
|
|
|
// we don't know what the plugin will do with it).
|
2013-05-23 01:42:44 +04:00
|
|
|
nsIDocument* doc = GetDocumentFromNPP(npp);
|
|
|
|
NS_ENSURE_TRUE(doc, nullptr);
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> outer = doc->GetWindow();
|
2013-05-23 01:42:44 +04:00
|
|
|
NS_ENSURE_TRUE(outer, nullptr);
|
|
|
|
|
2016-08-11 15:39:23 +03:00
|
|
|
JS::Rooted<JSObject*> global(dom::RootingCx(),
|
2016-05-27 20:30:10 +03:00
|
|
|
nsGlobalWindow::Cast(outer)->GetGlobalJSObject());
|
|
|
|
return nsJSObjWrapper::GetNewOrUsed(npp, global);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPObject*
|
2004-07-12 19:53:22 +04:00
|
|
|
_getpluginelement(NPP npp)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getpluginelement called from the wrong thread\n"));
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-03-30 19:23:21 +04:00
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2009-09-10 22:11:30 +04:00
|
|
|
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(npp->ndata);
|
|
|
|
if (!inst)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
2009-09-10 22:11:30 +04:00
|
|
|
inst->GetDOMElement(getter_AddRefs(element));
|
|
|
|
|
|
|
|
if (!element)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2014-06-26 15:08:49 +04:00
|
|
|
nsIDocument *doc = GetDocumentFromNPP(npp);
|
|
|
|
if (NS_WARN_IF(!doc)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
dom::AutoJSAPI jsapi;
|
|
|
|
if (NS_WARN_IF(!jsapi.Init(doc->GetInnerWindow()))) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
JSContext* cx = jsapi.cx();
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(xpc, nullptr);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2015-07-01 21:17:17 +03:00
|
|
|
JS::RootedObject obj(cx);
|
2013-07-30 03:45:27 +04:00
|
|
|
xpc->WrapNative(cx, ::JS::CurrentGlobalOrNull(cx), element,
|
2015-07-01 21:17:17 +03:00
|
|
|
NS_GET_IID(nsIDOMElement), obj.address());
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(obj, nullptr);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2016-05-27 20:30:10 +03:00
|
|
|
return nsJSObjWrapper::GetNewOrUsed(npp, obj);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPIdentifier
|
2004-07-12 19:53:22 +04:00
|
|
|
_getstringidentifier(const NPUTF8* name)
|
|
|
|
{
|
2008-03-30 18:55:42 +04:00
|
|
|
if (!name) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifier: passed null name"));
|
2013-10-24 00:34:30 +04:00
|
|
|
return nullptr;
|
2008-03-30 18:55:42 +04:00
|
|
|
}
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2008-03-30 18:55:42 +04:00
|
|
|
|
2013-05-06 17:04:17 +04:00
|
|
|
AutoSafeJSContext cx;
|
2004-07-12 19:53:22 +04:00
|
|
|
return doGetIdentifier(cx, name);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2004-07-12 19:53:22 +04:00
|
|
|
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
|
|
|
NPIdentifier *identifiers)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifiers called from the wrong thread\n"));
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2013-05-06 17:04:17 +04:00
|
|
|
AutoSafeJSContext cx;
|
2006-06-13 02:39:55 +04:00
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
for (int32_t i = 0; i < nameCount; ++i) {
|
2008-03-30 18:55:42 +04:00
|
|
|
if (names[i]) {
|
|
|
|
identifiers[i] = doGetIdentifier(cx, names[i]);
|
|
|
|
} else {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS, ("NPN_getstringidentifiers: passed null name"));
|
2013-10-24 00:34:30 +04:00
|
|
|
identifiers[i] = nullptr;
|
2008-03-30 18:55:42 +04:00
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPIdentifier
|
2004-07-12 19:53:22 +04:00
|
|
|
_getintidentifier(int32_t intid)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getstringidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2010-07-15 10:19:36 +04:00
|
|
|
return IntToNPIdentifier(intid);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPUTF8*
|
2010-07-15 10:19:36 +04:00
|
|
|
_utf8fromidentifier(NPIdentifier id)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_utf8fromidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2010-07-15 10:19:36 +04:00
|
|
|
if (!id)
|
2013-10-24 00:34:30 +04:00
|
|
|
return nullptr;
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2010-07-15 10:19:36 +04:00
|
|
|
if (!NPIdentifierIsString(id)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2010-07-15 10:19:36 +04:00
|
|
|
JSString *str = NPIdentifierToString(id);
|
2014-07-12 11:43:06 +04:00
|
|
|
nsAutoString autoStr;
|
|
|
|
AssignJSFlatString(autoStr, JS_ASSERT_STRING_IS_FLAT(str));
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2014-07-12 11:43:06 +04:00
|
|
|
return ToNewUTF8String(autoStr);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
int32_t
|
2010-07-15 10:19:36 +04:00
|
|
|
_intfromidentifier(NPIdentifier id)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_intfromidentifier called from the wrong thread\n"));
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2010-07-15 10:19:36 +04:00
|
|
|
if (!NPIdentifierIsInt(id)) {
|
2012-09-28 10:57:33 +04:00
|
|
|
return INT32_MIN;
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2010-07-15 10:19:36 +04:00
|
|
|
return NPIdentifierToInt(id);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2010-07-15 10:19:36 +04:00
|
|
|
_identifierisstring(NPIdentifier id)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_identifierisstring called from the wrong thread\n"));
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2010-07-15 10:19:36 +04:00
|
|
|
return NPIdentifierIsString(id);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPObject*
|
2004-07-30 08:00:05 +04:00
|
|
|
_createobject(NPP npp, NPClass* aClass)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_createobject called from the wrong thread\n"));
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-03-30 19:23:21 +04:00
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp) {
|
|
|
|
NS_ERROR("Null npp passed to _createobject()!");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-07-30 08:00:05 +04:00
|
|
|
}
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
if (!aClass) {
|
|
|
|
NS_ERROR("Null class passed to _createobject()!");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2004-07-30 08:00:05 +04:00
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
NPObject *npobj;
|
|
|
|
|
|
|
|
if (aClass->allocate) {
|
2004-08-27 04:58:44 +04:00
|
|
|
npobj = aClass->allocate(npp, aClass);
|
2004-07-12 19:53:22 +04:00
|
|
|
} else {
|
|
|
|
npobj = (NPObject *)PR_Malloc(sizeof(NPObject));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (npobj) {
|
|
|
|
npobj->_class = aClass;
|
|
|
|
npobj->referenceCount = 1;
|
2009-11-13 01:16:54 +03:00
|
|
|
NS_LOG_ADDREF(npobj, 1, "BrowserNPObject", sizeof(NPObject));
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("Created NPObject %p, NPClass %p\n", npobj, aClass));
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
return npobj;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPObject*
|
2004-07-12 19:53:22 +04:00
|
|
|
_retainobject(NPObject* npobj)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_retainobject called from the wrong thread\n"));
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
if (npobj) {
|
2011-02-06 08:27:31 +03:00
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
2010-07-11 16:50:47 +04:00
|
|
|
int32_t refCnt =
|
|
|
|
#endif
|
2012-08-22 19:56:38 +04:00
|
|
|
PR_ATOMIC_INCREMENT((int32_t*)&npobj->referenceCount);
|
2009-11-13 01:16:54 +03:00
|
|
|
NS_LOG_ADDREF(npobj, refCnt, "BrowserNPObject", sizeof(NPObject));
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return npobj;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2004-07-12 19:53:22 +04:00
|
|
|
_releaseobject(NPObject* npobj)
|
|
|
|
{
|
2015-12-04 01:51:52 +03:00
|
|
|
// If nothing is passed, just return, even if we're on the wrong thread.
|
|
|
|
if (!npobj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS IS A KNOWN LEAK. SEE BUG 1221448.
|
|
|
|
// If releaseobject is called off the main thread and we have a valid pointer,
|
|
|
|
// we at least know it was created on the main thread (see _createobject
|
|
|
|
// implementation). However, forwarding the deletion back to the main thread
|
|
|
|
// without careful checking could cause bad memory management races. So, for
|
|
|
|
// now, we leak by warning and then just returning early. But it should fix
|
|
|
|
// java 7 crashes.
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_releaseobject called from the wrong thread\n"));
|
2004-07-12 19:53:22 +04:00
|
|
|
return;
|
2015-12-04 01:51:52 +03:00
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t refCnt = PR_ATOMIC_DECREMENT((int32_t*)&npobj->referenceCount);
|
2009-11-13 01:16:54 +03:00
|
|
|
NS_LOG_RELEASE(npobj, refCnt, "BrowserNPObject");
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
if (refCnt == 0) {
|
2007-08-10 02:22:26 +04:00
|
|
|
nsNPObjWrapper::OnDestroy(npobj);
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("Deleting NPObject %p, refcount hit 0\n", npobj));
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
if (npobj->_class && npobj->_class->deallocate) {
|
|
|
|
npobj->_class->deallocate(npobj);
|
|
|
|
} else {
|
|
|
|
PR_Free(npobj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-08-30 08:31:16 +04:00
|
|
|
_invoke(NPP npp, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invoke called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->invoke)
|
|
|
|
return false;
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2004-07-30 08:00:05 +04:00
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_Invoke(npp %p, npobj %p, method %p, args %d\n", npp,
|
|
|
|
npobj, method, argCount));
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
return npobj->_class->invoke(npobj, method, args, argCount, result);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-08-30 08:31:16 +04:00
|
|
|
_invokeDefault(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_invokedefault called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-08-30 08:31:16 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->invokeDefault)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_InvokeDefault(npp %p, npobj %p, args %d\n", npp,
|
|
|
|
npobj, argCount));
|
|
|
|
|
2004-08-30 08:31:16 +04:00
|
|
|
return npobj->_class->invokeDefault(npobj, args, argCount, result);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-07-12 19:53:22 +04:00
|
|
|
_evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_evaluate called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
|
|
|
|
2008-01-15 03:51:29 +03:00
|
|
|
nsIDocument *doc = GetDocumentFromNPP(npp);
|
|
|
|
NS_ENSURE_TRUE(doc, false);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* win = nsGlobalWindow::Cast(doc->GetInnerWindow());
|
2014-03-09 22:35:52 +04:00
|
|
|
if (NS_WARN_IF(!win || !win->FastGetGlobalJSObject())) {
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2015-07-09 09:41:43 +03:00
|
|
|
nsAutoMicroTask mt;
|
2015-04-09 04:23:48 +03:00
|
|
|
dom::AutoEntryScript aes(win, "NPAPI NPN_evaluate");
|
2014-07-28 12:27:23 +04:00
|
|
|
JSContext* cx = aes.cx();
|
2009-12-23 00:54:06 +03:00
|
|
|
|
2013-05-04 11:52:57 +04:00
|
|
|
JS::Rooted<JSObject*> obj(cx, nsNPObjWrapper::GetNewOrUsed(npp, cx, npobj));
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
if (!obj) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-06 21:03:51 +03:00
|
|
|
obj = js::ToWindowIfWindowProxy(obj);
|
|
|
|
MOZ_ASSERT(obj, "ToWindowIfWindowProxy should never return null");
|
2010-08-11 03:11:32 +04:00
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
if (result) {
|
|
|
|
// Initialize the out param to void
|
|
|
|
VOID_TO_NPVARIANT(*result);
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:48:42 +03:00
|
|
|
if (!script || !script->UTF8Length || !script->UTF8Characters) {
|
2004-07-12 19:53:22 +04:00
|
|
|
// Nothing to evaluate.
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:48:42 +03:00
|
|
|
NS_ConvertUTF8toUTF16 utf16script(script->UTF8Characters,
|
|
|
|
script->UTF8Length);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-01-15 03:51:29 +03:00
|
|
|
nsIPrincipal *principal = doc->NodePrincipal();
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString specStr;
|
2008-01-15 03:51:29 +03: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-29 10:19:26 +04:00
|
|
|
bool isChrome = false;
|
2008-01-15 03:51:29 +03:00
|
|
|
|
|
|
|
if (uri && NS_SUCCEEDED(uri->SchemeIs("chrome", &isChrome)) && isChrome) {
|
|
|
|
uri->GetSpec(specStr);
|
|
|
|
spec = specStr.get();
|
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
spec = nullptr;
|
2008-01-15 03:51:29 +03:00
|
|
|
}
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_Evaluate(npp %p, npobj %p, script <<<%s>>>) called\n",
|
2008-12-17 07:48:42 +03:00
|
|
|
npp, npobj, script->UTF8Characters));
|
2008-02-29 05:06:00 +03:00
|
|
|
|
2013-01-17 06:50:26 +04:00
|
|
|
JS::CompileOptions options(cx);
|
|
|
|
options.setFileAndLine(spec, 0)
|
|
|
|
.setVersion(JSVERSION_DEFAULT);
|
2014-01-23 23:49:40 +04:00
|
|
|
JS::Rooted<JS::Value> rval(cx);
|
2014-11-13 01:04:29 +03:00
|
|
|
nsJSUtils::EvaluateOptions evalOptions(cx);
|
|
|
|
if (obj != js::GetGlobalForObjectCrossCompartment(obj) &&
|
|
|
|
!evalOptions.scopeChain.append(obj)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
obj = js::GetGlobalForObjectCrossCompartment(obj);
|
2014-03-09 22:35:52 +04:00
|
|
|
nsresult rv = nsJSUtils::EvaluateString(cx, utf16script, obj, options,
|
2014-04-01 14:34:39 +04:00
|
|
|
evalOptions, &rval);
|
2006-08-04 00:39:45 +04:00
|
|
|
|
|
|
|
return NS_SUCCEEDED(rv) &&
|
2014-01-23 23:49:40 +04:00
|
|
|
(!result || JSValToNPVariant(npp, cx, rval, result));
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-07-30 08:00:05 +04:00
|
|
|
_getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
|
|
|
NPVariant *result)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->getProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_GetProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, property));
|
|
|
|
|
2010-11-19 23:58:59 +03: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;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
2010-11-19 23:58:59 +03:00
|
|
|
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 18:20:58 +04:00
|
|
|
NPObject* document_obj = nullptr;
|
2010-11-19 23:58:59 +03: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-29 10:19:26 +04:00
|
|
|
bool javaCompatible = false;
|
2010-11-19 23:58:59 +03:00
|
|
|
if (NS_FAILED(NS_CheckIsJavaCompatibleURLString(url, &javaCompatible)))
|
2011-09-30 10:02:59 +04:00
|
|
|
javaCompatible = false;
|
2010-11-19 23:58:59 +03: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;
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-07-30 08:00:05 +04:00
|
|
|
_setproperty(NPP npp, NPObject* npobj, NPIdentifier property,
|
2004-07-12 19:53:22 +04:00
|
|
|
const NPVariant *value)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->setProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_SetProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, property));
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
return npobj->_class->setProperty(npobj, property, value);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-07-30 08:00:05 +04:00
|
|
|
_removeproperty(NPP npp, NPObject* npobj, NPIdentifier property)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_removeproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->removeProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_RemoveProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, property));
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
return npobj->_class->removeProperty(npobj, property);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-07-30 08:00:05 +04:00
|
|
|
_hasproperty(NPP npp, NPObject* npobj, NPIdentifier propertyName)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_hasproperty called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->hasProperty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_HasProperty(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, propertyName));
|
|
|
|
|
2004-07-12 19:53:22 +04:00
|
|
|
return npobj->_class->hasProperty(npobj, propertyName);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2004-07-30 08:00:05 +04:00
|
|
|
_hasmethod(NPP npp, NPObject* npobj, NPIdentifier methodName)
|
2004-07-12 19:53:22 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_hasmethod called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
if (!npp || !npobj || !npobj->_class || !npobj->_class->hasMethod)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NPPExceptionAutoHolder nppExceptionHolder;
|
|
|
|
NPPAutoPusher nppPusher(npp);
|
2004-07-12 19:53:22 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_HasMethod(npp %p, npobj %p, property %p) called\n",
|
|
|
|
npp, npobj, methodName));
|
|
|
|
|
2009-01-15 23:20:10 +03:00
|
|
|
return npobj->_class->hasMethod(npobj, methodName);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2006-03-01 03:13:38 +03:00
|
|
|
_enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
|
|
|
|
uint32_t *count)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_enumerate called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2006-03-01 03:13:38 +03:00
|
|
|
if (!npp || !npobj || !npobj->_class)
|
|
|
|
return false;
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
|
|
|
("NPN_Enumerate(npp %p, npobj %p) called\n", npp, npobj));
|
|
|
|
|
2006-03-01 03:13:38 +03: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);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
bool
|
2007-10-10 05:24:28 +04:00
|
|
|
_construct(NPP npp, NPObject* npobj, const NPVariant *args,
|
|
|
|
uint32_t argCount, NPVariant *result)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_construct called from the wrong thread\n"));
|
|
|
|
return false;
|
|
|
|
}
|
2007-10-10 05:24:28 +04: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);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2004-07-12 19:53:22 +04:00
|
|
|
_releasevariantvalue(NPVariant* variant)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_releasevariantvalue called from the wrong thread\n"));
|
|
|
|
}
|
2004-07-12 19:53:22 +04: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-17 07:48:42 +03:00
|
|
|
if (s->UTF8Characters) {
|
2011-05-08 21:45:56 +04:00
|
|
|
#if defined(MOZ_MEMORY_WINDOWS)
|
2008-12-17 07:48:42 +03:00
|
|
|
if (malloc_usable_size((void *)s->UTF8Characters) != 0) {
|
|
|
|
PR_Free((void *)s->UTF8Characters);
|
2008-05-01 04:17:54 +04:00
|
|
|
} else {
|
2008-12-17 07:48:42 +03:00
|
|
|
void *p = (void *)s->UTF8Characters;
|
2008-05-01 04:17:54 +04:00
|
|
|
DWORD nheaps = 0;
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<HANDLE, 50> heaps;
|
2008-05-01 04:17:54 +04:00
|
|
|
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
|
2015-04-01 08:29:55 +03:00
|
|
|
free((void *)s->UTF8Characters);
|
2008-05-01 04:17:54 +04:00
|
|
|
#endif
|
|
|
|
}
|
2004-07-12 19:53:22 +04: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);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2004-07-12 19:53:22 +04:00
|
|
|
_setexception(NPObject* npobj, const NPUTF8 *message)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setexception called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-30 23:15:22 +03:00
|
|
|
if (!message) return;
|
|
|
|
|
2004-07-30 08:00:05 +04:00
|
|
|
if (gNPPException) {
|
|
|
|
// If a plugin throws multiple exceptions, we'll only report the
|
|
|
|
// last one for now.
|
|
|
|
free(gNPPException);
|
|
|
|
}
|
|
|
|
|
|
|
|
gNPPException = strdup(message);
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2000-11-14 00:40:27 +03:00
|
|
|
_getvalue(NPP npp, NPNVariable variable, void *result)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getvalue called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2005-03-23 03:34:39 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetValue: npp=%p, var=%d\n",
|
|
|
|
(void*)npp, (int)variable));
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2000-05-27 02:14:39 +04:00
|
|
|
nsresult res;
|
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(npp);
|
|
|
|
|
2014-10-09 08:28:00 +04:00
|
|
|
// Cast NPNVariable enum to int to avoid warnings about including switch
|
|
|
|
// cases for android_npapi.h's non-standard ANPInterface values.
|
|
|
|
switch (static_cast<int>(variable)) {
|
|
|
|
|
2002-11-06 04:24:57 +03:00
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
2001-09-22 04:18:55 +04:00
|
|
|
case NPNVxDisplay : {
|
2011-08-24 20:15:58 +04:00
|
|
|
#if defined(MOZ_X11)
|
2005-03-23 03:34:39 +03:00
|
|
|
if (npp) {
|
2008-09-15 16:45:01 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool windowless = false;
|
2009-09-17 05:30:26 +04:00
|
|
|
inst->IsWindowless(&windowless);
|
2012-03-02 10:17:26 +04: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-17 05:19:54 +04:00
|
|
|
if (!windowless) {
|
2012-03-02 10:17:26 +04:00
|
|
|
res = inst->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needsXEmbed);
|
2011-03-23 21:46:09 +03:00
|
|
|
// If the call returned an error code make sure we still use our default value.
|
|
|
|
if (NS_FAILED(res)) {
|
2012-03-02 10:17:26 +04:00
|
|
|
needsXEmbed = 0;
|
2011-03-23 21:46:09 +03:00
|
|
|
}
|
2008-07-17 05:19:54 +04:00
|
|
|
}
|
2012-03-02 10:17:26 +04:00
|
|
|
if (windowless || needsXEmbed) {
|
2010-06-22 00:35:49 +04:00
|
|
|
(*(Display **)result) = mozilla::DefaultXDisplay();
|
2003-09-16 05:44:41 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2013-09-23 17:21:35 +04:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2005-03-23 03:34:39 +03: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
|
2001-09-22 04:18:55 +04:00
|
|
|
static GtkWidget *gtkXtBinHolder = 0;
|
|
|
|
if (!gtkXtBinHolder) {
|
2009-04-06 15:30:55 +04:00
|
|
|
gtkXtBinHolder = gtk_xtbin_new(gdk_get_default_root_window(),0);
|
2001-09-22 04:18:55 +04: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 22:49:34 +04:00
|
|
|
#endif
|
2001-09-22 04:18:55 +04:00
|
|
|
#endif
|
2001-09-08 05:04:03 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2001-09-22 04:18:55 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2005-03-23 03:37:58 +03:00
|
|
|
case NPNVxtAppContext:
|
2001-09-08 05:04:03 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
#endif
|
|
|
|
|
2016-07-13 03:28:31 +03:00
|
|
|
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
2001-09-08 05:04:03 +04:00
|
|
|
case NPNVnetscapeWindow: {
|
2001-09-22 04:18:55 +04:00
|
|
|
if (!npp || !npp->ndata)
|
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2001-09-08 05:04:03 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
|
2012-07-20 15:16:17 +04:00
|
|
|
NS_ENSURE_TRUE(owner, NPERR_NO_ERROR);
|
2009-06-29 22:53:52 +04:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(owner->GetNetscapeWindow(result))) {
|
2002-09-19 00:21:47 +04:00
|
|
|
return NPERR_NO_ERROR;
|
2001-08-16 06:59:03 +04:00
|
|
|
}
|
2001-09-08 05:04:03 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-08 05:04:03 +04:00
|
|
|
case NPNVjavascriptEnabledBool: {
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = false;
|
2012-04-04 08:09:20 +04:00
|
|
|
bool js = false;
|
|
|
|
res = Preferences::GetBool("javascript.enabled", &js);
|
|
|
|
if (NS_SUCCEEDED(res)) {
|
|
|
|
*(NPBool*)result = js;
|
2000-05-27 02:14:39 +04:00
|
|
|
}
|
2001-09-08 05:04:03 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2000-05-27 02:14:39 +04:00
|
|
|
|
2005-03-23 03:37:58 +03:00
|
|
|
case NPNVasdEnabledBool:
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = false;
|
2000-05-27 02:14:39 +04:00
|
|
|
return NPERR_NO_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2004-08-30 17:25:28 +04:00
|
|
|
case NPNVisOfflineBool: {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool offline = false;
|
2005-03-23 03:34:39 +03:00
|
|
|
nsCOMPtr<nsIIOService> ioservice =
|
|
|
|
do_GetService(NS_IOSERVICE_CONTRACTID, &res);
|
2004-08-30 17:25:28 +04:00
|
|
|
if (NS_SUCCEEDED(res))
|
|
|
|
res = ioservice->GetOffline(&offline);
|
2004-08-30 17:52:20 +04:00
|
|
|
if (NS_FAILED(res))
|
2004-08-30 17:25:28 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2005-03-23 03:37:58 +03:00
|
|
|
*(NPBool*)result = offline;
|
2000-05-27 02:14:39 +04:00
|
|
|
return NPERR_NO_ERROR;
|
2004-08-30 17:25:28 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2003-09-16 05:44:41 +04:00
|
|
|
case NPNVToolkit: {
|
2012-06-28 04:15:32 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2003-09-16 05:44:41 +04:00
|
|
|
*((NPNToolkitType*)result) = NPNVGtk2;
|
|
|
|
#endif
|
|
|
|
|
2006-06-25 11:34:52 +04:00
|
|
|
if (*(NPNToolkitType*)result)
|
2003-09-16 05:44:41 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVSupportsXEmbedBool: {
|
2012-06-28 04:15:32 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = true;
|
2003-09-16 05:44:41 +04:00
|
|
|
#else
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = false;
|
2003-09-16 05:44:41 +04:00
|
|
|
#endif
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2004-07-12 19:53:22 +04:00
|
|
|
|
|
|
|
case NPNVWindowNPObject: {
|
|
|
|
*(NPObject **)result = _getwindowobject(npp);
|
|
|
|
|
2009-12-02 02:08:16 +03:00
|
|
|
return *(NPObject **)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case NPNVPluginElementNPObject: {
|
|
|
|
*(NPObject **)result = _getpluginelement(npp);
|
|
|
|
|
2010-02-02 17:46:25 +03:00
|
|
|
return *(NPObject **)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
2004-07-12 19:53:22 +04:00
|
|
|
}
|
|
|
|
|
2007-09-06 05:45:08 +04:00
|
|
|
case NPNVSupportsWindowless: {
|
2010-04-20 22:49:34 +04:00
|
|
|
#if defined(XP_WIN) || defined(XP_MACOSX) || \
|
2016-07-13 03:28:31 +03:00
|
|
|
(defined(MOZ_X11) && defined(MOZ_WIDGET_GTK))
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = true;
|
2007-09-06 05:45:08 +04:00
|
|
|
#else
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = false;
|
2007-09-06 05:45:08 +04:00
|
|
|
#endif
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-01-31 00:40:14 +03:00
|
|
|
case NPNVprivateModeBool: {
|
2012-10-30 00:20:03 +04:00
|
|
|
bool privacy;
|
2013-03-04 22:18:20 +04:00
|
|
|
nsNPAPIPluginInstance *inst = static_cast<nsNPAPIPluginInstance*>(npp->ndata);
|
|
|
|
if (!inst)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
nsresult rv = inst->IsPrivateBrowsing(&privacy);
|
2012-10-30 00:20:03 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
*(NPBool*)result = (NPBool)privacy;
|
|
|
|
return NPERR_NO_ERROR;
|
2009-01-31 00:40:14 +03:00
|
|
|
}
|
|
|
|
|
2011-09-14 20:22:27 +04: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;
|
|
|
|
}
|
|
|
|
|
2016-10-03 15:43:47 +03:00
|
|
|
nsCOMPtr<nsIIDNService> idnService = do_GetService(NS_IDNSERVICE_CONTRACTID);
|
|
|
|
if (!idnService) {
|
2011-09-14 20:22:27 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2016-10-03 15:43:47 +03:00
|
|
|
// This is a bit messy: we convert to UTF-8 here, but then
|
|
|
|
// nsIDNService::Normalize will convert back to UTF-16 for processing,
|
|
|
|
// and back to UTF-8 again to return the result.
|
|
|
|
// Alternative: perhaps we should add a NormalizeUTF16 version of the API,
|
|
|
|
// and just convert to UTF-8 for the final return (resulting in one
|
|
|
|
// encoding form conversion instead of three).
|
|
|
|
NS_ConvertUTF16toUTF8 utf8Origin(utf16Origin);
|
|
|
|
nsAutoCString normalizedUTF8Origin;
|
|
|
|
res = idnService->Normalize(utf8Origin, normalizedUTF8Origin);
|
2011-09-14 20:22:27 +04:00
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2016-10-03 15:43:47 +03:00
|
|
|
*(char**)result = ToNewCString(normalizedUTF8Origin);
|
2011-09-14 20:22:27 +04:00
|
|
|
return *(char**)result ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-03-27 05:07:57 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case NPNVpluginDrawingModel: {
|
|
|
|
if (npp) {
|
2008-09-15 16:45:01 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2007-03-27 05:07:57 +04:00
|
|
|
if (inst) {
|
2009-09-17 05:30:26 +04:00
|
|
|
NPDrawingModel drawingModel;
|
2012-08-22 19:56:38 +04:00
|
|
|
inst->GetDrawingModel((int32_t*)&drawingModel);
|
2009-09-17 05:30:26 +04:00
|
|
|
*(NPDrawingModel*)result = drawingModel;
|
2007-03-27 05:07:57 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2015-10-07 07:20:20 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2007-03-27 05:07:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef NP_NO_QUICKDRAW
|
|
|
|
case NPNVsupportsQuickDrawBool: {
|
2012-08-30 23:10:55 +04:00
|
|
|
*(NPBool*)result = false;
|
2014-09-03 22:25:56 +04:00
|
|
|
|
2007-03-27 05:07:57 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case NPNVsupportsCoreGraphicsBool: {
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = true;
|
2014-09-03 22:25:56 +04:00
|
|
|
|
2009-08-27 04:29:47 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-07-31 21:37:06 +04:00
|
|
|
case NPNVsupportsCoreAnimationBool: {
|
2014-12-11 17:44:07 +03:00
|
|
|
*(NPBool*)result = true;
|
2010-03-24 03:51:11 +03:00
|
|
|
|
2011-07-31 21:37:06 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2010-03-24 03:51:11 +03:00
|
|
|
|
2011-07-31 21:37:06 +04:00
|
|
|
case NPNVsupportsInvalidatingCoreAnimationBool: {
|
2014-12-11 17:44:07 +03:00
|
|
|
*(NPBool*)result = true;
|
2010-06-09 08:11:48 +04:00
|
|
|
|
2011-07-31 21:37:06 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2010-06-09 08:11:48 +04:00
|
|
|
|
2011-07-31 21:37:06 +04:00
|
|
|
case NPNVsupportsCompositingCoreAnimationPluginsBool: {
|
|
|
|
*(NPBool*)result = PR_TRUE;
|
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2010-03-24 03:51:11 +03:00
|
|
|
|
2009-08-27 04:29:47 +04:00
|
|
|
#ifndef NP_NO_CARBON
|
|
|
|
case NPNVsupportsCarbonBool: {
|
2012-10-15 16:38:34 +04:00
|
|
|
*(NPBool*)result = false;
|
2009-08-27 04:29:47 +04:00
|
|
|
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
case NPNVsupportsCocoaBool: {
|
2011-09-30 10:02:59 +04:00
|
|
|
*(NPBool*)result = true;
|
2009-08-27 04:29:47 +04:00
|
|
|
|
2007-03-27 05:07:57 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2011-01-21 04:08:11 +03:00
|
|
|
|
|
|
|
case NPNVsupportsUpdatedCocoaTextInputBool: {
|
|
|
|
*(NPBool*)result = true;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2015-09-17 23:31:34 +03:00
|
|
|
#endif
|
2012-10-02 23:48:05 +04:00
|
|
|
|
2015-09-17 23:31:34 +03:00
|
|
|
#if defined(XP_MACOSX) || defined(XP_WIN)
|
2012-10-02 23:48:05 +04:00
|
|
|
case NPNVcontentsScaleFactor: {
|
|
|
|
nsNPAPIPluginInstance *inst =
|
|
|
|
(nsNPAPIPluginInstance *) (npp ? npp->ndata : nullptr);
|
|
|
|
double scaleFactor = inst ? inst->GetContentsScaleFactor() : 1.0;
|
|
|
|
*(double*)result = scaleFactor;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2007-03-27 05:07:57 +04:00
|
|
|
#endif
|
|
|
|
|
2016-03-17 22:00:59 +03:00
|
|
|
case NPNVCSSZoomFactor: {
|
|
|
|
nsNPAPIPluginInstance *inst =
|
|
|
|
(nsNPAPIPluginInstance *) (npp ? npp->ndata : nullptr);
|
|
|
|
double scaleFactor = inst ? inst->GetCSSZoomFactor() : 1.0;
|
|
|
|
*(double*)result = scaleFactor;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-17 01:34:31 +04: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");
|
2016-03-11 23:07:26 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2011-09-17 01:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case kMatrixInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get matrix interface");
|
2016-03-11 23:07:26 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2011-09-17 01:34:31 +04:00
|
|
|
}
|
2014-09-03 22:25:56 +04:00
|
|
|
|
2011-09-17 01:34:31 +04:00
|
|
|
case kPathInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get path interface");
|
2016-03-11 23:07:26 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2011-09-17 01:34:31 +04:00
|
|
|
}
|
2014-09-03 22:25:56 +04:00
|
|
|
|
2011-09-17 01:34:31 +04:00
|
|
|
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 18:40:58 +04:00
|
|
|
InitAudioTrackInterfaceV0(i);
|
2011-09-17 01:34:31 +04: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");
|
2016-03-11 23:07:26 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2011-09-17 01:34:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case kSurfaceInterfaceV0_ANPGetValue: {
|
|
|
|
LOG("get surface interface");
|
|
|
|
ANPSurfaceInterfaceV0 *i = (ANPSurfaceInterfaceV0 *) result;
|
|
|
|
InitSurfaceInterface(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2014-09-03 22:25:56 +04:00
|
|
|
|
2011-09-17 01:34:31 +04:00
|
|
|
case kSupportedDrawingModel_ANPGetValue: {
|
|
|
|
LOG("get supported drawing model");
|
2016-03-11 23:07:26 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2014-04-01 16:29:25 +04:00
|
|
|
}
|
2011-09-17 01:34:31 +04:00
|
|
|
|
|
|
|
case kJavaContext_ANPGetValue: {
|
2016-03-11 23:07:26 +03:00
|
|
|
LOG("get java context");
|
2016-07-21 20:49:04 +03:00
|
|
|
auto ret = java::GeckoAppShell::GetContext();
|
2013-05-28 20:49:04 +04:00
|
|
|
if (!ret)
|
2012-01-30 00:39:30 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2015-01-10 03:33:57 +03:00
|
|
|
*static_cast<jobject*>(result) = ret.Forget();
|
2011-09-17 01:34:31 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2012-01-31 18:40:58 +04: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");
|
2016-03-03 18:30:53 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-01-31 18:40:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case kWindowInterfaceV1_ANPGetValue: {
|
|
|
|
LOG("get Window interface V1");
|
2016-03-11 23:07:26 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-01-31 18:40:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case kWindowInterfaceV2_ANPGetValue: {
|
|
|
|
LOG("get Window interface V2");
|
|
|
|
ANPWindowInterfaceV2 *i = (ANPWindowInterfaceV2 *) result;
|
|
|
|
InitWindowInterfaceV2(i);
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kVideoInterfaceV0_ANPGetValue: {
|
2016-03-11 23:07:26 +03:00
|
|
|
LOG("get video interface V0");
|
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-01-31 18:40:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case kVideoInterfaceV1_ANPGetValue: {
|
2016-03-11 23:07:26 +03:00
|
|
|
LOG("get video interface V1");
|
2012-01-31 18:40:58 +04:00
|
|
|
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-17 01:34:31 +04:00
|
|
|
#endif
|
|
|
|
|
2011-05-08 21:45:56 +04:00
|
|
|
// we no longer hand out any XPCOM objects
|
2009-11-30 13:11:20 +03:00
|
|
|
case NPNVDOMElement:
|
|
|
|
case NPNVDOMWindow:
|
|
|
|
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 18:20:58 +04:00
|
|
|
*(nsISupports**)result = nullptr;
|
2015-10-07 07:20:20 +03:00
|
|
|
MOZ_FALLTHROUGH;
|
|
|
|
|
2008-08-14 16:47:04 +04:00
|
|
|
default:
|
2011-09-17 01:34:31 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_getvalue unhandled get value: %d\n", variable));
|
2008-08-14 16:47:04 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2000-11-14 00:40:27 +03:00
|
|
|
_setvalue(NPP npp, NPPVariable variable, void *result)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setvalue called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2005-03-23 03:34:39 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_SetValue: npp=%p, var=%d\n",
|
|
|
|
(void*)npp, (int)variable));
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2005-03-23 03:34:39 +03:00
|
|
|
if (!npp)
|
2001-08-16 06:59:03 +04:00
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2008-11-03 22:23:07 +03:00
|
|
|
NS_ASSERTION(inst, "null instance");
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-11-03 22:23:07 +03:00
|
|
|
if (!inst)
|
2001-08-16 06:59:03 +04:00
|
|
|
return NPERR_INVALID_INSTANCE_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-02-29 05:06:00 +03:00
|
|
|
PluginDestructionGuard guard(inst);
|
|
|
|
|
2014-10-09 08:28:00 +04:00
|
|
|
// Cast NPNVariable enum to int to avoid warnings about including switch
|
|
|
|
// cases for android_npapi.h's non-standard ANPInterface values.
|
|
|
|
switch (static_cast<int>(variable)) {
|
2001-11-07 02:45:01 +03:00
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
// we should keep backward compatibility with NPAPI where the
|
2001-11-07 02:45:01 +03:00
|
|
|
// actual pointer value is checked rather than its content
|
2007-03-20 05:35:56 +03:00
|
|
|
// when passing booleans
|
2001-09-08 05:04:03 +04:00
|
|
|
case NPPVpluginWindowBool: {
|
2008-12-09 20:22:51 +03: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 18:20:58 +04:00
|
|
|
NPBool bWindowless = (result == nullptr);
|
2001-08-16 06:59:03 +04:00
|
|
|
return inst->SetWindowless(bWindowless);
|
2008-12-09 20:22:51 +03:00
|
|
|
#endif
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
2001-11-07 02:45:01 +03:00
|
|
|
case NPPVpluginTransparentBool: {
|
2012-07-30 18:20:58 +04:00
|
|
|
NPBool bTransparent = (result != nullptr);
|
2001-11-07 02:45:01 +03:00
|
|
|
return inst->SetTransparent(bTransparent);
|
2002-01-31 04:32:43 +03:00
|
|
|
}
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2013-04-11 15:48:10 +04:00
|
|
|
case NPPVjavascriptPushCallerBool: {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2002-03-26 02:42:32 +03:00
|
|
|
case NPPVpluginKeepLibraryInMemory: {
|
2012-07-30 18:20:58 +04:00
|
|
|
NPBool bCached = (result != nullptr);
|
2012-08-14 13:10:42 +04:00
|
|
|
inst->SetCached(bCached);
|
|
|
|
return NPERR_NO_ERROR;
|
2002-03-26 02:42:32 +03:00
|
|
|
}
|
2008-08-05 01:17:55 +04:00
|
|
|
|
2011-04-08 23:58:04 +04:00
|
|
|
case NPPVpluginUsesDOMForCursorBool: {
|
2012-07-30 18:20:58 +04:00
|
|
|
bool useDOMForCursor = (result != nullptr);
|
2011-04-08 23:58:04 +04:00
|
|
|
return inst->SetUsesDOMForCursor(useDOMForCursor);
|
|
|
|
}
|
|
|
|
|
2015-07-28 23:59:26 +03:00
|
|
|
case NPPVpluginIsPlayingAudio: {
|
2015-07-29 00:09:48 +03:00
|
|
|
bool isMuted = !result;
|
|
|
|
|
|
|
|
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*) npp->ndata;
|
|
|
|
MOZ_ASSERT(inst);
|
|
|
|
|
|
|
|
if (isMuted && !inst->HasAudioChannelAgent()) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> agent;
|
|
|
|
nsresult rv = inst->GetOrCreateAudioChannelAgent(getter_AddRefs(agent));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(agent);
|
|
|
|
|
|
|
|
if (isMuted) {
|
2015-10-07 22:06:47 +03:00
|
|
|
rv = agent->NotifyStoppedPlaying();
|
2015-07-29 00:09:48 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
2016-05-03 04:52:44 +03:00
|
|
|
|
|
|
|
dom::AudioPlaybackConfig config;
|
2016-05-03 12:59:32 +03:00
|
|
|
rv = agent->NotifyStartedPlaying(&config,
|
|
|
|
dom::AudioChannelService::AudibleState::eAudible);
|
2016-05-03 04:52:44 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = inst->WindowVolumeChanged(config.mVolume, config.mMuted);
|
2015-07-29 00:09:48 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2016-05-31 05:17:47 +03:00
|
|
|
// Since we only support for muting now, the implementation of suspend
|
|
|
|
// is equal to muting. Therefore, if we have already muted the plugin,
|
|
|
|
// then we don't need to call WindowSuspendChanged() again.
|
|
|
|
if (config.mMuted) {
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2016-05-03 04:52:44 +03:00
|
|
|
rv = inst->WindowSuspendChanged(config.mSuspend);
|
2015-07-29 00:09:48 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return NPERR_NO_ERROR;
|
2015-07-28 23:59:26 +03:00
|
|
|
}
|
|
|
|
}
|
2015-07-29 00:09:48 +03:00
|
|
|
|
2015-07-28 23:59:26 +03:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-02-16 07:24:38 +04:00
|
|
|
#ifndef MOZ_WIDGET_ANDROID
|
|
|
|
// On android, their 'drawing model' uses the same constant!
|
2007-11-13 23:02:03 +03:00
|
|
|
case NPPVpluginDrawingModel: {
|
2007-03-27 05:07:57 +04:00
|
|
|
if (inst) {
|
2009-08-13 02:32:41 +04:00
|
|
|
inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result));
|
2007-03-27 05:07:57 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2012-02-16 07:24:38 +04:00
|
|
|
#endif
|
2009-08-27 04:29:47 +04:00
|
|
|
|
2012-02-16 07:24:38 +04:00
|
|
|
#ifdef XP_MACOSX
|
2009-08-27 04:29:47 +04:00
|
|
|
case NPPVpluginEventModel: {
|
|
|
|
if (inst) {
|
|
|
|
inst->SetEventModel((NPEventModel)NS_PTR_TO_INT32(result));
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 05:07:57 +04:00
|
|
|
#endif
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-17 01:34:31 +04:00
|
|
|
case kRequestDrawingModel_ANPSetValue:
|
|
|
|
if (inst)
|
2012-01-18 02:45:06 +04:00
|
|
|
inst->SetANPDrawingModel(NS_PTR_TO_INT32(result));
|
2011-09-17 01:34:31 +04:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
case kAcceptEvents_ANPSetValue:
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
#endif
|
2001-09-08 05:04:03 +04:00
|
|
|
default:
|
2009-03-18 00:20:24 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2001-08-16 06:59:03 +04:00
|
|
|
}
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2000-11-14 00:40:27 +03:00
|
|
|
_requestread(NPStream *pstream, NPByteRange *rangeList)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_requestread called from the wrong thread\n"));
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
2005-03-23 03:34:39 +03:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_RequestRead: stream=%p\n",
|
|
|
|
(void*)pstream));
|
2001-08-16 06:59:03 +04:00
|
|
|
|
2005-04-29 16:11:45 +04:00
|
|
|
#ifdef PLUGIN_LOGGING
|
2012-07-30 18:20:58 +04:00
|
|
|
for(NPByteRange * range = rangeList; range != nullptr; range = range->next)
|
2015-05-21 23:22:04 +03:00
|
|
|
MOZ_LOG(nsPluginLogging::gNPNLog,PLUGIN_LOG_NOISY,
|
2001-08-16 06:59:03 +04:00
|
|
|
("%i-%i", range->offset, range->offset + range->length - 1));
|
2001-05-23 02:32:45 +04:00
|
|
|
|
2015-05-21 23:22:04 +03:00
|
|
|
MOZ_LOG(nsPluginLogging::gNPNLog,PLUGIN_LOG_NOISY, ("\n\n"));
|
2001-08-16 06:59:03 +04:00
|
|
|
PR_LogFlush();
|
|
|
|
#endif
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2005-03-23 03:34:39 +03:00
|
|
|
if (!pstream || !rangeList || !pstream->ndata)
|
2001-05-23 02:32:45 +04:00
|
|
|
return NPERR_INVALID_PARAM;
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2012-05-18 03:54:26 +04:00
|
|
|
nsNPAPIStreamWrapper* streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
|
|
|
|
nsNPAPIPluginStreamListener* streamlistener = streamWrapper->GetStreamListener();
|
|
|
|
if (!streamlistener) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
2005-03-23 03:34:39 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t streamtype = NP_NORMAL;
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2001-05-23 02:32:45 +04:00
|
|
|
streamlistener->GetStreamType(&streamtype);
|
2005-03-23 03:34:39 +03:00
|
|
|
|
2009-09-17 05:30:26 +04:00
|
|
|
if (streamtype != NP_SEEK)
|
1999-07-08 00:18:27 +04:00
|
|
|
return NPERR_STREAM_NOT_SEEKABLE;
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2012-06-05 17:58:39 +04:00
|
|
|
if (!streamlistener->mStreamListenerPeer)
|
2010-02-24 05:58:27 +03:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2012-06-05 17:58:39 +04:00
|
|
|
nsresult rv = streamlistener->mStreamListenerPeer->RequestRead((NPByteRange *)rangeList);
|
2010-02-24 05:58:27 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
2005-03-23 03:37:58 +03:00
|
|
|
|
2012-08-07 19:11:35 +04:00
|
|
|
return NPERR_NO_ERROR;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2008-07-12 01:28:12 +04:00
|
|
|
// Deprecated, only stubbed out
|
2014-02-11 02:57:01 +04:00
|
|
|
void* /* OJI type: JRIEnv* */
|
2010-02-01 00:41:26 +03:00
|
|
|
_getJavaEnv()
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaEnv\n"));
|
2013-10-24 00:34:30 +04:00
|
|
|
return nullptr;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
const char *
|
2000-11-14 00:40:27 +03:00
|
|
|
_useragent(NPP npp)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_useragent called from the wrong thread\n"));
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-03-30 19:23:21 +04:00
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_UserAgent: npp=%p\n", (void*)npp));
|
|
|
|
|
2011-05-21 17:28:54 +04:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
|
|
|
|
if (!pluginHost) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-05-21 17:28:54 +04:00
|
|
|
}
|
2004-04-11 09:33:17 +04:00
|
|
|
|
2008-03-30 19:23:21 +04:00
|
|
|
const char *retstr;
|
2009-06-26 01:06:54 +04:00
|
|
|
nsresult rv = pluginHost->UserAgent(&retstr);
|
2008-03-30 19:23:21 +04:00
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-04-11 09:33:17 +04:00
|
|
|
|
2000-06-14 03:16:05 +04:00
|
|
|
return retstr;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void *
|
2008-09-11 19:10:26 +04:00
|
|
|
_memalloc (uint32_t size)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,("NPN_memalloc called from the wrong thread\n"));
|
|
|
|
}
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemAlloc: size=%d\n", size));
|
2015-03-27 03:01:12 +03:00
|
|
|
return moz_xmalloc(size);
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2008-07-12 01:28:12 +04:00
|
|
|
// Deprecated, only stubbed out
|
2014-02-11 02:57:01 +04:00
|
|
|
void* /* OJI type: jref */
|
2000-11-14 00:40:27 +03:00
|
|
|
_getJavaPeer(NPP npp)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2001-08-16 06:59:03 +04:00
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaPeer: npp=%p\n", (void*)npp));
|
2013-10-24 00:34:30 +04:00
|
|
|
return nullptr;
|
2001-08-16 06:59:03 +04:00
|
|
|
}
|
2003-03-25 09:54:52 +03:00
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2005-06-18 10:06:45 +04:00
|
|
|
_pushpopupsenabledstate(NPP npp, NPBool enabled)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_pushpopupsenabledstate called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2013-10-24 00:34:30 +04:00
|
|
|
nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : nullptr;
|
2005-06-18 10:06:45 +04:00
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->PushPopupsEnabledState(enabled);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2005-06-18 10:06:45 +04:00
|
|
|
_poppopupsenabledstate(NPP npp)
|
|
|
|
{
|
2008-03-30 19:23:21 +04:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_poppopupsenabledstate called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
2013-10-24 00:34:30 +04:00
|
|
|
nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : nullptr;
|
2005-06-18 10:06:45 +04:00
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->PopPopupsEnabledState();
|
|
|
|
}
|
2004-07-30 08:00:05 +04:00
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2007-07-13 00:38:11 +04:00
|
|
|
_pluginthreadasynccall(NPP instance, PluginThreadCallback func, void *userData)
|
2007-07-12 03:25:45 +04:00
|
|
|
{
|
2008-03-30 19:23:21 +04: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"));
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginThreadRunnable> evt =
|
2007-07-12 03:25:45 +04:00
|
|
|
new nsPluginThreadRunnable(instance, func, userData);
|
|
|
|
|
|
|
|
if (evt && evt->IsValid()) {
|
|
|
|
NS_DispatchToMainThread(evt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2009-01-13 03:55:52 +03:00
|
|
|
_getvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
|
|
|
char **value, uint32_t *len)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getvalueforurl called from the wrong thread\n"));
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-01-13 03:55:52 +03:00
|
|
|
if (!instance) {
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!url || !*url || !len) {
|
|
|
|
return NPERR_INVALID_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
|
|
|
|
switch (variable) {
|
|
|
|
case NPNURLVProxy:
|
|
|
|
{
|
2011-05-21 17:28:54 +04:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
|
2009-06-26 01:06:54 +04:00
|
|
|
if (pluginHost && NS_SUCCEEDED(pluginHost->FindProxyForURL(url, value))) {
|
2013-05-08 07:40:12 +04:00
|
|
|
*len = *value ? strlen(*value) : 0;
|
2009-01-13 03:55:52 +03:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NPNURLVCookie:
|
2017-01-27 19:03:41 +03:00
|
|
|
// NPNURLVCookie is no longer supported.
|
|
|
|
*value = nullptr;
|
|
|
|
return NPERR_GENERIC_ERROR;
|
2009-01-13 03:55:52 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
// Fall through and return an error...
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2009-01-13 03:55:52 +03:00
|
|
|
_setvalueforurl(NPP instance, NPNURLVariable variable, const char *url,
|
|
|
|
const char *value, uint32_t len)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_setvalueforurl called from the wrong thread\n"));
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-01-13 03:55:52 +03:00
|
|
|
if (!instance) {
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!url || !*url) {
|
|
|
|
return NPERR_INVALID_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (variable) {
|
|
|
|
case NPNURLVCookie:
|
2017-01-27 19:03:41 +03:00
|
|
|
// NPNURLVCookie is no longer supported.
|
|
|
|
return NPERR_GENERIC_ERROR;
|
2009-01-13 03:55:52 +03:00
|
|
|
|
|
|
|
case NPNURLVProxy:
|
|
|
|
// We don't support setting proxy values, fall through...
|
|
|
|
default:
|
|
|
|
// Fall through and return an error...
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2009-01-13 03:55:52 +03:00
|
|
|
_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)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getauthenticationinfo called from the wrong thread\n"));
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-01-13 03:55:52 +03:00
|
|
|
if (!instance || !protocol || !host || !scheme || !realm || !username ||
|
|
|
|
!ulen || !password || !plen)
|
|
|
|
return NPERR_INVALID_PARAM;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*username = nullptr;
|
|
|
|
*password = nullptr;
|
2009-01-13 03:55:52 +03: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;
|
|
|
|
|
2013-03-04 22:18:20 +04:00
|
|
|
nsNPAPIPluginInstance *inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
|
|
|
|
if (!inst)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2012-10-30 00:20:03 +04:00
|
|
|
bool authPrivate = false;
|
2013-03-04 22:18:20 +04:00
|
|
|
if (NS_FAILED(inst->IsPrivateBrowsing(&authPrivate)))
|
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-10-30 00:20:03 +04:00
|
|
|
|
2012-12-05 11:33:20 +04:00
|
|
|
nsIDocument *doc = GetDocumentFromNPP(instance);
|
|
|
|
NS_ENSURE_TRUE(doc, NPERR_GENERIC_ERROR);
|
|
|
|
nsIPrincipal *principal = doc->NodePrincipal();
|
|
|
|
|
2009-01-13 03:55:52 +03:00
|
|
|
nsAutoString unused, uname16, pwd16;
|
|
|
|
if (NS_FAILED(authManager->GetAuthIdentity(proto, nsDependentCString(host),
|
|
|
|
port, nsDependentCString(scheme),
|
|
|
|
nsDependentCString(realm),
|
|
|
|
EmptyCString(), unused, uname16,
|
2012-12-05 11:33:20 +04:00
|
|
|
pwd16, authPrivate, principal))) {
|
2009-01-13 03:55:52 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
uint32_t
|
2009-12-02 00:27:13 +03:00
|
|
|
_scheduletimer(NPP instance, uint32_t interval, NPBool repeat, PluginTimerFunc timerFunc)
|
2009-07-01 19:09:49 +04:00
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_scheduletimer called from the wrong thread\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return inst->ScheduleTimer(interval, repeat, timerFunc);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2009-07-01 19:09:49 +04:00
|
|
|
_unscheduletimer(NPP instance, uint32_t timerID)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_unscheduletimer called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:16:26 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// Sometimes Flash calls this with a dead NPP instance. Ensure the one we have
|
|
|
|
// here is valid and maps to a nsNPAPIPluginInstance.
|
|
|
|
nsNPAPIPluginInstance *inst = nsNPAPIPluginInstance::GetFromNPP(instance);
|
|
|
|
#else
|
2009-07-01 19:09:49 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
2013-01-23 18:16:26 +04:00
|
|
|
#endif
|
2009-07-01 19:09:49 +04:00
|
|
|
if (!inst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
inst->UnscheduleTimer(timerID);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPError
|
2009-08-27 04:29:47 +04:00
|
|
|
_popupcontextmenu(NPP instance, NPMenu* menu)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_popupcontextmenu called from the wrong thread\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-11 17:44:07 +03:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
2009-08-27 04:29:47 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
2014-12-11 17:44:07 +03:00
|
|
|
|
|
|
|
double pluginX, pluginY;
|
|
|
|
double screenX, screenY;
|
|
|
|
|
|
|
|
const NPCocoaEvent* currentEvent = static_cast<NPCocoaEvent*>(inst->GetCurrentEvent());
|
|
|
|
if (!currentEvent) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that the events has an x/y value.
|
|
|
|
if (currentEvent->type != NPCocoaEventMouseDown &&
|
|
|
|
currentEvent->type != NPCocoaEventMouseUp &&
|
|
|
|
currentEvent->type != NPCocoaEventMouseMoved &&
|
|
|
|
currentEvent->type != NPCocoaEventMouseEntered &&
|
|
|
|
currentEvent->type != NPCocoaEventMouseExited &&
|
|
|
|
currentEvent->type != NPCocoaEventMouseDragged) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
pluginX = currentEvent->data.mouse.pluginX;
|
|
|
|
pluginY = currentEvent->data.mouse.pluginY;
|
|
|
|
|
|
|
|
if ((pluginX < 0.0) || (pluginY < 0.0))
|
2009-08-27 04:29:47 +04:00
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
2014-12-11 17:44:07 +03:00
|
|
|
NPBool success = _convertpoint(instance,
|
|
|
|
pluginX, pluginY, NPCoordinateSpacePlugin,
|
|
|
|
&screenX, &screenY, NPCoordinateSpaceScreen);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
return mozilla::plugins::PluginUtilsOSX::ShowCocoaContextMenu(menu,
|
|
|
|
screenX, screenY,
|
|
|
|
nullptr,
|
|
|
|
nullptr);
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Convertpoint failed, could not created contextmenu.");
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NS_WARNING("Not supported on this platform!");
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
#endif
|
2009-08-27 04:29:47 +04:00
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
NPBool
|
2009-08-27 04:29:47 +04:00
|
|
|
_convertpoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_convertpoint called from the wrong thread\n"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-27 04:29:47 +04:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst)
|
2011-09-30 10:02:59 +04:00
|
|
|
return false;
|
2009-08-27 04:29:47 +04:00
|
|
|
|
|
|
|
return inst->ConvertPoint(sourceX, sourceY, sourceSpace, destX, destY, destSpace);
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:57:01 +04:00
|
|
|
void
|
2011-01-05 22:44:21 +03:00
|
|
|
_urlredirectresponse(NPP instance, void* notifyData, NPBool allow)
|
|
|
|
{
|
2015-07-17 10:17:09 +03:00
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_convertpoint called from the wrong thread\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-05 22:44:21 +03:00
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
inst->URLRedirectResponse(notifyData, allow);
|
|
|
|
}
|
|
|
|
|
2015-12-02 22:31:16 +03:00
|
|
|
NPError
|
|
|
|
_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
|
|
|
|
_finalizeasyncsurface(NPP instance, NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst) {
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return inst->FinalizeAsyncSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_setcurrentasyncsurface(NPP instance, NPAsyncSurface *surface, NPRect *changed)
|
|
|
|
{
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
|
|
|
|
if (!inst) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
inst->SetCurrentAsyncSurface(surface, changed);
|
|
|
|
}
|
|
|
|
|
2009-12-02 00:27:13 +03:00
|
|
|
} /* namespace parent */
|
|
|
|
} /* namespace plugins */
|
|
|
|
} /* namespace mozilla */
|