Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsNPAPIPluginInstance_h_ |
michael@0 | 7 | #define nsNPAPIPluginInstance_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsCOMPtr.h" |
michael@0 | 10 | #include "nsTArray.h" |
michael@0 | 11 | #include "nsPIDOMWindow.h" |
michael@0 | 12 | #include "nsITimer.h" |
michael@0 | 13 | #include "nsIPluginInstanceOwner.h" |
michael@0 | 14 | #include "nsIURI.h" |
michael@0 | 15 | #include "nsIChannel.h" |
michael@0 | 16 | #include "nsInterfaceHashtable.h" |
michael@0 | 17 | #include "nsHashKeys.h" |
michael@0 | 18 | #include <prinrval.h> |
michael@0 | 19 | #include "js/TypeDecls.h" |
michael@0 | 20 | #ifdef MOZ_WIDGET_ANDROID |
michael@0 | 21 | #include "nsAutoPtr.h" |
michael@0 | 22 | #include "nsIRunnable.h" |
michael@0 | 23 | #include "GLContextTypes.h" |
michael@0 | 24 | #include "nsSurfaceTexture.h" |
michael@0 | 25 | #include "AndroidBridge.h" |
michael@0 | 26 | #include <map> |
michael@0 | 27 | class PluginEventRunnable; |
michael@0 | 28 | class SharedPluginTexture; |
michael@0 | 29 | #endif |
michael@0 | 30 | |
michael@0 | 31 | #include "mozilla/TimeStamp.h" |
michael@0 | 32 | #include "mozilla/PluginLibrary.h" |
michael@0 | 33 | |
michael@0 | 34 | class nsPluginStreamListenerPeer; // browser-initiated stream class |
michael@0 | 35 | class nsNPAPIPluginStreamListener; // plugin-initiated stream class |
michael@0 | 36 | class nsIPluginInstanceOwner; |
michael@0 | 37 | class nsIOutputStream; |
michael@0 | 38 | class nsPluginInstanceOwner; |
michael@0 | 39 | |
michael@0 | 40 | #if defined(OS_WIN) |
michael@0 | 41 | const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin; |
michael@0 | 42 | #elif defined(MOZ_X11) |
michael@0 | 43 | const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncX; |
michael@0 | 44 | #elif defined(XP_MACOSX) |
michael@0 | 45 | #ifndef NP_NO_QUICKDRAW |
michael@0 | 46 | const NPDrawingModel kDefaultDrawingModel = NPDrawingModelQuickDraw; // Not supported |
michael@0 | 47 | #else |
michael@0 | 48 | const NPDrawingModel kDefaultDrawingModel = NPDrawingModelCoreGraphics; |
michael@0 | 49 | #endif |
michael@0 | 50 | #else |
michael@0 | 51 | const NPDrawingModel kDefaultDrawingModel = static_cast<NPDrawingModel>(0); |
michael@0 | 52 | #endif |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Used to indicate whether it's OK to reenter Gecko and repaint, flush frames, |
michael@0 | 56 | * run scripts, etc, during this plugin call. |
michael@0 | 57 | * When NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO is set, we try to avoid dangerous |
michael@0 | 58 | * Gecko activities when the plugin spins a nested event loop, on a best-effort |
michael@0 | 59 | * basis. |
michael@0 | 60 | */ |
michael@0 | 61 | enum NSPluginCallReentry { |
michael@0 | 62 | NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO, |
michael@0 | 63 | NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | class nsNPAPITimer |
michael@0 | 67 | { |
michael@0 | 68 | public: |
michael@0 | 69 | NPP npp; |
michael@0 | 70 | uint32_t id; |
michael@0 | 71 | nsCOMPtr<nsITimer> timer; |
michael@0 | 72 | void (*callback)(NPP npp, uint32_t timerID); |
michael@0 | 73 | bool inCallback; |
michael@0 | 74 | bool needUnschedule; |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | class nsNPAPIPluginInstance : public nsISupports |
michael@0 | 78 | { |
michael@0 | 79 | private: |
michael@0 | 80 | typedef mozilla::PluginLibrary PluginLibrary; |
michael@0 | 81 | |
michael@0 | 82 | public: |
michael@0 | 83 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 84 | |
michael@0 | 85 | nsresult Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const char* aMIMEType); |
michael@0 | 86 | nsresult Start(); |
michael@0 | 87 | nsresult Stop(); |
michael@0 | 88 | nsresult SetWindow(NPWindow* window); |
michael@0 | 89 | nsresult NewStreamFromPlugin(const char* type, const char* target, nsIOutputStream* *result); |
michael@0 | 90 | nsresult Print(NPPrint* platformPrint); |
michael@0 | 91 | nsresult HandleEvent(void* event, int16_t* result, |
michael@0 | 92 | NSPluginCallReentry aSafeToReenterGecko = NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO); |
michael@0 | 93 | nsresult GetValueFromPlugin(NPPVariable variable, void* value); |
michael@0 | 94 | nsresult GetDrawingModel(int32_t* aModel); |
michael@0 | 95 | nsresult IsRemoteDrawingCoreAnimation(bool* aDrawing); |
michael@0 | 96 | nsresult ContentsScaleFactorChanged(double aContentsScaleFactor); |
michael@0 | 97 | nsresult GetJSObject(JSContext *cx, JSObject** outObject); |
michael@0 | 98 | bool ShouldCache(); |
michael@0 | 99 | nsresult IsWindowless(bool* isWindowless); |
michael@0 | 100 | nsresult AsyncSetWindow(NPWindow* window); |
michael@0 | 101 | nsresult GetImageContainer(mozilla::layers::ImageContainer **aContainer); |
michael@0 | 102 | nsresult GetImageSize(nsIntSize* aSize); |
michael@0 | 103 | nsresult NotifyPainted(void); |
michael@0 | 104 | nsresult GetIsOOP(bool* aIsOOP); |
michael@0 | 105 | nsresult SetBackgroundUnknown(); |
michael@0 | 106 | nsresult BeginUpdateBackground(nsIntRect* aRect, gfxContext** aContext); |
michael@0 | 107 | nsresult EndUpdateBackground(gfxContext* aContext, nsIntRect* aRect); |
michael@0 | 108 | nsresult IsTransparent(bool* isTransparent); |
michael@0 | 109 | nsresult GetFormValue(nsAString& aValue); |
michael@0 | 110 | nsresult PushPopupsEnabledState(bool aEnabled); |
michael@0 | 111 | nsresult PopPopupsEnabledState(); |
michael@0 | 112 | nsresult GetPluginAPIVersion(uint16_t* version); |
michael@0 | 113 | nsresult InvalidateRect(NPRect *invalidRect); |
michael@0 | 114 | nsresult InvalidateRegion(NPRegion invalidRegion); |
michael@0 | 115 | nsresult GetMIMEType(const char* *result); |
michael@0 | 116 | nsresult GetJSContext(JSContext* *outContext); |
michael@0 | 117 | nsPluginInstanceOwner* GetOwner(); |
michael@0 | 118 | void SetOwner(nsPluginInstanceOwner *aOwner); |
michael@0 | 119 | nsresult ShowStatus(const char* message); |
michael@0 | 120 | |
michael@0 | 121 | nsNPAPIPlugin* GetPlugin(); |
michael@0 | 122 | |
michael@0 | 123 | nsresult GetNPP(NPP * aNPP); |
michael@0 | 124 | |
michael@0 | 125 | NPError SetWindowless(bool aWindowless); |
michael@0 | 126 | |
michael@0 | 127 | NPError SetTransparent(bool aTransparent); |
michael@0 | 128 | |
michael@0 | 129 | NPError SetWantsAllNetworkStreams(bool aWantsAllNetworkStreams); |
michael@0 | 130 | |
michael@0 | 131 | NPError SetUsesDOMForCursor(bool aUsesDOMForCursor); |
michael@0 | 132 | bool UsesDOMForCursor(); |
michael@0 | 133 | |
michael@0 | 134 | void SetDrawingModel(NPDrawingModel aModel); |
michael@0 | 135 | void RedrawPlugin(); |
michael@0 | 136 | #ifdef XP_MACOSX |
michael@0 | 137 | void SetEventModel(NPEventModel aModel); |
michael@0 | 138 | #endif |
michael@0 | 139 | |
michael@0 | 140 | #ifdef MOZ_WIDGET_ANDROID |
michael@0 | 141 | void NotifyForeground(bool aForeground); |
michael@0 | 142 | void NotifyOnScreen(bool aOnScreen); |
michael@0 | 143 | void MemoryPressure(); |
michael@0 | 144 | void NotifyFullScreen(bool aFullScreen); |
michael@0 | 145 | void NotifySize(nsIntSize size); |
michael@0 | 146 | |
michael@0 | 147 | nsIntSize CurrentSize() { return mCurrentSize; } |
michael@0 | 148 | |
michael@0 | 149 | bool IsOnScreen() { |
michael@0 | 150 | return mOnScreen; |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | uint32_t GetANPDrawingModel() { return mANPDrawingModel; } |
michael@0 | 154 | void SetANPDrawingModel(uint32_t aModel); |
michael@0 | 155 | |
michael@0 | 156 | void* GetJavaSurface(); |
michael@0 | 157 | |
michael@0 | 158 | void PostEvent(void* event); |
michael@0 | 159 | |
michael@0 | 160 | // These are really mozilla::dom::ScreenOrientation, but it's |
michael@0 | 161 | // difficult to include that here |
michael@0 | 162 | uint32_t FullScreenOrientation() { return mFullScreenOrientation; } |
michael@0 | 163 | void SetFullScreenOrientation(uint32_t orientation); |
michael@0 | 164 | |
michael@0 | 165 | void SetWakeLock(bool aLock); |
michael@0 | 166 | |
michael@0 | 167 | mozilla::gl::GLContext* GLContext(); |
michael@0 | 168 | |
michael@0 | 169 | // For ANPOpenGL |
michael@0 | 170 | class TextureInfo { |
michael@0 | 171 | public: |
michael@0 | 172 | TextureInfo() : |
michael@0 | 173 | mTexture(0), mWidth(0), mHeight(0), mInternalFormat(0) |
michael@0 | 174 | { |
michael@0 | 175 | } |
michael@0 | 176 | |
michael@0 | 177 | TextureInfo(GLuint aTexture, int32_t aWidth, int32_t aHeight, GLuint aInternalFormat) : |
michael@0 | 178 | mTexture(aTexture), mWidth(aWidth), mHeight(aHeight), mInternalFormat(aInternalFormat) |
michael@0 | 179 | { |
michael@0 | 180 | } |
michael@0 | 181 | |
michael@0 | 182 | GLuint mTexture; |
michael@0 | 183 | int32_t mWidth; |
michael@0 | 184 | int32_t mHeight; |
michael@0 | 185 | GLuint mInternalFormat; |
michael@0 | 186 | }; |
michael@0 | 187 | |
michael@0 | 188 | TextureInfo LockContentTexture(); |
michael@0 | 189 | void ReleaseContentTexture(TextureInfo& aTextureInfo); |
michael@0 | 190 | |
michael@0 | 191 | // For ANPNativeWindow |
michael@0 | 192 | void* AcquireContentWindow(); |
michael@0 | 193 | |
michael@0 | 194 | mozilla::gl::SharedTextureHandle CreateSharedHandle(); |
michael@0 | 195 | |
michael@0 | 196 | // For ANPVideo |
michael@0 | 197 | class VideoInfo { |
michael@0 | 198 | public: |
michael@0 | 199 | VideoInfo(nsSurfaceTexture* aSurfaceTexture) : |
michael@0 | 200 | mSurfaceTexture(aSurfaceTexture) |
michael@0 | 201 | { |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | ~VideoInfo() |
michael@0 | 205 | { |
michael@0 | 206 | mSurfaceTexture = nullptr; |
michael@0 | 207 | } |
michael@0 | 208 | |
michael@0 | 209 | nsRefPtr<nsSurfaceTexture> mSurfaceTexture; |
michael@0 | 210 | gfxRect mDimensions; |
michael@0 | 211 | }; |
michael@0 | 212 | |
michael@0 | 213 | void* AcquireVideoWindow(); |
michael@0 | 214 | void ReleaseVideoWindow(void* aWindow); |
michael@0 | 215 | void SetVideoDimensions(void* aWindow, gfxRect aDimensions); |
michael@0 | 216 | |
michael@0 | 217 | void GetVideos(nsTArray<VideoInfo*>& aVideos); |
michael@0 | 218 | |
michael@0 | 219 | void SetInverted(bool aInverted); |
michael@0 | 220 | bool Inverted() { return mInverted; } |
michael@0 | 221 | |
michael@0 | 222 | static nsNPAPIPluginInstance* GetFromNPP(NPP npp); |
michael@0 | 223 | #endif |
michael@0 | 224 | |
michael@0 | 225 | nsresult NewStreamListener(const char* aURL, void* notifyData, |
michael@0 | 226 | nsNPAPIPluginStreamListener** listener); |
michael@0 | 227 | |
michael@0 | 228 | nsNPAPIPluginInstance(); |
michael@0 | 229 | virtual ~nsNPAPIPluginInstance(); |
michael@0 | 230 | |
michael@0 | 231 | // To be called when an instance becomes orphaned, when |
michael@0 | 232 | // it's plugin is no longer guaranteed to be around. |
michael@0 | 233 | void Destroy(); |
michael@0 | 234 | |
michael@0 | 235 | // Indicates whether the plugin is running normally. |
michael@0 | 236 | bool IsRunning() { |
michael@0 | 237 | return RUNNING == mRunning; |
michael@0 | 238 | } |
michael@0 | 239 | bool HasStartedDestroying() { |
michael@0 | 240 | return mRunning >= DESTROYING; |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | // Indicates whether the plugin is running normally or being shut down |
michael@0 | 244 | bool CanFireNotifications() { |
michael@0 | 245 | return mRunning == RUNNING || mRunning == DESTROYING; |
michael@0 | 246 | } |
michael@0 | 247 | |
michael@0 | 248 | // return is only valid when the plugin is not running |
michael@0 | 249 | mozilla::TimeStamp StopTime(); |
michael@0 | 250 | |
michael@0 | 251 | // cache this NPAPI plugin |
michael@0 | 252 | void SetCached(bool aCache); |
michael@0 | 253 | |
michael@0 | 254 | already_AddRefed<nsPIDOMWindow> GetDOMWindow(); |
michael@0 | 255 | |
michael@0 | 256 | nsresult PrivateModeStateChanged(bool aEnabled); |
michael@0 | 257 | |
michael@0 | 258 | nsresult IsPrivateBrowsing(bool *aEnabled); |
michael@0 | 259 | |
michael@0 | 260 | nsresult GetDOMElement(nsIDOMElement* *result); |
michael@0 | 261 | |
michael@0 | 262 | nsNPAPITimer* TimerWithID(uint32_t id, uint32_t* index); |
michael@0 | 263 | uint32_t ScheduleTimer(uint32_t interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32_t timerID)); |
michael@0 | 264 | void UnscheduleTimer(uint32_t timerID); |
michael@0 | 265 | NPError PopUpContextMenu(NPMenu* menu); |
michael@0 | 266 | NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); |
michael@0 | 267 | |
michael@0 | 268 | |
michael@0 | 269 | nsTArray<nsNPAPIPluginStreamListener*> *StreamListeners(); |
michael@0 | 270 | |
michael@0 | 271 | nsTArray<nsPluginStreamListenerPeer*> *FileCachedStreamListeners(); |
michael@0 | 272 | |
michael@0 | 273 | nsresult AsyncSetWindow(NPWindow& window); |
michael@0 | 274 | |
michael@0 | 275 | void URLRedirectResponse(void* notifyData, NPBool allow); |
michael@0 | 276 | |
michael@0 | 277 | NPError InitAsyncSurface(NPSize *size, NPImageFormat format, |
michael@0 | 278 | void *initData, NPAsyncSurface *surface); |
michael@0 | 279 | NPError FinalizeAsyncSurface(NPAsyncSurface *surface); |
michael@0 | 280 | void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed); |
michael@0 | 281 | |
michael@0 | 282 | // Called when the instance fails to instantiate beceause the Carbon |
michael@0 | 283 | // event model is not supported. |
michael@0 | 284 | void CarbonNPAPIFailure(); |
michael@0 | 285 | |
michael@0 | 286 | // Returns the contents scale factor of the screen the plugin is drawn on. |
michael@0 | 287 | double GetContentsScaleFactor(); |
michael@0 | 288 | |
michael@0 | 289 | static bool InPluginCallUnsafeForReentry() { return gInUnsafePluginCalls > 0; } |
michael@0 | 290 | static void BeginPluginCall(NSPluginCallReentry aReentryState) |
michael@0 | 291 | { |
michael@0 | 292 | if (aReentryState == NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO) { |
michael@0 | 293 | ++gInUnsafePluginCalls; |
michael@0 | 294 | } |
michael@0 | 295 | } |
michael@0 | 296 | static void EndPluginCall(NSPluginCallReentry aReentryState) |
michael@0 | 297 | { |
michael@0 | 298 | if (aReentryState == NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO) { |
michael@0 | 299 | NS_ASSERTION(gInUnsafePluginCalls > 0, "Must be in plugin call"); |
michael@0 | 300 | --gInUnsafePluginCalls; |
michael@0 | 301 | } |
michael@0 | 302 | } |
michael@0 | 303 | |
michael@0 | 304 | protected: |
michael@0 | 305 | |
michael@0 | 306 | nsresult GetTagType(nsPluginTagType *result); |
michael@0 | 307 | nsresult GetAttributes(uint16_t& n, const char*const*& names, |
michael@0 | 308 | const char*const*& values); |
michael@0 | 309 | nsresult GetParameters(uint16_t& n, const char*const*& names, |
michael@0 | 310 | const char*const*& values); |
michael@0 | 311 | nsresult GetMode(int32_t *result); |
michael@0 | 312 | |
michael@0 | 313 | // check if this is a Java applet and affected by bug 750480 |
michael@0 | 314 | void CheckJavaC2PJSObjectQuirk(uint16_t paramCount, |
michael@0 | 315 | const char* const* names, |
michael@0 | 316 | const char* const* values); |
michael@0 | 317 | |
michael@0 | 318 | // The structure used to communicate between the plugin instance and |
michael@0 | 319 | // the browser. |
michael@0 | 320 | NPP_t mNPP; |
michael@0 | 321 | |
michael@0 | 322 | NPDrawingModel mDrawingModel; |
michael@0 | 323 | |
michael@0 | 324 | #ifdef MOZ_WIDGET_ANDROID |
michael@0 | 325 | uint32_t mANPDrawingModel; |
michael@0 | 326 | |
michael@0 | 327 | friend class PluginEventRunnable; |
michael@0 | 328 | |
michael@0 | 329 | nsTArray<nsRefPtr<PluginEventRunnable>> mPostedEvents; |
michael@0 | 330 | void PopPostedEvent(PluginEventRunnable* r); |
michael@0 | 331 | void OnSurfaceTextureFrameAvailable(); |
michael@0 | 332 | |
michael@0 | 333 | uint32_t mFullScreenOrientation; |
michael@0 | 334 | bool mWakeLocked; |
michael@0 | 335 | bool mFullScreen; |
michael@0 | 336 | bool mInverted; |
michael@0 | 337 | |
michael@0 | 338 | nsRefPtr<SharedPluginTexture> mContentTexture; |
michael@0 | 339 | nsRefPtr<nsSurfaceTexture> mContentSurface; |
michael@0 | 340 | #endif |
michael@0 | 341 | |
michael@0 | 342 | enum { |
michael@0 | 343 | NOT_STARTED, |
michael@0 | 344 | RUNNING, |
michael@0 | 345 | DESTROYING, |
michael@0 | 346 | DESTROYED |
michael@0 | 347 | } mRunning; |
michael@0 | 348 | |
michael@0 | 349 | // these are used to store the windowless properties |
michael@0 | 350 | // which the browser will later query |
michael@0 | 351 | bool mWindowless; |
michael@0 | 352 | bool mTransparent; |
michael@0 | 353 | bool mCached; |
michael@0 | 354 | bool mUsesDOMForCursor; |
michael@0 | 355 | |
michael@0 | 356 | public: |
michael@0 | 357 | // True while creating the plugin, or calling NPP_SetWindow() on it. |
michael@0 | 358 | bool mInPluginInitCall; |
michael@0 | 359 | |
michael@0 | 360 | nsXPIDLCString mFakeURL; |
michael@0 | 361 | |
michael@0 | 362 | private: |
michael@0 | 363 | nsNPAPIPlugin* mPlugin; |
michael@0 | 364 | |
michael@0 | 365 | nsTArray<nsNPAPIPluginStreamListener*> mStreamListeners; |
michael@0 | 366 | |
michael@0 | 367 | nsTArray<nsPluginStreamListenerPeer*> mFileCachedStreamListeners; |
michael@0 | 368 | |
michael@0 | 369 | nsTArray<PopupControlState> mPopupStates; |
michael@0 | 370 | |
michael@0 | 371 | char* mMIMEType; |
michael@0 | 372 | |
michael@0 | 373 | // Weak pointer to the owner. The owner nulls this out (by calling |
michael@0 | 374 | // InvalidateOwner()) when it's no longer our owner. |
michael@0 | 375 | nsPluginInstanceOwner *mOwner; |
michael@0 | 376 | |
michael@0 | 377 | nsTArray<nsNPAPITimer*> mTimers; |
michael@0 | 378 | |
michael@0 | 379 | // non-null during a HandleEvent call |
michael@0 | 380 | void* mCurrentPluginEvent; |
michael@0 | 381 | |
michael@0 | 382 | // Timestamp for the last time this plugin was stopped. |
michael@0 | 383 | // This is only valid when the plugin is actually stopped! |
michael@0 | 384 | mozilla::TimeStamp mStopTime; |
michael@0 | 385 | |
michael@0 | 386 | #ifdef MOZ_WIDGET_ANDROID |
michael@0 | 387 | void EnsureSharedTexture(); |
michael@0 | 388 | nsSurfaceTexture* CreateSurfaceTexture(); |
michael@0 | 389 | |
michael@0 | 390 | std::map<void*, VideoInfo*> mVideos; |
michael@0 | 391 | bool mOnScreen; |
michael@0 | 392 | |
michael@0 | 393 | nsIntSize mCurrentSize; |
michael@0 | 394 | #endif |
michael@0 | 395 | |
michael@0 | 396 | // is this instance Java and affected by bug 750480? |
michael@0 | 397 | bool mHaveJavaC2PJSObjectQuirk; |
michael@0 | 398 | |
michael@0 | 399 | static uint32_t gInUnsafePluginCalls; |
michael@0 | 400 | }; |
michael@0 | 401 | |
michael@0 | 402 | // On Android, we need to guard against plugin code leaking entries in the local |
michael@0 | 403 | // JNI ref table. See https://bugzilla.mozilla.org/show_bug.cgi?id=780831#c21 |
michael@0 | 404 | #ifdef MOZ_WIDGET_ANDROID |
michael@0 | 405 | #define MAIN_THREAD_JNI_REF_GUARD mozilla::AutoLocalJNIFrame jniFrame |
michael@0 | 406 | #else |
michael@0 | 407 | #define MAIN_THREAD_JNI_REF_GUARD |
michael@0 | 408 | #endif |
michael@0 | 409 | |
michael@0 | 410 | PRIntervalTime NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState); |
michael@0 | 411 | void NS_NotifyPluginCall(PRIntervalTime aTime, NSPluginCallReentry aReentryState); |
michael@0 | 412 | |
michael@0 | 413 | #define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst, pluginCallReentry) \ |
michael@0 | 414 | PR_BEGIN_MACRO \ |
michael@0 | 415 | MAIN_THREAD_JNI_REF_GUARD; \ |
michael@0 | 416 | PRIntervalTime startTime = NS_NotifyBeginPluginCall(pluginCallReentry); \ |
michael@0 | 417 | ret = fun; \ |
michael@0 | 418 | NS_NotifyPluginCall(startTime, pluginCallReentry); \ |
michael@0 | 419 | PR_END_MACRO |
michael@0 | 420 | |
michael@0 | 421 | #define NS_TRY_SAFE_CALL_VOID(fun, pluginInst, pluginCallReentry) \ |
michael@0 | 422 | PR_BEGIN_MACRO \ |
michael@0 | 423 | MAIN_THREAD_JNI_REF_GUARD; \ |
michael@0 | 424 | PRIntervalTime startTime = NS_NotifyBeginPluginCall(pluginCallReentry); \ |
michael@0 | 425 | fun; \ |
michael@0 | 426 | NS_NotifyPluginCall(startTime, pluginCallReentry); \ |
michael@0 | 427 | PR_END_MACRO |
michael@0 | 428 | |
michael@0 | 429 | #endif // nsNPAPIPluginInstance_h_ |