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"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 IPropertyBag IPropertyBag_iface
;
40 IPropertyBag2 IPropertyBag2_iface
;
53 static void free_prop(param_prop_t
*prop
)
55 list_remove(&prop
->entry
);
57 heap_free(prop
->name
);
58 heap_free(prop
->value
);
62 static param_prop_t
*find_prop(PropertyBag
*prop_bag
, const WCHAR
*name
)
66 LIST_FOR_EACH_ENTRY(iter
, &prop_bag
->props
, param_prop_t
, entry
) {
67 if(!wcsicmp(iter
->name
, name
))
74 static HRESULT
add_prop(PropertyBag
*prop_bag
, const WCHAR
*name
, const WCHAR
*value
)
81 TRACE("%p %s %s\n", prop_bag
, debugstr_w(name
), debugstr_w(value
));
83 prop
= heap_alloc(sizeof(*prop
));
87 prop
->name
= heap_strdupW(name
);
88 prop
->value
= heap_strdupW(value
);
89 if(!prop
->name
|| !prop
->value
) {
90 list_init(&prop
->entry
);
95 list_add_tail(&prop_bag
->props
, &prop
->entry
);
99 static inline PropertyBag
*impl_from_IPropertyBag(IPropertyBag
*iface
)
101 return CONTAINING_RECORD(iface
, PropertyBag
, IPropertyBag_iface
);
104 static HRESULT WINAPI
PropertyBag_QueryInterface(IPropertyBag
*iface
, REFIID riid
, void **ppv
)
106 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
108 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
109 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
110 *ppv
= &This
->IPropertyBag_iface
;
111 }else if(IsEqualGUID(&IID_IPropertyBag
, riid
)) {
112 TRACE("(%p)->(IID_IPropertyBag %p)\n", This
, ppv
);
113 *ppv
= &This
->IPropertyBag_iface
;
114 }else if(IsEqualGUID(&IID_IPropertyBag2
, riid
)) {
115 TRACE("(%p)->(IID_IPropertyBag2 %p)\n", This
, ppv
);
116 *ppv
= &This
->IPropertyBag2_iface
;
118 WARN("Unsopported interface %s\n", debugstr_guid(riid
));
120 return E_NOINTERFACE
;
123 IUnknown_AddRef((IUnknown
*)*ppv
);
127 static ULONG WINAPI
PropertyBag_AddRef(IPropertyBag
*iface
)
129 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
130 LONG ref
= InterlockedIncrement(&This
->ref
);
132 TRACE("(%p) ref=%d\n", This
, ref
);
137 static ULONG WINAPI
PropertyBag_Release(IPropertyBag
*iface
)
139 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
140 LONG ref
= InterlockedDecrement(&This
->ref
);
142 TRACE("(%p) ref=%d\n", This
, ref
);
145 while(!list_empty(&This
->props
))
146 free_prop(LIST_ENTRY(This
->props
.next
, param_prop_t
, entry
));
153 static HRESULT WINAPI
PropertyBag_Read(IPropertyBag
*iface
, LPCOLESTR pszPropName
, VARIANT
*pVar
, IErrorLog
*pErrorLog
)
155 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
159 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
161 prop
= find_prop(This
, pszPropName
);
163 TRACE("Not found\n");
167 V_BSTR(&v
) = SysAllocString(prop
->value
);
169 return E_OUTOFMEMORY
;
171 if(V_VT(pVar
) != VT_BSTR
) {
175 hres
= VariantChangeType(pVar
, &v
, 0, V_VT(pVar
));
176 SysFreeString(V_BSTR(&v
));
180 V_BSTR(pVar
) = V_BSTR(&v
);
184 static HRESULT WINAPI
PropertyBag_Write(IPropertyBag
*iface
, LPCOLESTR pszPropName
, VARIANT
*pVar
)
186 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
187 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(pszPropName
), debugstr_variant(pVar
));
191 static const IPropertyBagVtbl PropertyBagVtbl
= {
192 PropertyBag_QueryInterface
,
199 static inline PropertyBag
*impl_from_IPropertyBag2(IPropertyBag2
*iface
)
201 return CONTAINING_RECORD(iface
, PropertyBag
, IPropertyBag2_iface
);
204 static HRESULT WINAPI
PropertyBag2_QueryInterface(IPropertyBag2
*iface
, REFIID riid
, void **ppv
)
206 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
207 return IPropertyBag_QueryInterface(&This
->IPropertyBag_iface
, riid
, ppv
);
210 static ULONG WINAPI
PropertyBag2_AddRef(IPropertyBag2
*iface
)
212 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
213 return IPropertyBag_AddRef(&This
->IPropertyBag_iface
);
216 static ULONG WINAPI
PropertyBag2_Release(IPropertyBag2
*iface
)
218 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
219 return IPropertyBag_Release(&This
->IPropertyBag_iface
);
222 static HRESULT WINAPI
PropertyBag2_Read(IPropertyBag2
*iface
, ULONG cProperties
, PROPBAG2
*pPropBag
,
223 IErrorLog
*pErrLog
, VARIANT
*pvarValue
, HRESULT
*phrError
)
225 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
226 FIXME("(%p)->(%d %p %p %p %p)\n", This
, cProperties
, pPropBag
, pErrLog
, pvarValue
, phrError
);
230 static HRESULT WINAPI
PropertyBag2_Write(IPropertyBag2
*iface
, ULONG cProperties
, PROPBAG2
*pPropBag
, VARIANT
*pvarValue
)
232 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
233 FIXME("(%p)->(%d %p %s)\n", This
, cProperties
, pPropBag
, debugstr_variant(pvarValue
));
237 static HRESULT WINAPI
PropertyBag2_CountProperties(IPropertyBag2
*iface
, ULONG
*pcProperties
)
239 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
240 FIXME("(%p)->(%p)\n", This
, pcProperties
);
244 static HRESULT WINAPI
PropertyBag2_GetPropertyInfo(IPropertyBag2
*iface
, ULONG iProperty
, ULONG cProperties
,
245 PROPBAG2
*pPropBag
, ULONG
*pcProperties
)
247 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
248 FIXME("(%p)->(%u %u %p %p)\n", This
, iProperty
, cProperties
, pPropBag
, pcProperties
);
252 static HRESULT WINAPI
PropertyBag2_LoadObject(IPropertyBag2
*iface
, LPCOLESTR pstrName
, DWORD dwHint
,
253 IUnknown
*pUnkObject
, IErrorLog
*pErrLog
)
255 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
256 FIXME("(%p)->(%s %x %p %p)\n", This
, debugstr_w(pstrName
), dwHint
, pUnkObject
, pErrLog
);
260 static const IPropertyBag2Vtbl PropertyBag2Vtbl
= {
261 PropertyBag2_QueryInterface
,
263 PropertyBag2_Release
,
266 PropertyBag2_CountProperties
,
267 PropertyBag2_GetPropertyInfo
,
268 PropertyBag2_LoadObject
271 static HRESULT
fill_props(nsIDOMElement
*nselem
, PropertyBag
*prop_bag
)
273 const PRUnichar
*name
, *value
;
274 nsAString name_str
, value_str
;
275 nsIDOMHTMLCollection
*params
;
276 nsIDOMElement
*param_elem
;
282 static const PRUnichar nameW
[] = {'n','a','m','e',0};
283 static const PRUnichar paramW
[] = {'p','a','r','a','m',0};
284 static const PRUnichar valueW
[] = {'v','a','l','u','e',0};
286 nsAString_InitDepend(&name_str
, paramW
);
287 nsres
= nsIDOMElement_GetElementsByTagName(nselem
, &name_str
, ¶ms
);
288 nsAString_Finish(&name_str
);
292 nsres
= nsIDOMHTMLCollection_GetLength(params
, &length
);
296 for(i
=0; i
< length
; i
++) {
297 nsres
= nsIDOMHTMLCollection_Item(params
, i
, &nsnode
);
298 if(NS_FAILED(nsres
)) {
303 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMElement
, (void**)¶m_elem
);
304 nsIDOMNode_Release(nsnode
);
305 if(NS_FAILED(nsres
)) {
310 nsres
= get_elem_attr_value(param_elem
, nameW
, &name_str
, &name
);
311 if(NS_SUCCEEDED(nsres
)) {
312 nsres
= get_elem_attr_value(param_elem
, valueW
, &value_str
, &value
);
313 if(NS_SUCCEEDED(nsres
)) {
314 hres
= add_prop(prop_bag
, name
, value
);
315 nsAString_Finish(&value_str
);
318 nsAString_Finish(&name_str
);
321 nsIDOMElement_Release(param_elem
);
324 if(NS_FAILED(nsres
)) {
330 nsIDOMHTMLCollection_Release(params
);
334 static HRESULT
create_param_prop_bag(nsIDOMElement
*nselem
, IPropertyBag
**ret
)
336 PropertyBag
*prop_bag
;
339 prop_bag
= heap_alloc(sizeof(*prop_bag
));
341 return E_OUTOFMEMORY
;
343 prop_bag
->IPropertyBag_iface
.lpVtbl
= &PropertyBagVtbl
;
344 prop_bag
->IPropertyBag2_iface
.lpVtbl
= &PropertyBag2Vtbl
;
347 list_init(&prop_bag
->props
);
348 hres
= fill_props(nselem
, prop_bag
);
349 if(FAILED(hres
) || list_empty(&prop_bag
->props
)) {
350 IPropertyBag_Release(&prop_bag
->IPropertyBag_iface
);
355 *ret
= &prop_bag
->IPropertyBag_iface
;
359 static BOOL
check_load_safety(PluginHost
*host
)
361 DWORD policy_size
, policy
;
362 struct CONFIRMSAFETY cs
;
366 cs
.clsid
= host
->clsid
;
367 cs
.pUnk
= host
->plugin_unk
;
368 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
370 hres
= IInternetHostSecurityManager_QueryCustomPolicy(&host
->doc
->IInternetHostSecurityManager_iface
,
371 &GUID_CUSTOM_CONFIRMOBJECTSAFETY
, &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
375 policy
= *(DWORD
*)ppolicy
;
376 CoTaskMemFree(ppolicy
);
377 return policy
== URLPOLICY_ALLOW
;
380 static BOOL
check_script_safety(PluginHost
*host
)
382 DISPPARAMS params
= {NULL
,NULL
,0,0};
383 DWORD policy_size
, policy
;
384 struct CONFIRMSAFETY cs
;
390 cs
.clsid
= host
->clsid
;
391 cs
.pUnk
= host
->plugin_unk
;
394 hres
= IInternetHostSecurityManager_QueryCustomPolicy(&host
->doc
->IInternetHostSecurityManager_iface
,
395 &GUID_CUSTOM_CONFIRMOBJECTSAFETY
, &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
399 policy
= *(DWORD
*)ppolicy
;
400 CoTaskMemFree(ppolicy
);
402 if(policy
!= URLPOLICY_ALLOW
)
406 hres
= IDispatch_Invoke(host
->disp
, DISPID_SECURITYCTX
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &v
, NULL
, &err
);
407 if(SUCCEEDED(hres
)) {
408 FIXME("Handle security ctx %s\n", debugstr_variant(&v
));
415 static void update_readystate(PluginHost
*host
)
417 DISPPARAMS params
= {NULL
,NULL
,0,0};
424 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatchEx
, (void**)&dispex
);
425 if(SUCCEEDED(hres
)) {
426 FIXME("Use IDispatchEx\n");
427 IDispatchEx_Release(dispex
);
430 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
434 hres
= IDispatch_Invoke(disp
, DISPID_READYSTATE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &v
, NULL
, &err
);
435 IDispatch_Release(disp
);
436 if(SUCCEEDED(hres
)) {
437 /* FIXME: make plugin readystate affect document readystate */
438 TRACE("readystate = %s\n", debugstr_variant(&v
));
443 /* FIXME: We shouldn't need this function and we should embed plugin directly in the main document */
444 static void get_pos_rect(PluginHost
*host
, RECT
*ret
)
446 SetRect(ret
, 0, 0, host
->rect
.right
- host
->rect
.left
, host
->rect
.bottom
- host
->rect
.top
);
449 static void load_prop_bag(PluginHost
*host
, IPersistPropertyBag
*persist_prop_bag
)
451 IPropertyBag
*prop_bag
;
454 hres
= create_param_prop_bag(host
->element
->element
.dom_element
, &prop_bag
);
458 if(prop_bag
&& !check_load_safety(host
)) {
459 IPropertyBag_Release(prop_bag
);
464 hres
= IPersistPropertyBag_Load(persist_prop_bag
, prop_bag
, NULL
);
465 IPropertyBag_Release(prop_bag
);
467 WARN("Load failed: %08x\n", hres
);
469 hres
= IPersistPropertyBag_InitNew(persist_prop_bag
);
471 WARN("InitNew failed: %08x\n", hres
);
475 static void load_plugin(PluginHost
*host
)
477 IPersistPropertyBag2
*persist_prop_bag2
;
478 IPersistPropertyBag
*persist_prop_bag
;
481 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IPersistPropertyBag2
, (void**)&persist_prop_bag2
);
482 if(SUCCEEDED(hres
)) {
483 FIXME("Use IPersistPropertyBag2 iface\n");
484 IPersistPropertyBag2_Release(persist_prop_bag2
);
488 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IPersistPropertyBag
, (void**)&persist_prop_bag
);
489 if(SUCCEEDED(hres
)) {
490 load_prop_bag(host
, persist_prop_bag
);
491 IPersistPropertyBag_Release(persist_prop_bag
);
495 FIXME("No IPersistPropertyBag iface\n");
498 static void initialize_plugin_object(PluginHost
*host
)
500 IClientSecurity
*client_security
;
501 IQuickActivate
*quick_activate
;
502 IOleObject
*ole_obj
= NULL
;
503 IOleCommandTarget
*cmdtrg
;
504 IViewObjectEx
*view_obj
;
509 /* Note native calls QI on plugin for an undocumented IID and CLSID_HTMLDocument */
511 /* FIXME: call FreezeEvents(TRUE) */
513 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IClientSecurity
, (void**)&client_security
);
514 if(SUCCEEDED(hres
)) {
515 FIXME("Handle IClientSecurity\n");
516 IClientSecurity_Release(client_security
);
520 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IQuickActivate
, (void**)&quick_activate
);
521 if(SUCCEEDED(hres
)) {
522 QACONTAINER container
= {sizeof(container
)};
523 QACONTROL control
= {sizeof(control
)};
525 TRACE("Using IQuickActivate\n");
527 container
.pClientSite
= &host
->IOleClientSite_iface
;
528 container
.dwAmbientFlags
= QACONTAINER_SUPPORTSMNEMONICS
|QACONTAINER_MESSAGEREFLECT
|QACONTAINER_USERMODE
;
529 container
.pAdviseSink
= &host
->IAdviseSinkEx_iface
;
530 container
.pPropertyNotifySink
= &host
->IPropertyNotifySink_iface
;
532 hres
= IQuickActivate_QuickActivate(quick_activate
, &container
, &control
);
533 IQuickActivate_Release(quick_activate
);
535 FIXME("QuickActivate failed: %08x\n", hres
);
539 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
540 if(SUCCEEDED(hres
)) {
541 hres
= IOleObject_GetMiscStatus(ole_obj
, DVASPECT_CONTENT
, &status
);
542 TRACE("GetMiscStatus returned %08x %x\n", hres
, status
);
544 hres
= IOleObject_SetClientSite(ole_obj
, &host
->IOleClientSite_iface
);
545 IOleObject_Release(ole_obj
);
547 FIXME("SetClientSite failed: %08x\n", hres
);
551 TRACE("Plugin does not support IOleObject\n");
558 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IViewObjectEx
, (void**)&view_obj
);
559 if(SUCCEEDED(hres
)) {
560 DWORD view_status
= 0;
562 hres
= IViewObjectEx_SetAdvise(view_obj
, DVASPECT_CONTENT
, 0, (IAdviseSink
*)&host
->IAdviseSinkEx_iface
);
564 WARN("SetAdvise failed: %08x\n", hres
);
566 hres
= IViewObjectEx_GetViewStatus(view_obj
, &view_status
);
567 IViewObjectEx_Release(view_obj
);
568 TRACE("GetViewStatus returned %08x %x\n", hres
, view_status
);
572 update_readystate(host
);
574 /* NOTE: Native QIs for IActiveScript, an undocumented IID, IOleControl and IRunnableObject */
576 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatchEx
, (void**)&dispex
);
577 if(SUCCEEDED(hres
)) {
578 FIXME("Use IDispatchEx\n");
579 host
->disp
= (IDispatch
*)dispex
;
581 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
585 TRACE("no IDispatch iface\n");
588 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
589 if(SUCCEEDED(hres
)) {
590 FIXME("Use IOleCommandTarget\n");
591 IOleCommandTarget_Release(cmdtrg
);
595 static void embed_plugin_object(PluginHost
*host
)
601 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
603 FIXME("Plugin does not support IOleObject\n");
607 get_pos_rect(host
, &rect
);
608 hres
= IOleObject_DoVerb(ole_obj
, OLEIVERB_INPLACEACTIVATE
, NULL
, &host
->IOleClientSite_iface
, 0, host
->hwnd
, &rect
);
609 IOleObject_Release(ole_obj
);
611 WARN("DoVerb failed: %08x\n", hres
);
613 if(host
->ip_object
) {
616 hres
= IOleInPlaceObject_GetWindow(host
->ip_object
, &hwnd
);
618 TRACE("hwnd %p\n", hwnd
);
622 void update_plugin_window(PluginHost
*host
, HWND hwnd
, const RECT
*rect
)
624 BOOL rect_changed
= FALSE
;
626 if(!hwnd
|| (host
->hwnd
&& host
->hwnd
!= hwnd
)) {
627 FIXME("unhandled hwnd\n");
631 TRACE("%p %s\n", hwnd
, wine_dbgstr_rect(rect
));
633 if(!EqualRect(rect
, &host
->rect
)) {
640 embed_plugin_object(host
);
643 if(rect_changed
&& host
->ip_object
)
644 IOleInPlaceObject_SetObjectRects(host
->ip_object
, &host
->rect
, &host
->rect
);
647 static void notif_enabled(PluginHost
*plugin_host
)
649 DISPPARAMS args
= {NULL
, NULL
, 0, 0};
655 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
657 FIXME("Could not get IDispatch iface: %08x\n", hres
);
661 V_VT(&res
) = VT_EMPTY
;
662 hres
= IDispatch_Invoke(disp
, DISPID_ENABLED
, &IID_NULL
, 0/*FIXME*/, DISPATCH_PROPERTYGET
, &args
, &res
, NULL
, &err
);
663 IDispatch_Release(disp
);
664 if(SUCCEEDED(hres
)) {
665 FIXME("Got enabled %s\n", debugstr_variant(&res
));
670 void notif_container_change(HTMLPluginContainer
*plugin_container
, DISPID dispid
)
672 IOleControl
*ole_control
;
675 if(!plugin_container
->plugin_host
|| !plugin_container
->plugin_host
->plugin_unk
)
678 notif_enabled(plugin_container
->plugin_host
);
680 hres
= IUnknown_QueryInterface(plugin_container
->plugin_host
->plugin_unk
, &IID_IOleControl
, (void**)&ole_control
);
681 if(SUCCEEDED(hres
)) {
682 IOleControl_OnAmbientPropertyChange(ole_control
, dispid
);
683 IOleControl_Release(ole_control
);
687 HRESULT
get_plugin_disp(HTMLPluginContainer
*plugin_container
, IDispatch
**ret
)
691 host
= plugin_container
->plugin_host
;
693 ERR("No plugin host\n");
702 if(!check_script_safety(host
)) {
703 FIXME("Insecure object\n");
707 IDispatch_AddRef(host
->disp
);
712 HRESULT
get_plugin_dispid(HTMLPluginContainer
*plugin_container
, WCHAR
*name
, DISPID
*ret
)
719 if(!plugin_container
->plugin_host
) {
720 WARN("no plugin host\n");
721 return DISP_E_UNKNOWNNAME
;
724 disp
= plugin_container
->plugin_host
->disp
;
726 return DISP_E_UNKNOWNNAME
;
728 hres
= IDispatch_GetIDsOfNames(disp
, &IID_NULL
, &name
, 1, 0, &id
);
730 TRACE("no prop %s\n", debugstr_w(name
));
731 return DISP_E_UNKNOWNNAME
;
734 for(i
=0; i
< plugin_container
->props_len
; i
++) {
735 if(id
== plugin_container
->props
[i
]) {
736 *ret
= MSHTML_DISPID_CUSTOM_MIN
+i
;
741 if(!plugin_container
->props
) {
742 plugin_container
->props
= heap_alloc(8*sizeof(DISPID
));
743 if(!plugin_container
->props
)
744 return E_OUTOFMEMORY
;
745 plugin_container
->props_size
= 8;
746 }else if(plugin_container
->props_len
== plugin_container
->props_size
) {
749 new_props
= heap_realloc(plugin_container
->props
, plugin_container
->props_size
*2*sizeof(DISPID
));
751 return E_OUTOFMEMORY
;
753 plugin_container
->props
= new_props
;
754 plugin_container
->props_size
*= 2;
757 plugin_container
->props
[plugin_container
->props_len
] = id
;
758 *ret
= MSHTML_DISPID_CUSTOM_MIN
+plugin_container
->props_len
;
759 plugin_container
->props_len
++;
763 HRESULT
invoke_plugin_prop(HTMLPluginContainer
*plugin_container
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
764 VARIANT
*res
, EXCEPINFO
*ei
)
768 host
= plugin_container
->plugin_host
;
769 if(!host
|| !host
->disp
) {
770 FIXME("Called with no disp\n");
774 if(!check_script_safety(host
)) {
775 FIXME("Insecure object\n");
779 if(id
< MSHTML_DISPID_CUSTOM_MIN
|| id
> MSHTML_DISPID_CUSTOM_MIN
+ plugin_container
->props_len
) {
784 return IDispatch_Invoke(host
->disp
, plugin_container
->props
[id
-MSHTML_DISPID_CUSTOM_MIN
], &IID_NULL
,
785 lcid
, flags
, params
, res
, ei
, NULL
);
794 IDispatch IDispatch_iface
;
804 sink_entry_t
*handlers
;
809 static sink_entry_t
*find_sink_entry(PHEventSink
*sink
, DISPID id
)
813 for(iter
= sink
->handlers
; iter
< sink
->handlers
+sink
->handlers_cnt
; iter
++) {
821 static void add_sink_handler(PHEventSink
*sink
, DISPID id
, IDispatch
*disp
)
823 sink_entry_t
*entry
= find_sink_entry(sink
, id
);
827 IDispatch_Release(entry
->disp
);
829 if(!sink
->handlers_size
) {
830 sink
->handlers
= heap_alloc(4*sizeof(*sink
->handlers
));
833 sink
->handlers_size
= 4;
834 }else if(sink
->handlers_cnt
== sink
->handlers_size
) {
835 sink_entry_t
*new_handlers
;
837 new_handlers
= heap_realloc(sink
->handlers
, 2*sink
->handlers_size
*sizeof(*sink
->handlers
));
840 sink
->handlers
= new_handlers
;
841 sink
->handlers_size
*= 2;
843 entry
= sink
->handlers
+ sink
->handlers_cnt
++;
847 IDispatch_AddRef(disp
);
851 static inline PHEventSink
*PHEventSink_from_IDispatch(IDispatch
*iface
)
853 return CONTAINING_RECORD(iface
, PHEventSink
, IDispatch_iface
);
856 static HRESULT WINAPI
PHEventSink_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
858 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
860 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
861 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
862 *ppv
= &This
->IDispatch_iface
;
863 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
864 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
865 *ppv
= &This
->IDispatch_iface
;
866 }else if(This
->is_dispiface
&& IsEqualGUID(riid
, &This
->iid
)) {
867 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
868 *ppv
= &This
->IDispatch_iface
;
870 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
872 return E_NOINTERFACE
;
875 IUnknown_AddRef((IUnknown
*)*ppv
);
879 static ULONG WINAPI
PHEventSink_AddRef(IDispatch
*iface
)
881 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
882 LONG ref
= InterlockedIncrement(&This
->ref
);
884 TRACE("(%p)\n", This
);
889 static ULONG WINAPI
PHEventSink_Release(IDispatch
*iface
)
891 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
892 LONG ref
= InterlockedDecrement(&This
->ref
);
894 TRACE("(%p)\n", This
);
901 for(i
=0; i
< This
->handlers_cnt
; i
++) {
902 if(This
->handlers
[i
].disp
)
903 IDispatch_Release(This
->handlers
[i
].disp
);
905 heap_free(This
->handlers
);
912 static HRESULT WINAPI
PHEventSink_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
914 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
915 FIXME("(%p)->(%p)\n", This
, pctinfo
);
919 static HRESULT WINAPI
PHEventSink_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
920 LCID lcid
, ITypeInfo
**ppTInfo
)
922 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
923 FIXME("(%p)->(%d %d %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
927 static HRESULT WINAPI
PHEventSink_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
928 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
930 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
931 FIXME("(%p)->(%s %p %u %d %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
935 static HRESULT WINAPI
PHEventSink_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
936 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
938 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
943 TRACE("(%p)->(%d %s %d %x %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
), lcid
, wFlags
,
944 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
951 entry
= find_sink_entry(This
, dispIdMember
);
952 if(!entry
|| !entry
->disp
) {
953 WARN("No handler %d\n", dispIdMember
);
955 V_VT(pVarResult
) = VT_EMPTY
;
959 hres
= IDispatch_QueryInterface(entry
->disp
, &IID_IDispatchEx
, (void**)&dispex
);
961 TRACE("(%p) %d >>>\n", This
, entry
->id
);
962 if(SUCCEEDED(hres
)) {
963 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, NULL
);
964 IDispatchEx_Release(dispex
);
966 hres
= IDispatch_Invoke(entry
->disp
, DISPID_VALUE
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
969 TRACE("(%p) %d <<<\n", This
, entry
->id
);
971 WARN("(%p) %d <<< %08x\n", This
, entry
->id
, hres
);
975 static const IDispatchVtbl PHCPDispatchVtbl
= {
976 PHEventSink_QueryInterface
,
979 PHEventSink_GetTypeInfoCount
,
980 PHEventSink_GetTypeInfo
,
981 PHEventSink_GetIDsOfNames
,
985 static PHEventSink
*create_event_sink(PluginHost
*plugin_host
, ITypeInfo
*typeinfo
)
987 IConnectionPointContainer
*cp_container
;
989 IConnectionPoint
*cp
;
995 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &typeattr
);
999 typekind
= typeattr
->typekind
;
1000 guid
= typeattr
->guid
;
1001 ITypeInfo_ReleaseTypeAttr(typeinfo
, typeattr
);
1003 TRACE("guid %s typekind %d\n", debugstr_guid(&guid
), typekind
);
1005 if(typekind
!= TKIND_INTERFACE
&& typekind
!= TKIND_DISPATCH
) {
1006 WARN("invalid typekind %d\n", typekind
);
1010 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
1012 WARN("Could not get IConnectionPointContainer iface: %08x\n", hres
);
1016 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &guid
, &cp
);
1017 IConnectionPointContainer_Release(cp_container
);
1019 WARN("Could not find %s connection point\n", debugstr_guid(&guid
));
1023 ret
= heap_alloc_zero(sizeof(*ret
));
1025 ret
->IDispatch_iface
.lpVtbl
= &PHCPDispatchVtbl
;
1027 ret
->host
= plugin_host
;
1029 ret
->is_dispiface
= typekind
== TKIND_DISPATCH
;
1031 ITypeInfo_AddRef(typeinfo
);
1032 ret
->typeinfo
= typeinfo
;
1034 hres
= IConnectionPoint_Advise(cp
, (IUnknown
*)&ret
->IDispatch_iface
, &ret
->cookie
);
1036 hres
= E_OUTOFMEMORY
;
1039 IConnectionPoint_Release(cp
);
1041 WARN("Advise failed: %08x\n", hres
);
1048 static ITypeInfo
*get_eventiface_info(HTMLPluginContainer
*plugin_container
, ITypeInfo
*class_info
)
1050 int impl_types
, i
, impl_flags
;
1051 ITypeInfo
*ret
= NULL
;
1056 hres
= ITypeInfo_GetTypeAttr(class_info
, &typeattr
);
1060 if(typeattr
->typekind
!= TKIND_COCLASS
) {
1061 WARN("not coclass\n");
1062 ITypeInfo_ReleaseTypeAttr(class_info
, typeattr
);
1066 impl_types
= typeattr
->cImplTypes
;
1067 ITypeInfo_ReleaseTypeAttr(class_info
, typeattr
);
1069 for(i
=0; i
<impl_types
; i
++) {
1070 hres
= ITypeInfo_GetImplTypeFlags(class_info
, i
, &impl_flags
);
1074 if((impl_flags
& IMPLTYPEFLAG_FSOURCE
)) {
1075 if(!(impl_flags
& IMPLTYPEFLAG_FDEFAULT
)) {
1076 FIXME("Handle non-default source iface\n");
1080 hres
= ITypeInfo_GetRefTypeOfImplType(class_info
, i
, &ref
);
1084 hres
= ITypeInfo_GetRefTypeInfo(class_info
, ref
, &ret
);
1093 void bind_activex_event(HTMLDocumentNode
*doc
, HTMLPluginContainer
*plugin_container
, WCHAR
*event
, IDispatch
*disp
)
1095 PluginHost
*plugin_host
= plugin_container
->plugin_host
;
1096 ITypeInfo
*class_info
, *source_info
;
1100 TRACE("(%p %p %s %p)\n", doc
, plugin_host
, debugstr_w(event
), disp
);
1102 if(!plugin_host
|| !plugin_host
->plugin_unk
) {
1103 WARN("detached element %p\n", plugin_host
);
1107 if(plugin_host
->sink
) {
1108 source_info
= plugin_host
->sink
->typeinfo
;
1109 ITypeInfo_AddRef(source_info
);
1111 IProvideClassInfo
*provide_ci
;
1113 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IProvideClassInfo
, (void**)&provide_ci
);
1115 FIXME("No IProvideClassInfo, try GetTypeInfo?\n");
1119 hres
= IProvideClassInfo_GetClassInfo(provide_ci
, &class_info
);
1120 IProvideClassInfo_Release(provide_ci
);
1121 if(FAILED(hres
) || !class_info
) {
1122 WARN("GetClassInfo failed: %08x\n", hres
);
1126 source_info
= get_eventiface_info(plugin_container
, class_info
);
1127 ITypeInfo_Release(class_info
);
1132 hres
= ITypeInfo_GetIDsOfNames(source_info
, &event
, 1, &id
);
1134 WARN("Could not get disp id: %08x\n", hres
);
1135 else if(!plugin_host
->sink
)
1136 plugin_host
->sink
= create_event_sink(plugin_host
, source_info
);
1138 ITypeInfo_Release(source_info
);
1139 if(FAILED(hres
) || !plugin_host
->sink
)
1142 add_sink_handler(plugin_host
->sink
, id
, disp
);
1146 IOleInPlaceFrame IOleInPlaceFrame_iface
;
1150 static inline InPlaceFrame
*impl_from_IOleInPlaceFrame(IOleInPlaceFrame
*iface
)
1152 return CONTAINING_RECORD(iface
, InPlaceFrame
, IOleInPlaceFrame_iface
);
1155 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
,
1156 REFIID riid
, void **ppv
)
1158 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1160 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1162 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1163 *ppv
= &This
->IOleInPlaceFrame_iface
;
1164 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1165 *ppv
= &This
->IOleInPlaceFrame_iface
;
1166 }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow
, riid
)) {
1167 *ppv
= &This
->IOleInPlaceFrame_iface
;
1168 }else if(IsEqualGUID(&IID_IOleInPlaceFrame
, riid
)) {
1169 *ppv
= &This
->IOleInPlaceFrame_iface
;
1171 WARN("Unsopported interface %s\n", debugstr_mshtml_guid(riid
));
1173 return E_NOINTERFACE
;
1176 IUnknown_AddRef((IUnknown
*)*ppv
);
1180 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
1182 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1183 LONG ref
= InterlockedIncrement(&This
->ref
);
1185 TRACE("(%p) ref=%d\n", This
, ref
);
1190 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
1192 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1193 LONG ref
= InterlockedDecrement(&This
->ref
);
1195 TRACE("(%p) ref=%d\n", This
, ref
);
1203 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
1205 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1206 FIXME("(%p)->(%p)\n", This
, phwnd
);
1210 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
,
1213 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1214 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1218 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
1220 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1221 FIXME("(%p)->(%p)\n", This
, lprectBorder
);
1225 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
1226 LPCBORDERWIDTHS pborderwidths
)
1228 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1229 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1233 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
1234 LPCBORDERWIDTHS pborderwidths
)
1236 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1237 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1241 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
1242 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1244 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1245 FIXME("(%p)->(%p %s)\n", This
, pActiveObject
, debugstr_w(pszObjName
));
1249 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
1250 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
1252 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1253 FIXME("(%p)->(%p %p)\n", This
, hmenuShared
, lpMenuWidths
);
1257 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
1258 HOLEMENU holemenu
, HWND hwndActiveObject
)
1260 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1261 FIXME("(%p)->(%p %p %p)\n", This
, hmenuShared
, holemenu
, hwndActiveObject
);
1265 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
1267 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1268 FIXME("(%p)->(%p)\n", This
, hmenuShared
);
1272 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
,
1273 LPCOLESTR pszStatusText
)
1275 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1276 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszStatusText
));
1280 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
1282 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1283 FIXME("(%p)->(%x)\n", This
, fEnable
);
1287 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
,
1290 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1291 FIXME("(%p)->(%p %d)\n", This
, lpmsg
, wID
);
1295 static const IOleInPlaceFrameVtbl OleInPlaceFrameVtbl
= {
1296 InPlaceFrame_QueryInterface
,
1297 InPlaceFrame_AddRef
,
1298 InPlaceFrame_Release
,
1299 InPlaceFrame_GetWindow
,
1300 InPlaceFrame_ContextSensitiveHelp
,
1301 InPlaceFrame_GetBorder
,
1302 InPlaceFrame_RequestBorderSpace
,
1303 InPlaceFrame_SetBorderSpace
,
1304 InPlaceFrame_SetActiveObject
,
1305 InPlaceFrame_InsertMenus
,
1306 InPlaceFrame_SetMenu
,
1307 InPlaceFrame_RemoveMenus
,
1308 InPlaceFrame_SetStatusText
,
1309 InPlaceFrame_EnableModeless
,
1310 InPlaceFrame_TranslateAccelerator
1313 static HRESULT
create_ip_frame(IOleInPlaceFrame
**ret
)
1315 InPlaceFrame
*frame
;
1317 frame
= heap_alloc_zero(sizeof(*frame
));
1319 return E_OUTOFMEMORY
;
1321 frame
->IOleInPlaceFrame_iface
.lpVtbl
= &OleInPlaceFrameVtbl
;
1324 *ret
= &frame
->IOleInPlaceFrame_iface
;
1329 IOleInPlaceUIWindow IOleInPlaceUIWindow_iface
;
1333 static inline InPlaceUIWindow
*impl_from_IOleInPlaceUIWindow(IOleInPlaceUIWindow
*iface
)
1335 return CONTAINING_RECORD(iface
, InPlaceUIWindow
, IOleInPlaceUIWindow_iface
);
1338 static HRESULT WINAPI
InPlaceUIWindow_QueryInterface(IOleInPlaceUIWindow
*iface
, REFIID riid
, void **ppv
)
1340 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1342 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1344 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1345 *ppv
= &This
->IOleInPlaceUIWindow_iface
;
1346 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1347 *ppv
= &This
->IOleInPlaceUIWindow_iface
;
1348 }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow
, riid
)) {
1349 *ppv
= &This
->IOleInPlaceUIWindow_iface
;
1351 WARN("Unsopported interface %s\n", debugstr_mshtml_guid(riid
));
1353 return E_NOINTERFACE
;
1356 IUnknown_AddRef((IUnknown
*)*ppv
);
1360 static ULONG WINAPI
InPlaceUIWindow_AddRef(IOleInPlaceUIWindow
*iface
)
1362 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1363 LONG ref
= InterlockedIncrement(&This
->ref
);
1365 TRACE("(%p) ref=%d\n", This
, ref
);
1370 static ULONG WINAPI
InPlaceUIWindow_Release(IOleInPlaceUIWindow
*iface
)
1372 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1373 LONG ref
= InterlockedDecrement(&This
->ref
);
1375 TRACE("(%p) ref=%d\n", This
, ref
);
1383 static HRESULT WINAPI
InPlaceUIWindow_GetWindow(IOleInPlaceUIWindow
*iface
, HWND
*phwnd
)
1385 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1386 FIXME("(%p)->(%p)\n", This
, phwnd
);
1390 static HRESULT WINAPI
InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceUIWindow
*iface
,
1393 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1394 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1398 static HRESULT WINAPI
InPlaceUIWindow_GetBorder(IOleInPlaceUIWindow
*iface
, LPRECT lprectBorder
)
1400 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1401 FIXME("(%p)->(%p)\n", This
, lprectBorder
);
1405 static HRESULT WINAPI
InPlaceUIWindow_RequestBorderSpace(IOleInPlaceUIWindow
*iface
,
1406 LPCBORDERWIDTHS pborderwidths
)
1408 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1409 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1413 static HRESULT WINAPI
InPlaceUIWindow_SetBorderSpace(IOleInPlaceUIWindow
*iface
,
1414 LPCBORDERWIDTHS pborderwidths
)
1416 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1417 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1421 static HRESULT WINAPI
InPlaceUIWindow_SetActiveObject(IOleInPlaceUIWindow
*iface
,
1422 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1424 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1425 FIXME("(%p)->(%p %s)\n", This
, pActiveObject
, debugstr_w(pszObjName
));
1429 static const IOleInPlaceUIWindowVtbl OleInPlaceUIWindowVtbl
= {
1430 InPlaceUIWindow_QueryInterface
,
1431 InPlaceUIWindow_AddRef
,
1432 InPlaceUIWindow_Release
,
1433 InPlaceUIWindow_GetWindow
,
1434 InPlaceUIWindow_ContextSensitiveHelp
,
1435 InPlaceUIWindow_GetBorder
,
1436 InPlaceUIWindow_RequestBorderSpace
,
1437 InPlaceUIWindow_SetBorderSpace
,
1438 InPlaceUIWindow_SetActiveObject
,
1441 static HRESULT
create_ip_window(IOleInPlaceUIWindow
**ret
)
1443 InPlaceUIWindow
*uiwindow
;
1445 uiwindow
= heap_alloc_zero(sizeof(*uiwindow
));
1447 return E_OUTOFMEMORY
;
1449 uiwindow
->IOleInPlaceUIWindow_iface
.lpVtbl
= &OleInPlaceUIWindowVtbl
;
1452 *ret
= &uiwindow
->IOleInPlaceUIWindow_iface
;
1456 static inline PluginHost
*impl_from_IOleClientSite(IOleClientSite
*iface
)
1458 return CONTAINING_RECORD(iface
, PluginHost
, IOleClientSite_iface
);
1461 static HRESULT WINAPI
PHClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
1463 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1465 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1466 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1467 *ppv
= &This
->IOleClientSite_iface
;
1468 }else if(IsEqualGUID(&IID_IOleClientSite
, riid
)) {
1469 TRACE("(%p)->(IID_IOleClientSite %p)\n", This
, ppv
);
1470 *ppv
= &This
->IOleClientSite_iface
;
1471 }else if(IsEqualGUID(&IID_IAdviseSink
, riid
)) {
1472 TRACE("(%p)->(IID_IAdviseSink %p)\n", This
, ppv
);
1473 *ppv
= &This
->IAdviseSinkEx_iface
;
1474 }else if(IsEqualGUID(&IID_IAdviseSinkEx
, riid
)) {
1475 TRACE("(%p)->(IID_IAdviseSinkEx %p)\n", This
, ppv
);
1476 *ppv
= &This
->IAdviseSinkEx_iface
;
1477 }else if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
1478 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This
, ppv
);
1479 *ppv
= &This
->IPropertyNotifySink_iface
;
1480 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1481 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1482 *ppv
= &This
->IDispatch_iface
;
1483 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1484 TRACE("(%p)->(IID_IOleWindow %p)\n", This
, ppv
);
1485 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
1486 }else if(IsEqualGUID(&IID_IOleInPlaceSite
, riid
)) {
1487 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This
, ppv
);
1488 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
1489 }else if(IsEqualGUID(&IID_IOleInPlaceSiteEx
, riid
)) {
1490 TRACE("(%p)->(IID_IOleInPlaceSiteEx %p)\n", This
, ppv
);
1491 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
1492 }else if(IsEqualGUID(&IID_IOleControlSite
, riid
)) {
1493 TRACE("(%p)->(IID_IOleControlSite %p)\n", This
, ppv
);
1494 *ppv
= &This
->IOleControlSite_iface
;
1495 }else if(IsEqualGUID(&IID_IBindHost
, riid
)) {
1496 TRACE("(%p)->(IID_IBindHost %p)\n", This
, ppv
);
1497 *ppv
= &This
->IBindHost_iface
;
1498 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
1499 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
1500 *ppv
= &This
->IServiceProvider_iface
;
1502 WARN("Unsupported interface %s\n", debugstr_guid(riid
));
1504 return E_NOINTERFACE
;
1507 IUnknown_AddRef((IUnknown
*)*ppv
);
1511 static ULONG WINAPI
PHClientSite_AddRef(IOleClientSite
*iface
)
1513 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1514 LONG ref
= InterlockedIncrement(&This
->ref
);
1516 TRACE("(%p) ref=%d\n", This
, ref
);
1521 static void release_plugin_ifaces(PluginHost
*This
)
1524 IDispatch_Release(This
->disp
);
1528 if(This
->ip_object
) {
1529 IOleInPlaceObject_Release(This
->ip_object
);
1530 This
->ip_object
= NULL
;
1533 if(This
->plugin_unk
) {
1534 IUnknown
*unk
= This
->plugin_unk
;
1537 This
->plugin_unk
= NULL
;
1538 ref
= IUnknown_Release(unk
);
1540 TRACE("plugin ref = %d\n", ref
);
1544 static ULONG WINAPI
PHClientSite_Release(IOleClientSite
*iface
)
1546 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1547 LONG ref
= InterlockedDecrement(&This
->ref
);
1549 TRACE("(%p) ref=%d\n", This
, ref
);
1552 release_plugin_ifaces(This
);
1554 This
->sink
->host
= NULL
;
1555 IDispatch_Release(&This
->sink
->IDispatch_iface
);
1558 list_remove(&This
->entry
);
1560 This
->element
->plugin_host
= NULL
;
1567 static HRESULT WINAPI
PHClientSite_SaveObject(IOleClientSite
*iface
)
1569 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1570 FIXME("(%p)\n", This
);
1574 static HRESULT WINAPI
PHClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
,
1575 DWORD dwWhichMoniker
, IMoniker
**ppmk
)
1577 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1579 TRACE("(%p)->(%d %d %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
1581 switch(dwWhichMoniker
) {
1582 case OLEWHICHMK_CONTAINER
:
1583 if(!This
->doc
|| !This
->doc
->window
|| !This
->doc
->window
->mon
) {
1584 FIXME("no moniker\n");
1585 return E_UNEXPECTED
;
1588 *ppmk
= This
->doc
->window
->mon
;
1589 IMoniker_AddRef(*ppmk
);
1592 FIXME("which %d\n", dwWhichMoniker
);
1599 static HRESULT WINAPI
PHClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
1601 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1603 TRACE("(%p)->(%p)\n", This
, ppContainer
);
1606 ERR("Called on detached object\n");
1607 return E_UNEXPECTED
;
1610 *ppContainer
= &This
->doc
->basedoc
.IOleContainer_iface
;
1611 IOleContainer_AddRef(*ppContainer
);
1615 static HRESULT WINAPI
PHClientSite_ShowObject(IOleClientSite
*iface
)
1617 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1619 TRACE("(%p)\n", This
);
1624 static HRESULT WINAPI
PHClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
1626 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1627 FIXME("(%p)->(%x)\n", This
, fShow
);
1631 static HRESULT WINAPI
PHClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
1633 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1634 FIXME("(%p)\n", This
);
1638 static const IOleClientSiteVtbl OleClientSiteVtbl
= {
1639 PHClientSite_QueryInterface
,
1640 PHClientSite_AddRef
,
1641 PHClientSite_Release
,
1642 PHClientSite_SaveObject
,
1643 PHClientSite_GetMoniker
,
1644 PHClientSite_GetContainer
,
1645 PHClientSite_ShowObject
,
1646 PHClientSite_OnShowWindow
,
1647 PHClientSite_RequestNewObjectLayout
1650 static inline PluginHost
*impl_from_IAdviseSinkEx(IAdviseSinkEx
*iface
)
1652 return CONTAINING_RECORD(iface
, PluginHost
, IAdviseSinkEx_iface
);
1655 static HRESULT WINAPI
PHAdviseSinkEx_QueryInterface(IAdviseSinkEx
*iface
, REFIID riid
, void **ppv
)
1657 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1658 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1661 static ULONG WINAPI
PHAdviseSinkEx_AddRef(IAdviseSinkEx
*iface
)
1663 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1664 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1667 static ULONG WINAPI
PHAdviseSinkEx_Release(IAdviseSinkEx
*iface
)
1669 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1670 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1673 static void WINAPI
PHAdviseSinkEx_OnDataChange(IAdviseSinkEx
*iface
, FORMATETC
*pFormatetc
, STGMEDIUM
*pStgMedium
)
1675 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1676 FIXME("(%p)->(%p %p)\n", This
, pFormatetc
, pStgMedium
);
1679 static void WINAPI
PHAdviseSinkEx_OnViewChange(IAdviseSinkEx
*iface
, DWORD dwAspect
, LONG lindex
)
1681 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1682 FIXME("(%p)->(%d %d)\n", This
, dwAspect
, lindex
);
1685 static void WINAPI
PHAdviseSinkEx_OnRename(IAdviseSinkEx
*iface
, IMoniker
*pmk
)
1687 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1688 FIXME("(%p)->(%p)\n", This
, pmk
);
1691 static void WINAPI
PHAdviseSinkEx_OnSave(IAdviseSinkEx
*iface
)
1693 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1694 FIXME("(%p)\n", This
);
1697 static void WINAPI
PHAdviseSinkEx_OnClose(IAdviseSinkEx
*iface
)
1699 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1700 FIXME("(%p)\n", This
);
1703 static void WINAPI
PHAdviseSinkEx_OnViewStatusChange(IAdviseSinkEx
*iface
, DWORD dwViewStatus
)
1705 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1706 FIXME("(%p)->(%d)\n", This
, dwViewStatus
);
1709 static const IAdviseSinkExVtbl AdviseSinkExVtbl
= {
1710 PHAdviseSinkEx_QueryInterface
,
1711 PHAdviseSinkEx_AddRef
,
1712 PHAdviseSinkEx_Release
,
1713 PHAdviseSinkEx_OnDataChange
,
1714 PHAdviseSinkEx_OnViewChange
,
1715 PHAdviseSinkEx_OnRename
,
1716 PHAdviseSinkEx_OnSave
,
1717 PHAdviseSinkEx_OnClose
,
1718 PHAdviseSinkEx_OnViewStatusChange
1721 static inline PluginHost
*impl_from_IPropertyNotifySink(IPropertyNotifySink
*iface
)
1723 return CONTAINING_RECORD(iface
, PluginHost
, IPropertyNotifySink_iface
);
1726 static HRESULT WINAPI
PHPropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
, REFIID riid
, void **ppv
)
1728 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1729 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1732 static ULONG WINAPI
PHPropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
1734 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1735 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1738 static ULONG WINAPI
PHPropertyNotifySink_Release(IPropertyNotifySink
*iface
)
1740 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1741 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1744 static HRESULT WINAPI
PHPropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
1746 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1748 TRACE("(%p)->(%d)\n", This
, dispID
);
1751 case DISPID_READYSTATE
:
1752 update_readystate(This
);
1755 FIXME("Unimplemented dispID %d\n", dispID
);
1762 static HRESULT WINAPI
PHPropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1764 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1765 FIXME("(%p)->(%d)\n", This
, dispID
);
1769 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1770 PHPropertyNotifySink_QueryInterface
,
1771 PHPropertyNotifySink_AddRef
,
1772 PHPropertyNotifySink_Release
,
1773 PHPropertyNotifySink_OnChanged
,
1774 PHPropertyNotifySink_OnRequestEdit
1777 static inline PluginHost
*impl_from_IDispatch(IDispatch
*iface
)
1779 return CONTAINING_RECORD(iface
, PluginHost
, IDispatch_iface
);
1782 static HRESULT WINAPI
PHDispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
1784 PluginHost
*This
= impl_from_IDispatch(iface
);
1785 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1788 static ULONG WINAPI
PHDispatch_AddRef(IDispatch
*iface
)
1790 PluginHost
*This
= impl_from_IDispatch(iface
);
1791 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1794 static ULONG WINAPI
PHDispatch_Release(IDispatch
*iface
)
1796 PluginHost
*This
= impl_from_IDispatch(iface
);
1797 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1800 static HRESULT WINAPI
PHDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1802 PluginHost
*This
= impl_from_IDispatch(iface
);
1803 FIXME("(%p)->(%p)\n", This
, pctinfo
);
1807 static HRESULT WINAPI
PHDispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1808 LCID lcid
, ITypeInfo
**ppTInfo
)
1810 PluginHost
*This
= impl_from_IDispatch(iface
);
1811 FIXME("(%p)->(%d %d %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1815 static HRESULT WINAPI
PHDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1816 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1818 PluginHost
*This
= impl_from_IDispatch(iface
);
1819 FIXME("(%p)->(%s %p %d %d %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
1823 static HRESULT WINAPI
PHDispatch_Invoke(IDispatch
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
,
1824 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1826 PluginHost
*This
= impl_from_IDispatch(iface
);
1827 FIXME("(%p)->(%d %x %p %p)\n", This
, dispid
, wFlags
, pDispParams
, pVarResult
);
1831 static const IDispatchVtbl DispatchVtbl
= {
1832 PHDispatch_QueryInterface
,
1835 PHDispatch_GetTypeInfoCount
,
1836 PHDispatch_GetTypeInfo
,
1837 PHDispatch_GetIDsOfNames
,
1841 static inline PluginHost
*impl_from_IOleInPlaceSiteEx(IOleInPlaceSiteEx
*iface
)
1843 return CONTAINING_RECORD(iface
, PluginHost
, IOleInPlaceSiteEx_iface
);
1846 static HRESULT WINAPI
PHInPlaceSite_QueryInterface(IOleInPlaceSiteEx
*iface
, REFIID riid
, void **ppv
)
1848 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1849 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1852 static ULONG WINAPI
PHInPlaceSite_AddRef(IOleInPlaceSiteEx
*iface
)
1854 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1855 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1858 static ULONG WINAPI
PHInPlaceSite_Release(IOleInPlaceSiteEx
*iface
)
1860 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1861 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1864 static HRESULT WINAPI
PHInPlaceSite_GetWindow(IOleInPlaceSiteEx
*iface
, HWND
*phwnd
)
1866 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1868 TRACE("(%p)->(%p)\n", This
, phwnd
);
1870 *phwnd
= This
->hwnd
;
1874 static HRESULT WINAPI
PHInPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx
*iface
, BOOL fEnterMode
)
1876 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1877 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1881 static HRESULT WINAPI
PHInPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx
*iface
)
1883 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1885 TRACE("(%p)\n", This
);
1890 static HRESULT WINAPI
PHInPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx
*iface
)
1892 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1893 FIXME("(%p)\n", This
);
1897 static HRESULT WINAPI
PHInPlaceSite_OnUIActivate(IOleInPlaceSiteEx
*iface
)
1899 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1901 TRACE("(%p)\n", This
);
1903 if(!This
->plugin_unk
) {
1904 ERR("No plugin object\n");
1905 return E_UNEXPECTED
;
1908 This
->ui_active
= TRUE
;
1910 notif_enabled(This
);
1914 static HRESULT WINAPI
PHInPlaceSite_GetWindowContext(IOleInPlaceSiteEx
*iface
,
1915 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, RECT
*lprcPosRect
,
1916 RECT
*lprcClipRect
, OLEINPLACEFRAMEINFO
*frame_info
)
1918 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1919 IOleInPlaceUIWindow
*ip_window
;
1920 IOleInPlaceFrame
*ip_frame
;
1924 TRACE("(%p)->(%p %p %p %p %p)\n", This
, ppFrame
, ppDoc
, lprcPosRect
, lprcClipRect
, frame_info
);
1926 if(!This
->doc
|| !This
->doc
->basedoc
.doc_obj
|| !This
->doc
->basedoc
.doc_obj
->ipsite
) {
1927 FIXME("No ipsite\n");
1928 return E_UNEXPECTED
;
1931 hres
= IOleInPlaceSite_GetWindowContext(This
->doc
->basedoc
.doc_obj
->ipsite
, &ip_frame
, &ip_window
, &pr
, &cr
, frame_info
);
1933 WARN("GetWindowContext failed: %08x\n", hres
);
1938 IOleInPlaceUIWindow_Release(ip_window
);
1940 IOleInPlaceFrame_Release(ip_frame
);
1942 hres
= create_ip_frame(&ip_frame
);
1946 hres
= create_ip_window(ppDoc
);
1948 IOleInPlaceFrame_Release(ip_frame
);
1952 *ppFrame
= ip_frame
;
1953 *lprcPosRect
= This
->rect
;
1954 *lprcClipRect
= This
->rect
;
1958 static HRESULT WINAPI
PHInPlaceSite_Scroll(IOleInPlaceSiteEx
*iface
, SIZE scrollExtent
)
1960 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1961 FIXME("(%p)->({%d %d})\n", This
, scrollExtent
.cx
, scrollExtent
.cy
);
1965 static HRESULT WINAPI
PHInPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx
*iface
, BOOL fUndoable
)
1967 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1968 FIXME("(%p)->(%x)\n", This
, fUndoable
);
1972 static HRESULT WINAPI
PHInPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx
*iface
)
1974 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1976 TRACE("(%p)\n", This
);
1978 if(This
->ip_object
) {
1979 IOleInPlaceObject_Release(This
->ip_object
);
1980 This
->ip_object
= NULL
;
1986 static HRESULT WINAPI
PHInPlaceSite_DiscardUndoState(IOleInPlaceSiteEx
*iface
)
1988 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1989 FIXME("(%p)\n", This
);
1993 static HRESULT WINAPI
PHInPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx
*iface
)
1995 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1996 FIXME("(%p)\n", This
);
2000 static HRESULT WINAPI
PHInPlaceSite_OnPosRectChange(IOleInPlaceSiteEx
*iface
, LPCRECT lprcPosRect
)
2002 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
2003 FIXME("(%p)->(%p)\n", This
, lprcPosRect
);
2007 static HRESULT WINAPI
PHInPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx
*iface
, BOOL
*pfNoRedraw
, DWORD dwFlags
)
2009 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
2013 TRACE("(%p)->(%p %x)\n", This
, pfNoRedraw
, dwFlags
);
2018 hres
= IUnknown_QueryInterface(This
->plugin_unk
, &IID_IOleInPlaceObject
, (void**)&This
->ip_object
);
2022 hres
= IOleInPlaceObject_GetWindow(This
->ip_object
, &hwnd
);
2024 FIXME("Use hwnd %p\n", hwnd
);
2026 *pfNoRedraw
= FALSE
;
2030 static HRESULT WINAPI
PHInPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx
*iface
, BOOL fNoRedraw
)
2032 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
2033 FIXME("(%p)->(%x)\n", This
, fNoRedraw
);
2037 static HRESULT WINAPI
PHInPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx
*iface
)
2039 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
2040 FIXME("(%p)\n", This
);
2044 static const IOleInPlaceSiteExVtbl OleInPlaceSiteExVtbl
= {
2045 PHInPlaceSite_QueryInterface
,
2046 PHInPlaceSite_AddRef
,
2047 PHInPlaceSite_Release
,
2048 PHInPlaceSite_GetWindow
,
2049 PHInPlaceSite_ContextSensitiveHelp
,
2050 PHInPlaceSite_CanInPlaceActivate
,
2051 PHInPlaceSite_OnInPlaceActivate
,
2052 PHInPlaceSite_OnUIActivate
,
2053 PHInPlaceSite_GetWindowContext
,
2054 PHInPlaceSite_Scroll
,
2055 PHInPlaceSite_OnUIDeactivate
,
2056 PHInPlaceSite_OnInPlaceDeactivate
,
2057 PHInPlaceSite_DiscardUndoState
,
2058 PHInPlaceSite_DeactivateAndUndo
,
2059 PHInPlaceSite_OnPosRectChange
,
2060 PHInPlaceSiteEx_OnInPlaceActivateEx
,
2061 PHInPlaceSiteEx_OnInPlaceDeactivateEx
,
2062 PHInPlaceSiteEx_RequestUIActivate
2065 static inline PluginHost
*impl_from_IOleControlSite(IOleControlSite
*iface
)
2067 return CONTAINING_RECORD(iface
, PluginHost
, IOleControlSite_iface
);
2070 static HRESULT WINAPI
PHControlSite_QueryInterface(IOleControlSite
*iface
, REFIID riid
, void **ppv
)
2072 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2073 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2076 static ULONG WINAPI
PHControlSite_AddRef(IOleControlSite
*iface
)
2078 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2079 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
2082 static ULONG WINAPI
PHControlSite_Release(IOleControlSite
*iface
)
2084 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2085 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
2088 static HRESULT WINAPI
PHControlSite_OnControlInfoChanged(IOleControlSite
*iface
)
2090 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2091 FIXME("(%p)\n", This
);
2095 static HRESULT WINAPI
PHControlSite_LockInPlaceActive(IOleControlSite
*iface
, BOOL fLock
)
2097 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2098 FIXME("(%p)->(%x)\n", This
, fLock
);
2102 static HRESULT WINAPI
PHControlSite_GetExtendedControl(IOleControlSite
*iface
, IDispatch
**ppDisp
)
2104 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2105 FIXME("(%p)->(%p)\n", This
, ppDisp
);
2109 static HRESULT WINAPI
PHControlSite_TransformCoords(IOleControlSite
*iface
, POINTL
*pPtlHimetric
, POINTF
*pPtfContainer
, DWORD dwFlags
)
2111 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2112 FIXME("(%p)->(%p %p %x)\n", This
, pPtlHimetric
, pPtfContainer
, dwFlags
);
2116 static HRESULT WINAPI
PHControlSite_TranslateAccelerator(IOleControlSite
*iface
, MSG
*pMsg
, DWORD grfModifiers
)
2118 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2119 FIXME("(%p)->(%x)\n", This
, grfModifiers
);
2123 static HRESULT WINAPI
PHControlSite_OnFocus(IOleControlSite
*iface
, BOOL fGotFocus
)
2125 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2126 FIXME("(%p)->(%x)\n", This
, fGotFocus
);
2130 static HRESULT WINAPI
PHControlSite_ShowPropertyFrame(IOleControlSite
*iface
)
2132 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2133 FIXME("(%p)\n", This
);
2137 static const IOleControlSiteVtbl OleControlSiteVtbl
= {
2138 PHControlSite_QueryInterface
,
2139 PHControlSite_AddRef
,
2140 PHControlSite_Release
,
2141 PHControlSite_OnControlInfoChanged
,
2142 PHControlSite_LockInPlaceActive
,
2143 PHControlSite_GetExtendedControl
,
2144 PHControlSite_TransformCoords
,
2145 PHControlSite_TranslateAccelerator
,
2146 PHControlSite_OnFocus
,
2147 PHControlSite_ShowPropertyFrame
2150 static inline PluginHost
*impl_from_IBindHost(IBindHost
*iface
)
2152 return CONTAINING_RECORD(iface
, PluginHost
, IBindHost_iface
);
2155 static HRESULT WINAPI
PHBindHost_QueryInterface(IBindHost
*iface
, REFIID riid
, void **ppv
)
2157 PluginHost
*This
= impl_from_IBindHost(iface
);
2158 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2161 static ULONG WINAPI
PHBindHost_AddRef(IBindHost
*iface
)
2163 PluginHost
*This
= impl_from_IBindHost(iface
);
2164 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
2167 static ULONG WINAPI
PHBindHost_Release(IBindHost
*iface
)
2169 PluginHost
*This
= impl_from_IBindHost(iface
);
2170 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
2173 static HRESULT WINAPI
PHBindHost_CreateMoniker(IBindHost
*iface
, LPOLESTR szName
, IBindCtx
*pBC
, IMoniker
**ppmk
, DWORD dwReserved
)
2175 PluginHost
*This
= impl_from_IBindHost(iface
);
2177 TRACE("(%p)->(%s %p %p %x)\n", This
, debugstr_w(szName
), pBC
, ppmk
, dwReserved
);
2179 if(!This
->doc
|| !This
->doc
->window
|| !This
->doc
->window
->mon
) {
2180 FIXME("no moniker\n");
2181 return E_UNEXPECTED
;
2184 return CreateURLMoniker(This
->doc
->window
->mon
, szName
, ppmk
);
2187 static HRESULT WINAPI
PHBindHost_MonikerBindToStorage(IBindHost
*iface
, IMoniker
*pMk
, IBindCtx
*pBC
,
2188 IBindStatusCallback
*pBSC
, REFIID riid
, void **ppvObj
)
2190 PluginHost
*This
= impl_from_IBindHost(iface
);
2191 FIXME("(%p)->(%p %p %p %s %p)\n", This
, pMk
, pBC
, pBSC
, debugstr_guid(riid
), ppvObj
);
2195 static HRESULT WINAPI
PHBindHost_MonikerBindToObject(IBindHost
*iface
, IMoniker
*pMk
, IBindCtx
*pBC
,
2196 IBindStatusCallback
*pBSC
, REFIID riid
, void **ppvObj
)
2198 PluginHost
*This
= impl_from_IBindHost(iface
);
2199 FIXME("(%p)->(%p %p %p %s %p)\n", This
, pMk
, pBC
, pBSC
, debugstr_guid(riid
), ppvObj
);
2203 static const IBindHostVtbl BindHostVtbl
= {
2204 PHBindHost_QueryInterface
,
2207 PHBindHost_CreateMoniker
,
2208 PHBindHost_MonikerBindToStorage
,
2209 PHBindHost_MonikerBindToObject
2212 static inline PluginHost
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2214 return CONTAINING_RECORD(iface
, PluginHost
, IServiceProvider_iface
);
2217 static HRESULT WINAPI
PHServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2219 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2220 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2223 static ULONG WINAPI
PHServiceProvider_AddRef(IServiceProvider
*iface
)
2225 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2226 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
2229 static ULONG WINAPI
PHServiceProvider_Release(IServiceProvider
*iface
)
2231 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2232 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
2235 static HRESULT WINAPI
PHServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2237 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2239 if(IsEqualGUID(guidService
, &SID_SBindHost
)) {
2240 TRACE("SID_SBindHost service\n");
2241 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2244 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
2246 if(!This
->doc
|| !This
->doc
->basedoc
.window
) {
2248 return E_NOINTERFACE
;
2251 return IServiceProvider_QueryService(&This
->doc
->basedoc
.window
->base
.IServiceProvider_iface
,
2252 guidService
, riid
, ppv
);
2255 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2256 PHServiceProvider_QueryInterface
,
2257 PHServiceProvider_AddRef
,
2258 PHServiceProvider_Release
,
2259 PHServiceProvider_QueryService
2262 static BOOL
parse_classid(const PRUnichar
*classid
, CLSID
*clsid
)
2268 static const PRUnichar clsidW
[] = {'c','l','s','i','d',':'};
2270 if(wcsnicmp(classid
, clsidW
, ARRAY_SIZE(clsidW
)))
2273 ptr
= classid
+ ARRAY_SIZE(clsidW
);
2274 len
= lstrlenW(ptr
);
2277 hres
= CLSIDFromString(ptr
, clsid
);
2278 }else if(len
== 36) {
2282 memcpy(buf
+1, ptr
, len
*sizeof(WCHAR
));
2285 hres
= CLSIDFromString(buf
, clsid
);
2290 return SUCCEEDED(hres
);
2293 static BOOL
get_elem_clsid(nsIDOMElement
*elem
, CLSID
*clsid
)
2295 const PRUnichar
*val
;
2300 static const PRUnichar classidW
[] = {'c','l','a','s','s','i','d',0};
2302 nsres
= get_elem_attr_value(elem
, classidW
, &val_str
, &val
);
2303 if(NS_SUCCEEDED(nsres
)) {
2305 ret
= parse_classid(val
, clsid
);
2306 nsAString_Finish(&val_str
);
2313 IBindStatusCallback IBindStatusCallback_iface
;
2314 IWindowForBindingUI IWindowForBindingUI_iface
;
2318 static inline InstallCallback
*impl_from_IBindStatusCallback(IBindStatusCallback
*iface
)
2320 return CONTAINING_RECORD(iface
, InstallCallback
, IBindStatusCallback_iface
);
2323 static HRESULT WINAPI
InstallCallback_QueryInterface(IBindStatusCallback
*iface
,
2324 REFIID riid
, void **ppv
)
2326 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2328 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2329 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
2330 *ppv
= &This
->IBindStatusCallback_iface
;
2331 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
2332 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
2333 *ppv
= &This
->IBindStatusCallback_iface
;
2334 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
2335 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
2336 *ppv
= &This
->IWindowForBindingUI_iface
;
2338 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
2340 return E_NOINTERFACE
;
2343 IUnknown_AddRef((IUnknown
*)*ppv
);
2347 static ULONG WINAPI
InstallCallback_AddRef(IBindStatusCallback
*iface
)
2349 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2350 LONG ref
= InterlockedIncrement(&This
->ref
);
2352 TRACE("(%p) ref=%d\n", This
, ref
);
2357 static ULONG WINAPI
InstallCallback_Release(IBindStatusCallback
*iface
)
2359 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2360 LONG ref
= InterlockedIncrement(&This
->ref
);
2362 TRACE("(%p) ref=%d\n", This
, ref
);
2370 static HRESULT WINAPI
InstallCallback_OnStartBinding(IBindStatusCallback
*iface
,
2371 DWORD dwReserved
, IBinding
*pib
)
2373 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2374 TRACE("(%p)->(%x %p)\n", This
, dwReserved
, pib
);
2378 static HRESULT WINAPI
InstallCallback_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
2380 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2381 TRACE("(%p)->(%p)\n", This
, pnPriority
);
2385 static HRESULT WINAPI
InstallCallback_OnLowResource(IBindStatusCallback
*iface
, DWORD dwReserved
)
2387 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2388 TRACE("(%p)->(%x)\n", This
, dwReserved
);
2392 static HRESULT WINAPI
InstallCallback_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
2393 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
2395 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2396 TRACE("(%p)->(%u %u %u %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
, debugstr_w(szStatusText
));
2400 static HRESULT WINAPI
InstallCallback_OnStopBinding(IBindStatusCallback
*iface
,
2401 HRESULT hresult
, LPCWSTR szError
)
2403 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2404 TRACE("(%p)->(%08x %s)\n", This
, hresult
, debugstr_w(szError
));
2408 static HRESULT WINAPI
InstallCallback_GetBindInfo(IBindStatusCallback
*iface
,
2409 DWORD
* grfBINDF
, BINDINFO
* pbindinfo
)
2411 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2413 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
2415 *grfBINDF
= BINDF_ASYNCHRONOUS
;
2419 static HRESULT WINAPI
InstallCallback_OnDataAvailable(IBindStatusCallback
*iface
, DWORD grfBSCF
,
2420 DWORD dwSize
, FORMATETC
* pformatetc
, STGMEDIUM
* pstgmed
)
2422 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2423 ERR("(%p)\n", This
);
2427 static HRESULT WINAPI
InstallCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
2428 REFIID riid
, IUnknown
* punk
)
2430 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2431 ERR("(%p)\n", This
);
2435 static IBindStatusCallbackVtbl InstallCallbackVtbl
= {
2436 InstallCallback_QueryInterface
,
2437 InstallCallback_AddRef
,
2438 InstallCallback_Release
,
2439 InstallCallback_OnStartBinding
,
2440 InstallCallback_GetPriority
,
2441 InstallCallback_OnLowResource
,
2442 InstallCallback_OnProgress
,
2443 InstallCallback_OnStopBinding
,
2444 InstallCallback_GetBindInfo
,
2445 InstallCallback_OnDataAvailable
,
2446 InstallCallback_OnObjectAvailable
2449 static inline InstallCallback
*impl_from_IWindowForBindingUI(IWindowForBindingUI
*iface
)
2451 return CONTAINING_RECORD(iface
, InstallCallback
, IWindowForBindingUI_iface
);
2454 static HRESULT WINAPI
WindowForBindingUI_QueryInterface(IWindowForBindingUI
*iface
, REFIID riid
, void **ppv
)
2456 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2457 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
2460 static ULONG WINAPI
WindowForBindingUI_AddRef(IWindowForBindingUI
*iface
)
2462 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2463 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
2466 static ULONG WINAPI
WindowForBindingUI_Release(IWindowForBindingUI
*iface
)
2468 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2469 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
2472 static HRESULT WINAPI
WindowForBindingUI_GetWindow(IWindowForBindingUI
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
2474 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2475 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
2480 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl
= {
2481 WindowForBindingUI_QueryInterface
,
2482 WindowForBindingUI_AddRef
,
2483 WindowForBindingUI_Release
,
2484 WindowForBindingUI_GetWindow
2492 static struct list install_list
= LIST_INIT(install_list
);
2494 static CRITICAL_SECTION cs_install_list
;
2495 static CRITICAL_SECTION_DEBUG cs_install_list_dbg
=
2497 0, 0, &cs_install_list
,
2498 { &cs_install_list_dbg
.ProcessLocksList
, &cs_install_list_dbg
.ProcessLocksList
},
2499 0, 0, { (DWORD_PTR
)(__FILE__
": install_list") }
2501 static CRITICAL_SECTION cs_install_list
= { &cs_install_list_dbg
, -1, 0, 0, 0, 0 };
2503 static void install_codebase(const WCHAR
*url
)
2505 InstallCallback
*callback
;
2509 callback
= heap_alloc(sizeof(*callback
));
2513 callback
->IBindStatusCallback_iface
.lpVtbl
= &InstallCallbackVtbl
;
2514 callback
->IWindowForBindingUI_iface
.lpVtbl
= &WindowForBindingUIVtbl
;
2517 hres
= CreateAsyncBindCtx(0, &callback
->IBindStatusCallback_iface
, NULL
, &bctx
);
2518 IBindStatusCallback_Release(&callback
->IBindStatusCallback_iface
);
2522 hres
= AsyncInstallDistributionUnit(NULL
, NULL
, NULL
, 0, 0, url
, bctx
, NULL
, 0);
2523 IBindCtx_Release(bctx
);
2525 WARN("FAILED: %08x\n", hres
);
2528 static void check_codebase(HTMLInnerWindow
*window
, nsIDOMElement
*nselem
)
2530 BOOL is_on_list
= FALSE
;
2531 install_entry_t
*iter
;
2532 const PRUnichar
*val
;
2538 static const PRUnichar codebaseW
[] = {'c','o','d','e','b','a','s','e',0};
2540 nsres
= get_elem_attr_value(nselem
, codebaseW
, &val_str
, &val
);
2541 if(NS_SUCCEEDED(nsres
)) {
2543 hres
= CoInternetCombineUrlEx(window
->base
.outer_window
->uri
, val
, 0, &uri
, 0);
2547 nsAString_Finish(&val_str
);
2553 EnterCriticalSection(&cs_install_list
);
2555 LIST_FOR_EACH_ENTRY(iter
, &install_list
, install_entry_t
, entry
) {
2558 hres
= IUri_IsEqual(uri
, iter
->uri
, &eq
);
2559 if(SUCCEEDED(hres
) && eq
) {
2560 TRACE("already proceeded\n");
2567 iter
= heap_alloc(sizeof(*iter
));
2572 list_add_tail(&install_list
, &iter
->entry
);
2576 LeaveCriticalSection(&cs_install_list
);
2581 hres
= IUri_GetDisplayUri(uri
, &display_uri
);
2582 if(SUCCEEDED(hres
)) {
2583 install_codebase(display_uri
);
2584 SysFreeString(display_uri
);
2591 static IUnknown
*create_activex_object(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, CLSID
*clsid
)
2593 IClassFactoryEx
*cfex
;
2599 if(!get_elem_clsid(nselem
, clsid
)) {
2600 WARN("Could not determine element CLSID\n");
2604 TRACE("clsid %s\n", debugstr_guid(clsid
));
2607 hres
= IInternetHostSecurityManager_ProcessUrlAction(&doc
->IInternetHostSecurityManager_iface
,
2608 URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
, sizeof(policy
), (BYTE
*)clsid
, sizeof(GUID
), 0, 0);
2609 if(FAILED(hres
) || policy
!= URLPOLICY_ALLOW
) {
2610 WARN("ProcessUrlAction returned %08x %x\n", hres
, policy
);
2614 hres
= CoGetClassObject(clsid
, CLSCTX_INPROC_SERVER
|CLSCTX_LOCAL_SERVER
, NULL
, &IID_IClassFactory
, (void**)&cf
);
2615 if(hres
== REGDB_E_CLASSNOTREG
)
2616 check_codebase(doc
->window
, nselem
);
2620 hres
= IClassFactory_QueryInterface(cf
, &IID_IClassFactoryEx
, (void**)&cfex
);
2621 if(SUCCEEDED(hres
)) {
2622 FIXME("Use IClassFactoryEx\n");
2623 IClassFactoryEx_Release(cfex
);
2626 hres
= IClassFactory_CreateInstance(cf
, NULL
, &IID_IUnknown
, (void**)&obj
);
2627 IClassFactory_Release(cf
);
2634 void detach_plugin_host(PluginHost
*host
)
2638 TRACE("%p\n", host
);
2643 if(host
->ip_object
) {
2645 IOleInPlaceObject_UIDeactivate(host
->ip_object
);
2646 IOleInPlaceObject_InPlaceDeactivate(host
->ip_object
);
2649 if(host
->plugin_unk
) {
2650 IOleObject
*ole_obj
;
2652 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
2653 if(SUCCEEDED(hres
)) {
2654 if(!host
->ip_object
)
2655 IOleObject_Close(ole_obj
, OLECLOSE_NOSAVE
);
2656 IOleObject_SetClientSite(ole_obj
, NULL
);
2657 IOleObject_Release(ole_obj
);
2662 IConnectionPointContainer
*cp_container
;
2663 IConnectionPoint
*cp
;
2665 assert(host
->plugin_unk
!= NULL
);
2667 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
2668 if(SUCCEEDED(hres
)) {
2669 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &host
->sink
->iid
, &cp
);
2670 IConnectionPointContainer_Release(cp_container
);
2671 if(SUCCEEDED(hres
)) {
2672 IConnectionPoint_Unadvise(cp
, host
->sink
->cookie
);
2673 IConnectionPoint_Release(cp
);
2677 host
->sink
->host
= NULL
;
2678 IDispatch_Release(&host
->sink
->IDispatch_iface
);
2682 release_plugin_ifaces(host
);
2685 host
->element
->plugin_host
= NULL
;
2686 host
->element
= NULL
;
2689 list_remove(&host
->entry
);
2690 list_init(&host
->entry
);
2694 HRESULT
create_plugin_host(HTMLDocumentNode
*doc
, HTMLPluginContainer
*container
)
2700 assert(!container
->plugin_host
);
2702 unk
= create_activex_object(doc
, container
->element
.dom_element
, &clsid
);
2706 host
= heap_alloc_zero(sizeof(*host
));
2708 IUnknown_Release(unk
);
2709 return E_OUTOFMEMORY
;
2712 host
->IOleClientSite_iface
.lpVtbl
= &OleClientSiteVtbl
;
2713 host
->IAdviseSinkEx_iface
.lpVtbl
= &AdviseSinkExVtbl
;
2714 host
->IPropertyNotifySink_iface
.lpVtbl
= &PropertyNotifySinkVtbl
;
2715 host
->IDispatch_iface
.lpVtbl
= &DispatchVtbl
;
2716 host
->IOleInPlaceSiteEx_iface
.lpVtbl
= &OleInPlaceSiteExVtbl
;
2717 host
->IOleControlSite_iface
.lpVtbl
= &OleControlSiteVtbl
;
2718 host
->IBindHost_iface
.lpVtbl
= &BindHostVtbl
;
2719 host
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2723 host
->plugin_unk
= unk
;
2724 host
->clsid
= clsid
;
2727 list_add_tail(&doc
->plugin_hosts
, &host
->entry
);
2729 container
->plugin_host
= host
;
2730 host
->element
= container
;
2732 initialize_plugin_object(host
);