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;
114 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
115 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
116 *ppv = &This->IDispatch_iface;
117 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
118 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
119 *ppv = &This->IOleInPlaceSiteEx_iface;
120 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
121 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
122 *ppv = &This->IOleInPlaceSiteEx_iface;
123 }else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid)) {
124 TRACE("(%p)->(IID_IOleInPlaceSiteEx %p)\n", This, ppv);
125 *ppv = &This->IOleInPlaceSiteEx_iface;
127 WARN("Unsupported interface %s\n", debugstr_guid(riid));
129 return E_NOINTERFACE;
132 IOleClientSite_AddRef((IUnknown*)*ppv);
136 static ULONG WINAPI PHClientSite_AddRef(IOleClientSite *iface)
138 PluginHost *This = impl_from_IOleClientSite(iface);
139 LONG ref = InterlockedIncrement(&This->ref);
141 TRACE("(%p) ref=%d\n", This, ref);
146 static ULONG WINAPI PHClientSite_Release(IOleClientSite *iface)
148 PluginHost *This = impl_from_IOleClientSite(iface);
149 LONG ref = InterlockedDecrement(&This->ref);
151 TRACE("(%p) ref=%d\n", This, ref);
155 IUnknown_Release(This->plugin_unk);
162 static HRESULT WINAPI PHClientSite_SaveObject(IOleClientSite *iface)
164 PluginHost *This = impl_from_IOleClientSite(iface);
165 FIXME("(%p)\n", This);
169 static HRESULT WINAPI PHClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
170 DWORD dwWhichMoniker, IMoniker **ppmk)
172 PluginHost *This = impl_from_IOleClientSite(iface);
173 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
177 static HRESULT WINAPI PHClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
179 PluginHost *This = impl_from_IOleClientSite(iface);
180 FIXME("(%p)->(%p)\n", This, ppContainer);
184 static HRESULT WINAPI PHClientSite_ShowObject(IOleClientSite *iface)
186 PluginHost *This = impl_from_IOleClientSite(iface);
187 FIXME("(%p)\n", This);
191 static HRESULT WINAPI PHClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
193 PluginHost *This = impl_from_IOleClientSite(iface);
194 FIXME("(%p)->(%x)\n", This, fShow);
198 static HRESULT WINAPI PHClientSite_RequestNewObjectLayout(IOleClientSite *iface)
200 PluginHost *This = impl_from_IOleClientSite(iface);
201 FIXME("(%p)\n", This);
205 static const IOleClientSiteVtbl OleClientSiteVtbl = {
206 PHClientSite_QueryInterface,
208 PHClientSite_Release,
209 PHClientSite_SaveObject,
210 PHClientSite_GetMoniker,
211 PHClientSite_GetContainer,
212 PHClientSite_ShowObject,
213 PHClientSite_OnShowWindow,
214 PHClientSite_RequestNewObjectLayout
217 static inline PluginHost *impl_from_IAdviseSinkEx(IAdviseSinkEx *iface)
219 return CONTAINING_RECORD(iface, PluginHost, IAdviseSinkEx_iface);
222 static HRESULT WINAPI PHAdviseSinkEx_QueryInterface(IAdviseSinkEx *iface, REFIID riid, void **ppv)
224 PluginHost *This = impl_from_IAdviseSinkEx(iface);
225 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
228 static ULONG WINAPI PHAdviseSinkEx_AddRef(IAdviseSinkEx *iface)
230 PluginHost *This = impl_from_IAdviseSinkEx(iface);
231 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
234 static ULONG WINAPI PHAdviseSinkEx_Release(IAdviseSinkEx *iface)
236 PluginHost *This = impl_from_IAdviseSinkEx(iface);
237 return IOleClientSite_Release(&This->IOleClientSite_iface);
240 static void WINAPI PHAdviseSinkEx_OnDataChange(IAdviseSinkEx *iface, FORMATETC *pFormatetc, STGMEDIUM *pStgMedium)
242 PluginHost *This = impl_from_IAdviseSinkEx(iface);
243 FIXME("(%p)->(%p %p)\n", This, pFormatetc, pStgMedium);
246 static void WINAPI PHAdviseSinkEx_OnViewChange(IAdviseSinkEx *iface, DWORD dwAspect, LONG lindex)
248 PluginHost *This = impl_from_IAdviseSinkEx(iface);
249 FIXME("(%p)->(%d %d)\n", This, dwAspect, lindex);
252 static void WINAPI PHAdviseSinkEx_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
254 PluginHost *This = impl_from_IAdviseSinkEx(iface);
255 FIXME("(%p)->(%p)\n", This, pmk);
258 static void WINAPI PHAdviseSinkEx_OnSave(IAdviseSinkEx *iface)
260 PluginHost *This = impl_from_IAdviseSinkEx(iface);
261 FIXME("(%p)\n", This);
264 static void WINAPI PHAdviseSinkEx_OnClose(IAdviseSinkEx *iface)
266 PluginHost *This = impl_from_IAdviseSinkEx(iface);
267 FIXME("(%p)\n", This);
270 static void WINAPI PHAdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
272 PluginHost *This = impl_from_IAdviseSinkEx(iface);
273 FIXME("(%p)->(%d)\n", This, dwViewStatus);
276 static const IAdviseSinkExVtbl AdviseSinkExVtbl = {
277 PHAdviseSinkEx_QueryInterface,
278 PHAdviseSinkEx_AddRef,
279 PHAdviseSinkEx_Release,
280 PHAdviseSinkEx_OnDataChange,
281 PHAdviseSinkEx_OnViewChange,
282 PHAdviseSinkEx_OnRename,
283 PHAdviseSinkEx_OnSave,
284 PHAdviseSinkEx_OnClose,
285 PHAdviseSinkEx_OnViewStatusChange
288 static inline PluginHost *impl_from_IPropertyNotifySink(IPropertyNotifySink *iface)
290 return CONTAINING_RECORD(iface, PluginHost, IPropertyNotifySink_iface);
293 static HRESULT WINAPI PHPropertyNotifySink_QueryInterface(IPropertyNotifySink *iface, REFIID riid, void **ppv)
295 PluginHost *This = impl_from_IPropertyNotifySink(iface);
296 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
299 static ULONG WINAPI PHPropertyNotifySink_AddRef(IPropertyNotifySink *iface)
301 PluginHost *This = impl_from_IPropertyNotifySink(iface);
302 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
305 static ULONG WINAPI PHPropertyNotifySink_Release(IPropertyNotifySink *iface)
307 PluginHost *This = impl_from_IPropertyNotifySink(iface);
308 return IOleClientSite_Release(&This->IOleClientSite_iface);
311 static HRESULT WINAPI PHPropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
313 PluginHost *This = impl_from_IPropertyNotifySink(iface);
314 FIXME("(%p)->(%d)\n", This, dispID);
318 static HRESULT WINAPI PHPropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
320 PluginHost *This = impl_from_IPropertyNotifySink(iface);
321 FIXME("(%p)->(%d)\n", This, dispID);
325 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
326 PHPropertyNotifySink_QueryInterface,
327 PHPropertyNotifySink_AddRef,
328 PHPropertyNotifySink_Release,
329 PHPropertyNotifySink_OnChanged,
330 PHPropertyNotifySink_OnRequestEdit
333 static inline PluginHost *impl_from_IDispatch(IDispatch *iface)
335 return CONTAINING_RECORD(iface, PluginHost, IDispatch_iface);
338 static HRESULT WINAPI PHDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
340 PluginHost *This = impl_from_IDispatch(iface);
341 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
344 static ULONG WINAPI PHDispatch_AddRef(IDispatch *iface)
346 PluginHost *This = impl_from_IDispatch(iface);
347 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
350 static ULONG WINAPI PHDispatch_Release(IDispatch *iface)
352 PluginHost *This = impl_from_IDispatch(iface);
353 return IOleClientSite_Release(&This->IOleClientSite_iface);
356 static HRESULT WINAPI PHDispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
358 PluginHost *This = impl_from_IDispatch(iface);
359 FIXME("(%p)->(%p)\n", This, pctinfo);
363 static HRESULT WINAPI PHDispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo,
364 LCID lcid, ITypeInfo **ppTInfo)
366 PluginHost *This = impl_from_IDispatch(iface);
367 FIXME("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
371 static HRESULT WINAPI PHDispatch_GetIDsOfNames(IDispatch *iface, REFIID riid,
372 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
374 PluginHost *This = impl_from_IDispatch(iface);
375 FIXME("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
379 static HRESULT WINAPI PHDispatch_Invoke(IDispatch *iface, DISPID dispid, REFIID riid, LCID lcid,
380 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
382 PluginHost *This = impl_from_IDispatch(iface);
383 FIXME("(%p)->(%d %x %p %p)\n", This, dispid, wFlags, pDispParams, pVarResult);
387 static const IDispatchVtbl DispatchVtbl = {
388 PHDispatch_QueryInterface,
391 PHDispatch_GetTypeInfoCount,
392 PHDispatch_GetTypeInfo,
393 PHDispatch_GetIDsOfNames,
397 static inline PluginHost *impl_from_IOleInPlaceSiteEx(IOleInPlaceSiteEx *iface)
399 return CONTAINING_RECORD(iface, PluginHost, IOleInPlaceSiteEx_iface);
402 static HRESULT WINAPI PHInPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
404 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
405 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
408 static ULONG WINAPI PHInPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
410 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
411 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
414 static ULONG WINAPI PHInPlaceSite_Release(IOleInPlaceSiteEx *iface)
416 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
417 return IOleClientSite_Release(&This->IOleClientSite_iface);
420 static HRESULT WINAPI PHInPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
422 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
423 FIXME("(%p)->(%p)\n", This, phwnd);
427 static HRESULT WINAPI PHInPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
429 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
430 FIXME("(%p)->(%x)\n", This, fEnterMode);
434 static HRESULT WINAPI PHInPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
436 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
437 FIXME("(%p)\n", This);
441 static HRESULT WINAPI PHInPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
443 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
444 FIXME("(%p)\n", This);
448 static HRESULT WINAPI PHInPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
450 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
451 FIXME("(%p)\n", This);
455 static HRESULT WINAPI PHInPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
456 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, RECT *lprcPosRect,
457 RECT *lprcClipRect, OLEINPLACEFRAMEINFO *frame_info)
459 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
460 FIXME("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, frame_info);
464 static HRESULT WINAPI PHInPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtent)
466 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
467 FIXME("(%p)->({%d %d})\n", This, scrollExtent.cx, scrollExtent.cy);
471 static HRESULT WINAPI PHInPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
473 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
474 FIXME("(%p)->(%x)\n", This, fUndoable);
478 static HRESULT WINAPI PHInPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
480 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
481 FIXME("(%p)\n", This);
485 static HRESULT WINAPI PHInPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
487 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
488 FIXME("(%p)\n", This);
492 static HRESULT WINAPI PHInPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
494 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
495 FIXME("(%p)\n", This);
499 static HRESULT WINAPI PHInPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
501 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
502 FIXME("(%p)->(%p)\n", This, lprcPosRect);
506 static HRESULT WINAPI PHInPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
508 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
509 FIXME("(%p)->(%p %x)\n", This, pfNoRedraw, dwFlags);
513 static HRESULT WINAPI PHInPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
515 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
516 FIXME("(%p)->(%x)\n", This, fNoRedraw);
520 static HRESULT WINAPI PHInPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
522 PluginHost *This = impl_from_IOleInPlaceSiteEx(iface);
523 FIXME("(%p)\n", This);
527 static const IOleInPlaceSiteExVtbl OleInPlaceSiteExVtbl = {
528 PHInPlaceSite_QueryInterface,
529 PHInPlaceSite_AddRef,
530 PHInPlaceSite_Release,
531 PHInPlaceSite_GetWindow,
532 PHInPlaceSite_ContextSensitiveHelp,
533 PHInPlaceSite_CanInPlaceActivate,
534 PHInPlaceSite_OnInPlaceActivate,
535 PHInPlaceSite_OnUIActivate,
536 PHInPlaceSite_GetWindowContext,
537 PHInPlaceSite_Scroll,
538 PHInPlaceSite_OnUIDeactivate,
539 PHInPlaceSite_OnInPlaceDeactivate,
540 PHInPlaceSite_DiscardUndoState,
541 PHInPlaceSite_DeactivateAndUndo,
542 PHInPlaceSite_OnPosRectChange,
543 PHInPlaceSiteEx_OnInPlaceActivateEx,
544 PHInPlaceSiteEx_OnInPlaceDeactivateEx,
545 PHInPlaceSiteEx_RequestUIActivate
548 HRESULT create_plugin_host(IUnknown *unk, PluginHost **ret)
552 host = heap_alloc_zero(sizeof(*host));
554 return E_OUTOFMEMORY;
556 host->IOleClientSite_iface.lpVtbl = &OleClientSiteVtbl;
557 host->IAdviseSinkEx_iface.lpVtbl = &AdviseSinkExVtbl;
558 host->IPropertyNotifySink_iface.lpVtbl = &PropertyNotifySinkVtbl;
559 host->IDispatch_iface.lpVtbl = &DispatchVtbl;
560 host->IOleInPlaceSiteEx_iface.lpVtbl = &OleInPlaceSiteExVtbl;
564 IUnknown_AddRef(unk);
565 host->plugin_unk = unk;