1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Mozilla Plugin App.
18 * The Initial Developer of the Original Code is
19 * Chris Jones <jones.chris.g@gmail.com>
20 * Portions created by the Initial Developer are Copyright (C) 2009
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef dom_plugins_PluginInstanceParent_h
40 #define dom_plugins_PluginInstanceParent_h 1
42 #include "mozilla/plugins/PPluginInstanceParent.h"
43 #include "mozilla/plugins/PluginScriptableObjectParent.h"
45 #include "mozilla/gfx/SharedDIBWin.h"
46 #elif defined(OS_MACOSX)
47 #include "nsCoreAnimationSupport.h"
50 #include "npfunctions.h"
51 #include "nsAutoPtr.h"
52 #include "nsDataHashtable.h"
53 #include "nsHashKeys.h"
55 #include "gfxASurface.h"
56 #include "ImageLayers.h"
64 class PBrowserStreamParent
;
65 class PluginModuleParent
;
67 class PluginInstanceParent
: public PPluginInstanceParent
69 friend class PluginModuleParent
;
70 friend class BrowserStreamParent
;
71 friend class PluginStreamParent
;
72 friend class StreamNotifyParent
;
75 PluginInstanceParent(PluginModuleParent
* parent
,
77 const nsCString
& mimeType
,
78 const NPNetscapeFuncs
* npniface
);
80 virtual ~PluginInstanceParent();
85 NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why
);
87 virtual PPluginScriptableObjectParent
*
88 AllocPPluginScriptableObject();
90 NS_OVERRIDE
virtual bool
91 RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectParent
* aActor
);
94 DeallocPPluginScriptableObject(PPluginScriptableObjectParent
* aObject
);
95 virtual PBrowserStreamParent
*
96 AllocPBrowserStream(const nsCString
& url
,
97 const uint32_t& length
,
98 const uint32_t& lastmodified
,
99 PStreamNotifyParent
* notifyData
,
100 const nsCString
& headers
,
101 const nsCString
& mimeType
,
102 const bool& seekable
,
106 DeallocPBrowserStream(PBrowserStreamParent
* stream
);
108 virtual PPluginStreamParent
*
109 AllocPPluginStream(const nsCString
& mimeType
,
110 const nsCString
& target
,
113 DeallocPPluginStream(PPluginStreamParent
* stream
);
116 AnswerNPN_GetValue_NPNVjavascriptEnabledBool(bool* value
, NPError
* result
);
118 AnswerNPN_GetValue_NPNVisOfflineBool(bool* value
, NPError
* result
);
120 AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle
* value
,
123 AnswerNPN_GetValue_NPNVWindowNPObject(
124 PPluginScriptableObjectParent
** value
,
127 AnswerNPN_GetValue_NPNVPluginElementNPObject(
128 PPluginScriptableObjectParent
** value
,
131 AnswerNPN_GetValue_NPNVprivateModeBool(bool* value
, NPError
* result
);
134 AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed
, NPError
* result
);
136 AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent
,
139 AnswerNPN_SetValue_NPPVpluginDrawingModel(const int& drawingModel
,
142 AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel
,
146 AnswerNPN_GetURL(const nsCString
& url
, const nsCString
& target
,
150 AnswerNPN_PostURL(const nsCString
& url
, const nsCString
& target
,
151 const nsCString
& buffer
, const bool& file
,
154 virtual PStreamNotifyParent
*
155 AllocPStreamNotify(const nsCString
& url
, const nsCString
& target
,
156 const bool& post
, const nsCString
& buffer
,
160 NS_OVERRIDE
virtual bool
161 AnswerPStreamNotifyConstructor(PStreamNotifyParent
* actor
,
162 const nsCString
& url
,
163 const nsCString
& target
,
164 const bool& post
, const nsCString
& buffer
,
169 DeallocPStreamNotify(PStreamNotifyParent
* notifyData
);
172 RecvNPN_InvalidateRect(const NPRect
& rect
);
176 RecvShow(const NPRect
& updatedRect
,
177 const SurfaceDescriptor
& newSurface
,
178 SurfaceDescriptor
* prevSurface
);
180 virtual PPluginSurfaceParent
*
181 AllocPPluginSurface(const WindowsSharedMemoryHandle
& handle
,
182 const gfxIntSize
& size
,
183 const bool& transparent
);
186 DeallocPPluginSurface(PPluginSurfaceParent
* s
);
189 AnswerNPN_PushPopupsEnabledState(const bool& aState
);
192 AnswerNPN_PopPopupsEnabledState();
194 NS_OVERRIDE
virtual bool
195 AnswerNPN_GetValueForURL(const NPNURLVariable
& variable
,
196 const nsCString
& url
,
197 nsCString
* value
, NPError
* result
);
199 NS_OVERRIDE
virtual bool
200 AnswerNPN_SetValueForURL(const NPNURLVariable
& variable
,
201 const nsCString
& url
,
202 const nsCString
& value
, NPError
* result
);
204 NS_OVERRIDE
virtual bool
205 AnswerNPN_GetAuthenticationInfo(const nsCString
& protocol
,
206 const nsCString
& host
,
208 const nsCString
& scheme
,
209 const nsCString
& realm
,
214 NS_OVERRIDE
virtual bool
215 AnswerNPN_ConvertPoint(const double& sourceX
,
216 const bool& ignoreDestX
,
217 const double& sourceY
,
218 const bool& ignoreDestY
,
219 const NPCoordinateSpace
& sourceSpace
,
220 const NPCoordinateSpace
& destSpace
,
225 NS_OVERRIDE
virtual bool
226 RecvNegotiatedCarbon();
228 NPError
NPP_SetWindow(const NPWindow
* aWindow
);
230 NPError
NPP_GetValue(NPPVariable variable
, void* retval
);
231 NPError
NPP_SetValue(NPNVariable variable
, void* value
);
233 void NPP_URLRedirectNotify(const char* url
, int32_t status
,
236 NPError
NPP_NewStream(NPMIMEType type
, NPStream
* stream
,
237 NPBool seekable
, uint16_t* stype
);
238 NPError
NPP_DestroyStream(NPStream
* stream
, NPReason reason
);
240 void NPP_Print(NPPrint
* platformPrint
);
242 int16_t NPP_HandleEvent(void* event
);
244 void NPP_URLNotify(const char* url
, NPReason reason
, void* notifyData
);
246 PluginModuleParent
* Module()
251 const NPNetscapeFuncs
* GetNPNIface()
257 RegisterNPObjectForActor(NPObject
* aObject
,
258 PluginScriptableObjectParent
* aActor
);
261 UnregisterNPObject(NPObject
* aObject
);
263 PluginScriptableObjectParent
*
264 GetActorForNPObject(NPObject
* aObject
);
273 AnswerPluginFocusChange(const bool& gotFocus
);
275 #if defined(OS_MACOSX)
277 #endif // definied(OS_MACOSX)
279 nsresult
AsyncSetWindow(NPWindow
* window
);
280 nsresult
GetSurface(gfxASurface
** aSurface
);
281 nsresult
GetImage(mozilla::layers::ImageContainer
* aContainer
, mozilla::layers::Image
** aImage
);
283 nsresult
IsRemoteDrawingCoreAnimation(PRBool
*aDrawing
);
285 nsresult
SetBackgroundUnknown();
286 nsresult
BeginUpdateBackground(const nsIntRect
& aRect
,
288 nsresult
EndUpdateBackground(gfxContext
* aCtx
,
289 const nsIntRect
& aRect
);
292 // Create an appropriate platform surface for a background of size
293 // |aSize|. Return true if successful.
294 bool CreateBackground(const nsIntSize
& aSize
);
295 void DestroyBackground();
296 SurfaceDescriptor
BackgroundDescriptor() /*const*/;
299 virtual PPluginBackgroundDestroyerParent
*
300 AllocPPluginBackgroundDestroyer();
304 DeallocPPluginBackgroundDestroyer(PPluginBackgroundDestroyerParent
* aActor
);
306 // Quirks mode support for various plugin mime types
308 // OSX: Don't use the refresh timer for plug-ins
309 // using this quirk. These plug-in most have another
310 // way to refresh the window.
311 COREANIMATION_REFRESH_TIMER
= 1,
314 void InitQuirksModes(const nsCString
& aMimeType
);
316 bool InternalGetValueForNPObject(NPNVariable aVariable
,
317 PPluginScriptableObjectParent
** aValue
,
321 PluginModuleParent
* mParent
;
323 const NPNetscapeFuncs
* mNPNIface
;
324 NPWindowType mWindowType
;
327 nsDataHashtable
<nsVoidPtrHashKey
, PluginScriptableObjectParent
*> mScriptableObjects
;
331 // Used in rendering windowless plugins in other processes.
332 bool SharedSurfaceSetWindow(const NPWindow
* aWindow
, NPRemoteWindow
& aRemoteWindow
);
333 void SharedSurfaceBeforePaint(RECT
&rect
, NPRemoteEvent
& npremoteevent
);
334 void SharedSurfaceAfterPaint(NPEvent
* npevent
);
335 void SharedSurfaceRelease();
336 // Used in handling parent/child forwarding of events.
337 static LRESULT CALLBACK
PluginWindowHookProc(HWND hWnd
, UINT message
,
338 WPARAM wParam
, LPARAM lParam
);
339 void SubclassPluginWindow(HWND aWnd
);
340 void UnsubclassPluginWindow();
343 gfx::SharedDIBWin mSharedSurfaceDib
;
344 nsIntRect mPluginPort
;
345 nsIntRect mSharedSize
;
347 WNDPROC mPluginWndProc
;
348 bool mNestedEventState
;
349 #endif // defined(XP_WIN)
350 #if defined(OS_MACOSX)
355 CGColorSpaceRef mShColorSpace
;
356 int16_t mDrawingModel
;
357 nsIOSurface
*mIOSurface
;
358 #endif // definied(OS_MACOSX)
360 // ObjectFrame layer wrapper
361 nsRefPtr
<gfxASurface
> mFrontSurface
;
362 // For windowless+transparent instances, this surface contains a
363 // "pretty recent" copy of the pixels under its <object> frame.
364 // On the plugin side, we use this surface to avoid doing alpha
365 // recovery when possible. This surface is created and owned by
366 // the browser, but a "read-only" reference is sent to the plugin.
368 // We have explicitly chosen not to provide any guarantees about
369 // the consistency of the pixels in |mBackground|. A plugin may
370 // be able to observe partial updates to the background.
371 nsRefPtr
<gfxASurface
> mBackground
;
375 } // namespace plugins
376 } // namespace mozilla
378 #endif // ifndef dom_plugins_PluginInstanceParent_h