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
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
#include "prlog.h"
|
|
|
|
#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"
|
2012-12-02 08:54:55 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
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"
|
2013-12-03 18:44:38 +00:00
|
|
|
#include "GLSharedHandleHelpers.h"
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
|
2012-05-04 15:48:41 +00:00
|
|
|
|
|
|
|
class PluginEventRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
static nsRefPtr<GLContext> sPluginContext = nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
static bool EnsureGLContext()
|
|
|
|
{
|
|
|
|
if (!sPluginContext) {
|
2013-02-13 23:26:24 +00:00
|
|
|
gfxIntSize dummySize(16, 16);
|
2013-04-25 16:35:50 +00:00
|
|
|
sPluginContext = GLContextProvider::CreateOffscreen(dummySize,
|
|
|
|
GLContext::SurfaceCaps::Any());
|
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
|
|
|
}
|
|
|
|
|
|
|
|
class SharedPluginTexture {
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(SharedPluginTexture)
|
|
|
|
|
2012-08-16 16:48:35 +00:00
|
|
|
SharedPluginTexture() : mLock("SharedPluginTexture.mLock")
|
2012-07-20 19:20:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~SharedPluginTexture()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-29 16:24:04 +00:00
|
|
|
nsNPAPIPluginInstance::TextureInfo Lock()
|
2012-07-20 19:20:51 +00:00
|
|
|
{
|
|
|
|
if (!EnsureGLContext()) {
|
|
|
|
mTextureInfo.mTexture = 0;
|
|
|
|
return mTextureInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mTextureInfo.mTexture && sPluginContext->MakeCurrent()) {
|
|
|
|
sPluginContext->fGenTextures(1, &mTextureInfo.mTexture);
|
|
|
|
}
|
|
|
|
|
|
|
|
mLock.Lock();
|
|
|
|
return mTextureInfo;
|
|
|
|
}
|
|
|
|
|
2013-01-29 16:24:04 +00:00
|
|
|
void Release(nsNPAPIPluginInstance::TextureInfo& aTextureInfo)
|
2012-08-16 16:48:35 +00:00
|
|
|
{
|
2012-07-20 19:20:51 +00:00
|
|
|
mTextureInfo = aTextureInfo;
|
|
|
|
mLock.Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedTextureHandle CreateSharedHandle()
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
|
|
|
|
if (!EnsureGLContext())
|
2012-08-02 04:25:10 +00:00
|
|
|
return 0;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
if (mTextureInfo.mWidth == 0 || mTextureInfo.mHeight == 0)
|
2012-08-02 04:25:10 +00:00
|
|
|
return 0;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2012-11-26 22:23:27 +00:00
|
|
|
SharedTextureHandle handle =
|
2013-12-03 18:44:38 +00:00
|
|
|
gl::CreateSharedHandle(sPluginContext,
|
2014-01-10 18:55:23 +00:00
|
|
|
gl::SharedTextureShareType::SameProcess,
|
2013-12-03 18:44:38 +00:00
|
|
|
(void*)mTextureInfo.mTexture,
|
2014-01-10 18:55:23 +00:00
|
|
|
gl::SharedTextureBufferType::TextureID);
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
// We want forget about this now, so delete the texture. Assigning it to zero
|
|
|
|
// ensures that we create a new one in Lock()
|
|
|
|
sPluginContext->fDeleteTextures(1, &mTextureInfo.mTexture);
|
|
|
|
mTextureInfo.mTexture = 0;
|
|
|
|
|
2012-08-16 16:48:35 +00:00
|
|
|
return handle;
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-01-29 16:24:04 +00:00
|
|
|
nsNPAPIPluginInstance::TextureInfo mTextureInfo;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
Mutex mLock;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2013-07-19 02:21:20 +00:00
|
|
|
NS_IMPL_ISUPPORTS0(nsNPAPIPluginInstance)
|
2001-08-16 02:59:03 +00:00
|
|
|
|
2012-04-02 19:17:34 +00:00
|
|
|
nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
2010-07-20 02:11:26 +00:00
|
|
|
:
|
2012-02-16 03:24:38 +00:00
|
|
|
mDrawingModel(kDefaultDrawingModel),
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-01-17 22:45:06 +00:00
|
|
|
mANPDrawingModel(0),
|
2012-05-30 16:10:49 +00:00
|
|
|
mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary),
|
2012-06-07 02:39:18 +00:00
|
|
|
mWakeLocked(false),
|
2012-06-07 02:39:36 +00:00
|
|
|
mFullScreen(false),
|
2012-07-20 19:20:51 +00:00
|
|
|
mInverted(false),
|
2007-11-12 06:07:10 +00:00
|
|
|
#endif
|
2010-03-25 18:57:30 +00:00
|
|
|
mRunning(NOT_STARTED),
|
2011-09-30 06:02:59 +00:00
|
|
|
mWindowless(false),
|
|
|
|
mTransparent(false),
|
2011-11-12 01:10:31 +00:00
|
|
|
mCached(false),
|
2011-09-30 06:02:59 +00:00
|
|
|
mUsesDOMForCursor(false),
|
|
|
|
mInPluginInitCall(false),
|
2012-07-30 14:20:58 +00:00
|
|
|
mPlugin(nullptr),
|
|
|
|
mMIMEType(nullptr),
|
|
|
|
mOwner(nullptr),
|
2012-09-27 00:22:51 +00:00
|
|
|
mCurrentPluginEvent(nullptr)
|
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)
|
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
|
|
|
}
|
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;
|
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);
|
2012-07-26 13:39:21 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentTexture = nullptr;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const char* aMIMEType)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
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;
|
|
|
|
|
2009-06-28 23:43:19 +00:00
|
|
|
if (aMIMEType) {
|
2013-05-08 03:40:12 +00:00
|
|
|
mMIMEType = (char*)PR_Malloc(strlen(aMIMEType) + 1);
|
2012-04-02 19:17:34 +00:00
|
|
|
if (mMIMEType) {
|
2009-07-09 03:25:20 +00:00
|
|
|
PL_strcpy(mMIMEType, aMIMEType);
|
2012-04-02 19:17:34 +00:00
|
|
|
}
|
2009-06-28 23:43:19 +00:00
|
|
|
}
|
2012-04-24 04:49:25 +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) {
|
2005-11-28 23:56:44 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> 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) {
|
|
|
|
nsRefPtr<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
|
|
|
}
|
|
|
|
|
2005-11-28 23:56:44 +00:00
|
|
|
already_AddRefed<nsPIDOMWindow>
|
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
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
nsRefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
|
|
|
|
|
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
|
|
|
|
2013-04-22 11:15:59 +00:00
|
|
|
nsRefPtr<nsPIDOMWindow> 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::GetAttributes(uint16_t& n, const char*const*& names,
|
2009-06-29 18:53:52 +00:00
|
|
|
const char*const*& values)
|
|
|
|
{
|
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->GetAttributes(n, names, values);
|
2009-06-29 18:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNPAPIPluginInstance::GetParameters(uint16_t& n, const char*const*& names,
|
2009-06-29 18:53:52 +00:00
|
|
|
const char*const*& values)
|
|
|
|
{
|
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->GetParameters(n, names, values);
|
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;
|
|
|
|
}
|
|
|
|
|
2008-02-29 02:06:00 +00:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t count = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
const char* const* names = nullptr;
|
|
|
|
const char* const* values = nullptr;
|
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)) {
|
|
|
|
// Note: If we failed to get the tag type, we may be a full page plugin, so no arguments
|
2009-06-29 18:53:52 +00:00
|
|
|
rv = GetAttributes(count, names, values);
|
2001-12-12 18:50:16 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// nsPluginTagType_Object or Applet may also have PARAM tags
|
|
|
|
// Note: The arrays handed back by GetParameters() are
|
2005-11-25 21:57:13 +00:00
|
|
|
// crafted specially to be directly behind the arrays from GetAttributes()
|
2003-03-24 04:15:34 +00:00
|
|
|
// with a null entry as a separator. This is for 4.x backwards compatibility!
|
2001-12-12 18:50:16 +00:00
|
|
|
// see bug 111008 for details
|
|
|
|
if (tagtype != nsPluginTagType_Embed) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t pcount = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
const char* const* pnames = nullptr;
|
|
|
|
const char* const* pvalues = nullptr;
|
2009-06-29 18:53:52 +00:00
|
|
|
if (NS_SUCCEEDED(GetParameters(pcount, pnames, pvalues))) {
|
2011-10-05 18:43:16 +00:00
|
|
|
// Android expects an empty string as the separator instead of null
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-10-05 18:43:16 +00:00
|
|
|
NS_ASSERTION(PL_strcmp(values[count], "") == 0, "attribute/parameter array not setup correctly for Android NPAPI plugins");
|
|
|
|
#else
|
2008-11-03 19:23:07 +00:00
|
|
|
NS_ASSERTION(!values[count], "attribute/parameter array not setup correctly for NPAPI plugins");
|
2011-10-05 18:43:16 +00:00
|
|
|
#endif
|
2001-12-14 03:52:12 +00:00
|
|
|
if (pcount)
|
2008-11-03 19:23:07 +00:00
|
|
|
count += ++pcount; // if it's all setup correctly, then all we need is to
|
|
|
|
// change the count (attrs + PARAM/blank + params)
|
2001-12-12 18:50:16 +00:00
|
|
|
}
|
2001-12-11 15:53:07 +00:00
|
|
|
}
|
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
|
|
|
|
2012-10-03 15:49:04 +00:00
|
|
|
CheckJavaC2PJSObjectQuirk(count, names, values);
|
|
|
|
|
2003-01-31 19:37:32 +00:00
|
|
|
// Some older versions of Flash have a bug in them
|
|
|
|
// that causes the stack to become currupt if we
|
2009-06-30 22:55:16 +00:00
|
|
|
// pass swliveconnect=1 in the NPP_NewProc arrays.
|
2003-01-31 19:37:32 +00:00
|
|
|
// See bug 149336 (UNIX), bug 186287 (Mac)
|
|
|
|
//
|
|
|
|
// The code below disables the attribute unless
|
|
|
|
// the environment variable:
|
|
|
|
// MOZILLA_PLUGIN_DISABLE_FLASH_SWLIVECONNECT_HACK
|
|
|
|
// is set.
|
|
|
|
//
|
|
|
|
// It is okay to disable this attribute because
|
|
|
|
// back in 4.x, scripting required liveconnect to
|
|
|
|
// start Java which was slow. Scripting no longer
|
|
|
|
// requires starting Java and is quick plus controled
|
|
|
|
// from the browser, so Flash now ignores this attribute.
|
|
|
|
//
|
|
|
|
// This code can not be put at the time of creating
|
|
|
|
// the array because we may need to examine the
|
|
|
|
// stream header to determine we want Flash.
|
|
|
|
|
2002-06-25 01:29:59 +00:00
|
|
|
static const char flashMimeType[] = "application/x-shockwave-flash";
|
|
|
|
static const char blockedParam[] = "swliveconnect";
|
|
|
|
if (count && !PL_strcasecmp(mimetype, flashMimeType)) {
|
|
|
|
static int cachedDisableHack = 0;
|
|
|
|
if (!cachedDisableHack) {
|
|
|
|
if (PR_GetEnv("MOZILLA_PLUGIN_DISABLE_FLASH_SWLIVECONNECT_HACK"))
|
|
|
|
cachedDisableHack = -1;
|
|
|
|
else
|
|
|
|
cachedDisableHack = 1;
|
|
|
|
}
|
|
|
|
if (cachedDisableHack > 0) {
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint16_t i=0; i<count; i++) {
|
2002-06-25 01:29:59 +00:00
|
|
|
if (!PL_strcasecmp(names[i], blockedParam)) {
|
|
|
|
// BIG FAT WARNIG:
|
|
|
|
// I'm ugly casting |const char*| to |char*| and altering it
|
|
|
|
// because I know we do malloc it values in
|
|
|
|
// http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/html/base/src/nsObjectFrame.cpp&rev=1.349&root=/cvsroot#3020
|
|
|
|
// and free it at line #2096, so it couldn't be a const ptr to string literal
|
|
|
|
char *val = (char*) values[i];
|
|
|
|
if (val && *val) {
|
2005-11-25 08:16:51 +00:00
|
|
|
// we cannot just *val=0, it won't be free properly in such case
|
2002-06-25 01:29:59 +00:00
|
|
|
val[0] = '0';
|
|
|
|
val[1] = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
count, (char**)names, (char**)values,
|
|
|
|
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",
|
2009-07-13 02:44:48 +00:00
|
|
|
this, &mNPP, mimetype, mode, count, 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
|
|
|
}
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2002-06-14 20:45:29 +00:00
|
|
|
return NS_OK;
|
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.
|
2009-09-17 01:30:26 +00:00
|
|
|
if (!nsPluginHost::IsJavaMIMEType(mMIMEType) && window->type == NPWindowTypeWindow &&
|
2007-09-29 07:08:14 +00:00
|
|
|
(window->width <= 0 || window->height <= 0)) {
|
|
|
|
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);
|
|
|
|
|
2012-11-30 16:06:37 +00:00
|
|
|
DebugOnly<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);
|
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,
|
2012-11-30 16:06:37 +00:00
|
|
|
window->clipRect.top, window->clipRect.bottom, window->clipRect.left, window->clipRect.right, (NPError)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);
|
|
|
|
if (!stream)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-05-17 23:54:26 +00:00
|
|
|
nsRefPtr<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;
|
|
|
|
|
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) {
|
2009-08-27 00:29:47 +00:00
|
|
|
mCurrentPluginEvent = event;
|
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,
|
2009-09-17 01:30:26 +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;
|
2012-07-30 14:20:58 +00:00
|
|
|
mCurrentPluginEvent = nullptr;
|
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,
|
|
|
|
("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
|
|
|
}
|
|
|
|
|
2008-09-15 12:45:01 +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.
|
|
|
|
NS_NAMED_LITERAL_CSTRING(silverlight, "application/x-silverlight");
|
|
|
|
if (!PL_strncasecmp(mMIMEType, silverlight.get(), silverlight.Length())) {
|
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) {
|
2013-11-12 18:41:01 +00:00
|
|
|
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
|
|
|
{
|
2012-07-30 14:20:58 +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);
|
|
|
|
mPostedEvents.AppendElement(nsRefPtr<PluginEventRunnable>(r));
|
|
|
|
|
|
|
|
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) {
|
2013-11-12 18:41:01 +00:00
|
|
|
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
|
2013-11-12 18:41:01 +00:00
|
|
|
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;
|
|
|
|
hal::ModifyWakeLock(NS_LITERAL_STRING("nsNPAPIPluginInstance"),
|
|
|
|
mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE,
|
|
|
|
hal::WAKE_LOCK_NO_CHANGE);
|
|
|
|
}
|
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
void nsNPAPIPluginInstance::EnsureSharedTexture()
|
|
|
|
{
|
|
|
|
if (!mContentTexture)
|
|
|
|
mContentTexture = new SharedPluginTexture();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-01-29 16:24:04 +00:00
|
|
|
nsNPAPIPluginInstance::TextureInfo nsNPAPIPluginInstance::LockContentTexture()
|
2012-07-20 19:20:51 +00:00
|
|
|
{
|
|
|
|
EnsureSharedTexture();
|
|
|
|
return mContentTexture->Lock();
|
|
|
|
}
|
|
|
|
|
2013-01-29 16:24:04 +00:00
|
|
|
void nsNPAPIPluginInstance::ReleaseContentTexture(nsNPAPIPluginInstance::TextureInfo& aTextureInfo)
|
2012-07-20 19:20:51 +00:00
|
|
|
{
|
|
|
|
EnsureSharedTexture();
|
|
|
|
mContentTexture->Release(aTextureInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSurfaceTexture* nsNPAPIPluginInstance::CreateSurfaceTexture()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
nsSurfaceTexture* surface = nsSurfaceTexture::Create(texture);
|
|
|
|
if (!surface)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2012-07-26 13:39:21 +00:00
|
|
|
nsCOMPtr<nsIRunnable> frameCallback = NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
|
2012-07-20 19:20:51 +00:00
|
|
|
surface->SetFrameAvailableCallback(frameCallback);
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
2012-07-26 13:39:21 +00:00
|
|
|
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
|
|
|
|
{
|
|
|
|
if (mRunning == RUNNING && mOwner)
|
2012-08-16 16:47:22 +00:00
|
|
|
AndroidBridge::Bridge()->ScheduleComposite();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return mContentSurface->GetNativeWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedTextureHandle nsNPAPIPluginInstance::CreateSharedHandle()
|
|
|
|
{
|
|
|
|
if (mContentTexture) {
|
|
|
|
return mContentTexture->CreateSharedHandle();
|
|
|
|
} else if (mContentSurface) {
|
|
|
|
EnsureGLContext();
|
2013-12-03 18:44:38 +00:00
|
|
|
return gl::CreateSharedHandle(sPluginContext,
|
2014-01-10 18:55:23 +00:00
|
|
|
gl::SharedTextureShareType::SameProcess,
|
2013-12-03 18:44:38 +00:00
|
|
|
mContentSurface,
|
2014-01-10 18:55:23 +00:00
|
|
|
gl::SharedTextureBufferType::SurfaceTexture);
|
2012-08-02 04:25:10 +00:00
|
|
|
} else return 0;
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void* nsNPAPIPluginInstance::AcquireVideoWindow()
|
|
|
|
{
|
|
|
|
nsSurfaceTexture* surface = CreateSurfaceTexture();
|
|
|
|
if (!surface)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
VideoInfo* info = new VideoInfo(surface);
|
|
|
|
|
|
|
|
void* window = info->mSurfaceTexture->GetNativeWindow();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsNPAPIPluginInstance::SetInverted(bool aInverted)
|
|
|
|
{
|
|
|
|
if (aInverted == mInverted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mInverted = aInverted;
|
|
|
|
}
|
|
|
|
|
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-01-17 22:45:06 +00:00
|
|
|
#if defined(XP_MACOSX)
|
2012-08-22 15:56:38 +00:00
|
|
|
*aModel = (int32_t)mDrawingModel;
|
2009-09-17 01:30:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
#else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
#endif
|
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;
|
|
|
|
|
|
|
|
return library->IsRemoteDrawingCoreAnimation(&mNPP, aDrawing);
|
|
|
|
#else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-10-16 19:41:21 +00:00
|
|
|
nsresult nsNPAPIPluginInstance::ContentsScaleFactorChanged(double aContentsScaleFactor)
|
|
|
|
{
|
|
|
|
#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;
|
|
|
|
|
|
|
|
return library->ContentsScaleFactorChanged(&mNPP, aContentsScaleFactor);
|
|
|
|
#else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
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:
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
operator bool() { return !!mLibrary; }
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
gfxContext** aContext)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
2010-09-15 16:02:47 +00:00
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
return library->BeginUpdateBackground(&mNPP, *aRect, aContext);
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2011-02-16 22:43:31 +00:00
|
|
|
nsNPAPIPluginInstance::EndUpdateBackground(gfxContext* aContext,
|
|
|
|
nsIntRect* aRect)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return library->EndUpdateBackground(&mNPP, aContext, *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.
|
|
|
|
nsMemory::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
|
|
|
{
|
2005-11-28 23:56:44 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = GetDOMWindow();
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2005-11-28 23:56:44 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = GetDOMWindow();
|
|
|
|
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);
|
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);
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindow> domwindow = doc->GetWindow();
|
|
|
|
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
|
|
|
// Show the context menu at the location for the current event.
|
|
|
|
// This can only be called from within an NPP_SendEvent call.
|
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::PopUpContextMenu(NPMenu* menu)
|
|
|
|
{
|
|
|
|
if (mOwner && mCurrentPluginEvent)
|
|
|
|
return mOwner->ShowNativeContextMenu(menu, mCurrentPluginEvent);
|
|
|
|
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
NPBool
|
|
|
|
nsNPAPIPluginInstance::ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
|
|
|
|
double *destX, double *destY, NPCoordinateSpace destSpace)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->ConvertPoint(sourceX, sourceY, sourceSpace, destX, destY, destSpace);
|
|
|
|
|
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;
|
|
|
|
|
2012-10-03 02:43:18 +00:00
|
|
|
nsRefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult
|
2009-06-29 18:53:52 +00:00
|
|
|
nsNPAPIPluginInstance::ShowStatus(const char* message)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->ShowStatus(message);
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-02-16 03:08:41 +00:00
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::InitAsyncSurface(NPSize *size, NPImageFormat format,
|
|
|
|
void *initData, NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->InitAsyncSurface(size, format, initData, surface);
|
|
|
|
|
2012-03-12 14:39:54 +00:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-02-16 03:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::FinalizeAsyncSurface(NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->FinalizeAsyncSurface(surface);
|
|
|
|
|
2012-03-12 14:39:54 +00:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-02-16 03:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
mOwner->SetCurrentAsyncSurface(surface, changed);
|
|
|
|
}
|
|
|
|
|
2011-02-03 17:31:01 +00:00
|
|
|
class CarbonEventModelFailureEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
|
|
|
|
CarbonEventModelFailureEvent(nsIContent* aContent)
|
|
|
|
: mContent(aContent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~CarbonEventModelFailureEvent() {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CarbonEventModelFailureEvent::Run()
|
|
|
|
{
|
|
|
|
nsString type = NS_LITERAL_STRING("npapi-carbon-event-model-failure");
|
|
|
|
nsContentUtils::DispatchTrustedEvent(mContent->GetDocument(), 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)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < pluginTag->mMimeTypes.Length(); ++i) {
|
|
|
|
nsCString type = pluginTag->mMimeTypes[i];
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-20 18:29:00 +00:00
|
|
|
nsRefPtr<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;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::Version version = javaVersion.get();
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|