2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-30 09:10:49 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-06-06 19:39:18 -07:00
|
|
|
// For ScreenOrientation.h and Hal.h
|
2012-05-30 09:10:49 -07:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prlog.h"
|
|
|
|
#include "prmem.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "prenv.h"
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
#include "nsNPAPIPluginInstance.h"
|
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
#include "nsNPAPIPluginStreamListener.h"
|
2009-07-01 22:48:08 -07:00
|
|
|
#include "nsPluginHost.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsPluginSafety.h"
|
|
|
|
#include "nsPluginLogging.h"
|
2011-02-03 09:31:01 -08:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIDocument.h"
|
2009-06-28 16:43:19 -07:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2009-06-29 11:53:52 -07:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsJSNPRuntime.h"
|
2011-01-05 11:44:21 -08:00
|
|
|
#include "nsPluginStreamListenerPeer.h"
|
2011-05-21 06:28:54 -07:00
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsNetCID.h"
|
2011-07-20 12:18:54 -07:00
|
|
|
#include "nsIContent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-03 21:09:20 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-16 14:34:31 -07:00
|
|
|
#include "ANPBase.h"
|
|
|
|
#include <android/log.h>
|
|
|
|
#include "android_npapi.h"
|
2011-11-20 23:55:50 -08:00
|
|
|
#include "mozilla/Mutex.h"
|
2011-09-16 14:34:31 -07:00
|
|
|
#include "mozilla/CondVar.h"
|
|
|
|
#include "AndroidBridge.h"
|
2012-05-30 09:10:49 -07:00
|
|
|
#include "mozilla/dom/ScreenOrientation.h"
|
2012-06-06 19:39:18 -07:00
|
|
|
#include "mozilla/Hal.h"
|
2012-05-04 08:48:41 -07: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;
|
|
|
|
|
|
|
|
mInstance->HandleEvent(&mEvent, nsnull);
|
|
|
|
mInstance->PopPostedEvent(this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cancel() { mCanceled = true; }
|
|
|
|
private:
|
|
|
|
nsNPAPIPluginInstance* mInstance;
|
|
|
|
ANPEvent mEvent;
|
|
|
|
bool mCanceled;
|
|
|
|
};
|
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
#endif
|
|
|
|
|
2011-02-12 08:07:10 -08:00
|
|
|
using namespace mozilla;
|
2009-12-01 13:27:13 -08:00
|
|
|
using namespace mozilla::plugins::parent;
|
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS0(nsNPAPIPluginInstance)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-02 12:17:34 -07:00
|
|
|
nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
2010-07-19 19:11:26 -07:00
|
|
|
:
|
2012-02-15 19:24:38 -08:00
|
|
|
mDrawingModel(kDefaultDrawingModel),
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-16 14:34:31 -07:00
|
|
|
mSurface(nsnull),
|
2012-01-17 14:45:06 -08:00
|
|
|
mANPDrawingModel(0),
|
2012-02-15 12:34:31 -08:00
|
|
|
mOnScreen(true),
|
2012-05-30 09:10:49 -07:00
|
|
|
mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary),
|
2012-06-06 19:39:18 -07:00
|
|
|
mWakeLocked(false),
|
2012-06-06 19:39:36 -07:00
|
|
|
mFullScreen(false),
|
2007-11-11 22:07:10 -08:00
|
|
|
#endif
|
2010-03-25 11:57:30 -07:00
|
|
|
mRunning(NOT_STARTED),
|
2011-09-29 23:02:59 -07:00
|
|
|
mWindowless(false),
|
|
|
|
mTransparent(false),
|
2011-11-11 17:10:31 -08:00
|
|
|
mCached(false),
|
2011-09-29 23:02:59 -07:00
|
|
|
mUsesDOMForCursor(false),
|
|
|
|
mInPluginInitCall(false),
|
2012-04-02 12:17:34 -07:00
|
|
|
mPlugin(nsnull),
|
2009-08-26 17:29:47 -07:00
|
|
|
mMIMEType(nsnull),
|
|
|
|
mOwner(nsnull),
|
2010-10-02 09:00:45 -07:00
|
|
|
mCurrentPluginEvent(nsnull),
|
2011-07-12 07:31:18 -07:00
|
|
|
#if defined(MOZ_X11) || defined(XP_WIN) || defined(XP_MACOSX)
|
2011-09-29 23:02:59 -07:00
|
|
|
mUsePluginLayersPref(true)
|
2010-10-02 09:00:45 -07:00
|
|
|
#else
|
2011-09-29 23:02:59 -07:00
|
|
|
mUsePluginLayersPref(false)
|
2010-10-02 09:00:45 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-12 19:44:48 -07:00
|
|
|
mNPP.pdata = NULL;
|
|
|
|
mNPP.ndata = this;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-03 21:09:20 -07:00
|
|
|
mUsePluginLayersPref =
|
|
|
|
Preferences::GetBool("plugins.use_layers", mUsePluginLayersPref);
|
2010-10-02 09:00:45 -07:00
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-09 11:16:47 -07:00
|
|
|
nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-09-15 05:45:01 -07:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-28 16:43:19 -07:00
|
|
|
if (mMIMEType) {
|
|
|
|
PR_Free((void *)mMIMEType);
|
|
|
|
mMIMEType = nsnull;
|
|
|
|
}
|
2012-06-06 19:39:18 -07:00
|
|
|
|
|
|
|
#if MOZ_WIDGET_ANDROID
|
|
|
|
SetWakeLock(false);
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::Destroy()
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
mPlugin = nsnull;
|
|
|
|
}
|
|
|
|
|
2011-11-11 17:10:31 -08:00
|
|
|
TimeStamp
|
|
|
|
nsNPAPIPluginInstance::StopTime()
|
|
|
|
{
|
|
|
|
return mStopTime;
|
|
|
|
}
|
|
|
|
|
2012-04-02 12:17:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsIPluginInstanceOwner* aOwner, const char* aMIMEType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-09-15 05:45:01 -07:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::Initialize this=%p\n",this));
|
2009-06-29 11:53:52 -07:00
|
|
|
|
2012-04-02 12:17:34 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aPlugin);
|
|
|
|
NS_ENSURE_ARG_POINTER(aOwner);
|
|
|
|
|
|
|
|
mPlugin = aPlugin;
|
2009-06-29 11:53:52 -07:00
|
|
|
mOwner = aOwner;
|
|
|
|
|
2009-06-28 16:43:19 -07:00
|
|
|
if (aMIMEType) {
|
2009-07-08 20:25:20 -07:00
|
|
|
mMIMEType = (char*)PR_Malloc(PL_strlen(aMIMEType) + 1);
|
2012-04-02 12:17:34 -07:00
|
|
|
if (mMIMEType) {
|
2009-07-08 20:25:20 -07:00
|
|
|
PL_strcpy(mMIMEType, aMIMEType);
|
2012-04-02 12:17:34 -07:00
|
|
|
}
|
2009-06-28 16:43:19 -07:00
|
|
|
}
|
2012-04-23 21:49:25 -07:00
|
|
|
|
2012-04-02 12:17:34 -07:00
|
|
|
return Start();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::Stop()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-09-15 05:45:01 -07:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::Stop this=%p\n",this));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Make sure the plugin didn't leave popups enabled.
|
2009-03-28 06:57:13 -07:00
|
|
|
if (mPopupStates.Length() > 0) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsPIDOMWindow> window = GetDOMWindow();
|
|
|
|
|
|
|
|
if (window) {
|
|
|
|
window->PopPopupControlState(openAbused);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-08 13:54:04 -08:00
|
|
|
if (RUNNING != mRunning) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2009-01-10 09:13:31 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
// clean up all outstanding timers
|
|
|
|
for (PRUint32 i = mTimers.Length(); i > 0; i--)
|
|
|
|
UnscheduleTimer(mTimers[i - 1]->id);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
// If there's code from this plugin instance on the stack, delay the
|
|
|
|
// destroy.
|
|
|
|
if (PluginDestructionGuard::DelayDestroy(this)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-17 18:09:22 -08:00
|
|
|
// Make sure we lock while we're writing to mRunning after we've
|
2007-07-11 16:25:45 -07: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-03-31 21:29:02 -07:00
|
|
|
{
|
|
|
|
AsyncCallbackAutoLock lock;
|
|
|
|
mRunning = DESTROYING;
|
2011-11-11 17:10:31 -08: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-03-31 21:29:02 -07:00
|
|
|
}
|
2007-07-11 16:25:45 -07:00
|
|
|
|
2009-07-12 19:44:48 -07:00
|
|
|
OnPluginDestroy(&mNPP);
|
2007-07-11 16:25:45 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// clean up open streams
|
2011-01-05 11:44:21 -08:00
|
|
|
while (mStreamListeners.Length() > 0) {
|
|
|
|
nsRefPtr<nsNPAPIPluginStreamListener> currentListener(mStreamListeners[0]);
|
2010-08-09 11:38:43 -07:00
|
|
|
currentListener->CleanUpStream(NPRES_USER_BREAK);
|
2011-01-05 11:44:21 -08:00
|
|
|
mStreamListeners.RemoveElement(currentListener);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-10-14 14:06:31 -07:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-19 19:11:26 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2010-03-08 13:54:04 -08:00
|
|
|
NPError error = NPERR_GENERIC_ERROR;
|
2010-07-19 19:11:26 -07:00
|
|
|
if (pluginFunctions->destroy) {
|
2010-03-08 13:54:04 -08:00
|
|
|
NPSavedData *sdata = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-14 14:06:31 -07:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->destroy)(&mNPP, &sdata), this);
|
2010-03-08 13:54:04 -08:00
|
|
|
|
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPP Destroy called: this=%p, npp=%p, return=%d\n", this, &mNPP, error));
|
|
|
|
}
|
|
|
|
mRunning = DESTROYED;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-04 08:48:41 -07:00
|
|
|
#if MOZ_WIDGET_ANDROID
|
|
|
|
for (PRUint32 i = 0; i < mPostedEvents.Length(); i++) {
|
|
|
|
mPostedEvents[i]->Cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
mPostedEvents.Clear();
|
|
|
|
#endif
|
|
|
|
|
2009-07-12 19:44:48 -07:00
|
|
|
nsJSNPRuntime::OnPluginDestroy(&mNPP);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-12 13:23:30 -07:00
|
|
|
if (error != NPERR_NO_ERROR)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
else
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsPIDOMWindow>
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance::GetDOMWindow()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
2009-06-29 11:53:52 -07:00
|
|
|
GetOwner(getter_AddRefs(owner));
|
2008-11-03 11:23:07 -08:00
|
|
|
if (!owner)
|
2007-03-22 10:30:00 -07:00
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
owner->GetDocument(getter_AddRefs(doc));
|
2008-11-03 11:23:07 -08:00
|
|
|
if (!doc)
|
2007-03-22 10:30:00 -07:00
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsPIDOMWindow *window = doc->GetWindow();
|
|
|
|
NS_IF_ADDREF(window);
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetTagType(nsPluginTagType *result)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-06-29 11:53:52 -07:00
|
|
|
if (mOwner) {
|
2009-07-01 17:54:18 -07:00
|
|
|
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
|
2009-06-29 11:53:52 -07:00
|
|
|
if (tinfo)
|
|
|
|
return tinfo->GetTagType(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetAttributes(PRUint16& n, const char*const*& names,
|
|
|
|
const char*const*& values)
|
|
|
|
{
|
|
|
|
if (mOwner) {
|
2009-07-01 17:54:18 -07:00
|
|
|
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
|
2009-06-29 11:53:52 -07:00
|
|
|
if (tinfo)
|
|
|
|
return tinfo->GetAttributes(n, names, values);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetParameters(PRUint16& n, const char*const*& names,
|
|
|
|
const char*const*& values)
|
|
|
|
{
|
|
|
|
if (mOwner) {
|
2009-07-01 17:54:18 -07:00
|
|
|
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
|
2009-06-29 11:53:52 -07:00
|
|
|
if (tinfo)
|
|
|
|
return tinfo->GetParameters(n, names, values);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2009-09-16 18:30:26 -07:00
|
|
|
nsNPAPIPluginInstance::GetMode(PRInt32 *result)
|
2009-06-29 11:53:52 -07:00
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->GetMode(result);
|
|
|
|
else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-07-17 16:47:29 -07:00
|
|
|
nsTArray<nsNPAPIPluginStreamListener*>*
|
2011-01-05 11:44:21 -08:00
|
|
|
nsNPAPIPluginInstance::StreamListeners()
|
2010-07-17 16:47:29 -07:00
|
|
|
{
|
2011-01-05 11:44:21 -08:00
|
|
|
return &mStreamListeners;
|
2010-07-17 16:47:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsPluginStreamListenerPeer*>*
|
2011-01-05 11:44:21 -08:00
|
|
|
nsNPAPIPluginInstance::FileCachedStreamListeners()
|
2010-07-17 16:47:29 -07:00
|
|
|
{
|
2011-01-05 11:44:21 -08:00
|
|
|
return &mFileCachedStreamListeners;
|
2010-07-17 16:47:29 -07:00
|
|
|
}
|
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
nsresult
|
2012-04-02 12:17:34 -07:00
|
|
|
nsNPAPIPluginInstance::Start()
|
|
|
|
{
|
|
|
|
if (mRunning == RUNNING) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
PRUint16 count = 0;
|
|
|
|
const char* const* names = nsnull;
|
|
|
|
const char* const* values = nsnull;
|
|
|
|
nsPluginTagType tagtype;
|
2009-06-29 11:53:52 -07:00
|
|
|
nsresult rv = GetTagType(&tagtype);
|
2007-03-22 10:30:00 -07: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 11:53:52 -07:00
|
|
|
rv = GetAttributes(count, names, values);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// nsPluginTagType_Object or Applet may also have PARAM tags
|
|
|
|
// Note: The arrays handed back by GetParameters() are
|
|
|
|
// crafted specially to be directly behind the arrays from GetAttributes()
|
|
|
|
// with a null entry as a separator. This is for 4.x backwards compatibility!
|
|
|
|
// see bug 111008 for details
|
|
|
|
if (tagtype != nsPluginTagType_Embed) {
|
|
|
|
PRUint16 pcount = 0;
|
|
|
|
const char* const* pnames = nsnull;
|
|
|
|
const char* const* pvalues = nsnull;
|
2009-06-29 11:53:52 -07:00
|
|
|
if (NS_SUCCEEDED(GetParameters(pcount, pnames, pvalues))) {
|
2011-10-05 11:43:16 -07:00
|
|
|
// Android expects an empty string as the separator instead of null
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-10-05 11:43:16 -07:00
|
|
|
NS_ASSERTION(PL_strcmp(values[count], "") == 0, "attribute/parameter array not setup correctly for Android NPAPI plugins");
|
|
|
|
#else
|
2008-11-03 11:23:07 -08:00
|
|
|
NS_ASSERTION(!values[count], "attribute/parameter array not setup correctly for NPAPI plugins");
|
2011-10-05 11:43:16 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
if (pcount)
|
2008-11-03 11:23:07 -08:00
|
|
|
count += ++pcount; // if it's all setup correctly, then all we need is to
|
|
|
|
// change the count (attrs + PARAM/blank + params)
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-16 18:30:26 -07:00
|
|
|
PRInt32 mode;
|
2009-07-13 09:27:46 -07:00
|
|
|
const char* mimetype;
|
2010-01-27 15:45:34 -08:00
|
|
|
NPError error = NPERR_GENERIC_ERROR;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
GetMode(&mode);
|
2009-06-28 16:43:19 -07:00
|
|
|
GetMIMEType(&mimetype);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Some older versions of Flash have a bug in them
|
|
|
|
// that causes the stack to become currupt if we
|
2009-06-30 15:55:16 -07:00
|
|
|
// pass swliveconnect=1 in the NPP_NewProc arrays.
|
2007-03-22 10:30:00 -07: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.
|
|
|
|
|
|
|
|
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) {
|
|
|
|
for (PRUint16 i=0; i<count; i++) {
|
|
|
|
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) {
|
|
|
|
// we cannot just *val=0, it won't be free properly in such case
|
|
|
|
val[0] = '0';
|
|
|
|
val[1] = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool oldVal = mInPluginInitCall;
|
2011-09-29 23:02:59 -07:00
|
|
|
mInPluginInitCall = true;
|
2007-11-11 22:07:10 -08:00
|
|
|
|
2009-10-07 16:50:48 -07: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-19 19:11:26 -07: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;
|
|
|
|
|
2012-05-21 18:35:29 -07:00
|
|
|
#if MOZ_WIDGET_ANDROID
|
|
|
|
// Flash creates some local JNI references during initialization (NPP_New). It does not
|
|
|
|
// remove these references later, so essentially they are leaked. AutoLocalJNIFrame
|
|
|
|
// prevents this by pushing a JNI frame. As a result, all local references created
|
|
|
|
// by Flash are contained in this frame. AutoLocalJNIFrame pops the frame once we
|
|
|
|
// go out of scope and the local references are deleted, preventing the leak.
|
|
|
|
JNIEnv* env = AndroidBridge::GetJNIEnv();
|
|
|
|
if (!env)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
mozilla::AutoLocalJNIFrame frame(env);
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (PRUint16)mode, count, (char**)names, (char**)values, NULL, &error);
|
2007-11-11 22:07:10 -08:00
|
|
|
mInPluginInitCall = oldVal;
|
|
|
|
|
2007-03-22 10:30:00 -07: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-12 19:44:48 -07:00
|
|
|
this, &mNPP, mimetype, mode, count, error));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-03 13:10:45 -08:00
|
|
|
if (NS_FAILED(newResult) || error != NPERR_NO_ERROR) {
|
2010-03-08 13:54:04 -08:00
|
|
|
mRunning = DESTROYED;
|
2011-02-03 13:10:45 -08:00
|
|
|
nsJSNPRuntime::OnPluginDestroy(&mNPP);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-26 17:29:47 -07:00
|
|
|
// NPAPI plugins don't want a SetWindow(NULL).
|
2010-03-08 13:54:04 -08:00
|
|
|
if (!window || RUNNING != mRunning)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
2008-01-29 18:32:38 -08:00
|
|
|
|
2009-08-26 17:29:47 -07:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
2008-01-29 18:32:38 -08:00
|
|
|
// bug 108347, flash plugin on linux doesn't like window->width <=
|
|
|
|
// 0, but Java needs wants this call.
|
2009-09-16 18:30:26 -07:00
|
|
|
if (!nsPluginHost::IsJavaMIMEType(mMIMEType) && window->type == NPWindowTypeWindow &&
|
2007-09-29 00:08:14 -07:00
|
|
|
(window->width <= 0 || window->height <= 0)) {
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-08-26 17:29:47 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-14 14:06:31 -07:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-19 19:11:26 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
if (pluginFunctions->setwindow) {
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX Turns out that NPPluginWindow and NPWindow are structurally
|
|
|
|
// identical (on purpose!), so there's no need to make a copy.
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetWindow (about to call it) this=%p\n",this));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool oldVal = mInPluginInitCall;
|
2011-09-29 23:02:59 -07:00
|
|
|
mInPluginInitCall = true;
|
2007-11-11 22:07:10 -08:00
|
|
|
|
2009-10-07 16:50:48 -07:00
|
|
|
NPPAutoPusher nppPusher(&mNPP);
|
|
|
|
|
2009-08-26 17:29:47 -07:00
|
|
|
NPError error;
|
2010-10-14 14:06:31 -07:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setwindow)(&mNPP, (NPWindow*)window), this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-11 22:07:10 -08:00
|
|
|
mInPluginInitCall = oldVal;
|
2007-03-22 10:30:00 -07: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",
|
|
|
|
this, window->x, window->y, window->width, window->height,
|
|
|
|
window->clipRect.top, window->clipRect.bottom, window->clipRect.left, window->clipRect.right, error));
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-07-08 20:25:20 -07:00
|
|
|
nsNPAPIPluginInstance::NewStreamFromPlugin(const char* type, const char* target,
|
2009-06-29 11:53:52 -07: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 11:44:21 -08:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::NewStreamListener(const char* aURL, void* notifyData,
|
2012-05-17 16:54:26 -07:00
|
|
|
nsNPAPIPluginStreamListener** listener)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-05-17 16:54:26 -07:00
|
|
|
nsRefPtr<nsNPAPIPluginStreamListener> sl = new nsNPAPIPluginStreamListener(this, notifyData, aURL);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
mStreamListeners.AppendElement(sl);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-17 16:54:26 -07:00
|
|
|
sl.forget(listener);
|
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::Print(NPPrint* platformPrint)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(platformPrint, NS_ERROR_NULL_POINTER);
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2010-10-14 14:06:31 -07:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-19 19:11:26 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NPPrint* thePrint = (NPPrint *)platformPrint;
|
|
|
|
|
|
|
|
// to be compatible with the older SDK versions and to match what
|
2008-11-03 11:23:07 -08:00
|
|
|
// NPAPI and other browsers do, overwrite |window.type| field with one
|
2007-03-22 10:30:00 -07:00
|
|
|
// more copy of |platformPrint|. See bug 113264
|
2010-07-19 19:11:26 -07:00
|
|
|
PRUint16 sdkmajorversion = (pluginFunctions->version & 0xff00)>>8;
|
|
|
|
PRUint16 sdkminorversion = pluginFunctions->version & 0x00ff;
|
2009-08-12 02:49:55 -07: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");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
if (pluginFunctions->print)
|
2010-10-14 14:06:31 -07:00
|
|
|
NS_TRY_SAFE_CALL_VOID((*pluginFunctions->print)(&mNPP, thePrint), this);
|
2007-03-22 10:30:00 -07: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));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::HandleEvent(void* event, PRInt16* result)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-03-08 13:54:04 -08:00
|
|
|
if (RUNNING != mRunning)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
|
2008-09-12 13:23:30 -07:00
|
|
|
if (!event)
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(this);
|
|
|
|
|
2010-10-14 14:06:31 -07:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-19 19:11:26 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2010-06-09 17:56:17 -07:00
|
|
|
PRInt16 tmpResult = kNPEventNotHandled;
|
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
if (pluginFunctions->event) {
|
2009-08-26 17:29:47 -07:00
|
|
|
mCurrentPluginEvent = event;
|
2009-09-16 18:30:26 -07:00
|
|
|
#if defined(XP_WIN) || defined(XP_OS2)
|
2010-10-14 14:06:31 -07:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(tmpResult, (*pluginFunctions->event)(&mNPP, event), this);
|
2009-09-16 18:30:26 -07:00
|
|
|
#else
|
2010-07-19 19:11:26 -07:00
|
|
|
tmpResult = (*pluginFunctions->event)(&mNPP, event);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2009-08-26 17:29:47 -07:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
2009-09-16 18:30:26 -07:00
|
|
|
("NPP HandleEvent called: this=%p, npp=%p, event=%p, return=%d\n",
|
2010-06-09 17:56:17 -07:00
|
|
|
this, &mNPP, event, tmpResult));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-09 17:56:17 -07:00
|
|
|
if (result)
|
|
|
|
*result = tmpResult;
|
2009-08-26 17:29:47 -07:00
|
|
|
mCurrentPluginEvent = nsnull;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::GetValueFromPlugin(NPPVariable variable, void* value)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-10-14 14:06:31 -07:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-19 19:11:26 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2011-03-23 11:46:09 -07:00
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
if (pluginFunctions->getvalue && RUNNING == mRunning) {
|
2008-02-28 18:06:00 -08:00
|
|
|
PluginDestructionGuard guard(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-03-23 11:46:09 -07:00
|
|
|
NPError pluginError = NPERR_GENERIC_ERROR;
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(pluginError, (*pluginFunctions->getvalue)(&mNPP, variable, value), this);
|
2007-03-22 10:30:00 -07:00
|
|
|
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
|
|
|
("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
|
2011-03-23 11:46:09 -07:00
|
|
|
this, &mNPP, variable, value, pluginError));
|
|
|
|
|
|
|
|
if (pluginError == NPERR_NO_ERROR) {
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-19 19:11:26 -07:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNPAPIPlugin* nsNPAPIPluginInstance::GetPlugin()
|
|
|
|
{
|
|
|
|
return mPlugin;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::GetNPP(NPP* aNPP)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-11-03 11:23:07 -08:00
|
|
|
if (aNPP)
|
2009-07-12 19:44:48 -07:00
|
|
|
*aNPP = &mNPP;
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NPError nsNPAPIPluginInstance::SetWindowless(bool aWindowless)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mWindowless = aWindowless;
|
2010-04-12 14:37:28 -07:00
|
|
|
|
|
|
|
if (mMIMEType) {
|
2010-10-27 06:13:53 -07: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-29 23:02:59 -07:00
|
|
|
mTransparent = true;
|
2010-10-27 06:13:53 -07:00
|
|
|
}
|
2010-04-12 14:37:28 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NPError nsNPAPIPluginInstance::SetTransparent(bool aTransparent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mTransparent = aTransparent;
|
2008-08-04 14:17:55 -07:00
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NPError nsNPAPIPluginInstance::SetUsesDOMForCursor(bool aUsesDOMForCursor)
|
2011-04-08 12:58:04 -07:00
|
|
|
{
|
|
|
|
mUsesDOMForCursor = aUsesDOMForCursor;
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2011-04-08 12:58:04 -07:00
|
|
|
nsNPAPIPluginInstance::UsesDOMForCursor()
|
|
|
|
{
|
|
|
|
return mUsesDOMForCursor;
|
|
|
|
}
|
|
|
|
|
2008-09-15 05:45:01 -07:00
|
|
|
void nsNPAPIPluginInstance::SetDrawingModel(NPDrawingModel aModel)
|
2007-03-26 18:07:57 -07:00
|
|
|
{
|
|
|
|
mDrawingModel = aModel;
|
|
|
|
}
|
|
|
|
|
2012-02-15 19:30:22 -08:00
|
|
|
void nsNPAPIPluginInstance::RedrawPlugin()
|
|
|
|
{
|
|
|
|
mOwner->RedrawPlugin();
|
|
|
|
}
|
|
|
|
|
2012-02-15 19:24:38 -08:00
|
|
|
#if defined(XP_MACOSX)
|
2009-08-26 17:29:47 -07:00
|
|
|
void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
|
2007-03-26 18:07:57 -07:00
|
|
|
{
|
2009-11-09 19:58:48 -08:00
|
|
|
// the event model needs to be set for the object frame immediately
|
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
|
|
|
GetOwner(getter_AddRefs(owner));
|
|
|
|
if (!owner) {
|
|
|
|
NS_WARNING("Trying to set event model without a plugin instance owner!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
owner->SetEventModel(aModel);
|
2007-03-26 18:07:57 -07:00
|
|
|
}
|
2011-09-16 14:34:31 -07:00
|
|
|
#endif
|
|
|
|
|
2011-11-10 16:17:46 -08:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2012-02-15 12:34:31 -08:00
|
|
|
|
|
|
|
static void SendLifecycleEvent(nsNPAPIPluginInstance* aInstance, PRUint32 aAction)
|
|
|
|
{
|
|
|
|
ANPEvent event;
|
|
|
|
event.inSize = sizeof(ANPEvent);
|
|
|
|
event.eventType = kLifecycle_ANPEventType;
|
|
|
|
event.data.lifecycle.action = aAction;
|
|
|
|
aInstance->HandleEvent(&event, nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 09:10:49 -07:00
|
|
|
void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
|
2011-09-16 14:34:31 -07:00
|
|
|
{
|
2012-05-30 09:10:49 -07:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::NotifyFullScreen this=%p\n",this));
|
2011-09-16 14:34:31 -07:00
|
|
|
|
2012-06-06 19:39:36 -07:00
|
|
|
if (RUNNING != mRunning || mFullScreen == aFullScreen)
|
2012-05-30 09:10:49 -07:00
|
|
|
return;
|
2011-09-16 14:34:31 -07:00
|
|
|
|
2012-06-06 19:39:36 -07:00
|
|
|
mFullScreen = aFullScreen;
|
|
|
|
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
|
|
|
|
|
|
|
|
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
|
|
|
|
AndroidBridge::Bridge()->LockScreenOrientation(mFullScreenOrientation);
|
|
|
|
}
|
2011-09-16 14:34:31 -07:00
|
|
|
}
|
2009-08-26 17:29:47 -07:00
|
|
|
|
2012-05-30 09:10:49 -07:00
|
|
|
void nsNPAPIPluginInstance::SetANPDrawingModel(PRUint32 aModel)
|
2011-10-05 11:44:19 -07:00
|
|
|
{
|
2012-05-30 09:10:49 -07:00
|
|
|
mANPDrawingModel = aModel;
|
2011-10-05 11:44:19 -07:00
|
|
|
}
|
|
|
|
|
2012-05-30 09:10:49 -07:00
|
|
|
void* nsNPAPIPluginInstance::GetJavaSurface()
|
2011-10-05 11:44:19 -07:00
|
|
|
{
|
2012-05-30 09:10:49 -07:00
|
|
|
void* surface = nsnull;
|
|
|
|
nsresult rv = GetValueFromPlugin(kJavaSurface_ANPGetValue, &surface);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return nsnull;
|
2011-10-05 11:44:19 -07:00
|
|
|
|
2012-05-30 09:10:49 -07:00
|
|
|
return surface;
|
2011-10-05 11:44:19 -07:00
|
|
|
}
|
|
|
|
|
2012-05-04 08:48:41 -07:00
|
|
|
void nsNPAPIPluginInstance::PostEvent(void* event)
|
|
|
|
{
|
|
|
|
PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event);
|
|
|
|
mPostedEvents.AppendElement(nsRefPtr<PluginEventRunnable>(r));
|
|
|
|
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
}
|
|
|
|
|
2012-06-06 19:39:36 -07:00
|
|
|
void nsNPAPIPluginInstance::SetFullScreenOrientation(PRUint32 orientation)
|
|
|
|
{
|
|
|
|
if (mFullScreenOrientation == orientation)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PRUint32 oldOrientation = mFullScreenOrientation;
|
|
|
|
mFullScreenOrientation = orientation;
|
|
|
|
|
|
|
|
if (mFullScreen) {
|
|
|
|
// We're already fullscreen so immediately apply the orientation change
|
|
|
|
|
|
|
|
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
|
|
|
|
AndroidBridge::Bridge()->LockScreenOrientation(mFullScreenOrientation);
|
|
|
|
} else if (oldOrientation != dom::eScreenOrientation_None) {
|
|
|
|
// We applied an orientation when we entered fullscreen, but
|
|
|
|
// we don't want it anymore
|
|
|
|
AndroidBridge::Bridge()->UnlockScreenOrientation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-04 08:48:41 -07:00
|
|
|
void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
|
|
|
|
{
|
|
|
|
mPostedEvents.RemoveElement(r);
|
|
|
|
}
|
|
|
|
|
2012-06-06 19:39:18 -07: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);
|
|
|
|
}
|
|
|
|
|
2007-03-26 18:07:57 -07:00
|
|
|
#endif
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::GetDrawingModel(PRInt32* aModel)
|
2009-08-26 17:29:47 -07:00
|
|
|
{
|
2012-01-17 14:45:06 -08:00
|
|
|
#if defined(XP_MACOSX)
|
2009-09-16 18:30:26 -07:00
|
|
|
*aModel = (PRInt32)mDrawingModel;
|
|
|
|
return NS_OK;
|
|
|
|
#else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
#endif
|
2011-02-12 07:55:40 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult nsNPAPIPluginInstance::IsRemoteDrawingCoreAnimation(bool* aDrawing)
|
2011-06-30 09:46:26 -07: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
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-07-01 21:52:07 -07:00
|
|
|
nsNPAPIPluginInstance::GetJSObject(JSContext *cx, JSObject** outObject)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NPObject *npobj = nsnull;
|
2009-09-16 18:30:26 -07:00
|
|
|
nsresult rv = GetValueFromPlugin(NPPVpluginScriptableNPObject, &npobj);
|
2009-07-01 21:52:07 -07:00
|
|
|
if (NS_FAILED(rv) || !npobj)
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-12 19:44:48 -07:00
|
|
|
*outObject = nsNPObjWrapper::GetNewOrUsed(&mNPP, cx, npobj);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-01 21:52:07 -07:00
|
|
|
_releaseobject(npobj);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-01 21:52:07 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-11-11 17:10:31 -08:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::SetCached(bool aCache)
|
|
|
|
{
|
|
|
|
mCached = aCache;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsNPAPIPluginInstance::ShouldCache()
|
|
|
|
{
|
|
|
|
return mCached;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-09-28 23:19:26 -07:00
|
|
|
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
|
2009-09-16 18:30:26 -07:00
|
|
|
{
|
2011-11-10 16:17:46 -08:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-16 14:34:31 -07:00
|
|
|
// On android, pre-honeycomb, all plugins are treated as windowless.
|
2011-09-29 23:02:59 -07:00
|
|
|
*isWindowless = true;
|
2011-09-16 14:34:31 -07:00
|
|
|
#else
|
2009-09-16 18:30:26 -07:00
|
|
|
*isWindowless = mWindowless;
|
2011-09-16 14:34:31 -07:00
|
|
|
#endif
|
2009-09-16 18:30:26 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-12 08:07:10 -08:00
|
|
|
class NS_STACK_CLASS AutoPluginLibraryCall
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoPluginLibraryCall(nsNPAPIPluginInstance* aThis)
|
|
|
|
: mThis(aThis), mGuard(aThis), mLibrary(nsnull)
|
|
|
|
{
|
|
|
|
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-17 18:48:34 -07:00
|
|
|
nsresult
|
2010-09-10 11:28:52 -07:00
|
|
|
nsNPAPIPluginInstance::AsyncSetWindow(NPWindow* window)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-02-16 14:43:31 -08:00
|
|
|
AutoPluginLibraryCall library(this);
|
2010-09-10 11:28:52 -07:00
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return library->AsyncSetWindow(&mNPP, window);
|
|
|
|
}
|
|
|
|
|
2011-08-29 09:26:24 -07:00
|
|
|
#if defined(MOZ_WIDGET_QT) && (MOZ_PLATFORM_MAEMO == 6)
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::HandleGUIEvent(const nsGUIEvent& anEvent, bool* handled)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning) {
|
|
|
|
*handled = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return library->HandleGUIEvent(&mNPP, anEvent, handled);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2012-02-08 07:34:27 -08:00
|
|
|
nsNPAPIPluginInstance::GetImageContainer(ImageContainer**aContainer)
|
2011-02-12 08:07:10 -08:00
|
|
|
{
|
2012-02-08 07:34:27 -08:00
|
|
|
*aContainer = nsnull;
|
2011-02-22 21:38:09 -08:00
|
|
|
|
2011-02-12 08:07:10 -08:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
2012-02-08 07:34:27 -08:00
|
|
|
return !library ? NS_ERROR_FAILURE : library->GetImageContainer(&mNPP, aContainer);
|
2011-02-12 08:07:10 -08:00
|
|
|
}
|
2010-09-10 11:28:52 -07:00
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-02-22 21:38:09 -08: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-17 18:48:34 -07:00
|
|
|
nsresult
|
2010-09-10 11:28:52 -07:00
|
|
|
nsNPAPIPluginInstance::NotifyPainted(void)
|
|
|
|
{
|
2010-11-05 07:40:55 -07:00
|
|
|
NS_NOTREACHED("Dead code, shouldn't be called.");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-09-10 11:28:52 -07:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-09-28 23:19:26 -07:00
|
|
|
nsNPAPIPluginInstance::UseAsyncPainting(bool* aIsAsync)
|
2010-09-15 09:02:47 -07:00
|
|
|
{
|
2010-10-02 09:00:45 -07:00
|
|
|
if (!mUsePluginLayersPref) {
|
|
|
|
*aIsAsync = mUsePluginLayersPref;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-16 14:43:31 -08:00
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
2010-09-15 09:02:47 -07:00
|
|
|
|
2011-02-16 14:43:31 -08:00
|
|
|
*aIsAsync = library->UseAsyncPainting();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-02-16 14:43:31 -08:00
|
|
|
nsNPAPIPluginInstance::SetBackgroundUnknown()
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
|
|
|
if (!library)
|
2010-09-15 09:02:47 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-02-16 14:43:31 -08:00
|
|
|
return library->SetBackgroundUnknown(&mNPP);
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-02-16 14:43:31 -08:00
|
|
|
nsNPAPIPluginInstance::BeginUpdateBackground(nsIntRect* aRect,
|
|
|
|
gfxContext** aContext)
|
|
|
|
{
|
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
AutoPluginLibraryCall library(this);
|
2010-09-15 09:02:47 -07:00
|
|
|
if (!library)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-02-16 14:43:31 -08:00
|
|
|
return library->BeginUpdateBackground(&mNPP, *aRect, aContext);
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-02-16 14:43:31 -08: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 09:02:47 -07:00
|
|
|
}
|
2010-09-10 11:28:52 -07:00
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-09-28 23:19:26 -07:00
|
|
|
nsNPAPIPluginInstance::IsTransparent(bool* isTransparent)
|
2009-09-16 18:30:26 -07:00
|
|
|
{
|
|
|
|
*isTransparent = mTransparent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance::GetFormValue(nsAString& aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aValue.Truncate();
|
|
|
|
|
|
|
|
char *value = nsnull;
|
2009-09-16 18:30:26 -07:00
|
|
|
nsresult rv = GetValueFromPlugin(NPPVformValue, &value);
|
2009-07-01 21:52:07 -07:00
|
|
|
if (NS_FAILED(rv) || !value)
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-01 21:52:07 -07:00
|
|
|
CopyUTF8toUTF16(value, aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-07-01 21:52:07 -07:00
|
|
|
// NPPVformValue allocates with NPN_MemAlloc(), which uses
|
|
|
|
// nsMemory.
|
|
|
|
nsMemory::Free(value);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2011-09-28 23:19:26 -07:00
|
|
|
nsNPAPIPluginInstance::PushPopupsEnabledState(bool aEnabled)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = GetDOMWindow();
|
|
|
|
if (!window)
|
2009-07-01 21:52:07 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
PopupControlState oldState =
|
|
|
|
window->PushPopupControlState(aEnabled ? openAllowed : openAbused,
|
2011-09-29 23:02:59 -07:00
|
|
|
true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-03-28 06:57:13 -07:00
|
|
|
if (!mPopupStates.AppendElement(oldState)) {
|
2009-07-01 21:52:07 -07:00
|
|
|
// Appending to our state stack failed, pop what we just pushed.
|
2007-03-22 10:30:00 -07:00
|
|
|
window->PopPopupControlState(oldState);
|
2009-07-01 21:52:07 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-07-01 21:52:07 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2008-09-15 05:45:01 -07:00
|
|
|
nsNPAPIPluginInstance::PopPopupsEnabledState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-03-28 06:57:13 -07:00
|
|
|
PRInt32 last = mPopupStates.Length() - 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (last < 0) {
|
|
|
|
// Nothing to pop.
|
2009-07-01 21:52:07 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = GetDOMWindow();
|
|
|
|
if (!window)
|
2009-07-01 21:52:07 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-03-28 06:57:13 -07:00
|
|
|
PopupControlState &oldState = mPopupStates[last];
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
window->PopPopupControlState(oldState);
|
|
|
|
|
|
|
|
mPopupStates.RemoveElementAt(last);
|
2009-07-01 21:52:07 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-07-01 21:52:07 -07:00
|
|
|
nsNPAPIPluginInstance::GetPluginAPIVersion(PRUint16* version)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-01 21:52:07 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(version);
|
2010-07-19 19:11:26 -07:00
|
|
|
|
|
|
|
if (!mPlugin)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (!mPlugin->GetLibrary())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
|
|
|
*version = pluginFunctions->version;
|
|
|
|
|
2009-07-01 21:52:07 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-01-30 13:40:14 -08:00
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
nsresult
|
2012-04-23 21:49:25 -07:00
|
|
|
nsNPAPIPluginInstance::PrivateModeStateChanged(bool enabled)
|
2009-01-30 13:40:14 -08:00
|
|
|
{
|
2010-03-08 13:54:04 -08:00
|
|
|
if (RUNNING != mRunning)
|
2009-01-30 13:40:14 -08:00
|
|
|
return NS_OK;
|
2010-07-19 19:11:26 -07:00
|
|
|
|
2009-01-30 13:40:14 -08:00
|
|
|
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance informing plugin of private mode state change this=%p\n",this));
|
2010-07-19 19:11:26 -07:00
|
|
|
|
2010-10-14 14:06:31 -07:00
|
|
|
if (!mPlugin || !mPlugin->GetLibrary())
|
2010-07-19 19:11:26 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
|
|
|
|
|
2012-04-23 21:49:25 -07:00
|
|
|
if (!pluginFunctions->setvalue)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PluginDestructionGuard guard(this);
|
2009-01-30 13:40:14 -08:00
|
|
|
|
2012-04-23 21:49:25 -07:00
|
|
|
NPError error;
|
|
|
|
NPBool value = static_cast<NPBool>(enabled);
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, (*pluginFunctions->setvalue)(&mNPP, NPNVprivateModeBool, &value), this);
|
|
|
|
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
|
2009-01-30 13:40:14 -08:00
|
|
|
}
|
2009-06-26 10:30:36 -07:00
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
class DelayUnscheduleEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
nsRefPtr<nsNPAPIPluginInstance> mInstance;
|
|
|
|
uint32_t mTimerID;
|
|
|
|
DelayUnscheduleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aTimerId)
|
|
|
|
: mInstance(aInstance)
|
|
|
|
, mTimerID(aTimerId)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~DelayUnscheduleEvent() {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
DelayUnscheduleEvent::Run()
|
|
|
|
{
|
|
|
|
mInstance->UnscheduleTimer(mTimerID);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
static void
|
|
|
|
PluginTimerCallback(nsITimer *aTimer, void *aClosure)
|
|
|
|
{
|
|
|
|
nsNPAPITimer* t = (nsNPAPITimer*)aClosure;
|
|
|
|
NPP npp = t->npp;
|
|
|
|
uint32_t id = t->id;
|
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
// Some plugins (Flash on Android) calls unscheduletimer
|
|
|
|
// from this callback.
|
2011-09-29 23:02:59 -07:00
|
|
|
t->inCallback = true;
|
2009-07-01 08:09:49 -07:00
|
|
|
(*(t->callback))(npp, id);
|
2011-09-29 23:02:59 -07:00
|
|
|
t->inCallback = false;
|
2009-07-01 08:09:49 -07:00
|
|
|
|
|
|
|
// Make sure we still have an instance and the timer is still alive
|
|
|
|
// after the callback.
|
|
|
|
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
|
|
|
|
if (!inst || !inst->TimerWithID(id, NULL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// use UnscheduleTimer to clean up if this is a one-shot timer
|
|
|
|
PRUint32 timerType;
|
|
|
|
t->timer->GetType(&timerType);
|
|
|
|
if (timerType == nsITimer::TYPE_ONE_SHOT)
|
|
|
|
inst->UnscheduleTimer(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNPAPITimer*
|
|
|
|
nsNPAPIPluginInstance::TimerWithID(uint32_t id, PRUint32* index)
|
|
|
|
{
|
|
|
|
PRUint32 len = mTimers.Length();
|
|
|
|
for (PRUint32 i = 0; i < len; i++) {
|
|
|
|
if (mTimers[i]->id == id) {
|
|
|
|
if (index)
|
|
|
|
*index = i;
|
|
|
|
return mTimers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
nsNPAPIPluginInstance::ScheduleTimer(uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID))
|
|
|
|
{
|
|
|
|
nsNPAPITimer *newTimer = new nsNPAPITimer();
|
|
|
|
|
2011-09-29 23:02:59 -07:00
|
|
|
newTimer->inCallback = false;
|
2009-07-12 19:44:48 -07:00
|
|
|
newTimer->npp = &mNPP;
|
2009-07-01 08:09:49 -07:00
|
|
|
|
|
|
|
// generate ID that is unique to this instance
|
|
|
|
uint32_t uniqueID = mTimers.Length();
|
|
|
|
while ((uniqueID == 0) || TimerWithID(uniqueID, NULL))
|
|
|
|
uniqueID++;
|
|
|
|
newTimer->id = uniqueID;
|
|
|
|
|
|
|
|
// create new xpcom timer, scheduled correctly
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsITimer> xpcomTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
|
2010-04-14 09:03:00 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
delete newTimer;
|
2009-07-01 08:09:49 -07:00
|
|
|
return 0;
|
2010-04-14 09:03:00 -07:00
|
|
|
}
|
2009-07-01 08:09:49 -07: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
|
|
|
|
PRUint32 index;
|
|
|
|
nsNPAPITimer* t = TimerWithID(timerID, &index);
|
|
|
|
if (!t)
|
|
|
|
return;
|
|
|
|
|
2011-09-16 14:34:31 -07:00
|
|
|
if (t->inCallback) {
|
|
|
|
nsCOMPtr<nsIRunnable> e = new DelayUnscheduleEvent(this, timerID);
|
|
|
|
NS_DispatchToCurrentThread(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-01 08:09:49 -07:00
|
|
|
// cancel the timer
|
|
|
|
t->timer->Cancel();
|
|
|
|
|
|
|
|
// remove timer struct from array
|
|
|
|
mTimers.RemoveElementAt(index);
|
|
|
|
|
|
|
|
// delete timer
|
|
|
|
delete t;
|
|
|
|
}
|
|
|
|
|
2009-08-26 17:29:47 -07: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-29 23:02:59 -07:00
|
|
|
return false;
|
2009-08-26 17:29:47 -07:00
|
|
|
}
|
|
|
|
|
2009-06-29 11:53:52 -07:00
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::GetDOMElement(nsIDOMElement* *result)
|
|
|
|
{
|
|
|
|
if (!mOwner) {
|
|
|
|
*result = nsnull;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-07-01 17:54:18 -07:00
|
|
|
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
|
2009-06-29 11:53:52 -07:00
|
|
|
if (tinfo)
|
|
|
|
return tinfo->GetDOMElement(result);
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-09-16 18:30:26 -07:00
|
|
|
nsNPAPIPluginInstance::InvalidateRect(NPRect *invalidRect)
|
2009-06-26 10:30:36 -07:00
|
|
|
{
|
2010-12-21 15:03:00 -08:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
2009-06-26 10:30:36 -07:00
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
2009-06-29 11:53:52 -07:00
|
|
|
GetOwner(getter_AddRefs(owner));
|
2009-06-26 10:30:36 -07:00
|
|
|
if (!owner)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return owner->InvalidateRect(invalidRect);
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-09-16 18:30:26 -07:00
|
|
|
nsNPAPIPluginInstance::InvalidateRegion(NPRegion invalidRegion)
|
2009-06-26 10:30:36 -07:00
|
|
|
{
|
2010-12-21 15:03:00 -08:00
|
|
|
if (RUNNING != mRunning)
|
|
|
|
return NS_OK;
|
|
|
|
|
2009-06-26 10:30:36 -07:00
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
2009-06-29 11:53:52 -07:00
|
|
|
GetOwner(getter_AddRefs(owner));
|
2009-06-26 10:30:36 -07:00
|
|
|
if (!owner)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return owner->InvalidateRegion(invalidRegion);
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-07-13 09:27:46 -07:00
|
|
|
nsNPAPIPluginInstance::GetMIMEType(const char* *result)
|
2009-06-28 16:43:19 -07:00
|
|
|
{
|
|
|
|
if (!mMIMEType)
|
|
|
|
*result = "";
|
|
|
|
else
|
|
|
|
*result = mMIMEType;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-06-28 16:43:19 -07:00
|
|
|
nsNPAPIPluginInstance::GetJSContext(JSContext* *outContext)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
2009-06-29 11:53:52 -07:00
|
|
|
GetOwner(getter_AddRefs(owner));
|
2009-06-28 16:43:19 -07:00
|
|
|
if (!owner)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*outContext = NULL;
|
|
|
|
nsCOMPtr<nsIDocument> document;
|
|
|
|
|
|
|
|
nsresult rv = owner->GetDocument(getter_AddRefs(document));
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && document) {
|
|
|
|
nsIScriptGlobalObject *global = document->GetScriptGlobalObject();
|
|
|
|
|
|
|
|
if (global) {
|
|
|
|
nsIScriptContext *context = global->GetContext();
|
|
|
|
|
|
|
|
if (context) {
|
2011-09-18 02:22:17 -07:00
|
|
|
*outContext = context->GetNativeContext();
|
2009-06-28 16:43:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2009-06-29 11:53:52 -07:00
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-06-29 11:53:52 -07:00
|
|
|
nsNPAPIPluginInstance::GetOwner(nsIPluginInstanceOwner **aOwner)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aOwner);
|
|
|
|
*aOwner = mOwner;
|
|
|
|
NS_IF_ADDREF(mOwner);
|
|
|
|
return (mOwner ? NS_OK : NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-06-29 11:53:52 -07:00
|
|
|
nsNPAPIPluginInstance::SetOwner(nsIPluginInstanceOwner *aOwner)
|
|
|
|
{
|
|
|
|
mOwner = aOwner;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-06-29 11:53:52 -07:00
|
|
|
nsNPAPIPluginInstance::ShowStatus(const char* message)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->ShowStatus(message);
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult
|
2009-06-29 11:53:52 -07:00
|
|
|
nsNPAPIPluginInstance::InvalidateOwner()
|
|
|
|
{
|
|
|
|
mOwner = nsnull;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-09-10 11:28:52 -07:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNPAPIPluginInstance::AsyncSetWindow(NPWindow& window)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2011-01-05 11:44:21 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::URLRedirectResponse(void* notifyData, NPBool allow)
|
|
|
|
{
|
|
|
|
if (!notifyData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 listenerCount = mStreamListeners.Length();
|
|
|
|
for (PRUint32 i = 0; i < listenerCount; i++) {
|
|
|
|
nsNPAPIPluginStreamListener* currentListener = mStreamListeners[i];
|
|
|
|
if (currentListener->GetNotifyData() == notifyData) {
|
|
|
|
currentListener->URLRedirectResponse(allow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-03 09:31:01 -08:00
|
|
|
|
2012-02-15 19:08:41 -08:00
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::InitAsyncSurface(NPSize *size, NPImageFormat format,
|
|
|
|
void *initData, NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->InitAsyncSurface(size, format, initData, surface);
|
|
|
|
|
2012-03-12 07:39:54 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-02-15 19:08:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
nsNPAPIPluginInstance::FinalizeAsyncSurface(NPAsyncSurface *surface)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
return mOwner->FinalizeAsyncSurface(surface);
|
|
|
|
|
2012-03-12 07:39:54 -07:00
|
|
|
return NPERR_GENERIC_ERROR;
|
2012-02-15 19:08:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsNPAPIPluginInstance::SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed)
|
|
|
|
{
|
|
|
|
if (mOwner)
|
|
|
|
mOwner->SetCurrentAsyncSurface(surface, changed);
|
|
|
|
}
|
|
|
|
|
2011-02-03 09:31:01 -08: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-29 23:02:59 -07:00
|
|
|
type, true, true);
|
2011-02-03 09:31:01 -08: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.");
|
|
|
|
}
|
|
|
|
}
|