2009-07-20 13:36:23 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; 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/. */
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2008-09-15 12:45:01 +00:00
|
|
|
#ifndef nsNPAPIPluginInstance_h_
|
|
|
|
#define nsNPAPIPluginInstance_h_
|
1998-08-04 03:21:43 +00:00
|
|
|
|
2015-03-29 14:59:08 +00:00
|
|
|
#include "nsSize.h"
|
2002-10-03 21:31:41 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2009-03-28 13:57:13 +00:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2009-07-01 15:09:49 +00:00
|
|
|
#include "nsITimer.h"
|
2013-12-03 08:36:13 +00:00
|
|
|
#include "nsIPluginInstanceOwner.h"
|
2010-07-20 02:11:26 +00:00
|
|
|
#include "nsIURI.h"
|
2011-01-05 19:44:21 +00:00
|
|
|
#include "nsIChannel.h"
|
|
|
|
#include "nsHashKeys.h"
|
2013-03-12 10:34:07 +00:00
|
|
|
#include <prinrval.h>
|
2013-08-28 02:59:14 +00:00
|
|
|
#include "js/TypeDecls.h"
|
2015-07-28 21:09:48 +00:00
|
|
|
#include "nsIAudioChannelAgent.h"
|
2011-11-21 07:55:50 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#include "nsIRunnable.h"
|
2013-09-04 12:14:52 +00:00
|
|
|
#include "GLContextTypes.h"
|
2014-10-21 13:53:00 +00:00
|
|
|
#include "AndroidSurfaceTexture.h"
|
2013-03-12 10:34:07 +00:00
|
|
|
#include "AndroidBridge.h"
|
2012-07-20 19:20:51 +00:00
|
|
|
#include <map>
|
2012-05-04 15:48:41 +00:00
|
|
|
class PluginEventRunnable;
|
2011-11-21 07:55:50 +00:00
|
|
|
#endif
|
2011-10-05 18:44:19 +00:00
|
|
|
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 11:09:37 +00:00
|
|
|
#include "mozilla/EventForwards.h"
|
2010-07-13 18:42:03 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2009-10-27 19:51:12 +00:00
|
|
|
#include "mozilla/PluginLibrary.h"
|
2015-10-19 18:34:27 +00:00
|
|
|
#include "mozilla/WeakPtr.h"
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2010-07-17 23:47:29 +00:00
|
|
|
class nsPluginStreamListenerPeer; // browser-initiated stream class
|
|
|
|
class nsNPAPIPluginStreamListener; // plugin-initiated stream class
|
2010-07-13 18:42:03 +00:00
|
|
|
class nsIPluginInstanceOwner;
|
2011-05-18 01:48:34 +00:00
|
|
|
class nsIOutputStream;
|
2012-10-03 02:43:18 +00:00
|
|
|
class nsPluginInstanceOwner;
|
2001-07-24 20:48:36 +00:00
|
|
|
|
2012-02-16 03:24:38 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin;
|
|
|
|
#elif defined(MOZ_X11)
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncX;
|
2012-05-05 02:36:27 +00:00
|
|
|
#elif defined(XP_MACOSX)
|
2012-02-16 03:24:38 +00:00
|
|
|
#ifndef NP_NO_QUICKDRAW
|
2012-08-30 19:10:55 +00:00
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelQuickDraw; // Not supported
|
2012-02-16 03:24:38 +00:00
|
|
|
#else
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelCoreGraphics;
|
|
|
|
#endif
|
2012-05-05 02:36:27 +00:00
|
|
|
#else
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = static_cast<NPDrawingModel>(0);
|
2012-02-16 03:24:38 +00:00
|
|
|
#endif
|
|
|
|
|
2013-02-27 11:50:27 +00:00
|
|
|
/**
|
|
|
|
* Used to indicate whether it's OK to reenter Gecko and repaint, flush frames,
|
|
|
|
* run scripts, etc, during this plugin call.
|
|
|
|
* When NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO is set, we try to avoid dangerous
|
|
|
|
* Gecko activities when the plugin spins a nested event loop, on a best-effort
|
|
|
|
* basis.
|
|
|
|
*/
|
|
|
|
enum NSPluginCallReentry {
|
|
|
|
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO,
|
|
|
|
NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO
|
|
|
|
};
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
class nsNPAPITimer
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-07-01 15:09:49 +00:00
|
|
|
NPP npp;
|
|
|
|
uint32_t id;
|
|
|
|
nsCOMPtr<nsITimer> timer;
|
|
|
|
void (*callback)(NPP npp, uint32_t timerID);
|
2012-12-13 19:23:07 +00:00
|
|
|
bool inCallback;
|
2012-12-17 15:05:49 +00:00
|
|
|
bool needUnschedule;
|
2001-07-24 20:48:36 +00:00
|
|
|
};
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2015-07-28 21:09:48 +00:00
|
|
|
class nsNPAPIPluginInstance final : public nsIAudioChannelAgentCallback
|
2015-10-19 18:34:27 +00:00
|
|
|
, public mozilla::SupportsWeakPtr<nsNPAPIPluginInstance>
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
2009-10-27 19:51:12 +00:00
|
|
|
private:
|
|
|
|
typedef mozilla::PluginLibrary PluginLibrary;
|
|
|
|
|
1998-08-01 05:46:47 +00:00
|
|
|
public:
|
2015-12-18 03:39:10 +00:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
|
2015-10-19 18:34:27 +00:00
|
|
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsNPAPIPluginInstance)
|
2013-07-19 02:21:20 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2015-07-28 21:09:48 +00:00
|
|
|
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
2011-05-18 01:48:34 +00:00
|
|
|
|
2015-02-25 16:36:39 +00:00
|
|
|
nsresult Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const nsACString& aMIMEType);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult Start();
|
|
|
|
nsresult Stop();
|
|
|
|
nsresult SetWindow(NPWindow* window);
|
|
|
|
nsresult NewStreamFromPlugin(const char* type, const char* target, nsIOutputStream* *result);
|
|
|
|
nsresult Print(NPPrint* platformPrint);
|
2013-02-27 11:50:28 +00:00
|
|
|
nsresult HandleEvent(void* event, int16_t* result,
|
|
|
|
NSPluginCallReentry aSafeToReenterGecko = NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult GetValueFromPlugin(NPPVariable variable, void* value);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult GetDrawingModel(int32_t* aModel);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult IsRemoteDrawingCoreAnimation(bool* aDrawing);
|
2012-10-16 19:41:21 +00:00
|
|
|
nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
|
2016-03-17 19:00:59 +00:00
|
|
|
nsresult CSSZoomFactorChanged(float aCSSZoomFactor);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult GetJSObject(JSContext *cx, JSObject** outObject);
|
2011-11-12 01:10:31 +00:00
|
|
|
bool ShouldCache();
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult IsWindowless(bool* isWindowless);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult AsyncSetWindow(NPWindow* window);
|
2012-11-10 15:45:52 +00:00
|
|
|
nsresult GetImageContainer(mozilla::layers::ImageContainer **aContainer);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult GetImageSize(nsIntSize* aSize);
|
|
|
|
nsresult NotifyPainted(void);
|
2012-09-27 00:22:51 +00:00
|
|
|
nsresult GetIsOOP(bool* aIsOOP);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult SetBackgroundUnknown();
|
2015-12-18 03:39:10 +00:00
|
|
|
nsresult BeginUpdateBackground(nsIntRect* aRect, DrawTarget** aContext);
|
2015-12-18 03:39:09 +00:00
|
|
|
nsresult EndUpdateBackground(nsIntRect* aRect);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult IsTransparent(bool* isTransparent);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult GetFormValue(nsAString& aValue);
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult PushPopupsEnabledState(bool aEnabled);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult PopPopupsEnabledState();
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult GetPluginAPIVersion(uint16_t* version);
|
2011-05-18 01:48:34 +00:00
|
|
|
nsresult InvalidateRect(NPRect *invalidRect);
|
|
|
|
nsresult InvalidateRegion(NPRegion invalidRegion);
|
|
|
|
nsresult GetMIMEType(const char* *result);
|
2016-03-01 18:48:25 +00:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
nsresult GetScrollCaptureContainer(mozilla::layers::ImageContainer **aContainer);
|
|
|
|
#endif
|
Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved. However, posting all key events to the chrome process may make damage to the performance of text input. Therefore, this patch starts to post a key event whose key combination may be a shortcut key. However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.
For receiving response from widget, this patch defines nsIKeyEventInPluginCallback. It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply. Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process. However, if the widget is a PuppetWidget, it cannot return the result synchronously. Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks. Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().
MozReview-Commit-ID: G6brOU26NwQ
--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 11:09:37 +00:00
|
|
|
nsresult HandledWindowedPluginKeyEvent(
|
|
|
|
const mozilla::NativeEventData& aKeyEventData,
|
|
|
|
bool aIsConsumed);
|
2012-10-03 02:43:18 +00:00
|
|
|
nsPluginInstanceOwner* GetOwner();
|
|
|
|
void SetOwner(nsPluginInstanceOwner *aOwner);
|
2015-12-02 19:31:16 +00:00
|
|
|
void DidComposite();
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2015-07-28 21:09:48 +00:00
|
|
|
bool HasAudioChannelAgent() const
|
|
|
|
{
|
|
|
|
return !!mAudioChannelAgent;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult GetOrCreateAudioChannelAgent(nsIAudioChannelAgent** aAgent);
|
|
|
|
|
|
|
|
nsresult SetMuted(bool aIsMuted);
|
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
nsNPAPIPlugin* GetPlugin();
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsresult GetNPP(NPP * aNPP);
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError SetWindowless(bool aWindowless);
|
1998-09-15 03:48:58 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError SetTransparent(bool aTransparent);
|
1998-09-15 03:48:58 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError SetWantsAllNetworkStreams(bool aWantsAllNetworkStreams);
|
2008-08-04 21:17:55 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NPError SetUsesDOMForCursor(bool aUsesDOMForCursor);
|
|
|
|
bool UsesDOMForCursor();
|
2011-04-08 19:58:04 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
void SetDrawingModel(NPDrawingModel aModel);
|
2012-02-16 03:30:22 +00:00
|
|
|
void RedrawPlugin();
|
2012-02-16 03:24:38 +00:00
|
|
|
#ifdef XP_MACOSX
|
2009-08-27 00:29:47 +00:00
|
|
|
void SetEventModel(NPEventModel aModel);
|
2014-12-11 14:44:07 +00:00
|
|
|
|
|
|
|
void* GetCurrentEvent() {
|
|
|
|
return mCurrentPluginEvent;
|
|
|
|
}
|
2007-03-27 01:07:57 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-02-15 20:34:31 +00:00
|
|
|
void NotifyForeground(bool aForeground);
|
|
|
|
void NotifyOnScreen(bool aOnScreen);
|
|
|
|
void MemoryPressure();
|
2012-05-30 16:10:49 +00:00
|
|
|
void NotifyFullScreen(bool aFullScreen);
|
2012-07-20 19:20:51 +00:00
|
|
|
void NotifySize(nsIntSize size);
|
2012-02-15 20:34:31 +00:00
|
|
|
|
2012-09-18 18:52:15 +00:00
|
|
|
nsIntSize CurrentSize() { return mCurrentSize; }
|
|
|
|
|
2012-02-15 20:34:31 +00:00
|
|
|
bool IsOnScreen() {
|
|
|
|
return mOnScreen;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t GetANPDrawingModel() { return mANPDrawingModel; }
|
|
|
|
void SetANPDrawingModel(uint32_t aModel);
|
2012-01-31 14:40:58 +00:00
|
|
|
|
2011-09-16 21:34:31 +00:00
|
|
|
void* GetJavaSurface();
|
2012-05-04 15:48:41 +00:00
|
|
|
|
|
|
|
void PostEvent(void* event);
|
2012-05-30 16:10:49 +00:00
|
|
|
|
|
|
|
// These are really mozilla::dom::ScreenOrientation, but it's
|
|
|
|
// difficult to include that here
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t FullScreenOrientation() { return mFullScreenOrientation; }
|
|
|
|
void SetFullScreenOrientation(uint32_t orientation);
|
2012-06-07 02:39:18 +00:00
|
|
|
|
|
|
|
void SetWakeLock(bool aLock);
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
mozilla::gl::GLContext* GLContext();
|
2014-04-22 23:23:18 +00:00
|
|
|
|
2012-07-20 19:20:51 +00:00
|
|
|
// For ANPOpenGL
|
|
|
|
class TextureInfo {
|
|
|
|
public:
|
|
|
|
TextureInfo() :
|
|
|
|
mTexture(0), mWidth(0), mHeight(0), mInternalFormat(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
TextureInfo(GLuint aTexture, int32_t aWidth, int32_t aHeight, GLuint aInternalFormat) :
|
2012-07-20 19:20:51 +00:00
|
|
|
mTexture(aTexture), mWidth(aWidth), mHeight(aHeight), mInternalFormat(aInternalFormat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint mTexture;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mWidth;
|
|
|
|
int32_t mHeight;
|
2012-07-20 19:20:51 +00:00
|
|
|
GLuint mInternalFormat;
|
|
|
|
};
|
|
|
|
|
|
|
|
// For ANPNativeWindow
|
|
|
|
void* AcquireContentWindow();
|
|
|
|
|
2014-10-21 13:53:00 +00:00
|
|
|
mozilla::gl::AndroidSurfaceTexture* AsSurfaceTexture();
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
// For ANPVideo
|
|
|
|
class VideoInfo {
|
|
|
|
public:
|
2014-10-21 13:53:00 +00:00
|
|
|
VideoInfo(mozilla::gl::AndroidSurfaceTexture* aSurfaceTexture) :
|
2012-07-20 19:20:51 +00:00
|
|
|
mSurfaceTexture(aSurfaceTexture)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~VideoInfo()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
mSurfaceTexture = nullptr;
|
2012-07-20 19:20:51 +00:00
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
|
2012-07-20 19:20:51 +00:00
|
|
|
gfxRect mDimensions;
|
|
|
|
};
|
|
|
|
|
|
|
|
void* AcquireVideoWindow();
|
|
|
|
void ReleaseVideoWindow(void* aWindow);
|
|
|
|
void SetVideoDimensions(void* aWindow, gfxRect aDimensions);
|
|
|
|
|
|
|
|
void GetVideos(nsTArray<VideoInfo*>& aVideos);
|
|
|
|
|
2014-11-18 01:02:19 +00:00
|
|
|
void SetOriginPos(mozilla::gl::OriginPos aOriginPos) {
|
|
|
|
mOriginPos = aOriginPos;
|
|
|
|
}
|
|
|
|
mozilla::gl::OriginPos OriginPos() const { return mOriginPos; }
|
2013-01-23 14:16:26 +00:00
|
|
|
|
|
|
|
static nsNPAPIPluginInstance* GetFromNPP(NPP npp);
|
2011-09-16 21:34:31 +00:00
|
|
|
#endif
|
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
nsresult NewStreamListener(const char* aURL, void* notifyData,
|
2012-05-17 23:54:26 +00:00
|
|
|
nsNPAPIPluginStreamListener** listener);
|
1999-01-25 09:00:42 +00:00
|
|
|
|
2012-04-02 19:17:34 +00:00
|
|
|
nsNPAPIPluginInstance();
|
1999-01-25 09:00:42 +00:00
|
|
|
|
2010-07-20 02:11:26 +00:00
|
|
|
// To be called when an instance becomes orphaned, when
|
|
|
|
// it's plugin is no longer guaranteed to be around.
|
|
|
|
void Destroy();
|
|
|
|
|
2010-03-08 21:54:04 +00:00
|
|
|
// Indicates whether the plugin is running normally.
|
|
|
|
bool IsRunning() {
|
|
|
|
return RUNNING == mRunning;
|
|
|
|
}
|
2010-12-20 01:37:43 +00:00
|
|
|
bool HasStartedDestroying() {
|
|
|
|
return mRunning >= DESTROYING;
|
|
|
|
}
|
2010-03-08 21:54:04 +00:00
|
|
|
|
|
|
|
// Indicates whether the plugin is running normally or being shut down
|
|
|
|
bool CanFireNotifications() {
|
|
|
|
return mRunning == RUNNING || mRunning == DESTROYING;
|
|
|
|
}
|
2009-12-18 02:09:22 +00:00
|
|
|
|
2011-11-12 01:10:31 +00:00
|
|
|
// return is only valid when the plugin is not running
|
|
|
|
mozilla::TimeStamp StopTime();
|
|
|
|
|
|
|
|
// cache this NPAPI plugin
|
2012-08-14 09:10:42 +00:00
|
|
|
void SetCached(bool aCache);
|
2011-11-12 01:10:31 +00:00
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetDOMWindow();
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2012-04-24 04:49:25 +00:00
|
|
|
nsresult PrivateModeStateChanged(bool aEnabled);
|
2009-06-29 18:53:52 +00:00
|
|
|
|
2013-03-04 18:18:20 +00:00
|
|
|
nsresult IsPrivateBrowsing(bool *aEnabled);
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsresult GetDOMElement(nsIDOMElement* *result);
|
2009-06-29 18:53:52 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsNPAPITimer* TimerWithID(uint32_t id, uint32_t* index);
|
2009-07-01 15:09:49 +00:00
|
|
|
uint32_t ScheduleTimer(uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID));
|
|
|
|
void UnscheduleTimer(uint32_t timerID);
|
2009-08-27 00:29:47 +00:00
|
|
|
NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
|
2010-07-17 23:47:29 +00:00
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
|
|
|
|
nsTArray<nsNPAPIPluginStreamListener*> *StreamListeners();
|
|
|
|
|
|
|
|
nsTArray<nsPluginStreamListenerPeer*> *FileCachedStreamListeners();
|
2010-07-17 23:47:29 +00:00
|
|
|
|
2010-09-10 18:28:52 +00:00
|
|
|
nsresult AsyncSetWindow(NPWindow& window);
|
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
void URLRedirectResponse(void* notifyData, NPBool allow);
|
|
|
|
|
2015-12-02 19:31:16 +00:00
|
|
|
NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
|
|
|
|
void *initData, NPAsyncSurface *surface);
|
|
|
|
NPError FinalizeAsyncSurface(NPAsyncSurface *surface);
|
|
|
|
void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed);
|
|
|
|
|
2011-02-03 17:31:01 +00:00
|
|
|
// Called when the instance fails to instantiate beceause the Carbon
|
|
|
|
// event model is not supported.
|
|
|
|
void CarbonNPAPIFailure();
|
|
|
|
|
2012-10-02 19:48:05 +00:00
|
|
|
// Returns the contents scale factor of the screen the plugin is drawn on.
|
|
|
|
double GetContentsScaleFactor();
|
|
|
|
|
2016-03-17 19:00:59 +00:00
|
|
|
// Returns the css zoom factor of the document the plugin is drawn on.
|
|
|
|
float GetCSSZoomFactor();
|
|
|
|
|
2015-03-17 17:28:32 +00:00
|
|
|
nsresult GetRunID(uint32_t *aRunID);
|
|
|
|
|
2013-02-27 11:50:27 +00:00
|
|
|
static bool InPluginCallUnsafeForReentry() { return gInUnsafePluginCalls > 0; }
|
|
|
|
static void BeginPluginCall(NSPluginCallReentry aReentryState)
|
|
|
|
{
|
|
|
|
if (aReentryState == NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO) {
|
|
|
|
++gInUnsafePluginCalls;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void EndPluginCall(NSPluginCallReentry aReentryState)
|
2012-12-06 23:58:14 +00:00
|
|
|
{
|
2013-02-27 11:50:27 +00:00
|
|
|
if (aReentryState == NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO) {
|
|
|
|
NS_ASSERTION(gInUnsafePluginCalls > 0, "Must be in plugin call");
|
|
|
|
--gInUnsafePluginCalls;
|
|
|
|
}
|
2012-12-06 23:58:14 +00:00
|
|
|
}
|
|
|
|
|
2009-12-11 20:48:37 +00:00
|
|
|
protected:
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2014-06-23 19:56:07 +00:00
|
|
|
virtual ~nsNPAPIPluginInstance();
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsresult GetTagType(nsPluginTagType *result);
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult GetMode(int32_t *result);
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2012-10-03 15:49:04 +00:00
|
|
|
// check if this is a Java applet and affected by bug 750480
|
|
|
|
void CheckJavaC2PJSObjectQuirk(uint16_t paramCount,
|
|
|
|
const char* const* names,
|
|
|
|
const char* const* values);
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
// The structure used to communicate between the plugin instance and
|
|
|
|
// the browser.
|
2009-07-13 02:44:48 +00:00
|
|
|
NPP_t mNPP;
|
1998-09-15 03:48:58 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
NPDrawingModel mDrawingModel;
|
2007-03-27 01:07:57 +00:00
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mANPDrawingModel;
|
2012-05-04 15:48:41 +00:00
|
|
|
|
|
|
|
friend class PluginEventRunnable;
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<PluginEventRunnable>> mPostedEvents;
|
2012-05-04 15:48:41 +00:00
|
|
|
void PopPostedEvent(PluginEventRunnable* r);
|
2012-07-26 13:39:21 +00:00
|
|
|
void OnSurfaceTextureFrameAvailable();
|
2012-05-30 16:10:49 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mFullScreenOrientation;
|
2012-06-07 02:39:18 +00:00
|
|
|
bool mWakeLocked;
|
2012-06-07 02:39:36 +00:00
|
|
|
bool mFullScreen;
|
2014-11-18 01:02:19 +00:00
|
|
|
mozilla::gl::OriginPos mOriginPos;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
|
2011-09-16 21:34:31 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-08 21:54:04 +00:00
|
|
|
enum {
|
|
|
|
NOT_STARTED,
|
|
|
|
RUNNING,
|
|
|
|
DESTROYING,
|
|
|
|
DESTROYED
|
|
|
|
} mRunning;
|
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
// these are used to store the windowless properties
|
|
|
|
// which the browser will later query
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mWindowless;
|
|
|
|
bool mTransparent;
|
2011-11-12 01:10:31 +00:00
|
|
|
bool mCached;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mUsesDOMForCursor;
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2009-12-11 20:48:37 +00:00
|
|
|
public:
|
2009-07-01 15:09:49 +00:00
|
|
|
// True while creating the plugin, or calling NPP_SetWindow() on it.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInPluginInitCall;
|
2009-07-01 15:09:49 +00:00
|
|
|
|
2010-11-19 20:58:59 +00:00
|
|
|
nsXPIDLCString mFakeURL;
|
|
|
|
|
2009-12-11 20:48:37 +00:00
|
|
|
private:
|
2010-07-20 02:11:26 +00:00
|
|
|
nsNPAPIPlugin* mPlugin;
|
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
nsTArray<nsNPAPIPluginStreamListener*> mStreamListeners;
|
|
|
|
|
|
|
|
nsTArray<nsPluginStreamListenerPeer*> mFileCachedStreamListeners;
|
2010-07-17 23:47:29 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsTArray<PopupControlState> mPopupStates;
|
2005-06-18 06:06:45 +00:00
|
|
|
|
2009-07-09 03:25:20 +00:00
|
|
|
char* mMIMEType;
|
2009-06-28 23:43:19 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
// Weak pointer to the owner. The owner nulls this out (by calling
|
|
|
|
// InvalidateOwner()) when it's no longer our owner.
|
2012-10-03 02:43:18 +00:00
|
|
|
nsPluginInstanceOwner *mOwner;
|
2009-06-29 18:53:52 +00:00
|
|
|
|
2009-07-01 15:09:49 +00:00
|
|
|
nsTArray<nsNPAPITimer*> mTimers;
|
2009-08-27 00:29:47 +00:00
|
|
|
|
2014-12-11 14:44:07 +00:00
|
|
|
#ifdef XP_MACOSX
|
2009-08-27 00:29:47 +00:00
|
|
|
// non-null during a HandleEvent call
|
2009-09-17 01:30:26 +00:00
|
|
|
void* mCurrentPluginEvent;
|
2014-12-11 14:44:07 +00:00
|
|
|
#endif
|
2009-12-18 02:09:22 +00:00
|
|
|
|
2011-11-12 01:10:31 +00:00
|
|
|
// Timestamp for the last time this plugin was stopped.
|
|
|
|
// This is only valid when the plugin is actually stopped!
|
|
|
|
mozilla::TimeStamp mStopTime;
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2015-06-17 14:00:52 +00:00
|
|
|
already_AddRefed<mozilla::gl::AndroidSurfaceTexture> CreateSurfaceTexture();
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
std::map<void*, VideoInfo*> mVideos;
|
2012-02-15 20:34:31 +00:00
|
|
|
bool mOnScreen;
|
2012-07-20 19:20:51 +00:00
|
|
|
|
|
|
|
nsIntSize mCurrentSize;
|
2011-09-16 21:34:31 +00:00
|
|
|
#endif
|
2012-10-03 15:49:04 +00:00
|
|
|
|
|
|
|
// is this instance Java and affected by bug 750480?
|
|
|
|
bool mHaveJavaC2PJSObjectQuirk;
|
2012-12-06 23:58:14 +00:00
|
|
|
|
2013-02-27 11:50:27 +00:00
|
|
|
static uint32_t gInUnsafePluginCalls;
|
2014-08-15 21:17:35 +00:00
|
|
|
|
|
|
|
// The arrays can only be released when the plugin instance is destroyed,
|
|
|
|
// because the plugin, in in-process mode, might keep a reference to them.
|
|
|
|
uint32_t mCachedParamLength;
|
|
|
|
char **mCachedParamNames;
|
|
|
|
char **mCachedParamValues;
|
2015-07-28 21:09:48 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
2000-09-14 06:13:56 +00:00
|
|
|
};
|
1998-08-01 05:46:47 +00:00
|
|
|
|
2013-03-12 10:34:07 +00:00
|
|
|
// On Android, we need to guard against plugin code leaking entries in the local
|
|
|
|
// JNI ref table. See https://bugzilla.mozilla.org/show_bug.cgi?id=780831#c21
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#define MAIN_THREAD_JNI_REF_GUARD mozilla::AutoLocalJNIFrame jniFrame
|
|
|
|
#else
|
|
|
|
#define MAIN_THREAD_JNI_REF_GUARD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PRIntervalTime NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState);
|
|
|
|
void NS_NotifyPluginCall(PRIntervalTime aTime, NSPluginCallReentry aReentryState);
|
|
|
|
|
|
|
|
#define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst, pluginCallReentry) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
MAIN_THREAD_JNI_REF_GUARD; \
|
|
|
|
PRIntervalTime startTime = NS_NotifyBeginPluginCall(pluginCallReentry); \
|
|
|
|
ret = fun; \
|
|
|
|
NS_NotifyPluginCall(startTime, pluginCallReentry); \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#define NS_TRY_SAFE_CALL_VOID(fun, pluginInst, pluginCallReentry) \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
MAIN_THREAD_JNI_REF_GUARD; \
|
|
|
|
PRIntervalTime startTime = NS_NotifyBeginPluginCall(pluginCallReentry); \
|
|
|
|
fun; \
|
|
|
|
NS_NotifyPluginCall(startTime, pluginCallReentry); \
|
|
|
|
PR_END_MACRO
|
|
|
|
|
2008-09-15 12:45:01 +00:00
|
|
|
#endif // nsNPAPIPluginInstance_h_
|