Bug 522299 - Electrolysis: Get windowless plugins drawing on win32. r=jmuizelaar.
[mozilla-central.git] / dom / plugins / PluginInstanceParent.h
blobdc0a4f2ce9200f87a6d014136392eac448c37ee5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: sw=4 ts=4 et :
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
14 * License.
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.
23 * Contributor(s):
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"
44 #if defined(OS_WIN)
45 #include "mozilla/gfx/SharedDIBWin.h"
46 #endif
48 #include "npfunctions.h"
49 #include "nsAutoPtr.h"
50 #include "nsTArray.h"
51 #include "nsRect.h"
53 #undef _MOZ_LOG
54 #define _MOZ_LOG(s) printf("[PluginInstanceParent] %s\n", s)
56 namespace mozilla {
57 namespace plugins {
59 class PBrowserStreamParent;
60 class BrowserStreamParent;
61 class PluginModuleParent;
63 class PluginInstanceParent : public PPluginInstanceParent
65 friend class PluginModuleParent;
66 friend class BrowserStreamParent;
67 friend class PluginStreamParent;
69 public:
70 PluginInstanceParent(PluginModuleParent* parent,
71 NPP npp,
72 const NPNetscapeFuncs* npniface);
74 virtual ~PluginInstanceParent();
76 void Destroy();
78 virtual PPluginScriptableObjectParent*
79 AllocPPluginScriptableObject();
81 virtual bool
82 AnswerPPluginScriptableObjectConstructor(PPluginScriptableObjectParent* aActor);
84 virtual bool
85 DeallocPPluginScriptableObject(PPluginScriptableObjectParent* aObject);
86 virtual PBrowserStreamParent*
87 AllocPBrowserStream(const nsCString& url,
88 const uint32_t& length,
89 const uint32_t& lastmodified,
90 PStreamNotifyParent* notifyData,
91 const nsCString& headers,
92 const nsCString& mimeType,
93 const bool& seekable,
94 NPError* rv,
95 uint16_t *stype);
97 virtual bool
98 AnswerPBrowserStreamDestructor(PBrowserStreamParent* stream,
99 const NPError& reason,
100 const bool& artificial);
102 virtual bool
103 DeallocPBrowserStream(PBrowserStreamParent* stream,
104 const NPError& reason,
105 const bool& artificial);
107 virtual PPluginStreamParent*
108 AllocPPluginStream(const nsCString& mimeType,
109 const nsCString& target,
110 NPError* result);
112 virtual bool
113 DeallocPPluginStream(PPluginStreamParent* stream,
114 const NPError& reason,
115 const bool& artificial);
117 virtual bool
118 AnswerNPN_GetValue_NPNVjavascriptEnabledBool(bool* value, NPError* result);
119 virtual bool
120 AnswerNPN_GetValue_NPNVisOfflineBool(bool* value, NPError* result);
121 virtual bool
122 AnswerNPN_GetValue_NPNVWindowNPObject(
123 PPluginScriptableObjectParent** value,
124 NPError* result);
125 virtual bool
126 AnswerNPN_GetValue_NPNVPluginElementNPObject(
127 PPluginScriptableObjectParent** value,
128 NPError* result);
129 virtual bool
130 AnswerNPN_GetValue_NPNVprivateModeBool(bool* value, NPError* result);
132 virtual bool
133 AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result);
134 virtual bool
135 AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent,
136 NPError* result);
138 virtual bool
139 AnswerNPN_GetURL(const nsCString& url, const nsCString& target,
140 NPError *result);
142 virtual bool
143 AnswerNPN_PostURL(const nsCString& url, const nsCString& target,
144 const nsCString& buffer, const bool& file,
145 NPError* result);
147 virtual PStreamNotifyParent*
148 AllocPStreamNotify(const nsCString& url, const nsCString& target,
149 const bool& post, const nsCString& buffer,
150 const bool& file,
151 NPError* result);
153 NS_OVERRIDE virtual bool
154 AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
155 const nsCString& url,
156 const nsCString& target,
157 const bool& post, const nsCString& buffer,
158 const bool& file,
159 NPError* result);
161 virtual bool
162 DeallocPStreamNotify(PStreamNotifyParent* notifyData,
163 const NPReason& reason);
165 virtual bool
166 RecvNPN_InvalidateRect(const NPRect& rect);
168 virtual bool
169 AnswerNPN_PushPopupsEnabledState(const bool& aState,
170 bool* aSuccess);
172 virtual bool
173 AnswerNPN_PopPopupsEnabledState(bool* aSuccess);
175 NPError NPP_SetWindow(const NPWindow* aWindow);
177 NPError NPP_GetValue(NPPVariable variable, void *ret_value);
178 NPError NPP_SetValue(NPNVariable variable, void *value)
180 _MOZ_LOG(__FUNCTION__);
181 return 1;
184 NPError NPP_NewStream(NPMIMEType type, NPStream* stream,
185 NPBool seekable, uint16_t* stype);
186 NPError NPP_DestroyStream(NPStream* stream, NPReason reason);
188 void NPP_Print(NPPrint* platformPrint)
190 _MOZ_LOG(__FUNCTION__);
193 int16_t NPP_HandleEvent(void* event);
195 void NPP_URLNotify(const char* url, NPReason reason, void* notifyData);
197 PluginModuleParent* Module()
199 return mParent;
202 const NPNetscapeFuncs* GetNPNIface()
204 return mNPNIface;
207 PluginScriptableObjectParent*
208 GetActorForNPObject(NPObject* aObject);
211 GetNPP()
213 return mNPP;
216 private:
217 bool InternalGetValueForNPObject(NPNVariable aVariable,
218 PPluginScriptableObjectParent** aValue,
219 NPError* aResult);
221 private:
222 PluginModuleParent* mParent;
223 NPP mNPP;
224 const NPNetscapeFuncs* mNPNIface;
225 NPWindowType mWindowType;
227 nsTArray<nsAutoPtr<PluginScriptableObjectParent> > mScriptableObjects;
229 #if defined(OS_WIN)
230 private:
231 // Used in rendering windowless plugins in other processes.
232 bool SharedSurfaceSetWindow(const NPWindow* aWindow, NPRemoteWindow& aRemoteWindow);
233 bool SharedSurfaceBeforePaint(RECT &rect, NPRemoteEvent& npremoteevent);
234 void SharedSurfaceAfterPaint(NPEvent* npevent);
235 void SharedSurfaceRelease();
237 private:
238 gfx::SharedDIBWin mSharedSurfaceDib;
239 nsIntRect mPluginPort;
240 nsIntRect mSharedSize;
241 PRUint32 mDoublePassEvent;
242 bool mLocalCopyRender;
243 #endif // defined(XP_WIN)
247 } // namespace plugins
248 } // namespace mozilla
250 #endif // ifndef dom_plugins_PluginInstanceParent_h