2009-07-20 17:36:23 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
#ifndef nsNPAPIPluginInstance_h_
|
|
|
|
#define nsNPAPIPluginInstance_h_
|
1998-08-04 07:21:43 +04:00
|
|
|
|
2002-10-04 01:31:41 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2009-03-28 16:57:13 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2009-07-01 19:09:49 +04:00
|
|
|
#include "nsITimer.h"
|
2010-07-13 22:42:03 +04:00
|
|
|
#include "nsIPluginTagInfo.h"
|
2010-07-20 06:11:26 +04:00
|
|
|
#include "nsIURI.h"
|
2011-01-05 22:44:21 +03:00
|
|
|
#include "nsIChannel.h"
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2011-11-21 11:55:50 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#include "nsIRunnable.h"
|
2012-05-04 19:48:41 +04:00
|
|
|
class PluginEventRunnable;
|
2011-11-21 11:55:50 +04:00
|
|
|
#endif
|
2011-10-05 22:44:19 +04:00
|
|
|
|
2010-07-13 22:42:03 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2009-10-27 22:51:12 +03:00
|
|
|
#include "mozilla/PluginLibrary.h"
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2011-05-18 05:48:34 +04:00
|
|
|
struct JSObject;
|
|
|
|
|
2010-07-18 03:47:29 +04:00
|
|
|
class nsPluginStreamListenerPeer; // browser-initiated stream class
|
|
|
|
class nsNPAPIPluginStreamListener; // plugin-initiated stream class
|
2010-07-13 22:42:03 +04:00
|
|
|
class nsIPluginInstanceOwner;
|
2011-05-18 05:48:34 +04:00
|
|
|
class nsIOutputStream;
|
2001-07-25 00:48:36 +04:00
|
|
|
|
2012-02-16 07:24:38 +04:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin;
|
|
|
|
#elif defined(MOZ_X11)
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncX;
|
2012-05-05 06:36:27 +04:00
|
|
|
#elif defined(XP_MACOSX)
|
2012-02-16 07:24:38 +04:00
|
|
|
#ifndef NP_NO_QUICKDRAW
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelQuickDraw;
|
|
|
|
#else
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelCoreGraphics;
|
|
|
|
#endif
|
2012-05-05 06:36:27 +04:00
|
|
|
#else
|
|
|
|
const NPDrawingModel kDefaultDrawingModel = static_cast<NPDrawingModel>(0);
|
2012-02-16 07:24:38 +04:00
|
|
|
#endif
|
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
class nsNPAPITimer
|
1998-08-01 09:46:47 +04:00
|
|
|
{
|
|
|
|
public:
|
2009-07-01 19:09:49 +04:00
|
|
|
NPP npp;
|
|
|
|
uint32_t id;
|
|
|
|
nsCOMPtr<nsITimer> timer;
|
|
|
|
void (*callback)(NPP npp, uint32_t timerID);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool inCallback;
|
2001-07-25 00:48:36 +04:00
|
|
|
};
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2011-05-18 05:48:34 +04:00
|
|
|
class nsNPAPIPluginInstance : public nsISupports
|
1998-08-01 09:46:47 +04:00
|
|
|
{
|
2009-10-27 22:51:12 +03:00
|
|
|
private:
|
|
|
|
typedef mozilla::PluginLibrary PluginLibrary;
|
|
|
|
|
1998-08-01 09:46:47 +04:00
|
|
|
public:
|
2009-07-01 19:09:49 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2011-05-18 05:48:34 +04:00
|
|
|
|
2012-04-02 23:17:34 +04:00
|
|
|
nsresult Initialize(nsNPAPIPlugin *aPlugin, nsIPluginInstanceOwner* aOwner, const char* aMIMEType);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult Start();
|
|
|
|
nsresult Stop();
|
|
|
|
nsresult SetWindow(NPWindow* window);
|
|
|
|
nsresult NewStreamFromPlugin(const char* type, const char* target, nsIOutputStream* *result);
|
|
|
|
nsresult Print(NPPrint* platformPrint);
|
|
|
|
nsresult HandleEvent(void* event, PRInt16* result);
|
|
|
|
nsresult GetValueFromPlugin(NPPVariable variable, void* value);
|
|
|
|
nsresult GetDrawingModel(PRInt32* aModel);
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult IsRemoteDrawingCoreAnimation(bool* aDrawing);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult GetJSObject(JSContext *cx, JSObject** outObject);
|
2011-11-12 05:10:31 +04:00
|
|
|
bool ShouldCache();
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult IsWindowless(bool* isWindowless);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult AsyncSetWindow(NPWindow* window);
|
2012-02-08 19:34:27 +04:00
|
|
|
nsresult GetImageContainer(ImageContainer **aContainer);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult GetImageSize(nsIntSize* aSize);
|
|
|
|
nsresult NotifyPainted(void);
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult UseAsyncPainting(bool* aIsAsync);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult SetBackgroundUnknown();
|
|
|
|
nsresult BeginUpdateBackground(nsIntRect* aRect, gfxContext** aContext);
|
|
|
|
nsresult EndUpdateBackground(gfxContext* aContext, nsIntRect* aRect);
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult IsTransparent(bool* isTransparent);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult GetFormValue(nsAString& aValue);
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult PushPopupsEnabledState(bool aEnabled);
|
2011-05-18 05:48:34 +04:00
|
|
|
nsresult PopPopupsEnabledState();
|
|
|
|
nsresult GetPluginAPIVersion(PRUint16* version);
|
|
|
|
nsresult InvalidateRect(NPRect *invalidRect);
|
|
|
|
nsresult InvalidateRegion(NPRegion invalidRegion);
|
|
|
|
nsresult GetMIMEType(const char* *result);
|
|
|
|
nsresult GetJSContext(JSContext* *outContext);
|
|
|
|
nsresult GetOwner(nsIPluginInstanceOwner **aOwner);
|
|
|
|
nsresult SetOwner(nsIPluginInstanceOwner *aOwner);
|
|
|
|
nsresult ShowStatus(const char* message);
|
|
|
|
nsresult InvalidateOwner();
|
2011-08-29 20:26:24 +04:00
|
|
|
#if defined(MOZ_WIDGET_QT) && (MOZ_PLATFORM_MAEMO == 6)
|
|
|
|
nsresult HandleGUIEvent(const nsGUIEvent& anEvent, bool* handled);
|
|
|
|
#endif
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2010-07-20 06:11:26 +04:00
|
|
|
nsNPAPIPlugin* GetPlugin();
|
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsresult GetNPP(NPP * aNPP);
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NPError SetWindowless(bool aWindowless);
|
1998-09-15 07:48:58 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NPError SetTransparent(bool aTransparent);
|
1998-09-15 07:48:58 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NPError SetWantsAllNetworkStreams(bool aWantsAllNetworkStreams);
|
2008-08-05 01:17:55 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NPError SetUsesDOMForCursor(bool aUsesDOMForCursor);
|
|
|
|
bool UsesDOMForCursor();
|
2011-04-08 23:58:04 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
void SetDrawingModel(NPDrawingModel aModel);
|
2012-02-16 07:30:22 +04:00
|
|
|
void RedrawPlugin();
|
2012-02-16 07:24:38 +04:00
|
|
|
#ifdef XP_MACOSX
|
2009-08-27 04:29:47 +04:00
|
|
|
void SetEventModel(NPEventModel aModel);
|
2007-03-27 05:07:57 +04:00
|
|
|
#endif
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-02-16 00:34:31 +04:00
|
|
|
void NotifyForeground(bool aForeground);
|
|
|
|
void NotifyOnScreen(bool aOnScreen);
|
|
|
|
void MemoryPressure();
|
|
|
|
|
|
|
|
bool IsOnScreen() {
|
|
|
|
return mOnScreen;
|
|
|
|
}
|
|
|
|
|
2012-01-18 02:45:06 +04:00
|
|
|
PRUint32 GetANPDrawingModel() { return mANPDrawingModel; }
|
|
|
|
void SetANPDrawingModel(PRUint32 aModel);
|
2012-01-31 18:40:58 +04:00
|
|
|
|
2012-05-30 19:58:50 +04:00
|
|
|
// This stuff is for kSurface_ANPDrawingModel
|
2011-09-17 01:34:31 +04:00
|
|
|
void* GetJavaSurface();
|
2012-05-30 19:58:50 +04:00
|
|
|
void SetJavaSurface(void* aSurface);
|
|
|
|
void RequestJavaSurface();
|
2012-05-04 19:48:41 +04:00
|
|
|
|
|
|
|
void PostEvent(void* event);
|
2011-09-17 01:34:31 +04:00
|
|
|
#endif
|
|
|
|
|
2011-01-05 22:44:21 +03:00
|
|
|
nsresult NewStreamListener(const char* aURL, void* notifyData,
|
2012-05-18 03:54:26 +04:00
|
|
|
nsNPAPIPluginStreamListener** listener);
|
1999-01-25 12:00:42 +03:00
|
|
|
|
2012-04-02 23:17:34 +04:00
|
|
|
nsNPAPIPluginInstance();
|
2009-07-01 19:09:49 +04:00
|
|
|
virtual ~nsNPAPIPluginInstance();
|
1999-01-25 12:00:42 +03:00
|
|
|
|
2010-07-20 06:11:26 +04:00
|
|
|
// To be called when an instance becomes orphaned, when
|
|
|
|
// it's plugin is no longer guaranteed to be around.
|
|
|
|
void Destroy();
|
|
|
|
|
2010-03-09 00:54:04 +03:00
|
|
|
// Indicates whether the plugin is running normally.
|
|
|
|
bool IsRunning() {
|
|
|
|
return RUNNING == mRunning;
|
|
|
|
}
|
2010-12-20 04:37:43 +03:00
|
|
|
bool HasStartedDestroying() {
|
|
|
|
return mRunning >= DESTROYING;
|
|
|
|
}
|
2010-03-09 00:54:04 +03:00
|
|
|
|
|
|
|
// Indicates whether the plugin is running normally or being shut down
|
|
|
|
bool CanFireNotifications() {
|
|
|
|
return mRunning == RUNNING || mRunning == DESTROYING;
|
|
|
|
}
|
2009-12-18 05:09:22 +03:00
|
|
|
|
2011-11-12 05:10:31 +04:00
|
|
|
// return is only valid when the plugin is not running
|
|
|
|
mozilla::TimeStamp StopTime();
|
|
|
|
|
|
|
|
// cache this NPAPI plugin
|
|
|
|
nsresult SetCached(bool aCache);
|
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
already_AddRefed<nsPIDOMWindow> GetDOMWindow();
|
2005-06-18 10:06:45 +04:00
|
|
|
|
2012-04-24 08:49:25 +04:00
|
|
|
nsresult PrivateModeStateChanged(bool aEnabled);
|
2009-06-29 22:53:52 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsresult GetDOMElement(nsIDOMElement* *result);
|
2009-06-29 22:53:52 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsNPAPITimer* TimerWithID(uint32_t id, PRUint32* index);
|
|
|
|
uint32_t ScheduleTimer(uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID));
|
|
|
|
void UnscheduleTimer(uint32_t timerID);
|
2009-08-27 04:29:47 +04:00
|
|
|
NPError PopUpContextMenu(NPMenu* menu);
|
|
|
|
NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
|
2010-07-18 03:47:29 +04:00
|
|
|
|
2011-01-05 22:44:21 +03:00
|
|
|
|
|
|
|
nsTArray<nsNPAPIPluginStreamListener*> *StreamListeners();
|
|
|
|
|
|
|
|
nsTArray<nsPluginStreamListenerPeer*> *FileCachedStreamListeners();
|
2010-07-18 03:47:29 +04:00
|
|
|
|
2010-09-10 22:28:52 +04:00
|
|
|
nsresult AsyncSetWindow(NPWindow& window);
|
|
|
|
|
2011-01-05 22:44:21 +03:00
|
|
|
void URLRedirectResponse(void* notifyData, NPBool allow);
|
|
|
|
|
2012-02-16 07:08:41 +04:00
|
|
|
NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
|
|
|
|
void *initData, NPAsyncSurface *surface);
|
|
|
|
NPError FinalizeAsyncSurface(NPAsyncSurface *surface);
|
|
|
|
void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed);
|
|
|
|
|
2011-02-03 20:31:01 +03:00
|
|
|
// Called when the instance fails to instantiate beceause the Carbon
|
|
|
|
// event model is not supported.
|
|
|
|
void CarbonNPAPIFailure();
|
|
|
|
|
2009-12-11 23:48:37 +03:00
|
|
|
protected:
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsresult GetTagType(nsPluginTagType *result);
|
|
|
|
nsresult GetAttributes(PRUint16& n, const char*const*& names,
|
|
|
|
const char*const*& values);
|
|
|
|
nsresult GetParameters(PRUint16& n, const char*const*& names,
|
|
|
|
const char*const*& values);
|
2009-09-17 05:30:26 +04:00
|
|
|
nsresult GetMode(PRInt32 *result);
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
// The structure used to communicate between the plugin instance and
|
|
|
|
// the browser.
|
2009-07-13 06:44:48 +04:00
|
|
|
NPP_t mNPP;
|
1998-09-15 07:48:58 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
NPDrawingModel mDrawingModel;
|
2007-03-27 05:07:57 +04:00
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-01-18 02:45:06 +04:00
|
|
|
PRUint32 mANPDrawingModel;
|
2011-11-21 11:55:50 +04:00
|
|
|
nsCOMPtr<nsIRunnable> mSurfaceGetter;
|
2012-05-04 19:48:41 +04:00
|
|
|
|
|
|
|
friend class PluginEventRunnable;
|
|
|
|
|
|
|
|
nsTArray<nsCOMPtr<PluginEventRunnable>> mPostedEvents;
|
|
|
|
void PopPostedEvent(PluginEventRunnable* r);
|
2011-09-17 01:34:31 +04:00
|
|
|
#endif
|
|
|
|
|
2010-03-09 00:54:04 +03:00
|
|
|
enum {
|
|
|
|
NOT_STARTED,
|
|
|
|
RUNNING,
|
|
|
|
DESTROYING,
|
|
|
|
DESTROYED
|
|
|
|
} mRunning;
|
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
// these are used to store the windowless properties
|
|
|
|
// which the browser will later query
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mWindowless;
|
|
|
|
bool mTransparent;
|
2011-11-12 05:10:31 +04:00
|
|
|
bool mCached;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUsesDOMForCursor;
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2009-12-11 23:48:37 +03:00
|
|
|
public:
|
2009-07-01 19:09:49 +04:00
|
|
|
// True while creating the plugin, or calling NPP_SetWindow() on it.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInPluginInitCall;
|
2009-07-01 19:09:49 +04:00
|
|
|
|
2010-11-19 23:58:59 +03:00
|
|
|
nsXPIDLCString mFakeURL;
|
|
|
|
|
2009-12-11 23:48:37 +03:00
|
|
|
private:
|
2010-07-20 06:11:26 +04:00
|
|
|
nsNPAPIPlugin* mPlugin;
|
|
|
|
|
2011-01-05 22:44:21 +03:00
|
|
|
nsTArray<nsNPAPIPluginStreamListener*> mStreamListeners;
|
|
|
|
|
|
|
|
nsTArray<nsPluginStreamListenerPeer*> mFileCachedStreamListeners;
|
2010-07-18 03:47:29 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsTArray<PopupControlState> mPopupStates;
|
2005-06-18 10:06:45 +04:00
|
|
|
|
2009-07-09 07:25:20 +04:00
|
|
|
char* mMIMEType;
|
2009-06-29 03:43:19 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
// Weak pointer to the owner. The owner nulls this out (by calling
|
|
|
|
// InvalidateOwner()) when it's no longer our owner.
|
|
|
|
nsIPluginInstanceOwner *mOwner;
|
2009-06-29 22:53:52 +04:00
|
|
|
|
2009-07-01 19:09:49 +04:00
|
|
|
nsTArray<nsNPAPITimer*> mTimers;
|
2009-08-27 04:29:47 +04:00
|
|
|
|
|
|
|
// non-null during a HandleEvent call
|
2009-09-17 05:30:26 +04:00
|
|
|
void* mCurrentPluginEvent;
|
2009-12-18 05:09:22 +03:00
|
|
|
|
2011-11-12 05:10:31 +04:00
|
|
|
// Timestamp for the last time this plugin was stopped.
|
|
|
|
// This is only valid when the plugin is actually stopped!
|
|
|
|
mozilla::TimeStamp mStopTime;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUsePluginLayersPref;
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2011-09-17 01:34:31 +04:00
|
|
|
void* mSurface;
|
2012-02-16 00:34:31 +04:00
|
|
|
bool mOnScreen;
|
2011-09-17 01:34:31 +04:00
|
|
|
#endif
|
2000-09-14 10:13:56 +04:00
|
|
|
};
|
1998-08-01 09:46:47 +04:00
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
#endif // nsNPAPIPluginInstance_h_
|