dom/plugins/ipc/PluginInstanceParent.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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: 4 -*-
michael@0 2 * vim: sw=4 ts=4 et :
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef dom_plugins_PluginInstanceParent_h
michael@0 8 #define dom_plugins_PluginInstanceParent_h 1
michael@0 9
michael@0 10 #include "mozilla/plugins/PPluginInstanceParent.h"
michael@0 11 #include "mozilla/plugins/PluginScriptableObjectParent.h"
michael@0 12 #if defined(OS_WIN)
michael@0 13 #include "mozilla/gfx/SharedDIBWin.h"
michael@0 14 #include <d3d10_1.h>
michael@0 15 #include "nsRefPtrHashtable.h"
michael@0 16 #elif defined(MOZ_WIDGET_COCOA)
michael@0 17 #include "mozilla/gfx/QuartzSupport.h"
michael@0 18 #endif
michael@0 19
michael@0 20 #include "npfunctions.h"
michael@0 21 #include "nsAutoPtr.h"
michael@0 22 #include "nsDataHashtable.h"
michael@0 23 #include "nsHashKeys.h"
michael@0 24 #include "nsRect.h"
michael@0 25
michael@0 26 #ifdef MOZ_X11
michael@0 27 class gfxXlibSurface;
michael@0 28 #endif
michael@0 29 #include "mozilla/unused.h"
michael@0 30
michael@0 31 class gfxASurface;
michael@0 32 class gfxContext;
michael@0 33
michael@0 34 namespace mozilla {
michael@0 35 namespace layers {
michael@0 36 class ImageContainer;
michael@0 37 class CompositionNotifySink;
michael@0 38 }
michael@0 39 namespace plugins {
michael@0 40
michael@0 41 class PBrowserStreamParent;
michael@0 42 class PluginModuleParent;
michael@0 43
michael@0 44 class PluginInstanceParent : public PPluginInstanceParent
michael@0 45 {
michael@0 46 friend class PluginModuleParent;
michael@0 47 friend class BrowserStreamParent;
michael@0 48 friend class PluginStreamParent;
michael@0 49 friend class StreamNotifyParent;
michael@0 50
michael@0 51 public:
michael@0 52 PluginInstanceParent(PluginModuleParent* parent,
michael@0 53 NPP npp,
michael@0 54 const nsCString& mimeType,
michael@0 55 const NPNetscapeFuncs* npniface);
michael@0 56
michael@0 57 virtual ~PluginInstanceParent();
michael@0 58
michael@0 59 bool Init();
michael@0 60 NPError Destroy();
michael@0 61
michael@0 62 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
michael@0 63
michael@0 64 virtual PPluginScriptableObjectParent*
michael@0 65 AllocPPluginScriptableObjectParent() MOZ_OVERRIDE;
michael@0 66
michael@0 67 virtual bool
michael@0 68 RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectParent* aActor) MOZ_OVERRIDE;
michael@0 69
michael@0 70 virtual bool
michael@0 71 DeallocPPluginScriptableObjectParent(PPluginScriptableObjectParent* aObject) MOZ_OVERRIDE;
michael@0 72 virtual PBrowserStreamParent*
michael@0 73 AllocPBrowserStreamParent(const nsCString& url,
michael@0 74 const uint32_t& length,
michael@0 75 const uint32_t& lastmodified,
michael@0 76 PStreamNotifyParent* notifyData,
michael@0 77 const nsCString& headers,
michael@0 78 const nsCString& mimeType,
michael@0 79 const bool& seekable,
michael@0 80 NPError* rv,
michael@0 81 uint16_t *stype) MOZ_OVERRIDE;
michael@0 82 virtual bool
michael@0 83 DeallocPBrowserStreamParent(PBrowserStreamParent* stream) MOZ_OVERRIDE;
michael@0 84
michael@0 85 virtual PPluginStreamParent*
michael@0 86 AllocPPluginStreamParent(const nsCString& mimeType,
michael@0 87 const nsCString& target,
michael@0 88 NPError* result) MOZ_OVERRIDE;
michael@0 89 virtual bool
michael@0 90 DeallocPPluginStreamParent(PPluginStreamParent* stream) MOZ_OVERRIDE;
michael@0 91
michael@0 92 virtual bool
michael@0 93 AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* value,
michael@0 94 NPError* result) MOZ_OVERRIDE;
michael@0 95 virtual bool
michael@0 96 AnswerNPN_GetValue_NPNVWindowNPObject(
michael@0 97 PPluginScriptableObjectParent** value,
michael@0 98 NPError* result) MOZ_OVERRIDE;
michael@0 99 virtual bool
michael@0 100 AnswerNPN_GetValue_NPNVPluginElementNPObject(
michael@0 101 PPluginScriptableObjectParent** value,
michael@0 102 NPError* result) MOZ_OVERRIDE;
michael@0 103 virtual bool
michael@0 104 AnswerNPN_GetValue_NPNVprivateModeBool(bool* value, NPError* result) MOZ_OVERRIDE;
michael@0 105
michael@0 106 virtual bool
michael@0 107 AnswerNPN_GetValue_DrawingModelSupport(const NPNVariable& model, bool* value) MOZ_OVERRIDE;
michael@0 108
michael@0 109 virtual bool
michael@0 110 AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value, NPError* result) MOZ_OVERRIDE;
michael@0 111
michael@0 112 virtual bool
michael@0 113 AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result) MOZ_OVERRIDE;
michael@0 114 virtual bool
michael@0 115 AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent,
michael@0 116 NPError* result) MOZ_OVERRIDE;
michael@0 117 virtual bool
michael@0 118 AnswerNPN_SetValue_NPPVpluginUsesDOMForCursor(const bool& useDOMForCursor,
michael@0 119 NPError* result) MOZ_OVERRIDE;
michael@0 120 virtual bool
michael@0 121 AnswerNPN_SetValue_NPPVpluginDrawingModel(const int& drawingModel,
michael@0 122 OptionalShmem *remoteImageData,
michael@0 123 CrossProcessMutexHandle *mutex,
michael@0 124 NPError* result) MOZ_OVERRIDE;
michael@0 125 virtual bool
michael@0 126 AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel,
michael@0 127 NPError* result) MOZ_OVERRIDE;
michael@0 128
michael@0 129 virtual bool
michael@0 130 AnswerNPN_GetURL(const nsCString& url, const nsCString& target,
michael@0 131 NPError *result) MOZ_OVERRIDE;
michael@0 132
michael@0 133 virtual bool
michael@0 134 AnswerNPN_PostURL(const nsCString& url, const nsCString& target,
michael@0 135 const nsCString& buffer, const bool& file,
michael@0 136 NPError* result) MOZ_OVERRIDE;
michael@0 137
michael@0 138 virtual PStreamNotifyParent*
michael@0 139 AllocPStreamNotifyParent(const nsCString& url, const nsCString& target,
michael@0 140 const bool& post, const nsCString& buffer,
michael@0 141 const bool& file,
michael@0 142 NPError* result) MOZ_OVERRIDE;
michael@0 143
michael@0 144 virtual bool
michael@0 145 AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
michael@0 146 const nsCString& url,
michael@0 147 const nsCString& target,
michael@0 148 const bool& post, const nsCString& buffer,
michael@0 149 const bool& file,
michael@0 150 NPError* result) MOZ_OVERRIDE;
michael@0 151
michael@0 152 virtual bool
michael@0 153 DeallocPStreamNotifyParent(PStreamNotifyParent* notifyData) MOZ_OVERRIDE;
michael@0 154
michael@0 155 virtual bool
michael@0 156 RecvNPN_InvalidateRect(const NPRect& rect) MOZ_OVERRIDE;
michael@0 157
michael@0 158 // Async rendering
michael@0 159 virtual bool
michael@0 160 RecvShow(const NPRect& updatedRect,
michael@0 161 const SurfaceDescriptor& newSurface,
michael@0 162 SurfaceDescriptor* prevSurface) MOZ_OVERRIDE;
michael@0 163
michael@0 164 virtual PPluginSurfaceParent*
michael@0 165 AllocPPluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
michael@0 166 const gfxIntSize& size,
michael@0 167 const bool& transparent) MOZ_OVERRIDE;
michael@0 168
michael@0 169 virtual bool
michael@0 170 DeallocPPluginSurfaceParent(PPluginSurfaceParent* s) MOZ_OVERRIDE;
michael@0 171
michael@0 172 virtual bool
michael@0 173 AnswerNPN_PushPopupsEnabledState(const bool& aState) MOZ_OVERRIDE;
michael@0 174
michael@0 175 virtual bool
michael@0 176 AnswerNPN_PopPopupsEnabledState() MOZ_OVERRIDE;
michael@0 177
michael@0 178 virtual bool
michael@0 179 AnswerNPN_GetValueForURL(const NPNURLVariable& variable,
michael@0 180 const nsCString& url,
michael@0 181 nsCString* value, NPError* result) MOZ_OVERRIDE;
michael@0 182
michael@0 183 virtual bool
michael@0 184 AnswerNPN_SetValueForURL(const NPNURLVariable& variable,
michael@0 185 const nsCString& url,
michael@0 186 const nsCString& value, NPError* result) MOZ_OVERRIDE;
michael@0 187
michael@0 188 virtual bool
michael@0 189 AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
michael@0 190 const nsCString& host,
michael@0 191 const int32_t& port,
michael@0 192 const nsCString& scheme,
michael@0 193 const nsCString& realm,
michael@0 194 nsCString* username,
michael@0 195 nsCString* password,
michael@0 196 NPError* result) MOZ_OVERRIDE;
michael@0 197
michael@0 198 virtual bool
michael@0 199 AnswerNPN_ConvertPoint(const double& sourceX,
michael@0 200 const bool& ignoreDestX,
michael@0 201 const double& sourceY,
michael@0 202 const bool& ignoreDestY,
michael@0 203 const NPCoordinateSpace& sourceSpace,
michael@0 204 const NPCoordinateSpace& destSpace,
michael@0 205 double *destX,
michael@0 206 double *destY,
michael@0 207 bool *result) MOZ_OVERRIDE;
michael@0 208
michael@0 209 virtual bool
michael@0 210 AnswerNPN_InitAsyncSurface(const gfxIntSize& size,
michael@0 211 const NPImageFormat& format,
michael@0 212 NPRemoteAsyncSurface* surfData,
michael@0 213 bool* result) MOZ_OVERRIDE;
michael@0 214
michael@0 215 virtual bool
michael@0 216 RecvRedrawPlugin() MOZ_OVERRIDE;
michael@0 217
michael@0 218 virtual bool
michael@0 219 RecvNegotiatedCarbon() MOZ_OVERRIDE;
michael@0 220
michael@0 221 virtual bool RecvReleaseDXGISharedSurface(const DXGISharedSurfaceHandle &aHandle) MOZ_OVERRIDE;
michael@0 222
michael@0 223 NPError NPP_SetWindow(const NPWindow* aWindow);
michael@0 224
michael@0 225 NPError NPP_GetValue(NPPVariable variable, void* retval);
michael@0 226 NPError NPP_SetValue(NPNVariable variable, void* value);
michael@0 227
michael@0 228 void NPP_URLRedirectNotify(const char* url, int32_t status,
michael@0 229 void* notifyData);
michael@0 230
michael@0 231 NPError NPP_NewStream(NPMIMEType type, NPStream* stream,
michael@0 232 NPBool seekable, uint16_t* stype);
michael@0 233 NPError NPP_DestroyStream(NPStream* stream, NPReason reason);
michael@0 234
michael@0 235 void NPP_Print(NPPrint* platformPrint);
michael@0 236
michael@0 237 int16_t NPP_HandleEvent(void* event);
michael@0 238
michael@0 239 void NPP_URLNotify(const char* url, NPReason reason, void* notifyData);
michael@0 240
michael@0 241 PluginModuleParent* Module()
michael@0 242 {
michael@0 243 return mParent;
michael@0 244 }
michael@0 245
michael@0 246 const NPNetscapeFuncs* GetNPNIface()
michael@0 247 {
michael@0 248 return mNPNIface;
michael@0 249 }
michael@0 250
michael@0 251 bool
michael@0 252 RegisterNPObjectForActor(NPObject* aObject,
michael@0 253 PluginScriptableObjectParent* aActor);
michael@0 254
michael@0 255 void
michael@0 256 UnregisterNPObject(NPObject* aObject);
michael@0 257
michael@0 258 PluginScriptableObjectParent*
michael@0 259 GetActorForNPObject(NPObject* aObject);
michael@0 260
michael@0 261 NPP
michael@0 262 GetNPP()
michael@0 263 {
michael@0 264 return mNPP;
michael@0 265 }
michael@0 266
michael@0 267 virtual bool
michael@0 268 AnswerPluginFocusChange(const bool& gotFocus) MOZ_OVERRIDE;
michael@0 269
michael@0 270 nsresult AsyncSetWindow(NPWindow* window);
michael@0 271 nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer);
michael@0 272 nsresult GetImageSize(nsIntSize* aSize);
michael@0 273 #ifdef XP_MACOSX
michael@0 274 nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing);
michael@0 275 nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
michael@0 276 #endif
michael@0 277 nsresult SetBackgroundUnknown();
michael@0 278 nsresult BeginUpdateBackground(const nsIntRect& aRect,
michael@0 279 gfxContext** aCtx);
michael@0 280 nsresult EndUpdateBackground(gfxContext* aCtx,
michael@0 281 const nsIntRect& aRect);
michael@0 282 void DidComposite() { unused << SendNPP_DidComposite(); }
michael@0 283
michael@0 284 private:
michael@0 285 // Create an appropriate platform surface for a background of size
michael@0 286 // |aSize|. Return true if successful.
michael@0 287 bool CreateBackground(const nsIntSize& aSize);
michael@0 288 void DestroyBackground();
michael@0 289 SurfaceDescriptor BackgroundDescriptor() /*const*/;
michael@0 290
michael@0 291 typedef mozilla::layers::ImageContainer ImageContainer;
michael@0 292 ImageContainer *GetImageContainer();
michael@0 293
michael@0 294 virtual PPluginBackgroundDestroyerParent*
michael@0 295 AllocPPluginBackgroundDestroyerParent() MOZ_OVERRIDE;
michael@0 296
michael@0 297 virtual bool
michael@0 298 DeallocPPluginBackgroundDestroyerParent(PPluginBackgroundDestroyerParent* aActor) MOZ_OVERRIDE;
michael@0 299
michael@0 300 bool InternalGetValueForNPObject(NPNVariable aVariable,
michael@0 301 PPluginScriptableObjectParent** aValue,
michael@0 302 NPError* aResult);
michael@0 303
michael@0 304 bool IsAsyncDrawing();
michael@0 305
michael@0 306 private:
michael@0 307 PluginModuleParent* mParent;
michael@0 308 NPP mNPP;
michael@0 309 const NPNetscapeFuncs* mNPNIface;
michael@0 310 NPWindowType mWindowType;
michael@0 311 Shmem mRemoteImageDataShmem;
michael@0 312 nsAutoPtr<CrossProcessMutex> mRemoteImageDataMutex;
michael@0 313 int16_t mDrawingModel;
michael@0 314 nsAutoPtr<mozilla::layers::CompositionNotifySink> mNotifySink;
michael@0 315
michael@0 316 nsDataHashtable<nsPtrHashKey<NPObject>, PluginScriptableObjectParent*> mScriptableObjects;
michael@0 317
michael@0 318 #if defined(OS_WIN)
michael@0 319 private:
michael@0 320 // Used in rendering windowless plugins in other processes.
michael@0 321 bool SharedSurfaceSetWindow(const NPWindow* aWindow, NPRemoteWindow& aRemoteWindow);
michael@0 322 void SharedSurfaceBeforePaint(RECT &rect, NPRemoteEvent& npremoteevent);
michael@0 323 void SharedSurfaceAfterPaint(NPEvent* npevent);
michael@0 324 void SharedSurfaceRelease();
michael@0 325 // Used in handling parent/child forwarding of events.
michael@0 326 static LRESULT CALLBACK PluginWindowHookProc(HWND hWnd, UINT message,
michael@0 327 WPARAM wParam, LPARAM lParam);
michael@0 328 void SubclassPluginWindow(HWND aWnd);
michael@0 329 void UnsubclassPluginWindow();
michael@0 330
michael@0 331 private:
michael@0 332 gfx::SharedDIBWin mSharedSurfaceDib;
michael@0 333 nsIntRect mPluginPort;
michael@0 334 nsIntRect mSharedSize;
michael@0 335 HWND mPluginHWND;
michael@0 336 WNDPROC mPluginWndProc;
michael@0 337 bool mNestedEventState;
michael@0 338
michael@0 339 // This will automatically release the textures when this object goes away.
michael@0 340 nsRefPtrHashtable<nsPtrHashKey<void>, ID3D10Texture2D> mTextureMap;
michael@0 341 #endif // defined(XP_WIN)
michael@0 342 #if defined(MOZ_WIDGET_COCOA)
michael@0 343 private:
michael@0 344 Shmem mShSurface;
michael@0 345 uint16_t mShWidth;
michael@0 346 uint16_t mShHeight;
michael@0 347 CGColorSpaceRef mShColorSpace;
michael@0 348 RefPtr<MacIOSurface> mIOSurface;
michael@0 349 RefPtr<MacIOSurface> mFrontIOSurface;
michael@0 350 #endif // definied(MOZ_WIDGET_COCOA)
michael@0 351
michael@0 352 // ObjectFrame layer wrapper
michael@0 353 nsRefPtr<gfxASurface> mFrontSurface;
michael@0 354 // For windowless+transparent instances, this surface contains a
michael@0 355 // "pretty recent" copy of the pixels under its <object> frame.
michael@0 356 // On the plugin side, we use this surface to avoid doing alpha
michael@0 357 // recovery when possible. This surface is created and owned by
michael@0 358 // the browser, but a "read-only" reference is sent to the plugin.
michael@0 359 //
michael@0 360 // We have explicitly chosen not to provide any guarantees about
michael@0 361 // the consistency of the pixels in |mBackground|. A plugin may
michael@0 362 // be able to observe partial updates to the background.
michael@0 363 nsRefPtr<gfxASurface> mBackground;
michael@0 364
michael@0 365 nsRefPtr<ImageContainer> mImageContainer;
michael@0 366 };
michael@0 367
michael@0 368
michael@0 369 } // namespace plugins
michael@0 370 } // namespace mozilla
michael@0 371
michael@0 372 #endif // ifndef dom_plugins_PluginInstanceParent_h

mercurial