2 * Copyright 2010 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "mshtml_private.h"
32 #include "pluginhost.h"
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 static void activate_plugin(PluginHost *host)
41 IClientSecurity *client_security;
42 IQuickActivate *quick_activate;
48 /* Note native calls QI on plugin for an undocumented IID and CLSID_HTMLDocument */
50 /* FIXME: call FreezeEvents(TRUE) */
52 hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IClientSecurity, (void**)&client_security);
54 FIXME("Handle IClientSecurity\n");
55 IClientSecurity_Release(client_security);
59 hres = IUnknown_QueryInterface(host->plugin_unk, &IID_IQuickActivate, (void**)&quick_activate);
61 QACONTAINER container = {sizeof(container)};
62 QACONTROL control = {sizeof(control)};
64 container.pClientSite = &host->IOleClientSite_iface;
65 container.dwAmbientFlags = QACONTAINER_SUPPORTSMNEMONICS|QACONTAINER_MESSAGEREFLECT|QACONTAINER_USERMODE;
66 container.pAdviseSink = &host->IAdviseSinkEx_iface;
67 container.pPropertyNotifySink = &host->IPropertyNotifySink_iface;
69 hres = IQuickActivate_QuickActivate(quick_activate, &container, &control);
71 FIXME("QuickActivate failed: %08x\n", hres);
73 FIXME("No IQuickActivate\n");
77 void update_plugin_window(PluginHost *host, HWND hwnd, const RECT *rect)
79 if(!hwnd || (host->hwnd && host->hwnd != hwnd)) {
80 FIXME("unhandled hwnd\n");
86 activate_plugin(host);
90 static inline PluginHost *impl_from_IOleClientSite(IOleClientSite *iface)
92 return CONTAINING_RECORD(iface, PluginHost, IOleClientSite_iface);
95 static HRESULT WINAPI PHClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
97 PluginHost *This = impl_from_IOleClientSite(iface);
99 if(IsEqualGUID(&IID_IUnknown, riid)) {
100 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
101 *ppv = &This->IOleClientSite_iface;
102 }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
103 TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
104 *ppv = &This->IOleClientSite_iface;
105 }else if(IsEqualGUID(&IID_IAdviseSink, riid)) {
106 TRACE("(%p)->(IID_IAdviseSink %p)\n", This, ppv);
107 *ppv = &This->IAdviseSinkEx_iface;
108 }else if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) {
109 TRACE("(%p)->(IID_IAdviseSinkEx %p)\n", This, ppv);
110 *ppv = &This->IAdviseSinkEx_iface;
111 }else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
112 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppv);
113 *ppv = &This->IPropertyNotifySink_iface;
115 WARN("Unsupported interface %s\n", debugstr_guid(riid));
117 return E_NOINTERFACE;
120 IOleClientSite_AddRef((IUnknown*)*ppv);
124 static ULONG WINAPI PHClientSite_AddRef(IOleClientSite *iface)
126 PluginHost *This = impl_from_IOleClientSite(iface);
127 LONG ref = InterlockedIncrement(&This->ref);
129 TRACE("(%p) ref=%d\n", This, ref);
134 static ULONG WINAPI PHClientSite_Release(IOleClientSite *iface)
136 PluginHost *This = impl_from_IOleClientSite(iface);
137 LONG ref = InterlockedDecrement(&This->ref);
139 TRACE("(%p) ref=%d\n", This, ref);
143 IUnknown_Release(This->plugin_unk);
150 static HRESULT WINAPI PHClientSite_SaveObject(IOleClientSite *iface)
152 PluginHost *This = impl_from_IOleClientSite(iface);
153 FIXME("(%p)\n", This);
157 static HRESULT WINAPI PHClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
158 DWORD dwWhichMoniker, IMoniker **ppmk)
160 PluginHost *This = impl_from_IOleClientSite(iface);
161 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
165 static HRESULT WINAPI PHClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
167 PluginHost *This = impl_from_IOleClientSite(iface);
168 FIXME("(%p)->(%p)\n", This, ppContainer);
172 static HRESULT WINAPI PHClientSite_ShowObject(IOleClientSite *iface)
174 PluginHost *This = impl_from_IOleClientSite(iface);
175 FIXME("(%p)\n", This);
179 static HRESULT WINAPI PHClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
181 PluginHost *This = impl_from_IOleClientSite(iface);
182 FIXME("(%p)->(%x)\n", This, fShow);
186 static HRESULT WINAPI PHClientSite_RequestNewObjectLayout(IOleClientSite *iface)
188 PluginHost *This = impl_from_IOleClientSite(iface);
189 FIXME("(%p)\n", This);
193 static const IOleClientSiteVtbl OleClientSiteVtbl = {
194 PHClientSite_QueryInterface,
196 PHClientSite_Release,
197 PHClientSite_SaveObject,
198 PHClientSite_GetMoniker,
199 PHClientSite_GetContainer,
200 PHClientSite_ShowObject,
201 PHClientSite_OnShowWindow,
202 PHClientSite_RequestNewObjectLayout
205 static inline PluginHost *impl_from_IAdviseSinkEx(IAdviseSinkEx *iface)
207 return CONTAINING_RECORD(iface, PluginHost, IAdviseSinkEx_iface);
210 static HRESULT WINAPI PHAdviseSinkEx_QueryInterface(IAdviseSinkEx *iface, REFIID riid, void **ppv)
212 PluginHost *This = impl_from_IAdviseSinkEx(iface);
213 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
216 static ULONG WINAPI PHAdviseSinkEx_AddRef(IAdviseSinkEx *iface)
218 PluginHost *This = impl_from_IAdviseSinkEx(iface);
219 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
222 static ULONG WINAPI PHAdviseSinkEx_Release(IAdviseSinkEx *iface)
224 PluginHost *This = impl_from_IAdviseSinkEx(iface);
225 return IOleClientSite_Release(&This->IOleClientSite_iface);
228 static void WINAPI PHAdviseSinkEx_OnDataChange(IAdviseSinkEx *iface, FORMATETC *pFormatetc, STGMEDIUM *pStgMedium)
230 PluginHost *This = impl_from_IAdviseSinkEx(iface);
231 FIXME("(%p)->(%p %p)\n", This, pFormatetc, pStgMedium);
234 static void WINAPI PHAdviseSinkEx_OnViewChange(IAdviseSinkEx *iface, DWORD dwAspect, LONG lindex)
236 PluginHost *This = impl_from_IAdviseSinkEx(iface);
237 FIXME("(%p)->(%d %d)\n", This, dwAspect, lindex);
240 static void WINAPI PHAdviseSinkEx_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
242 PluginHost *This = impl_from_IAdviseSinkEx(iface);
243 FIXME("(%p)->(%p)\n", This, pmk);
246 static void WINAPI PHAdviseSinkEx_OnSave(IAdviseSinkEx *iface)
248 PluginHost *This = impl_from_IAdviseSinkEx(iface);
249 FIXME("(%p)\n", This);
252 static void WINAPI PHAdviseSinkEx_OnClose(IAdviseSinkEx *iface)
254 PluginHost *This = impl_from_IAdviseSinkEx(iface);
255 FIXME("(%p)\n", This);
258 static void WINAPI PHAdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
260 PluginHost *This = impl_from_IAdviseSinkEx(iface);
261 FIXME("(%p)->(%d)\n", This, dwViewStatus);
264 static const IAdviseSinkExVtbl AdviseSinkExVtbl = {
265 PHAdviseSinkEx_QueryInterface,
266 PHAdviseSinkEx_AddRef,
267 PHAdviseSinkEx_Release,
268 PHAdviseSinkEx_OnDataChange,
269 PHAdviseSinkEx_OnViewChange,
270 PHAdviseSinkEx_OnRename,
271 PHAdviseSinkEx_OnSave,
272 PHAdviseSinkEx_OnClose,
273 PHAdviseSinkEx_OnViewStatusChange
276 static inline PluginHost *impl_from_IPropertyNotifySink(IPropertyNotifySink *iface)
278 return CONTAINING_RECORD(iface, PluginHost, IPropertyNotifySink_iface);
281 static HRESULT WINAPI PHPropertyNotifySink_QueryInterface(IPropertyNotifySink *iface, REFIID riid, void **ppv)
283 PluginHost *This = impl_from_IPropertyNotifySink(iface);
284 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
287 static ULONG WINAPI PHPropertyNotifySink_AddRef(IPropertyNotifySink *iface)
289 PluginHost *This = impl_from_IPropertyNotifySink(iface);
290 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
293 static ULONG WINAPI PHPropertyNotifySink_Release(IPropertyNotifySink *iface)
295 PluginHost *This = impl_from_IPropertyNotifySink(iface);
296 return IOleClientSite_Release(&This->IOleClientSite_iface);
299 static HRESULT WINAPI PHPropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
301 PluginHost *This = impl_from_IPropertyNotifySink(iface);
302 FIXME("(%p)->(%d)\n", This, dispID);
306 static HRESULT WINAPI PHPropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
308 PluginHost *This = impl_from_IPropertyNotifySink(iface);
309 FIXME("(%p)->(%d)\n", This, dispID);
313 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
314 PHPropertyNotifySink_QueryInterface,
315 PHPropertyNotifySink_AddRef,
316 PHPropertyNotifySink_Release,
317 PHPropertyNotifySink_OnChanged,
318 PHPropertyNotifySink_OnRequestEdit
321 HRESULT create_plugin_host(IUnknown *unk, PluginHost **ret)
325 host = heap_alloc_zero(sizeof(*host));
327 return E_OUTOFMEMORY;
329 host->IOleClientSite_iface.lpVtbl = &OleClientSiteVtbl;
330 host->IAdviseSinkEx_iface.lpVtbl = &AdviseSinkExVtbl;
331 host->IPropertyNotifySink_iface.lpVtbl = &PropertyNotifySinkVtbl;
335 IUnknown_AddRef(unk);
336 host->plugin_unk = unk;