2004-04-11 05:33:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-07 20:18:27 +00:00
|
|
|
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-05-30 16:10:49 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-06-07 02:39:18 +00:00
|
|
|
// For ScreenOrientation.h and Hal.h
|
2012-05-30 16:10:49 +00:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
#endif
|
|
|
|
|
2015-05-19 18:15:34 +00:00
|
|
|
#include "mozilla/Logging.h"
|
1999-07-07 20:18:27 +00:00
|
|
|
#include "prmem.h"
|
|
|
|
#include "nscore.h"
|
2002-06-25 01:29:59 +00:00
|
|
|
#include "prenv.h"
|
2001-12-10 01:22:29 +00:00
|
|
|
|
2008-09-15 12:45:01 +00:00
|
|
|
#include "nsNPAPIPluginInstance.h"
|
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
#include "nsNPAPIPluginStreamListener.h"
|
2009-07-02 05:48:08 +00:00
|
|
|
#include "nsPluginHost.h"
|
2001-08-16 02:59:03 +00:00
|
|
|
#include "nsPluginLogging.h"
|
2011-02-03 17:31:01 +00:00
|
|
|
#include "nsContentUtils.h"
|
2012-10-03 02:43:18 +00:00
|
|
|
#include "nsPluginInstanceOwner.h"
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2013-09-19 13:54:42 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2013-08-22 06:30:55 +00:00
|
|
|
#include "nsIDOMElement.h"
|
2005-06-18 06:06:45 +00:00
|
|
|
#include "nsIDocument.h"
|
2013-03-04 18:18:20 +00:00
|
|
|
#include "nsIDocShell.h"
|
2009-06-28 23:43:19 +00:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2009-06-29 18:53:52 +00:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2004-07-12 15:53:22 +00:00
|
|
|
#include "nsJSNPRuntime.h"
|
2011-01-05 19:44:21 +00:00
|
|
|
#include "nsPluginStreamListenerPeer.h"
|
2011-05-21 13:28:54 +00:00
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsNetCID.h"
|
2011-07-20 19:18:54 +00:00
|
|
|
#include "nsIContent.h"
|
2012-10-03 15:49:04 +00:00
|
|
|
#include "nsVersionComparator.h"
|
2012-12-02 08:54:55 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/unused.h"
|
2013-10-08 02:21:07 +00:00
|
|
|
#include "nsILoadContext.h"
|
2014-08-15 21:17:35 +00:00
|
|
|
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
2015-07-28 21:09:48 +00:00
|
|
|
#include "AudioChannelService.h"
|
2012-12-02 08:54:55 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2014-08-15 21:17:35 +00:00
|
|
|
using namespace mozilla::dom;
|
2012-04-04 04:09:20 +00:00
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-16 21:34:31 +00:00
|
|
|
#include "ANPBase.h"
|
|
|
|
#include <android/log.h>
|
|
|
|
#include "android_npapi.h"
|
2011-11-21 07:55:50 +00:00
|
|
|
#include "mozilla/Mutex.h"
|
2011-09-16 21:34:31 +00:00
|
|
|
#include "mozilla/CondVar.h"
|
|
|
|
#include "AndroidBridge.h"
|
2012-05-30 16:10:49 +00:00
|
|
|
#include "mozilla/dom/ScreenOrientation.h"
|
2012-06-07 02:39:18 +00:00
|
|
|
#include "mozilla/Hal.h"
|
2012-07-20 19:20:51 +00:00
|
|
|
#include "GLContextProvider.h"
|
2013-09-04 12:14:52 +00:00
|
|
|
#include "GLContext.h"
|
2012-07-20 19:20:51 +00:00
|
|
|
#include "TexturePoolOGL.h"
|
2014-07-11 22:10:49 +00:00
|
|
|
#include "SurfaceTypes.h"
|
2014-09-17 13:13:29 +00:00
|
|
|
#include "EGLUtils.h"
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2014-09-17 13:13:29 +00:00
|
|
|
using namespace mozilla;
|
2012-07-20 19:20:51 +00:00
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
|
2012-05-04 15:48:41 +00:00
|
|
|
|
2016-04-26 00:23:21 +00:00
|
|
|
class PluginEventRunnable : public Runnable
|
2012-05-04 15:48:41 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
PluginEventRunnable(nsNPAPIPluginInstance* instance, ANPEvent* event)
|
|
|
|
: mInstance(instance), mEvent(*event), mCanceled(false) {}
|
|
|
|
|
|
|
|
virtual nsresult Run() {
|
|
|
|
if (mCanceled)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mInstance->HandleEvent(&mEvent, nullptr);
|
2012-05-04 15:48:41 +00:00
|
|
|
mInstance->PopPostedEvent(this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cancel() { mCanceled = true; }
|
|
|
|
private:
|
|
|
|
nsNPAPIPluginInstance* mInstance;
|
|
|
|
ANPEvent mEvent;
|
|
|
|
bool mCanceled;
|
|
|
|
};
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
static RefPtr<GLContext> sPluginContext = nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
static bool EnsureGLContext()
|
|
|
|
{
|
|
|
|
if (!sPluginContext) {
|
2015-07-29 20:35:55 +00:00
|
|
|
sPluginContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE);
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return sPluginContext != nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 14:16:26 +00:00
|
|
|
static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
|
|
|
|
|
2011-09-16 21:34:31 +00:00
|
|
|
#endif
|
|
|
|
|
2011-02-12 16:07:10 +00:00
|
|
|
using namespace mozilla;
|
2009-12-01 21:27:13 +00:00
|
|
|
using namespace mozilla::plugins::parent;
|
2012-11-10 15:45:52 +00:00
|
|
|
using namespace mozilla::layers;
|
2009-12-01 21:27:13 +00:00
|
|
|
|
2009-06-29 18:53:52 +00:00
|
|
|
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
2007-03-16 23:53:16 +00:00
|
|
|
|
2015-07-28 21:09:48 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsNPAPIPluginInstance, nsIAudioChannelAgentCallback)
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2012-04-02 19:17:34 +00:00
|
|
|
nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
2014-12-11 14:44:07 +00:00
|
|
|
: mDrawingModel(kDefaultDrawingModel)
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2014-12-11 14:44:07 +00:00
|
|
|
, mANPDrawingModel(0)
|
|
|
|
, mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary)
|
|
|
|
, mWakeLocked(false)
|
|
|
|
, mFullScreen(false)
|
2014-11-18 01:02:19 +00:00
|
|
|
, mOriginPos(gl::OriginPos::TopLeft)
|
2014-12-11 14:44:07 +00:00
|
|
|
#endif
|
|
|
|
, mRunning(NOT_STARTED)
|
|
|
|
, mWindowless(false)
|
|
|
|
, mTransparent(false)
|
|
|
|
, mCached(false)
|
|
|
|
, mUsesDOMForCursor(false)
|
|
|
|
, mInPluginInitCall(false)
|
|
|
|
, mPlugin(nullptr)
|
|
|
|
, mMIMEType(nullptr)
|
|
|
|
, mOwner(nullptr)
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
, mCurrentPluginEvent(nullptr)
|
2007-11-12 06:07:10 +00:00
|
|
|
#endif
|
2012-08-07 07:06:29 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
, mOnScreen(true)
|
|
|
|
#endif
|
2012-10-03 15:49:04 +00:00
|
|
|
, mHaveJavaC2PJSObjectQuirk(false)
|
2014-08-15 21:17:35 +00:00
|
|
|
, mCachedParamLength(0)
|
|
|
|
, mCachedParamNames(nullptr)
|
|
|
|
, mCachedParamValues(nullptr)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2013-10-23 20:34:30 +00:00
|
|
|
mNPP.pdata = nullptr;
|
2009-07-13 02:44:48 +00:00
|
|
|
mNPP.ndata = this;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2008-09-15 12:45:01 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
2013-01-23 14:16:26 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
sPluginNPPMap[&mNPP] = this;
|
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 18:16:47 +00:00
|
|
|
nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2008-09-15 12:45:01 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2013-01-23 14:16:26 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
sPluginNPPMap.erase(&mNPP);
|
|
|
|
#endif
|
|
|
|
|
2009-06-28 23:43:19 +00:00
|
|
|
if (mMIMEType) {
|
|
|
|
PR_Free((void *)mMIMEType);
|
2012-07-30 14:20:58 +00:00
|
|
|
mMIMEType = nullptr;
|
2009-06-28 23:43:19 +00:00
|
|
|
}
|
2014-08-15 21:17:35 +00:00
|
|
|
|
|
|
|
if (!mCachedParamValues || !mCachedParamNames) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mCachedParamValues && mCachedParamNames);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mCachedParamLength; i++) {
|
|
|
|
if (mCachedParamNames[i]) {
|
2015-04-01 05:29:55 +00:00
|
|
|
free(mCachedParamNames[i]);
|
2014-08-15 21:17:35 +00:00
|
|
|
mCachedParamNames[i] = nullptr;
|
|
|
|
}
|
|
|
|
if (mCachedParamValues[i]) {
|
2015-04-01 05:29:55 +00:00
|
|
|
free(mCachedParamValues[i]);
|
2014-08-15 21:17:35 +00:00
|
|
|
mCachedParamValues[i] = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-01 05:29:55 +00:00
|
|
|
free(mCachedParamNames);
|
2014-08-15 21:17:35 +00:00
|
|
|
mCachedParamNames = nullptr;
|
|
|
|
|
2015-04-01 05:29:55 +00:00
|
|
|
free(mCachedParamValues);
|
2014-08-15 21:17:35 +00:00
|
|
|
mCachedParamValues = nullptr;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 11:50:27 +00:00
|
|
|
uint32_t nsNPAPIPluginInstance::gInUnsafePluginCalls = 0;
|
2012-12-06 23:58:14 +00:00
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::Destroy()
|
|
|
|
{
|
|
|
|
Stop();
|
2012-07-30 14:20:58 +00:00
|
|
|
mPlugin = nullptr;
|
2015-07-28 21:09:48 +00:00
|
|
|
mAudioChannelAgent = nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
#if MOZ_WIDGET_ANDROID
|
2012-07-26 13:39:21 +00:00
|
|
|
if (mContentSurface)
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentSurface->SetFrameAvailableCallback(nullptr);
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentSurface = nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
std::map<void*, VideoInfo*>::iterator it;
|
|
|
|
for (it = mVideos.begin(); it != mVideos.end(); it++) {
|
2012-07-30 14:20:58 +00:00
|
|
|
it->second->mSurfaceTexture->SetFrameAvailableCallback(nullptr);
|
2012-07-20 19:20:51 +00:00
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
mVideos.clear();
|
|
|
|
SetWakeLock(false);
|
|
|
|
#endif
|
2010-07-20 02:11:26 +00:00
|
|
|
}
|
|
|
|
|
2011-11-12 01:10:31 +00:00
|
|
|
TimeStamp
|
|
|
|
nsNPAPIPluginInstance::StopTime()
|
|
|
|
{
|
|
|
|
return mStopTime;
|
|
|
|
}
|
|
|
|
|
2015-02-25 16:36:39 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const nsACString& aMIMEType)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2016-01-15 10:38:03 +00:00
|
|
|
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
2008-09-15 12:45:01 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::Initialize this=%p\n",this));
|
2009-06-29 18:53:52 +00:00
|
|
|
|
2012-04-02 19:17:34 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aPlugin);
|
|
|
|
NS_ENSURE_ARG_POINTER(aOwner);
|
|
|
|
|
|
|
|
mPlugin = aPlugin;
|
2009-06-29 18:53:52 +00:00
|
|
|
mOwner = aOwner;
|
|
|
|
|
2015-02-25 16:36:39 +00:00
|
|
|
if (!aMIMEType.IsEmpty()) {
|
|
|
|
mMIMEType = ToNewCString(aMIMEType);
|
2009-06-28 23:43:19 +00:00
|
|
|
}
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2012-04-02 19:17:34 +00:00
|
|
|
return Start();
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::Stop()
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2008-09-15 12:45:01 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::Stop this=%p\n",this));
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2005-06-18 06:06:45 +00:00
|
|
|
// Make sure the plugin didn't leave popups enabled.
|
2009-03-28 13:57:13 +00:00
|
|
|
if (mPopupStates.Length() > 0) {
|
2016-01-30 17:05:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2005-11-28 23:56:44 +00:00
|
|
|
if (window) {
|
|
|
|
window->PopPopupControlState(openAbused);
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-08 21:54:04 +00:00
|
|
|
if (RUNNING != mRunning) {
|
2001-02-02 23:48:17 +00:00
|
|
|
return NS_OK;
|
2009-01-10 17:13:31 +00:00
|
|
|
}
|
2000-07-11 21:44:39 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
// clean up all outstanding timers
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = mTimers.Length(); i > 0; i--)
|
2009-07-01 15:09:49 +00:00
|
|
|
UnscheduleTimer(mTimers[i - 1]->id);
|
|
|
|
|
2008-02-29 02:06:00 +00:00
|
|
|
// If there's code from this plugin instance on the stack, delay the
|
|
|
|
// destroy.
|
|
|
|
if (PluginDestructionGuard::DelayDestroy(this)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-18 02:09:22 +00:00
|
|
|
// Make sure we lock while we're writing to mRunning after we've
|
2007-07-11 23:25:45 +00:00
|
|
|
// started as other threads might be checking that inside a lock.
|
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 04:29:02 +00:00
|
|
|
{
|
|
|
|
AsyncCallbackAutoLock lock;
|
|
|
|
mRunning = DESTROYING;
|
2011-11-12 01:10:31 +00:00
|
|
|
mStopTime = TimeStamp::Now();
|
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 04:29:02 +00:00
|
|
|
}
|
2007-07-11 23:25:45 +00:00
|
|
|
|
2009-07-13 02:44:48 +00:00
|
|
|
OnPluginDestroy(&mNPP);
|
2007-07-11 23:25:45 +00:00
|
|
|
|
2001-07-24 20:48:36 +00:00
|
|
|
// clean up open streams
|
2011-01-05 19:44:21 +00:00
|
|
|
while (mStreamListeners.Length() > 0) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsNPAPIPluginStreamListener> currentListener(mStreamListeners[0]);
|
2010-08-09 18:38:43 +00:00
|
|
|
currentListener->CleanUpStream(NPRES_USER_BREAK);
|
2011-01-05 19:44:21 +00:00
|
|
|
mStreamListeners.RemoveElement(currentListener);
|
2001-07-24 20:48:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 21:06:31 +00:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-20 02:11:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2010-03-08 21:54:04 +00:00
|
|
|
NPError error = NPERR_GENERIC_ERROR;
|
2010-07-20 02:11:26 +00:00
|
|
|
if (pluginFunctions->destroy) {
|
2010-03-08 21:54:04 +00:00
|
|
|
NPSavedData *sdata = 0;
|
2000-09-29 00:46:18 +00:00
|
|
|
|
2013-02-27 11:50:27 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->destroy)(&mNPP, &sdata), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
2010-03-08 21:54:04 +00:00
|
|
|
|
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPP Destroy called: this=%p, npp=%p, return=%d\n", this, &mNPP, error));
|
|
|
|
}
|
|
|
|
mRunning = DESTROYED;
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2012-05-04 15:48:41 +00:00
|
|
|
#if MOZ_WIDGET_ANDROID
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < mPostedEvents.Length(); i++) {
|
2012-05-04 15:48:41 +00:00
|
|
|
mPostedEvents[i]->Cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
mPostedEvents.Clear();
|
|
|
|
#endif
|
|
|
|
|
2009-07-13 02:44:48 +00:00
|
|
|
nsJSNPRuntime::OnPluginDestroy(&mNPP);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2008-09-12 20:23:30 +00:00
|
|
|
if (error != NPERR_NO_ERROR)
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
else
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter>
|
2008-09-15 12:45:01 +00:00
|
|
|
nsNPAPIPluginInstance::GetDOMWindow()
|
2005-06-18 06:06:45 +00:00
|
|
|
{
|
2012-10-03 02:43:18 +00:00
|
|
|
if (!mOwner)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
|
2012-10-03 02:43:18 +00:00
|
|
|
|
2005-06-18 06:06:45 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
2012-10-03 02:43:18 +00:00
|
|
|
mOwner->GetDocument(getter_AddRefs(doc));
|
2008-11-03 19:23:07 +00:00
|
|
|
if (!doc)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
RefPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
|
2005-12-02 00:50:19 +00:00
|
|
|
|
2013-04-22 11:15:59 +00:00
|
|
|
return window.forget();
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2009-06-29 18:53:52 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetTagType(nsPluginTagType *result)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2012-10-03 02:43:18 +00:00
|
|
|
if (!mOwner) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2009-06-29 18:53:52 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
return mOwner->GetTagType(result);
|
2009-06-29 18:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNPAPIPluginInstance::GetMode(int32_t *result)
|
2009-06-29 18:53:52 +00:00
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->GetMode(result);
|
|
|
|
else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-07-17 23:47:29 +00:00
|
|
|
nsTArray<nsNPAPIPluginStreamListener*>*
|
2011-01-05 19:44:21 +00:00
|
|
|
nsNPAPIPluginInstance::StreamListeners()
|
2010-07-17 23:47:29 +00:00
|
|
|
{
|
2011-01-05 19:44:21 +00:00
|
|
|
return &mStreamListeners;
|
2010-07-17 23:47:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsPluginStreamListenerPeer*>*
|
2011-01-05 19:44:21 +00:00
|
|
|
nsNPAPIPluginInstance::FileCachedStreamListeners()
|
2010-07-17 23:47:29 +00:00
|
|
|
{
|
2011-01-05 19:44:21 +00:00
|
|
|
return &mFileCachedStreamListeners;
|
2010-07-17 23:47:29 +00:00
|
|
|
}
|
|
|
|
|
2009-06-29 18:53:52 +00:00
|
|
|
nsresult
|
2012-04-02 19:17:34 +00:00
|
|
|
nsNPAPIPluginInstance::Start()
|
|
|
|
{
|
|
|
|
if (mRunning == RUNNING) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-15 21:17:35 +00:00
|
|
|
if (!mOwner) {
|
|
|
|
MOZ_ASSERT(false, "Should not be calling Start() on unowned plugin.");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2008-02-29 02:06:00 +00:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2014-08-15 21:17:35 +00:00
|
|
|
nsTArray<MozPluginParameter> attributes;
|
|
|
|
nsTArray<MozPluginParameter> params;
|
|
|
|
|
2001-12-12 18:50:16 +00:00
|
|
|
nsPluginTagType tagtype;
|
2009-06-29 18:53:52 +00:00
|
|
|
nsresult rv = GetTagType(&tagtype);
|
2001-12-12 18:50:16 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2014-08-15 21:17:35 +00:00
|
|
|
mOwner->GetAttributes(attributes);
|
|
|
|
mOwner->GetParameters(params);
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(false, "Failed to get tag type.");
|
|
|
|
}
|
|
|
|
|
|
|
|
mCachedParamLength = attributes.Length() + 1 + params.Length();
|
|
|
|
|
|
|
|
// We add an extra entry "PARAM" as a separator between the attribute
|
|
|
|
// and param values, but we don't count it if there are no <param> entries.
|
|
|
|
// Legacy behavior quirk.
|
|
|
|
uint32_t quirkParamLength = params.Length() ?
|
|
|
|
mCachedParamLength : attributes.Length();
|
|
|
|
|
2015-04-01 05:29:55 +00:00
|
|
|
mCachedParamNames = (char**)moz_xmalloc(sizeof(char*) * mCachedParamLength);
|
|
|
|
mCachedParamValues = (char**)moz_xmalloc(sizeof(char*) * mCachedParamLength);
|
2014-08-15 21:17:35 +00:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < attributes.Length(); i++) {
|
|
|
|
mCachedParamNames[i] = ToNewUTF8String(attributes[i].mName);
|
|
|
|
mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Android expects and empty string instead of null.
|
|
|
|
mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING(""));
|
|
|
|
#else
|
|
|
|
mCachedParamValues[attributes.Length()] = nullptr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) {
|
|
|
|
mCachedParamNames[pos] = ToNewUTF8String(params[i].mName);
|
|
|
|
mCachedParamValues[pos] = ToNewUTF8String(params[i].mValue);
|
|
|
|
pos++;
|
2001-09-24 04:35:02 +00:00
|
|
|
}
|
2001-12-11 15:53:07 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mode;
|
2009-07-13 16:27:46 +00:00
|
|
|
const char* mimetype;
|
2010-01-27 23:45:34 +00:00
|
|
|
NPError error = NPERR_GENERIC_ERROR;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2009-06-29 18:53:52 +00:00
|
|
|
GetMode(&mode);
|
2009-06-28 23:43:19 +00:00
|
|
|
GetMIMEType(&mimetype);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2014-08-15 21:17:35 +00:00
|
|
|
CheckJavaC2PJSObjectQuirk(quirkParamLength, mCachedParamNames, mCachedParamValues);
|
2002-06-25 01:29:59 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool oldVal = mInPluginInitCall;
|
2011-09-30 06:02:59 +00:00
|
|
|
mInPluginInitCall = true;
|
2007-11-12 06:07:10 +00:00
|
|
|
|
2009-10-07 23:50:48 +00:00
|
|
|
// Need this on the stack before calling NPP_New otherwise some callbacks that
|
|
|
|
// the plugin may make could fail (NPN_HasProperty, for example).
|
|
|
|
NPPAutoPusher autopush(&mNPP);
|
2010-07-20 02:11:26 +00:00
|
|
|
|
|
|
|
if (!mPlugin)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginLibrary* library = mPlugin->GetLibrary();
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Mark this instance as running before calling NPP_New because the plugin may
|
|
|
|
// call other NPAPI functions, like NPN_GetURLNotify, that assume this is set
|
|
|
|
// before returning. If the plugin returns failure, we'll clear it out below.
|
|
|
|
mRunning = RUNNING;
|
|
|
|
|
2013-10-23 20:34:30 +00:00
|
|
|
nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (uint16_t)mode,
|
2014-08-15 21:17:35 +00:00
|
|
|
quirkParamLength, mCachedParamNames,
|
|
|
|
mCachedParamValues, nullptr, &error);
|
2007-11-12 06:07:10 +00:00
|
|
|
mInPluginInitCall = oldVal;
|
|
|
|
|
2001-08-16 02:59:03 +00:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPP New called: this=%p, npp=%p, mime=%s, mode=%d, argc=%d, return=%d\n",
|
2014-08-15 21:17:35 +00:00
|
|
|
this, &mNPP, mimetype, mode, quirkParamLength, error));
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2011-02-03 21:10:45 +00:00
|
|
|
if (NS_FAILED(newResult) || error != NPERR_NO_ERROR) {
|
2010-03-08 21:54:04 +00:00
|
|
|
mRunning = DESTROYED;
|
2011-02-03 21:10:45 +00:00
|
|
|
nsJSNPRuntime::OnPluginDestroy(&mNPP);
|
2002-06-14 20:45:29 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-09-20 00:17:28 +00:00
|
|
|
}
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2014-12-29 23:12:40 +00:00
|
|
|
return newResult;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2013-10-23 20:34:30 +00:00
|
|
|
// NPAPI plugins don't want a SetWindow(nullptr).
|
2010-03-08 21:54:04 +00:00
|
|
|
if (!window || RUNNING != mRunning)
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_OK;
|
2008-01-30 02:32:38 +00:00
|
|
|
|
2014-02-11 14:22:45 +00:00
|
|
|
#if MOZ_WIDGET_GTK
|
2008-01-30 02:32:38 +00:00
|
|
|
// bug 108347, flash plugin on linux doesn't like window->width <=
|
|
|
|
// 0, but Java needs wants this call.
|
2015-01-30 15:54:19 +00:00
|
|
|
if (window && window->type == NPWindowTypeWindow &&
|
|
|
|
(window->width <= 0 || window->height <= 0) &&
|
|
|
|
(nsPluginHost::GetSpecialType(nsDependentCString(mMIMEType)) !=
|
|
|
|
nsPluginHost::eSpecialType_Java)) {
|
2007-09-29 07:08:14 +00:00
|
|
|
return NS_OK;
|
2003-09-16 01:44:41 +00:00
|
|
|
}
|
2009-08-27 00:29:47 +00:00
|
|
|
#endif
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2010-10-14 21:06:31 +00:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-20 02:11:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
if (pluginFunctions->setwindow) {
|
2008-02-29 02:06:00 +00:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
// XXX Turns out that NPPluginWindow and NPWindow are structurally
|
|
|
|
// identical (on purpose!), so there's no need to make a copy.
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2008-09-15 12:45:01 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetWindow (about to call it) this=%p\n",this));
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool oldVal = mInPluginInitCall;
|
2011-09-30 06:02:59 +00:00
|
|
|
mInPluginInitCall = true;
|
2007-11-12 06:07:10 +00:00
|
|
|
|
2009-10-07 23:50:48 +00:00
|
|
|
NPPAutoPusher nppPusher(&mNPP);
|
|
|
|
|
2014-10-03 17:44:13 +00:00
|
|
|
NPError error;
|
2013-02-27 11:50:27 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setwindow)(&mNPP, (NPWindow*)window), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
2014-10-03 17:44:13 +00:00
|
|
|
// 'error' is only used if this is a logging-enabled build.
|
|
|
|
// That is somewhat complex to check, so we just use "unused"
|
|
|
|
// to suppress any compiler warnings in build configurations
|
|
|
|
// where the logging is a no-op.
|
2015-11-02 05:53:26 +00:00
|
|
|
mozilla::Unused << error;
|
2002-06-01 00:56:38 +00:00
|
|
|
|
2007-11-12 06:07:10 +00:00
|
|
|
mInPluginInitCall = oldVal;
|
2000-09-29 00:46:18 +00:00
|
|
|
|
2001-08-16 02:59:03 +00:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPP SetWindow called: this=%p, [x=%d,y=%d,w=%d,h=%d], clip[t=%d,b=%d,l=%d,r=%d], return=%d\n",
|
2002-03-13 04:24:45 +00:00
|
|
|
this, window->x, window->y, window->width, window->height,
|
2014-10-03 17:44:13 +00:00
|
|
|
window->clipRect.top, window->clipRect.bottom, window->clipRect.left, window->clipRect.right, error));
|
2000-04-22 20:50:22 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-07-09 03:25:20 +00:00
|
|
|
nsNPAPIPluginInstance::NewStreamFromPlugin(const char* type, const char* target,
|
2009-06-29 18:53:52 +00:00
|
|
|
nsIOutputStream* *result)
|
|
|
|
{
|
|
|
|
nsPluginStreamToFile* stream = new nsPluginStreamToFile(target, mOwner);
|
|
|
|
return stream->QueryInterface(kIOutputStreamIID, (void**)result);
|
|
|
|
}
|
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::NewStreamListener(const char* aURL, void* notifyData,
|
2012-05-17 23:54:26 +00:00
|
|
|
nsNPAPIPluginStreamListener** listener)
|
2001-07-24 20:48:36 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsNPAPIPluginStreamListener> sl = new nsNPAPIPluginStreamListener(this, notifyData, aURL);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2012-05-17 23:54:26 +00:00
|
|
|
mStreamListeners.AppendElement(sl);
|
2001-07-24 20:48:36 +00:00
|
|
|
|
2012-05-17 23:54:26 +00:00
|
|
|
sl.forget(listener);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::Print(NPPrint* platformPrint)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2001-09-18 02:11:09 +00:00
|
|
|
NS_ENSURE_TRUE(platformPrint, NS_ERROR_NULL_POINTER);
|
|
|
|
|
2008-02-29 02:06:00 +00:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2010-10-14 21:06:31 +00:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-20 02:11:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2001-09-18 02:11:09 +00:00
|
|
|
NPPrint* thePrint = (NPPrint *)platformPrint;
|
|
|
|
|
2001-12-08 01:13:05 +00:00
|
|
|
// to be compatible with the older SDK versions and to match what
|
2008-11-03 19:23:07 +00:00
|
|
|
// NPAPI and other browsers do, overwrite |window.type| field with one
|
2001-12-08 01:13:05 +00:00
|
|
|
// more copy of |platformPrint|. See bug 113264
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t sdkmajorversion = (pluginFunctions->version & 0xff00)>>8;
|
|
|
|
uint16_t sdkminorversion = pluginFunctions->version & 0x00ff;
|
2009-08-12 09:49:55 +00:00
|
|
|
if ((sdkmajorversion == 0) && (sdkminorversion < 11)) {
|
|
|
|
// Let's copy platformPrint bytes over to where it was supposed to be
|
|
|
|
// in older versions -- four bytes towards the beginning of the struct
|
|
|
|
// but we should be careful about possible misalignments
|
|
|
|
if (sizeof(NPWindowType) >= sizeof(void *)) {
|
|
|
|
void* source = thePrint->print.embedPrint.platformPrint;
|
|
|
|
void** destination = (void **)&(thePrint->print.embedPrint.window.type);
|
|
|
|
*destination = source;
|
|
|
|
} else {
|
|
|
|
NS_ERROR("Incompatible OS for assignment");
|
2001-12-08 01:13:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
if (pluginFunctions->print)
|
2013-02-27 11:50:27 +00:00
|
|
|
NS_TRY_SAFE_CALL_VOID((*pluginFunctions->print)(&mNPP, thePrint), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
2001-09-18 02:11:09 +00:00
|
|
|
|
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPP PrintProc called: this=%p, pDC=%p, [x=%d,y=%d,w=%d,h=%d], clip[t=%d,b=%d,l=%d,r=%d]\n",
|
|
|
|
this,
|
|
|
|
platformPrint->print.embedPrint.platformPrint,
|
|
|
|
platformPrint->print.embedPrint.window.x,
|
|
|
|
platformPrint->print.embedPrint.window.y,
|
|
|
|
platformPrint->print.embedPrint.window.width,
|
|
|
|
platformPrint->print.embedPrint.window.height,
|
|
|
|
platformPrint->print.embedPrint.window.clipRect.top,
|
|
|
|
platformPrint->print.embedPrint.window.clipRect.bottom,
|
|
|
|
platformPrint->print.embedPrint.window.clipRect.left,
|
|
|
|
platformPrint->print.embedPrint.window.clipRect.right));
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-27 11:50:28 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::HandleEvent(void* event, int16_t* result,
|
|
|
|
NSPluginCallReentry aSafeToReenterGecko)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2010-03-08 21:54:04 +00:00
|
|
|
if (RUNNING != mRunning)
|
2001-03-12 02:07:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2016-01-15 10:38:03 +00:00
|
|
|
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
|
|
|
|
2008-09-12 20:23:30 +00:00
|
|
|
if (!event)
|
2001-02-02 23:48:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2008-02-29 02:06:00 +00:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2010-10-14 21:06:31 +00:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-20 02:11:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t tmpResult = kNPEventNotHandled;
|
2010-06-10 00:56:17 +00:00
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
if (pluginFunctions->event) {
|
2014-12-11 14:44:07 +00:00
|
|
|
#ifdef XP_MACOSX
|
2009-08-27 00:29:47 +00:00
|
|
|
mCurrentPluginEvent = event;
|
2014-12-11 14:44:07 +00:00
|
|
|
#endif
|
2014-02-10 22:57:01 +00:00
|
|
|
#if defined(XP_WIN)
|
2013-02-27 11:50:27 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(tmpResult, (*pluginFunctions->event)(&mNPP, event), this,
|
2013-02-27 11:50:28 +00:00
|
|
|
aSafeToReenterGecko);
|
2009-09-17 01:30:26 +00:00
|
|
|
#else
|
2012-12-13 05:32:17 +00:00
|
|
|
MAIN_THREAD_JNI_REF_GUARD;
|
2010-07-20 02:11:26 +00:00
|
|
|
tmpResult = (*pluginFunctions->event)(&mNPP, event);
|
1999-07-07 20:18:27 +00:00
|
|
|
#endif
|
2009-08-27 00:29:47 +00:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
2014-04-22 23:23:18 +00:00
|
|
|
("NPP HandleEvent called: this=%p, npp=%p, event=%p, return=%d\n",
|
2010-06-10 00:56:17 +00:00
|
|
|
this, &mNPP, event, tmpResult));
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2010-06-10 00:56:17 +00:00
|
|
|
if (result)
|
|
|
|
*result = tmpResult;
|
2014-12-11 14:44:07 +00:00
|
|
|
#ifdef XP_MACOSX
|
2012-07-30 14:20:58 +00:00
|
|
|
mCurrentPluginEvent = nullptr;
|
2014-12-11 14:44:07 +00:00
|
|
|
#endif
|
2009-08-27 00:29:47 +00:00
|
|
|
}
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::GetValueFromPlugin(NPPVariable variable, void* value)
|
2003-02-27 01:47:53 +00:00
|
|
|
{
|
2010-10-14 21:06:31 +00:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-20 02:11:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2011-03-23 18:46:09 +00:00
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
if (pluginFunctions->getvalue && RUNNING == mRunning) {
|
2008-02-29 02:06:00 +00:00
|
|
|
PluginDestructionGuard guard(this);
|
2003-02-27 01:47:53 +00:00
|
|
|
|
2011-03-23 18:46:09 +00:00
|
|
|
NPError pluginError = NPERR_GENERIC_ERROR;
|
2013-02-27 11:50:27 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(pluginError, (*pluginFunctions->getvalue)(&mNPP, variable, value), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
2003-02-27 01:47:53 +00:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
2014-04-22 23:23:18 +00:00
|
|
|
("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
|
2011-03-23 18:46:09 +00:00
|
|
|
this, &mNPP, variable, value, pluginError));
|
|
|
|
|
|
|
|
if (pluginError == NPERR_NO_ERROR) {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
2003-02-27 01:47:53 +00:00
|
|
|
}
|
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNPAPIPlugin* nsNPAPIPluginInstance::GetPlugin()
|
|
|
|
{
|
|
|
|
return mPlugin;
|
2003-02-27 01:47:53 +00:00
|
|
|
}
|
|
|
|
|
2014-04-22 23:23:18 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::GetNPP(NPP* aNPP)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2008-11-03 19:23:07 +00:00
|
|
|
if (aNPP)
|
2009-07-13 02:44:48 +00:00
|
|
|
*aNPP = &mNPP;
|
2001-04-03 22:49:38 +00:00
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError nsNPAPIPluginInstance::SetWindowless(bool aWindowless)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
|
|
|
mWindowless = aWindowless;
|
2010-04-12 21:37:28 +00:00
|
|
|
|
|
|
|
if (mMIMEType) {
|
2010-10-27 13:13:53 +00:00
|
|
|
// bug 558434 - Prior to 3.6.4, we assumed windowless was transparent.
|
|
|
|
// Silverlight apparently relied on this quirk, so we default to
|
|
|
|
// transparent unless they specify otherwise after setting the windowless
|
|
|
|
// property. (Last tested version: sl 4.0).
|
|
|
|
// Changes to this code should be matched with changes in
|
|
|
|
// PluginInstanceChild::InitQuirksMode.
|
2015-01-30 15:54:19 +00:00
|
|
|
if (nsPluginHost::GetSpecialType(nsDependentCString(mMIMEType)) ==
|
|
|
|
nsPluginHost::eSpecialType_Silverlight) {
|
2011-09-30 06:02:59 +00:00
|
|
|
mTransparent = true;
|
2010-10-27 13:13:53 +00:00
|
|
|
}
|
2010-04-12 21:37:28 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 02:35:56 +00:00
|
|
|
return NPERR_NO_ERROR;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError nsNPAPIPluginInstance::SetTransparent(bool aTransparent)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
|
|
|
mTransparent = aTransparent;
|
2008-08-04 21:17:55 +00:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError nsNPAPIPluginInstance::SetUsesDOMForCursor(bool aUsesDOMForCursor)
|
2011-04-08 19:58:04 +00:00
|
|
|
{
|
|
|
|
mUsesDOMForCursor = aUsesDOMForCursor;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-04-08 19:58:04 +00:00
|
|
|
nsNPAPIPluginInstance::UsesDOMForCursor()
|
|
|
|
{
|
|
|
|
return mUsesDOMForCursor;
|
|
|
|
}
|
|
|
|
|
2008-09-15 12:45:01 +00:00
|
|
|
void nsNPAPIPluginInstance::SetDrawingModel(NPDrawingModel aModel)
|
2007-03-27 01:07:57 +00:00
|
|
|
{
|
|
|
|
mDrawingModel = aModel;
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:30:22 +00:00
|
|
|
void nsNPAPIPluginInstance::RedrawPlugin()
|
|
|
|
{
|
|
|
|
mOwner->RedrawPlugin();
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:24:38 +00:00
|
|
|
#if defined(XP_MACOSX)
|
2009-08-27 00:29:47 +00:00
|
|
|
void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
|
2007-03-27 01:07:57 +00:00
|
|
|
{
|
2009-11-10 03:58:48 +00:00
|
|
|
// the event model needs to be set for the object frame immediately
|
2012-10-03 02:43:18 +00:00
|
|
|
if (!mOwner) {
|
2009-11-10 03:58:48 +00:00
|
|
|
NS_WARNING("Trying to set event model without a plugin instance owner!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
mOwner->SetEventModel(aModel);
|
2007-03-27 01:07:57 +00:00
|
|
|
}
|
2011-09-16 21:34:31 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2012-02-15 20:34:31 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static void SendLifecycleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aAction)
|
2012-02-15 20:34:31 +00:00
|
|
|
{
|
|
|
|
ANPEvent event;
|
|
|
|
event.inSize = sizeof(ANPEvent);
|
|
|
|
event.eventType = kLifecycle_ANPEventType;
|
|
|
|
event.data.lifecycle.action = aAction;
|
2012-07-30 14:20:58 +00:00
|
|
|
aInstance->HandleEvent(&event, nullptr);
|
2012-02-15 20:34:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::NotifyForeground(bool aForeground)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetForeground this=%p\n foreground=%d",this, aForeground));
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SendLifecycleEvent(this, aForeground ? kResume_ANPLifecycleAction : kPause_ANPLifecycleAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::NotifyOnScreen(bool aOnScreen)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetOnScreen this=%p\n onScreen=%d",this, aOnScreen));
|
|
|
|
if (RUNNING != mRunning || mOnScreen == aOnScreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mOnScreen = aOnScreen;
|
|
|
|
SendLifecycleEvent(this, aOnScreen ? kOnScreen_ANPLifecycleAction : kOffScreen_ANPLifecycleAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::MemoryPressure()
|
|
|
|
{
|
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::MemoryPressure this=%p\n",this));
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SendLifecycleEvent(this, kFreeMemory_ANPLifecycleAction);
|
|
|
|
}
|
|
|
|
|
2012-05-30 16:10:49 +00:00
|
|
|
void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
|
2011-09-16 21:34:31 +00:00
|
|
|
{
|
2012-05-30 16:10:49 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::NotifyFullScreen this=%p\n",this));
|
2011-09-16 21:34:31 +00:00
|
|
|
|
2012-06-07 02:39:36 +00:00
|
|
|
if (RUNNING != mRunning || mFullScreen == aFullScreen)
|
2012-05-30 16:10:49 +00:00
|
|
|
return;
|
2011-09-16 21:34:31 +00:00
|
|
|
|
2012-06-07 02:39:36 +00:00
|
|
|
mFullScreen = aFullScreen;
|
|
|
|
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
|
|
|
|
|
|
|
|
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
|
2015-01-10 00:33:57 +00:00
|
|
|
widget::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
2012-06-07 02:39:36 +00:00
|
|
|
}
|
2011-09-16 21:34:31 +00:00
|
|
|
}
|
2009-08-27 00:29:47 +00:00
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
void nsNPAPIPluginInstance::NotifySize(nsIntSize size)
|
|
|
|
{
|
|
|
|
if (kOpenGL_ANPDrawingModel != GetANPDrawingModel() ||
|
|
|
|
size == mCurrentSize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mCurrentSize = size;
|
|
|
|
|
|
|
|
ANPEvent event;
|
|
|
|
event.inSize = sizeof(ANPEvent);
|
|
|
|
event.eventType = kDraw_ANPEventType;
|
|
|
|
event.data.draw.model = kOpenGL_ANPDrawingModel;
|
|
|
|
event.data.draw.data.surfaceSize.width = size.width;
|
|
|
|
event.data.draw.data.surfaceSize.height = size.height;
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
HandleEvent(&event, nullptr);
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsNPAPIPluginInstance::SetANPDrawingModel(uint32_t aModel)
|
2011-10-05 18:44:19 +00:00
|
|
|
{
|
2012-05-30 16:10:49 +00:00
|
|
|
mANPDrawingModel = aModel;
|
2011-10-05 18:44:19 +00:00
|
|
|
}
|
|
|
|
|
2012-05-30 16:10:49 +00:00
|
|
|
void* nsNPAPIPluginInstance::GetJavaSurface()
|
2011-10-05 18:44:19 +00:00
|
|
|
{
|
2014-04-22 23:23:18 +00:00
|
|
|
void* surface = nullptr;
|
2012-05-30 16:10:49 +00:00
|
|
|
nsresult rv = GetValueFromPlugin(kJavaSurface_ANPGetValue, &surface);
|
|
|
|
if (NS_FAILED(rv))
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-10-05 18:44:19 +00:00
|
|
|
|
2012-05-30 16:10:49 +00:00
|
|
|
return surface;
|
2011-10-05 18:44:19 +00:00
|
|
|
}
|
|
|
|
|
2012-05-04 15:48:41 +00:00
|
|
|
void nsNPAPIPluginInstance::PostEvent(void* event)
|
|
|
|
{
|
|
|
|
PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event);
|
2015-10-18 05:24:48 +00:00
|
|
|
mPostedEvents.AppendElement(RefPtr<PluginEventRunnable>(r));
|
2012-05-04 15:48:41 +00:00
|
|
|
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation)
|
2012-06-07 02:39:36 +00:00
|
|
|
{
|
|
|
|
if (mFullScreenOrientation == orientation)
|
|
|
|
return;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t oldOrientation = mFullScreenOrientation;
|
2012-06-07 02:39:36 +00:00
|
|
|
mFullScreenOrientation = orientation;
|
|
|
|
|
|
|
|
if (mFullScreen) {
|
|
|
|
// We're already fullscreen so immediately apply the orientation change
|
|
|
|
|
|
|
|
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
|
2015-01-10 00:33:57 +00:00
|
|
|
widget::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
2012-06-07 02:39:36 +00:00
|
|
|
} else if (oldOrientation != dom::eScreenOrientation_None) {
|
|
|
|
// We applied an orientation when we entered fullscreen, but
|
|
|
|
// we don't want it anymore
|
2015-01-10 00:33:57 +00:00
|
|
|
widget::GeckoAppShell::UnlockScreenOrientation();
|
2012-06-07 02:39:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-04 15:48:41 +00:00
|
|
|
void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
|
|
|
|
{
|
|
|
|
mPostedEvents.RemoveElement(r);
|
|
|
|
}
|
|
|
|
|
2012-06-07 02:39:18 +00:00
|
|
|
void nsNPAPIPluginInstance::SetWakeLock(bool aLocked)
|
|
|
|
{
|
|
|
|
if (aLocked == mWakeLocked)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mWakeLocked = aLocked;
|
2015-02-02 21:25:22 +00:00
|
|
|
hal::ModifyWakeLock(NS_LITERAL_STRING("screen"),
|
2012-06-07 02:39:18 +00:00
|
|
|
mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE,
|
|
|
|
hal::WAKE_LOCK_NO_CHANGE);
|
|
|
|
}
|
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
GLContext* nsNPAPIPluginInstance::GLContext()
|
|
|
|
{
|
|
|
|
if (!EnsureGLContext())
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
return sPluginContext;
|
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
already_AddRefed<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
|
2012-07-20 19:20:51 +00:00
|
|
|
{
|
|
|
|
if (!EnsureGLContext())
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
GLuint texture = TexturePoolOGL::AcquireTexture();
|
|
|
|
if (!texture)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
|
2014-11-13 18:47:24 +00:00
|
|
|
texture);
|
|
|
|
if (!surface) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2014-11-13 18:47:24 +00:00
|
|
|
}
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2016-05-05 08:45:00 +00:00
|
|
|
nsCOMPtr<nsIRunnable> frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
|
2012-07-20 19:20:51 +00:00
|
|
|
surface->SetFrameAvailableCallback(frameCallback);
|
2014-11-13 18:47:24 +00:00
|
|
|
return surface.forget();
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:39:21 +00:00
|
|
|
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
|
|
|
|
{
|
|
|
|
if (mRunning == RUNNING && mOwner)
|
2015-06-11 15:20:04 +00:00
|
|
|
AndroidBridge::Bridge()->InvalidateAndScheduleComposite();
|
2012-07-26 13:39:21 +00:00
|
|
|
}
|
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
void* nsNPAPIPluginInstance::AcquireContentWindow()
|
|
|
|
{
|
|
|
|
if (!mContentSurface) {
|
|
|
|
mContentSurface = CreateSurfaceTexture();
|
|
|
|
|
|
|
|
if (!mContentSurface)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 13:53:00 +00:00
|
|
|
return mContentSurface->NativeWindow()->Handle();
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 13:53:00 +00:00
|
|
|
AndroidSurfaceTexture*
|
2014-09-17 13:13:29 +00:00
|
|
|
nsNPAPIPluginInstance::AsSurfaceTexture()
|
2012-07-20 19:20:51 +00:00
|
|
|
{
|
2014-09-17 13:13:29 +00:00
|
|
|
if (!mContentSurface)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return mContentSurface;
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void* nsNPAPIPluginInstance::AcquireVideoWindow()
|
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
|
2014-11-13 18:47:24 +00:00
|
|
|
if (!surface) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2014-11-13 18:47:24 +00:00
|
|
|
}
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
VideoInfo* info = new VideoInfo(surface);
|
|
|
|
|
2014-10-21 13:53:00 +00:00
|
|
|
void* window = info->mSurfaceTexture->NativeWindow()->Handle();
|
2012-07-20 19:20:51 +00:00
|
|
|
mVideos.insert(std::pair<void*, VideoInfo*>(window, info));
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::ReleaseVideoWindow(void* window)
|
|
|
|
{
|
|
|
|
std::map<void*, VideoInfo*>::iterator it = mVideos.find(window);
|
|
|
|
if (it == mVideos.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
delete it->second;
|
|
|
|
mVideos.erase(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::SetVideoDimensions(void* window, gfxRect aDimensions)
|
|
|
|
{
|
|
|
|
std::map<void*, VideoInfo*>::iterator it;
|
|
|
|
|
|
|
|
it = mVideos.find(window);
|
|
|
|
if (it == mVideos.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
it->second->mDimensions = aDimensions;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::GetVideos(nsTArray<VideoInfo*>& aVideos)
|
|
|
|
{
|
|
|
|
std::map<void*, VideoInfo*>::iterator it;
|
|
|
|
for (it = mVideos.begin(); it != mVideos.end(); it++)
|
|
|
|
aVideos.AppendElement(it->second);
|
|
|
|
}
|
|
|
|
|
2013-01-23 14:16:26 +00:00
|
|
|
nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp)
|
|
|
|
{
|
|
|
|
std::map<NPP, nsNPAPIPluginInstance*>::iterator it;
|
|
|
|
|
|
|
|
it = sPluginNPPMap.find(npp);
|
|
|
|
if (it == sPluginNPPMap.end())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
2007-03-27 01:07:57 +00:00
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
|
2009-08-27 00:29:47 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
*aModel = (int32_t)mDrawingModel;
|
2009-09-17 01:30:26 +00:00
|
|
|
return NS_OK;
|
2011-02-12 15:55:40 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::IsRemoteDrawingCoreAnimation(bool* aDrawing)
|
2011-06-30 16:46:26 +00:00
|
|
|
{
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
if (!mPlugin)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginLibrary* library = mPlugin->GetLibrary();
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2011-06-30 16:46:26 +00:00
|
|
|
return library->IsRemoteDrawingCoreAnimation(&mNPP, aDrawing);
|
|
|
|
#else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-17 19:00:59 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::ContentsScaleFactorChanged(double aContentsScaleFactor)
|
2012-10-16 19:41:21 +00:00
|
|
|
{
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
if (!mPlugin)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginLibrary* library = mPlugin->GetLibrary();
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// We only need to call this if the plugin is running OOP.
|
|
|
|
if (!library->IsOOP())
|
|
|
|
return NS_OK;
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2012-10-16 19:41:21 +00:00
|
|
|
return library->ContentsScaleFactorChanged(&mNPP, aContentsScaleFactor);
|
|
|
|
#else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-17 19:00:59 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::CSSZoomFactorChanged(float aCSSZoomFactor)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance informing plugin of CSS Zoom Factor change this=%p\n",this));
|
|
|
|
|
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
if (!pluginFunctions->setvalue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
|
|
|
NPError error;
|
|
|
|
double value = static_cast<double>(aCSSZoomFactor);
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setvalue)(&mNPP, NPNVCSSZoomFactor, &value), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
|
|
|
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-07-02 04:52:07 +00:00
|
|
|
nsNPAPIPluginInstance::GetJSObject(JSContext *cx, JSObject** outObject)
|
2004-07-12 15:53:22 +00:00
|
|
|
{
|
2012-10-03 15:49:04 +00:00
|
|
|
if (mHaveJavaC2PJSObjectQuirk) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
NPObject *npobj = nullptr;
|
2009-09-17 01:30:26 +00:00
|
|
|
nsresult rv = GetValueFromPlugin(NPPVpluginScriptableNPObject, &npobj);
|
2009-07-02 04:52:07 +00:00
|
|
|
if (NS_FAILED(rv) || !npobj)
|
|
|
|
return NS_ERROR_FAILURE;
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2009-07-13 02:44:48 +00:00
|
|
|
*outObject = nsNPObjWrapper::GetNewOrUsed(&mNPP, cx, npobj);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2009-07-02 04:52:07 +00:00
|
|
|
_releaseobject(npobj);
|
2004-07-12 15:53:22 +00:00
|
|
|
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_OK;
|
2004-07-12 15:53:22 +00:00
|
|
|
}
|
2005-03-09 17:01:22 +00:00
|
|
|
|
2012-08-14 09:10:42 +00:00
|
|
|
void
|
2011-11-12 01:10:31 +00:00
|
|
|
nsNPAPIPluginInstance::SetCached(bool aCache)
|
|
|
|
{
|
|
|
|
mCached = aCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsNPAPIPluginInstance::ShouldCache()
|
|
|
|
{
|
|
|
|
return mCached;
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
|
2009-09-17 01:30:26 +00:00
|
|
|
{
|
2014-12-11 14:44:07 +00:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID) || defined(XP_MACOSX)
|
|
|
|
// All OS X plugins are windowless.
|
2011-09-16 21:34:31 +00:00
|
|
|
// On android, pre-honeycomb, all plugins are treated as windowless.
|
2011-09-30 06:02:59 +00:00
|
|
|
*isWindowless = true;
|
2011-09-16 21:34:31 +00:00
|
|
|
#else
|
2009-09-17 01:30:26 +00:00
|
|
|
*isWindowless = mWindowless;
|
2011-09-16 21:34:31 +00:00
|
|
|
#endif
|
2009-09-17 01:30:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-12 03:20:18 +00:00
|
|
|
class MOZ_STACK_CLASS AutoPluginLibraryCall
|
2011-02-12 16:07:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 22:26:43 +00:00
|
|
|
explicit AutoPluginLibraryCall(nsNPAPIPluginInstance* aThis)
|
2012-07-30 14:20:58 +00:00
|
|
|
: mThis(aThis), mGuard(aThis), mLibrary(nullptr)
|
2011-02-12 16:07:10 +00:00
|
|
|
{
|
|
|
|
nsNPAPIPlugin* plugin = mThis->GetPlugin();
|
|
|
|
if (plugin)
|
|
|
|
mLibrary = plugin->GetLibrary();
|
|
|
|
}
|
2015-04-11 03:05:46 +00:00
|
|
|
explicit operator bool() { return !!mLibrary; }
|
2011-02-12 16:07:10 +00:00
|
|
|
PluginLibrary* operator->() { return mLibrary; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsNPAPIPluginInstance* mThis;
|
|
|
|
PluginDestructionGuard mGuard;
|
|
|
|
PluginLibrary* mLibrary;
|
|
|
|
};
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2010-09-10 18:28:52 +00:00
|
|
|
nsNPAPIPluginInstance::AsyncSetWindow(NPWindow* window)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
AutoPluginLibraryCall library(this);
|
2010-09-10 18:28:52 +00:00
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return library->AsyncSetWindow(&mNPP, window);
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2012-02-08 15:34:27 +00:00
|
|
|
nsNPAPIPluginInstance::GetImageContainer(ImageContainer**aContainer)
|
2011-02-12 16:07:10 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aContainer = nullptr;
|
2011-02-23 05:38:09 +00:00
|
|
|
|
2011-02-12 16:07:10 +00:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
2012-02-08 15:34:27 +00:00
|
|
|
return !library ? NS_ERROR_FAILURE : library->GetImageContainer(&mNPP, aContainer);
|
2011-02-12 16:07:10 +00:00
|
|
|
}
|
2010-09-10 18:28:52 +00:00
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-02-23 05:38:09 +00:00
|
|
|
nsNPAPIPluginInstance::GetImageSize(nsIntSize* aSize)
|
|
|
|
{
|
|
|
|
*aSize = nsIntSize(0, 0);
|
|
|
|
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
return !library ? NS_ERROR_FAILURE : library->GetImageSize(&mNPP, aSize);
|
|
|
|
}
|
|
|
|
|
2016-03-01 18:48:25 +00:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetScrollCaptureContainer(ImageContainer**aContainer)
|
|
|
|
{
|
|
|
|
*aContainer = nullptr;
|
|
|
|
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
return !library ? NS_ERROR_FAILURE : library->GetScrollCaptureContainer(&mNPP, aContainer);
|
|
|
|
}
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::UpdateScrollState(bool aIsScrolling)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
return !library ? NS_ERROR_FAILURE : library->UpdateScrollState(&mNPP, aIsScrolling);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 11:09:37 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::HandledWindowedPluginKeyEvent(
|
|
|
|
const NativeEventData& aKeyEventData,
|
|
|
|
bool aIsConsumed)
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!mPlugin)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginLibrary* library = mPlugin->GetLibrary();
|
|
|
|
if (NS_WARN_IF(!library)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return library->HandledWindowedPluginKeyEvent(&mNPP, aKeyEventData,
|
|
|
|
aIsConsumed);
|
|
|
|
}
|
|
|
|
|
2015-12-02 19:31:16 +00:00
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::DidComposite()
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
library->DidComposite(&mNPP);
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2010-09-10 18:28:52 +00:00
|
|
|
nsNPAPIPluginInstance::NotifyPainted(void)
|
|
|
|
{
|
2010-11-05 14:40:55 +00:00
|
|
|
NS_NOTREACHED("Dead code, shouldn't be called.");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-09-10 18:28:52 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2012-09-27 00:22:51 +00:00
|
|
|
nsNPAPIPluginInstance::GetIsOOP(bool* aIsAsync)
|
2010-09-15 16:02:47 +00:00
|
|
|
{
|
2011-02-16 22:43:31 +00:00
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
2010-09-15 16:02:47 +00:00
|
|
|
|
2012-08-01 20:34:08 +00:00
|
|
|
*aIsAsync = library->IsOOP();
|
2011-02-16 22:43:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-02-16 22:43:31 +00:00
|
|
|
nsNPAPIPluginInstance::SetBackgroundUnknown()
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
2010-09-15 16:02:47 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
return library->SetBackgroundUnknown(&mNPP);
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-02-16 22:43:31 +00:00
|
|
|
nsNPAPIPluginInstance::BeginUpdateBackground(nsIntRect* aRect,
|
2015-12-18 03:39:10 +00:00
|
|
|
DrawTarget** aDrawTarget)
|
2011-02-16 22:43:31 +00:00
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
2010-09-15 16:02:47 +00:00
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2015-12-18 03:39:10 +00:00
|
|
|
return library->BeginUpdateBackground(&mNPP, *aRect, aDrawTarget);
|
2011-02-16 22:43:31 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2015-12-18 03:39:09 +00:00
|
|
|
nsNPAPIPluginInstance::EndUpdateBackground(nsIntRect* aRect)
|
2011-02-16 22:43:31 +00:00
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2015-12-18 03:39:09 +00:00
|
|
|
return library->EndUpdateBackground(&mNPP, *aRect);
|
2010-09-15 16:02:47 +00:00
|
|
|
}
|
2010-09-10 18:28:52 +00:00
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsNPAPIPluginInstance::IsTransparent(bool* isTransparent)
|
2009-09-17 01:30:26 +00:00
|
|
|
{
|
|
|
|
*isTransparent = mTransparent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2008-09-15 12:45:01 +00:00
|
|
|
nsNPAPIPluginInstance::GetFormValue(nsAString& aValue)
|
2005-03-09 17:01:22 +00:00
|
|
|
{
|
|
|
|
aValue.Truncate();
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
char *value = nullptr;
|
2009-09-17 01:30:26 +00:00
|
|
|
nsresult rv = GetValueFromPlugin(NPPVformValue, &value);
|
2009-07-02 04:52:07 +00:00
|
|
|
if (NS_FAILED(rv) || !value)
|
|
|
|
return NS_ERROR_FAILURE;
|
2005-03-09 17:01:22 +00:00
|
|
|
|
2009-07-02 04:52:07 +00:00
|
|
|
CopyUTF8toUTF16(value, aValue);
|
2005-03-09 17:01:22 +00:00
|
|
|
|
2009-07-02 04:52:07 +00:00
|
|
|
// NPPVformValue allocates with NPN_MemAlloc(), which uses
|
|
|
|
// nsMemory.
|
2015-03-27 00:01:12 +00:00
|
|
|
free(value);
|
2005-03-09 17:01:22 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsNPAPIPluginInstance::PushPopupsEnabledState(bool aEnabled)
|
2005-06-18 06:06:45 +00:00
|
|
|
{
|
2016-01-30 17:05:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
|
2005-11-28 23:56:44 +00:00
|
|
|
if (!window)
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2005-06-18 06:06:45 +00:00
|
|
|
|
|
|
|
PopupControlState oldState =
|
2005-11-28 23:56:44 +00:00
|
|
|
window->PushPopupControlState(aEnabled ? openAllowed : openAbused,
|
2011-09-30 06:02:59 +00:00
|
|
|
true);
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2009-03-28 13:57:13 +00:00
|
|
|
if (!mPopupStates.AppendElement(oldState)) {
|
2009-07-02 04:52:07 +00:00
|
|
|
// Appending to our state stack failed, pop what we just pushed.
|
2005-11-28 23:56:44 +00:00
|
|
|
window->PopPopupControlState(oldState);
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
2009-07-02 04:52:07 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2008-09-15 12:45:01 +00:00
|
|
|
nsNPAPIPluginInstance::PopPopupsEnabledState()
|
2005-06-18 06:06:45 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t last = mPopupStates.Length() - 1;
|
2005-06-18 06:06:45 +00:00
|
|
|
|
|
|
|
if (last < 0) {
|
|
|
|
// Nothing to pop.
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_OK;
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
|
2005-11-28 23:56:44 +00:00
|
|
|
if (!window)
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2009-03-28 13:57:13 +00:00
|
|
|
PopupControlState &oldState = mPopupStates[last];
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2005-11-28 23:56:44 +00:00
|
|
|
window->PopPopupControlState(oldState);
|
2005-06-18 06:06:45 +00:00
|
|
|
|
|
|
|
mPopupStates.RemoveElementAt(last);
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_OK;
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNPAPIPluginInstance::GetPluginAPIVersion(uint16_t* version)
|
2005-06-18 06:06:45 +00:00
|
|
|
{
|
2009-07-02 04:52:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(version);
|
2010-07-20 02:11:26 +00:00
|
|
|
|
|
|
|
if (!mPlugin)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (!mPlugin->GetLibrary())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
*version = pluginFunctions->version;
|
|
|
|
|
2009-07-02 04:52:07 +00:00
|
|
|
return NS_OK;
|
2005-06-18 06:06:45 +00:00
|
|
|
}
|
2009-01-30 21:40:14 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsresult
|
2012-04-24 04:49:25 +00:00
|
|
|
nsNPAPIPluginInstance::PrivateModeStateChanged(bool enabled)
|
2009-01-30 21:40:14 +00:00
|
|
|
{
|
2010-03-08 21:54:04 +00:00
|
|
|
if (RUNNING != mRunning)
|
2009-01-30 21:40:14 +00:00
|
|
|
return NS_OK;
|
2010-07-20 02:11:26 +00:00
|
|
|
|
2009-01-30 21:40:14 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance informing plugin of private mode state change this=%p\n",this));
|
2010-07-20 02:11:26 +00:00
|
|
|
|
2010-10-14 21:06:31 +00:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-20 02:11:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2012-04-24 04:49:25 +00:00
|
|
|
if (!pluginFunctions->setvalue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginDestructionGuard guard(this);
|
2012-12-17 15:05:49 +00:00
|
|
|
|
2012-04-24 04:49:25 +00:00
|
|
|
NPError error;
|
|
|
|
NPBool value = static_cast<NPBool>(enabled);
|
2013-02-27 11:50:27 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setvalue)(&mNPP, NPNVprivateModeBool, &value), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
2012-04-24 04:49:25 +00:00
|
|
|
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
|
2009-01-30 21:40:14 +00:00
|
|
|
}
|
2009-06-26 17:30:36 +00:00
|
|
|
|
2013-03-04 18:18:20 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::IsPrivateBrowsing(bool* aEnabled)
|
|
|
|
{
|
|
|
|
if (!mOwner)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
mOwner->GetDocument(getter_AddRefs(doc));
|
|
|
|
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> domwindow = doc->GetWindow();
|
2013-03-04 18:18:20 +00:00
|
|
|
NS_ENSURE_TRUE(domwindow, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = domwindow->GetDocShell();
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
|
|
|
*aEnabled = (loadContext && loadContext->UsePrivateBrowsing());
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
static void
|
|
|
|
PluginTimerCallback(nsITimer *aTimer, void *aClosure)
|
|
|
|
{
|
|
|
|
nsNPAPITimer* t = (nsNPAPITimer*)aClosure;
|
|
|
|
NPP npp = t->npp;
|
|
|
|
uint32_t id = t->id;
|
|
|
|
|
2012-12-13 05:32:17 +00:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NOISY, ("nsNPAPIPluginInstance running plugin timer callback this=%p\n", npp->ndata));
|
|
|
|
|
|
|
|
MAIN_THREAD_JNI_REF_GUARD;
|
2012-12-13 19:23:07 +00:00
|
|
|
// Some plugins (Flash on Android) calls unscheduletimer
|
|
|
|
// from this callback.
|
|
|
|
t->inCallback = true;
|
2009-07-01 15:09:49 +00:00
|
|
|
(*(t->callback))(npp, id);
|
2012-12-13 19:23:07 +00:00
|
|
|
t->inCallback = false;
|
2009-07-01 15:09:49 +00:00
|
|
|
|
|
|
|
// Make sure we still have an instance and the timer is still alive
|
|
|
|
// after the callback.
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
2013-10-23 20:34:30 +00:00
|
|
|
if (!inst || !inst->TimerWithID(id, nullptr))
|
2009-07-01 15:09:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// use UnscheduleTimer to clean up if this is a one-shot timer
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t timerType;
|
2009-07-01 15:09:49 +00:00
|
|
|
t->timer->GetType(&timerType);
|
2012-12-17 15:05:49 +00:00
|
|
|
if (t->needUnschedule || timerType == nsITimer::TYPE_ONE_SHOT)
|
|
|
|
inst->UnscheduleTimer(id);
|
2009-07-01 15:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsNPAPITimer*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNPAPIPluginInstance::TimerWithID(uint32_t id, uint32_t* index)
|
2009-07-01 15:09:49 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t len = mTimers.Length();
|
|
|
|
for (uint32_t i = 0; i < len; i++) {
|
2009-07-01 15:09:49 +00:00
|
|
|
if (mTimers[i]->id == id) {
|
|
|
|
if (index)
|
|
|
|
*index = i;
|
|
|
|
return mTimers[i];
|
|
|
|
}
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-07-01 15:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
nsNPAPIPluginInstance::ScheduleTimer(uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID))
|
|
|
|
{
|
2012-09-11 14:24:25 +00:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return 0;
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsNPAPITimer *newTimer = new nsNPAPITimer();
|
|
|
|
|
2012-12-17 15:05:49 +00:00
|
|
|
newTimer->inCallback = newTimer->needUnschedule = false;
|
2009-07-13 02:44:48 +00:00
|
|
|
newTimer->npp = &mNPP;
|
2009-07-01 15:09:49 +00:00
|
|
|
|
|
|
|
// generate ID that is unique to this instance
|
|
|
|
uint32_t uniqueID = mTimers.Length();
|
2013-10-23 20:34:30 +00:00
|
|
|
while ((uniqueID == 0) || TimerWithID(uniqueID, nullptr))
|
2009-07-01 15:09:49 +00:00
|
|
|
uniqueID++;
|
|
|
|
newTimer->id = uniqueID;
|
|
|
|
|
|
|
|
// create new xpcom timer, scheduled correctly
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsITimer> xpcomTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
|
2010-04-14 16:03:00 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
delete newTimer;
|
2009-07-01 15:09:49 +00:00
|
|
|
return 0;
|
2010-04-14 16:03:00 +00:00
|
|
|
}
|
2009-07-01 15:09:49 +00:00
|
|
|
const short timerType = (repeat ? (short)nsITimer::TYPE_REPEATING_SLACK : (short)nsITimer::TYPE_ONE_SHOT);
|
|
|
|
xpcomTimer->InitWithFuncCallback(PluginTimerCallback, newTimer, interval, timerType);
|
|
|
|
newTimer->timer = xpcomTimer;
|
|
|
|
|
|
|
|
// save callback function
|
|
|
|
newTimer->callback = timerFunc;
|
|
|
|
|
|
|
|
// add timer to timers array
|
|
|
|
mTimers.AppendElement(newTimer);
|
|
|
|
|
|
|
|
return newTimer->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::UnscheduleTimer(uint32_t timerID)
|
|
|
|
{
|
|
|
|
// find the timer struct by ID
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t index;
|
2009-07-01 15:09:49 +00:00
|
|
|
nsNPAPITimer* t = TimerWithID(timerID, &index);
|
|
|
|
if (!t)
|
|
|
|
return;
|
|
|
|
|
2012-12-13 19:23:07 +00:00
|
|
|
if (t->inCallback) {
|
2012-12-17 15:05:49 +00:00
|
|
|
t->needUnschedule = true;
|
2012-12-13 19:23:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
// cancel the timer
|
|
|
|
t->timer->Cancel();
|
|
|
|
|
|
|
|
// remove timer struct from array
|
|
|
|
mTimers.RemoveElementAt(index);
|
|
|
|
|
|
|
|
// delete timer
|
|
|
|
delete t;
|
|
|
|
}
|
|
|
|
|
2009-08-27 00:29:47 +00:00
|
|
|
NPBool
|
|
|
|
nsNPAPIPluginInstance::ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
|
|
|
|
double *destX, double *destY, NPCoordinateSpace destSpace)
|
|
|
|
{
|
2014-12-11 14:44:07 +00:00
|
|
|
if (mOwner) {
|
2009-08-27 00:29:47 +00:00
|
|
|
return mOwner->ConvertPoint(sourceX, sourceY, sourceSpace, destX, destY, destSpace);
|
2014-12-11 14:44:07 +00:00
|
|
|
}
|
2009-08-27 00:29:47 +00:00
|
|
|
|
2011-09-30 06:02:59 +00:00
|
|
|
return false;
|
2009-08-27 00:29:47 +00:00
|
|
|
}
|
|
|
|
|
2009-06-29 18:53:52 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetDOMElement(nsIDOMElement* *result)
|
|
|
|
{
|
|
|
|
if (!mOwner) {
|
2012-07-30 14:20:58 +00:00
|
|
|
*result = nullptr;
|
2009-06-29 18:53:52 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
return mOwner->GetDOMElement(result);
|
2009-06-29 18:53:52 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-09-17 01:30:26 +00:00
|
|
|
nsNPAPIPluginInstance::InvalidateRect(NPRect *invalidRect)
|
2009-06-26 17:30:36 +00:00
|
|
|
{
|
2010-12-21 23:03:00 +00:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
if (!mOwner)
|
2009-06-26 17:30:36 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
return mOwner->InvalidateRect(invalidRect);
|
2009-06-26 17:30:36 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-09-17 01:30:26 +00:00
|
|
|
nsNPAPIPluginInstance::InvalidateRegion(NPRegion invalidRegion)
|
2009-06-26 17:30:36 +00:00
|
|
|
{
|
2010-12-21 23:03:00 +00:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
if (!mOwner)
|
2009-06-26 17:30:36 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
return mOwner->InvalidateRegion(invalidRegion);
|
2009-06-26 17:30:36 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-07-13 16:27:46 +00:00
|
|
|
nsNPAPIPluginInstance::GetMIMEType(const char* *result)
|
2009-06-28 23:43:19 +00:00
|
|
|
{
|
|
|
|
if (!mMIMEType)
|
|
|
|
*result = "";
|
|
|
|
else
|
|
|
|
*result = mMIMEType;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-06-28 23:43:19 +00:00
|
|
|
nsNPAPIPluginInstance::GetJSContext(JSContext* *outContext)
|
|
|
|
{
|
2012-10-03 02:43:18 +00:00
|
|
|
if (!mOwner)
|
2009-06-28 23:43:19 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
|
2012-10-03 02:43:18 +00:00
|
|
|
|
2013-10-23 20:34:30 +00:00
|
|
|
*outContext = nullptr;
|
2009-06-28 23:43:19 +00:00
|
|
|
nsCOMPtr<nsIDocument> document;
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
nsresult rv = mOwner->GetDocument(getter_AddRefs(document));
|
2009-06-28 23:43:19 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && document) {
|
2013-06-21 14:25:20 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> global =
|
|
|
|
do_QueryInterface(document->GetWindow());
|
2009-06-28 23:43:19 +00:00
|
|
|
|
|
|
|
if (global) {
|
|
|
|
nsIScriptContext *context = global->GetContext();
|
|
|
|
|
|
|
|
if (context) {
|
2011-09-18 09:22:17 +00:00
|
|
|
*outContext = context->GetNativeContext();
|
2009-06-28 23:43:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2009-06-29 18:53:52 +00:00
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
nsPluginInstanceOwner*
|
|
|
|
nsNPAPIPluginInstance::GetOwner()
|
2009-06-29 18:53:52 +00:00
|
|
|
{
|
2012-10-03 02:43:18 +00:00
|
|
|
return mOwner;
|
2009-06-29 18:53:52 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::SetOwner(nsPluginInstanceOwner *aOwner)
|
2009-06-29 18:53:52 +00:00
|
|
|
{
|
|
|
|
mOwner = aOwner;
|
|
|
|
}
|
|
|
|
|
2010-09-10 18:28:52 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::AsyncSetWindow(NPWindow& window)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2011-01-05 19:44:21 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::URLRedirectResponse(void* notifyData, NPBool allow)
|
|
|
|
{
|
|
|
|
if (!notifyData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t listenerCount = mStreamListeners.Length();
|
|
|
|
for (uint32_t i = 0; i < listenerCount; i++) {
|
2011-01-05 19:44:21 +00:00
|
|
|
nsNPAPIPluginStreamListener* currentListener = mStreamListeners[i];
|
|
|
|
if (currentListener->GetNotifyData() == notifyData) {
|
|
|
|
currentListener->URLRedirectResponse(allow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-03 17:31:01 +00:00
|
|
|
|
2015-12-02 19:31:16 +00:00
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::InitAsyncSurface(NPSize *size, NPImageFormat format,
|
|
|
|
void *initData, NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
if (mOwner) {
|
|
|
|
return mOwner->InitAsyncSurface(size, format, initData, surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::FinalizeAsyncSurface(NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
if (mOwner) {
|
|
|
|
return mOwner->FinalizeAsyncSurface(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed)
|
|
|
|
{
|
|
|
|
if (mOwner) {
|
|
|
|
mOwner->SetCurrentAsyncSurface(surface, changed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-26 00:23:21 +00:00
|
|
|
class CarbonEventModelFailureEvent : public Runnable {
|
2011-02-03 17:31:01 +00:00
|
|
|
public:
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
|
2014-09-01 22:26:43 +00:00
|
|
|
explicit CarbonEventModelFailureEvent(nsIContent* aContent)
|
2011-02-03 17:31:01 +00:00
|
|
|
: mContent(aContent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~CarbonEventModelFailureEvent() {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CarbonEventModelFailureEvent::Run()
|
|
|
|
{
|
|
|
|
nsString type = NS_LITERAL_STRING("npapi-carbon-event-model-failure");
|
2014-08-22 20:11:27 +00:00
|
|
|
nsContentUtils::DispatchTrustedEvent(mContent->GetComposedDoc(), mContent,
|
2011-09-30 06:02:59 +00:00
|
|
|
type, true, true);
|
2011-02-03 17:31:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::CarbonNPAPIFailure()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
|
|
|
GetDOMElement(getter_AddRefs(element));
|
|
|
|
if (!element) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(element));
|
|
|
|
if (!content) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRunnable> e = new CarbonEventModelFailureEvent(content);
|
|
|
|
nsresult rv = NS_DispatchToCurrentThread(e);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Failed to dispatch CarbonEventModelFailureEvent.");
|
|
|
|
}
|
|
|
|
}
|
2012-10-02 19:48:05 +00:00
|
|
|
|
2012-10-03 15:49:04 +00:00
|
|
|
static bool
|
|
|
|
GetJavaVersionFromMimetype(nsPluginTag* pluginTag, nsCString& version)
|
|
|
|
{
|
2015-05-20 13:30:05 +00:00
|
|
|
for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); ++i) {
|
|
|
|
nsCString type = pluginTag->MimeTypes()[i];
|
2012-10-03 15:49:04 +00:00
|
|
|
nsAutoCString jpi("application/x-java-applet;jpi-version=");
|
|
|
|
|
|
|
|
int32_t idx = type.Find(jpi, false, 0, -1);
|
|
|
|
if (idx != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
type.Cut(0, jpi.Length());
|
|
|
|
if (type.IsEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
type.ReplaceChar('_', '.');
|
|
|
|
version = type;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::CheckJavaC2PJSObjectQuirk(uint16_t paramCount,
|
|
|
|
const char* const* paramNames,
|
|
|
|
const char* const* paramValues)
|
|
|
|
{
|
|
|
|
if (!mMIMEType || !mPlugin) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginTagType tagtype;
|
|
|
|
nsresult rv = GetTagType(&tagtype);
|
|
|
|
if (NS_FAILED(rv) ||
|
|
|
|
(tagtype != nsPluginTagType_Applet)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2012-11-19 22:03:24 +00:00
|
|
|
if (!pluginHost) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-03 15:49:04 +00:00
|
|
|
nsPluginTag* pluginTag = pluginHost->TagForPlugin(mPlugin);
|
|
|
|
if (!pluginTag ||
|
|
|
|
!pluginTag->mIsJavaPlugin) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the params for "code" being present and non-empty
|
|
|
|
bool haveCodeParam = false;
|
|
|
|
bool isCodeParamEmpty = true;
|
|
|
|
|
2013-06-11 14:58:43 +00:00
|
|
|
for (uint16_t i = paramCount; i > 0; --i) {
|
|
|
|
if (PL_strcasecmp(paramNames[i - 1], "code") == 0) {
|
2012-10-03 15:49:04 +00:00
|
|
|
haveCodeParam = true;
|
2013-06-11 14:58:43 +00:00
|
|
|
if (strlen(paramValues[i - 1]) > 0) {
|
2012-10-03 15:49:04 +00:00
|
|
|
isCodeParamEmpty = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Due to the Java version being specified inconsistently across platforms
|
|
|
|
// check the version via the mimetype for choosing specific Java versions
|
|
|
|
nsCString javaVersion;
|
|
|
|
if (!GetJavaVersionFromMimetype(pluginTag, javaVersion)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-30 00:43:56 +00:00
|
|
|
mozilla::Version version(javaVersion.get());
|
2012-10-03 15:49:04 +00:00
|
|
|
|
|
|
|
if (version >= "1.7.0.4") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!haveCodeParam && version >= "1.6.0.34" && version < "1.7") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (haveCodeParam && !isCodeParamEmpty) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mHaveJavaC2PJSObjectQuirk = true;
|
|
|
|
}
|
|
|
|
|
2012-10-02 19:48:05 +00:00
|
|
|
double
|
|
|
|
nsNPAPIPluginInstance::GetContentsScaleFactor()
|
|
|
|
{
|
|
|
|
double scaleFactor = 1.0;
|
|
|
|
if (mOwner) {
|
|
|
|
mOwner->GetContentsScaleFactor(&scaleFactor);
|
|
|
|
}
|
|
|
|
return scaleFactor;
|
|
|
|
}
|
2015-03-17 17:28:32 +00:00
|
|
|
|
2016-03-17 19:00:59 +00:00
|
|
|
float
|
|
|
|
nsNPAPIPluginInstance::GetCSSZoomFactor()
|
|
|
|
{
|
|
|
|
float zoomFactor = 1.0;
|
|
|
|
if (mOwner) {
|
|
|
|
mOwner->GetCSSZoomFactor(&zoomFactor);
|
|
|
|
}
|
|
|
|
return zoomFactor;
|
|
|
|
}
|
|
|
|
|
2015-03-17 17:28:32 +00:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetRunID(uint32_t* aRunID)
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!aRunID)) {
|
|
|
|
return NS_ERROR_INVALID_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!mPlugin)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginLibrary* library = mPlugin->GetLibrary();
|
|
|
|
if (!library) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return library->GetRunID(aRunID);
|
|
|
|
}
|
2015-07-28 21:09:48 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetOrCreateAudioChannelAgent(nsIAudioChannelAgent** aAgent)
|
|
|
|
{
|
|
|
|
if (!mAudioChannelAgent) {
|
|
|
|
nsresult rv;
|
|
|
|
mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
|
|
|
|
if (NS_WARN_IF(!mAudioChannelAgent)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
|
2015-07-28 21:09:48 +00:00
|
|
|
if (NS_WARN_IF(!window)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = mAudioChannelAgent->Init(window->GetCurrentInnerWindow(),
|
|
|
|
(int32_t)AudioChannelService::GetDefaultAudioChannel(),
|
|
|
|
this);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> agent = mAudioChannelAgent;
|
|
|
|
agent.forget(aAgent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
|
|
|
|
{
|
|
|
|
// We just support mute/unmute
|
|
|
|
nsresult rv = SetMuted(aMuted);
|
|
|
|
NS_WARN_IF(NS_FAILED(rv));
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:50:24 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsNPAPIPluginInstance::WindowSuspendChanged(nsSuspendedTypes aSuspend)
|
|
|
|
{
|
2016-05-03 01:52:38 +00:00
|
|
|
// It doesn't support suspended, so we just do something like mute/unmute.
|
|
|
|
WindowVolumeChanged(1.0, /* useless */
|
|
|
|
aSuspend != nsISuspendedTypes::NONE_SUSPENDED);
|
2016-05-03 01:50:24 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-28 21:09:48 +00:00
|
|
|
NS_IMETHODIMP
|
2015-12-24 09:28:45 +00:00
|
|
|
nsNPAPIPluginInstance::WindowAudioCaptureChanged(bool aCapture)
|
2015-07-28 21:09:48 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::SetMuted(bool aIsMuted)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance informing plugin of mute state change this=%p\n",this));
|
|
|
|
|
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
if (!pluginFunctions->setvalue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
|
|
|
NPError error;
|
|
|
|
NPBool value = static_cast<NPBool>(aIsMuted);
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setvalue)(&mNPP, NPNVmuteAudioBool, &value), this,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
|
|
|
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|