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
30 #include "mshtml_private.h"
31 #include "pluginhost.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 IPropertyBag IPropertyBag_iface
;
39 IPropertyBag2 IPropertyBag2_iface
;
52 static void free_prop(param_prop_t
*prop
)
54 list_remove(&prop
->entry
);
61 static param_prop_t
*find_prop(PropertyBag
*prop_bag
, const WCHAR
*name
)
65 LIST_FOR_EACH_ENTRY(iter
, &prop_bag
->props
, param_prop_t
, entry
) {
66 if(!wcsicmp(iter
->name
, name
))
73 static HRESULT
add_prop(PropertyBag
*prop_bag
, const WCHAR
*name
, const WCHAR
*value
)
80 TRACE("%p %s %s\n", prop_bag
, debugstr_w(name
), debugstr_w(value
));
82 prop
= malloc(sizeof(*prop
));
86 prop
->name
= wcsdup(name
);
87 prop
->value
= wcsdup(value
);
88 if(!prop
->name
|| !prop
->value
) {
89 list_init(&prop
->entry
);
94 list_add_tail(&prop_bag
->props
, &prop
->entry
);
98 static inline PropertyBag
*impl_from_IPropertyBag(IPropertyBag
*iface
)
100 return CONTAINING_RECORD(iface
, PropertyBag
, IPropertyBag_iface
);
103 static HRESULT WINAPI
PropertyBag_QueryInterface(IPropertyBag
*iface
, REFIID riid
, void **ppv
)
105 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
107 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
108 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
109 *ppv
= &This
->IPropertyBag_iface
;
110 }else if(IsEqualGUID(&IID_IPropertyBag
, riid
)) {
111 TRACE("(%p)->(IID_IPropertyBag %p)\n", This
, ppv
);
112 *ppv
= &This
->IPropertyBag_iface
;
113 }else if(IsEqualGUID(&IID_IPropertyBag2
, riid
)) {
114 TRACE("(%p)->(IID_IPropertyBag2 %p)\n", This
, ppv
);
115 *ppv
= &This
->IPropertyBag2_iface
;
117 WARN("Unsopported interface %s\n", debugstr_guid(riid
));
119 return E_NOINTERFACE
;
122 IUnknown_AddRef((IUnknown
*)*ppv
);
126 static ULONG WINAPI
PropertyBag_AddRef(IPropertyBag
*iface
)
128 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
129 LONG ref
= InterlockedIncrement(&This
->ref
);
131 TRACE("(%p) ref=%ld\n", This
, ref
);
136 static ULONG WINAPI
PropertyBag_Release(IPropertyBag
*iface
)
138 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
139 LONG ref
= InterlockedDecrement(&This
->ref
);
141 TRACE("(%p) ref=%ld\n", This
, ref
);
144 while(!list_empty(&This
->props
))
145 free_prop(LIST_ENTRY(This
->props
.next
, param_prop_t
, entry
));
152 static HRESULT WINAPI
PropertyBag_Read(IPropertyBag
*iface
, LPCOLESTR pszPropName
, VARIANT
*pVar
, IErrorLog
*pErrorLog
)
154 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
158 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
160 prop
= find_prop(This
, pszPropName
);
162 TRACE("Not found\n");
166 V_BSTR(&v
) = SysAllocString(prop
->value
);
168 return E_OUTOFMEMORY
;
170 if(V_VT(pVar
) != VT_BSTR
) {
174 hres
= VariantChangeType(pVar
, &v
, 0, V_VT(pVar
));
175 SysFreeString(V_BSTR(&v
));
179 V_BSTR(pVar
) = V_BSTR(&v
);
183 static HRESULT WINAPI
PropertyBag_Write(IPropertyBag
*iface
, LPCOLESTR pszPropName
, VARIANT
*pVar
)
185 PropertyBag
*This
= impl_from_IPropertyBag(iface
);
186 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(pszPropName
), debugstr_variant(pVar
));
190 static const IPropertyBagVtbl PropertyBagVtbl
= {
191 PropertyBag_QueryInterface
,
198 static inline PropertyBag
*impl_from_IPropertyBag2(IPropertyBag2
*iface
)
200 return CONTAINING_RECORD(iface
, PropertyBag
, IPropertyBag2_iface
);
203 static HRESULT WINAPI
PropertyBag2_QueryInterface(IPropertyBag2
*iface
, REFIID riid
, void **ppv
)
205 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
206 return IPropertyBag_QueryInterface(&This
->IPropertyBag_iface
, riid
, ppv
);
209 static ULONG WINAPI
PropertyBag2_AddRef(IPropertyBag2
*iface
)
211 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
212 return IPropertyBag_AddRef(&This
->IPropertyBag_iface
);
215 static ULONG WINAPI
PropertyBag2_Release(IPropertyBag2
*iface
)
217 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
218 return IPropertyBag_Release(&This
->IPropertyBag_iface
);
221 static HRESULT WINAPI
PropertyBag2_Read(IPropertyBag2
*iface
, ULONG cProperties
, PROPBAG2
*pPropBag
,
222 IErrorLog
*pErrLog
, VARIANT
*pvarValue
, HRESULT
*phrError
)
224 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
225 FIXME("(%p)->(%ld %p %p %p %p)\n", This
, cProperties
, pPropBag
, pErrLog
, pvarValue
, phrError
);
229 static HRESULT WINAPI
PropertyBag2_Write(IPropertyBag2
*iface
, ULONG cProperties
, PROPBAG2
*pPropBag
, VARIANT
*pvarValue
)
231 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
232 FIXME("(%p)->(%ld %p %s)\n", This
, cProperties
, pPropBag
, debugstr_variant(pvarValue
));
236 static HRESULT WINAPI
PropertyBag2_CountProperties(IPropertyBag2
*iface
, ULONG
*pcProperties
)
238 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
239 FIXME("(%p)->(%p)\n", This
, pcProperties
);
243 static HRESULT WINAPI
PropertyBag2_GetPropertyInfo(IPropertyBag2
*iface
, ULONG iProperty
, ULONG cProperties
,
244 PROPBAG2
*pPropBag
, ULONG
*pcProperties
)
246 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
247 FIXME("(%p)->(%lu %lu %p %p)\n", This
, iProperty
, cProperties
, pPropBag
, pcProperties
);
251 static HRESULT WINAPI
PropertyBag2_LoadObject(IPropertyBag2
*iface
, LPCOLESTR pstrName
, DWORD dwHint
,
252 IUnknown
*pUnkObject
, IErrorLog
*pErrLog
)
254 PropertyBag
*This
= impl_from_IPropertyBag2(iface
);
255 FIXME("(%p)->(%s %lx %p %p)\n", This
, debugstr_w(pstrName
), dwHint
, pUnkObject
, pErrLog
);
259 static const IPropertyBag2Vtbl PropertyBag2Vtbl
= {
260 PropertyBag2_QueryInterface
,
262 PropertyBag2_Release
,
265 PropertyBag2_CountProperties
,
266 PropertyBag2_GetPropertyInfo
,
267 PropertyBag2_LoadObject
270 static HRESULT
fill_props(nsIDOMElement
*nselem
, PropertyBag
*prop_bag
)
272 const PRUnichar
*name
, *value
;
273 nsAString name_str
, value_str
;
274 nsIDOMHTMLCollection
*params
;
275 nsIDOMElement
*param_elem
;
281 nsAString_InitDepend(&name_str
, L
"param");
282 nsres
= nsIDOMElement_GetElementsByTagName(nselem
, &name_str
, ¶ms
);
283 nsAString_Finish(&name_str
);
287 nsres
= nsIDOMHTMLCollection_GetLength(params
, &length
);
291 for(i
=0; i
< length
; i
++) {
292 nsres
= nsIDOMHTMLCollection_Item(params
, i
, &nsnode
);
293 if(NS_FAILED(nsres
)) {
298 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDOMElement
, (void**)¶m_elem
);
299 nsIDOMNode_Release(nsnode
);
300 if(NS_FAILED(nsres
)) {
305 nsres
= get_elem_attr_value(param_elem
, L
"name", &name_str
, &name
);
306 if(NS_SUCCEEDED(nsres
)) {
307 nsres
= get_elem_attr_value(param_elem
, L
"value", &value_str
, &value
);
308 if(NS_SUCCEEDED(nsres
)) {
309 hres
= add_prop(prop_bag
, name
, value
);
310 nsAString_Finish(&value_str
);
313 nsAString_Finish(&name_str
);
316 nsIDOMElement_Release(param_elem
);
319 if(NS_FAILED(nsres
)) {
325 nsIDOMHTMLCollection_Release(params
);
329 static HRESULT
create_param_prop_bag(nsIDOMElement
*nselem
, IPropertyBag
**ret
)
331 PropertyBag
*prop_bag
;
334 prop_bag
= malloc(sizeof(*prop_bag
));
336 return E_OUTOFMEMORY
;
338 prop_bag
->IPropertyBag_iface
.lpVtbl
= &PropertyBagVtbl
;
339 prop_bag
->IPropertyBag2_iface
.lpVtbl
= &PropertyBag2Vtbl
;
342 list_init(&prop_bag
->props
);
343 hres
= fill_props(nselem
, prop_bag
);
344 if(FAILED(hres
) || list_empty(&prop_bag
->props
)) {
345 IPropertyBag_Release(&prop_bag
->IPropertyBag_iface
);
350 *ret
= &prop_bag
->IPropertyBag_iface
;
354 static BOOL
check_load_safety(PluginHost
*host
)
356 DWORD policy_size
, policy
;
357 struct CONFIRMSAFETY cs
;
361 cs
.clsid
= host
->clsid
;
362 cs
.pUnk
= host
->plugin_unk
;
363 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
365 hres
= IInternetHostSecurityManager_QueryCustomPolicy(&host
->doc
->IInternetHostSecurityManager_iface
,
366 &GUID_CUSTOM_CONFIRMOBJECTSAFETY
, &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
370 policy
= *(DWORD
*)ppolicy
;
371 CoTaskMemFree(ppolicy
);
372 return policy
== URLPOLICY_ALLOW
;
375 static BOOL
check_script_safety(PluginHost
*host
)
377 DISPPARAMS params
= {NULL
,NULL
,0,0};
378 DWORD policy_size
, policy
;
379 struct CONFIRMSAFETY cs
;
385 cs
.clsid
= host
->clsid
;
386 cs
.pUnk
= host
->plugin_unk
;
389 hres
= IInternetHostSecurityManager_QueryCustomPolicy(&host
->doc
->IInternetHostSecurityManager_iface
,
390 &GUID_CUSTOM_CONFIRMOBJECTSAFETY
, &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
394 policy
= *(DWORD
*)ppolicy
;
395 CoTaskMemFree(ppolicy
);
397 if(policy
!= URLPOLICY_ALLOW
)
401 hres
= IDispatch_Invoke(host
->disp
, DISPID_SECURITYCTX
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &v
, NULL
, &err
);
402 if(SUCCEEDED(hres
)) {
403 FIXME("Handle security ctx %s\n", debugstr_variant(&v
));
410 static void update_readystate(PluginHost
*host
)
412 DISPPARAMS params
= {NULL
,NULL
,0,0};
419 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatchEx
, (void**)&dispex
);
420 if(SUCCEEDED(hres
)) {
421 FIXME("Use IDispatchEx\n");
422 IDispatchEx_Release(dispex
);
425 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
429 hres
= IDispatch_Invoke(disp
, DISPID_READYSTATE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &v
, NULL
, &err
);
430 IDispatch_Release(disp
);
431 if(SUCCEEDED(hres
)) {
432 /* FIXME: make plugin readystate affect document readystate */
433 TRACE("readystate = %s\n", debugstr_variant(&v
));
438 /* FIXME: We shouldn't need this function and we should embed plugin directly in the main document */
439 static void get_pos_rect(PluginHost
*host
, RECT
*ret
)
441 SetRect(ret
, 0, 0, host
->rect
.right
- host
->rect
.left
, host
->rect
.bottom
- host
->rect
.top
);
444 static void load_prop_bag(PluginHost
*host
, IPersistPropertyBag
*persist_prop_bag
)
446 IPropertyBag
*prop_bag
;
449 hres
= create_param_prop_bag(host
->element
->element
.dom_element
, &prop_bag
);
453 if(prop_bag
&& !check_load_safety(host
)) {
454 IPropertyBag_Release(prop_bag
);
459 hres
= IPersistPropertyBag_Load(persist_prop_bag
, prop_bag
, NULL
);
460 IPropertyBag_Release(prop_bag
);
462 WARN("Load failed: %08lx\n", hres
);
464 hres
= IPersistPropertyBag_InitNew(persist_prop_bag
);
466 WARN("InitNew failed: %08lx\n", hres
);
470 static void load_plugin(PluginHost
*host
)
472 IPersistPropertyBag2
*persist_prop_bag2
;
473 IPersistPropertyBag
*persist_prop_bag
;
476 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IPersistPropertyBag2
, (void**)&persist_prop_bag2
);
477 if(SUCCEEDED(hres
)) {
478 FIXME("Use IPersistPropertyBag2 iface\n");
479 IPersistPropertyBag2_Release(persist_prop_bag2
);
483 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IPersistPropertyBag
, (void**)&persist_prop_bag
);
484 if(SUCCEEDED(hres
)) {
485 load_prop_bag(host
, persist_prop_bag
);
486 IPersistPropertyBag_Release(persist_prop_bag
);
490 FIXME("No IPersistPropertyBag iface\n");
493 static void initialize_plugin_object(PluginHost
*host
)
495 IClientSecurity
*client_security
;
496 IQuickActivate
*quick_activate
;
497 IOleObject
*ole_obj
= NULL
;
498 IOleCommandTarget
*cmdtrg
;
499 IViewObjectEx
*view_obj
;
504 /* Note native calls QI on plugin for an undocumented IID and CLSID_HTMLDocument */
506 /* FIXME: call FreezeEvents(TRUE) */
508 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IClientSecurity
, (void**)&client_security
);
509 if(SUCCEEDED(hres
)) {
510 FIXME("Handle IClientSecurity\n");
511 IClientSecurity_Release(client_security
);
515 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IQuickActivate
, (void**)&quick_activate
);
516 if(SUCCEEDED(hres
)) {
517 QACONTAINER container
= {sizeof(container
)};
518 QACONTROL control
= {sizeof(control
)};
520 TRACE("Using IQuickActivate\n");
522 container
.pClientSite
= &host
->IOleClientSite_iface
;
523 container
.dwAmbientFlags
= QACONTAINER_SUPPORTSMNEMONICS
|QACONTAINER_MESSAGEREFLECT
|QACONTAINER_USERMODE
;
524 container
.pAdviseSink
= &host
->IAdviseSinkEx_iface
;
525 container
.pPropertyNotifySink
= &host
->IPropertyNotifySink_iface
;
527 hres
= IQuickActivate_QuickActivate(quick_activate
, &container
, &control
);
528 IQuickActivate_Release(quick_activate
);
530 FIXME("QuickActivate failed: %08lx\n", hres
);
534 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
535 if(SUCCEEDED(hres
)) {
536 hres
= IOleObject_GetMiscStatus(ole_obj
, DVASPECT_CONTENT
, &status
);
537 TRACE("GetMiscStatus returned %08lx %lx\n", hres
, status
);
539 hres
= IOleObject_SetClientSite(ole_obj
, &host
->IOleClientSite_iface
);
540 IOleObject_Release(ole_obj
);
542 FIXME("SetClientSite failed: %08lx\n", hres
);
546 TRACE("Plugin does not support IOleObject\n");
553 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IViewObjectEx
, (void**)&view_obj
);
554 if(SUCCEEDED(hres
)) {
555 DWORD view_status
= 0;
557 hres
= IViewObjectEx_SetAdvise(view_obj
, DVASPECT_CONTENT
, 0, (IAdviseSink
*)&host
->IAdviseSinkEx_iface
);
559 WARN("SetAdvise failed: %08lx\n", hres
);
561 hres
= IViewObjectEx_GetViewStatus(view_obj
, &view_status
);
562 IViewObjectEx_Release(view_obj
);
563 TRACE("GetViewStatus returned %08lx %lx\n", hres
, view_status
);
567 update_readystate(host
);
569 /* NOTE: Native QIs for IActiveScript, an undocumented IID, IOleControl and IRunnableObject */
571 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatchEx
, (void**)&dispex
);
572 if(SUCCEEDED(hres
)) {
573 FIXME("Use IDispatchEx\n");
574 host
->disp
= (IDispatch
*)dispex
;
576 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
580 TRACE("no IDispatch iface\n");
583 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
584 if(SUCCEEDED(hres
)) {
585 FIXME("Use IOleCommandTarget\n");
586 IOleCommandTarget_Release(cmdtrg
);
590 static void embed_plugin_object(PluginHost
*host
)
596 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
598 FIXME("Plugin does not support IOleObject\n");
602 get_pos_rect(host
, &rect
);
603 hres
= IOleObject_DoVerb(ole_obj
, OLEIVERB_INPLACEACTIVATE
, NULL
, &host
->IOleClientSite_iface
, 0, host
->hwnd
, &rect
);
604 IOleObject_Release(ole_obj
);
606 WARN("DoVerb failed: %08lx\n", hres
);
608 if(host
->ip_object
) {
611 hres
= IOleInPlaceObject_GetWindow(host
->ip_object
, &hwnd
);
613 TRACE("hwnd %p\n", hwnd
);
617 void update_plugin_window(PluginHost
*host
, HWND hwnd
, const RECT
*rect
)
619 BOOL rect_changed
= FALSE
;
621 if(!hwnd
|| (host
->hwnd
&& host
->hwnd
!= hwnd
)) {
622 FIXME("unhandled hwnd\n");
626 TRACE("%p %s\n", hwnd
, wine_dbgstr_rect(rect
));
628 if(!EqualRect(rect
, &host
->rect
)) {
635 embed_plugin_object(host
);
638 if(rect_changed
&& host
->ip_object
)
639 IOleInPlaceObject_SetObjectRects(host
->ip_object
, &host
->rect
, &host
->rect
);
642 static void notif_enabled(PluginHost
*plugin_host
)
644 DISPPARAMS args
= {NULL
, NULL
, 0, 0};
650 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
652 FIXME("Could not get IDispatch iface: %08lx\n", hres
);
656 V_VT(&res
) = VT_EMPTY
;
657 hres
= IDispatch_Invoke(disp
, DISPID_ENABLED
, &IID_NULL
, 0/*FIXME*/, DISPATCH_PROPERTYGET
, &args
, &res
, NULL
, &err
);
658 IDispatch_Release(disp
);
659 if(SUCCEEDED(hres
)) {
660 FIXME("Got enabled %s\n", debugstr_variant(&res
));
665 void notif_container_change(HTMLPluginContainer
*plugin_container
, DISPID dispid
)
667 IOleControl
*ole_control
;
670 if(!plugin_container
->plugin_host
|| !plugin_container
->plugin_host
->plugin_unk
)
673 notif_enabled(plugin_container
->plugin_host
);
675 hres
= IUnknown_QueryInterface(plugin_container
->plugin_host
->plugin_unk
, &IID_IOleControl
, (void**)&ole_control
);
676 if(SUCCEEDED(hres
)) {
677 IOleControl_OnAmbientPropertyChange(ole_control
, dispid
);
678 IOleControl_Release(ole_control
);
682 HRESULT
get_plugin_disp(HTMLPluginContainer
*plugin_container
, IDispatch
**ret
)
686 host
= plugin_container
->plugin_host
;
688 ERR("No plugin host\n");
697 if(!check_script_safety(host
)) {
698 FIXME("Insecure object\n");
702 IDispatch_AddRef(host
->disp
);
707 HRESULT
get_plugin_dispid(HTMLPluginContainer
*plugin_container
, WCHAR
*name
, DISPID
*ret
)
714 if(!plugin_container
->plugin_host
) {
715 WARN("no plugin host\n");
716 return DISP_E_UNKNOWNNAME
;
719 disp
= plugin_container
->plugin_host
->disp
;
721 return DISP_E_UNKNOWNNAME
;
723 hres
= IDispatch_GetIDsOfNames(disp
, &IID_NULL
, &name
, 1, 0, &id
);
725 TRACE("no prop %s\n", debugstr_w(name
));
726 return DISP_E_UNKNOWNNAME
;
729 for(i
=0; i
< plugin_container
->props_len
; i
++) {
730 if(id
== plugin_container
->props
[i
]) {
731 *ret
= MSHTML_DISPID_CUSTOM_MIN
+i
;
736 if(!plugin_container
->props
) {
737 plugin_container
->props
= malloc(8 * sizeof(DISPID
));
738 if(!plugin_container
->props
)
739 return E_OUTOFMEMORY
;
740 plugin_container
->props_size
= 8;
741 }else if(plugin_container
->props_len
== plugin_container
->props_size
) {
744 new_props
= realloc(plugin_container
->props
, plugin_container
->props_size
* 2 * sizeof(DISPID
));
746 return E_OUTOFMEMORY
;
748 plugin_container
->props
= new_props
;
749 plugin_container
->props_size
*= 2;
752 plugin_container
->props
[plugin_container
->props_len
] = id
;
753 *ret
= MSHTML_DISPID_CUSTOM_MIN
+plugin_container
->props_len
;
754 plugin_container
->props_len
++;
758 HRESULT
invoke_plugin_prop(HTMLPluginContainer
*plugin_container
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
759 VARIANT
*res
, EXCEPINFO
*ei
)
763 host
= plugin_container
->plugin_host
;
764 if(!host
|| !host
->disp
) {
765 FIXME("Called with no disp\n");
769 if(!check_script_safety(host
)) {
770 FIXME("Insecure object\n");
774 if(id
< MSHTML_DISPID_CUSTOM_MIN
|| id
> MSHTML_DISPID_CUSTOM_MIN
+ plugin_container
->props_len
) {
779 return IDispatch_Invoke(host
->disp
, plugin_container
->props
[id
-MSHTML_DISPID_CUSTOM_MIN
], &IID_NULL
,
780 lcid
, flags
, params
, res
, ei
, NULL
);
789 IDispatch IDispatch_iface
;
799 sink_entry_t
*handlers
;
804 static sink_entry_t
*find_sink_entry(PHEventSink
*sink
, DISPID id
)
808 for(iter
= sink
->handlers
; iter
< sink
->handlers
+sink
->handlers_cnt
; iter
++) {
816 static void add_sink_handler(PHEventSink
*sink
, DISPID id
, IDispatch
*disp
)
818 sink_entry_t
*entry
= find_sink_entry(sink
, id
);
822 IDispatch_Release(entry
->disp
);
824 if(!sink
->handlers_size
) {
825 sink
->handlers
= malloc(4 * sizeof(*sink
->handlers
));
828 sink
->handlers_size
= 4;
829 }else if(sink
->handlers_cnt
== sink
->handlers_size
) {
830 sink_entry_t
*new_handlers
;
832 new_handlers
= realloc(sink
->handlers
, 2 * sink
->handlers_size
* sizeof(*sink
->handlers
));
835 sink
->handlers
= new_handlers
;
836 sink
->handlers_size
*= 2;
838 entry
= sink
->handlers
+ sink
->handlers_cnt
++;
842 IDispatch_AddRef(disp
);
846 static inline PHEventSink
*PHEventSink_from_IDispatch(IDispatch
*iface
)
848 return CONTAINING_RECORD(iface
, PHEventSink
, IDispatch_iface
);
851 static HRESULT WINAPI
PHEventSink_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
853 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
855 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
856 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
857 *ppv
= &This
->IDispatch_iface
;
858 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
859 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
860 *ppv
= &This
->IDispatch_iface
;
861 }else if(This
->is_dispiface
&& IsEqualGUID(riid
, &This
->iid
)) {
862 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
863 *ppv
= &This
->IDispatch_iface
;
865 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
867 return E_NOINTERFACE
;
870 IUnknown_AddRef((IUnknown
*)*ppv
);
874 static ULONG WINAPI
PHEventSink_AddRef(IDispatch
*iface
)
876 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
877 LONG ref
= InterlockedIncrement(&This
->ref
);
879 TRACE("(%p)\n", This
);
884 static ULONG WINAPI
PHEventSink_Release(IDispatch
*iface
)
886 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
887 LONG ref
= InterlockedDecrement(&This
->ref
);
889 TRACE("(%p)\n", This
);
896 for(i
=0; i
< This
->handlers_cnt
; i
++) {
897 if(This
->handlers
[i
].disp
)
898 IDispatch_Release(This
->handlers
[i
].disp
);
900 free(This
->handlers
);
907 static HRESULT WINAPI
PHEventSink_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
909 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
910 FIXME("(%p)->(%p)\n", This
, pctinfo
);
914 static HRESULT WINAPI
PHEventSink_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
915 LCID lcid
, ITypeInfo
**ppTInfo
)
917 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
918 FIXME("(%p)->(%d %ld %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
922 static HRESULT WINAPI
PHEventSink_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
923 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
925 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
926 FIXME("(%p)->(%s %p %u %ld %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
930 static HRESULT WINAPI
PHEventSink_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
931 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
933 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
938 TRACE("(%p)->(%ld %s %ld %x %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
), lcid
, wFlags
,
939 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
946 entry
= find_sink_entry(This
, dispIdMember
);
947 if(!entry
|| !entry
->disp
) {
948 WARN("No handler %ld\n", dispIdMember
);
950 V_VT(pVarResult
) = VT_EMPTY
;
954 hres
= IDispatch_QueryInterface(entry
->disp
, &IID_IDispatchEx
, (void**)&dispex
);
956 TRACE("(%p) %ld >>>\n", This
, entry
->id
);
957 if(SUCCEEDED(hres
)) {
958 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, NULL
);
959 IDispatchEx_Release(dispex
);
961 hres
= IDispatch_Invoke(entry
->disp
, DISPID_VALUE
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
964 TRACE("(%p) %ld <<<\n", This
, entry
->id
);
966 WARN("(%p) %ld <<< %08lx\n", This
, entry
->id
, hres
);
970 static const IDispatchVtbl PHCPDispatchVtbl
= {
971 PHEventSink_QueryInterface
,
974 PHEventSink_GetTypeInfoCount
,
975 PHEventSink_GetTypeInfo
,
976 PHEventSink_GetIDsOfNames
,
980 static PHEventSink
*create_event_sink(PluginHost
*plugin_host
, ITypeInfo
*typeinfo
)
982 IConnectionPointContainer
*cp_container
;
984 IConnectionPoint
*cp
;
990 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &typeattr
);
994 typekind
= typeattr
->typekind
;
995 guid
= typeattr
->guid
;
996 ITypeInfo_ReleaseTypeAttr(typeinfo
, typeattr
);
998 TRACE("guid %s typekind %d\n", debugstr_guid(&guid
), typekind
);
1000 if(typekind
!= TKIND_INTERFACE
&& typekind
!= TKIND_DISPATCH
) {
1001 WARN("invalid typekind %d\n", typekind
);
1005 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
1007 WARN("Could not get IConnectionPointContainer iface: %08lx\n", hres
);
1011 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &guid
, &cp
);
1012 IConnectionPointContainer_Release(cp_container
);
1014 WARN("Could not find %s connection point\n", debugstr_guid(&guid
));
1018 ret
= calloc(1, sizeof(*ret
));
1020 ret
->IDispatch_iface
.lpVtbl
= &PHCPDispatchVtbl
;
1022 ret
->host
= plugin_host
;
1024 ret
->is_dispiface
= typekind
== TKIND_DISPATCH
;
1026 ITypeInfo_AddRef(typeinfo
);
1027 ret
->typeinfo
= typeinfo
;
1029 hres
= IConnectionPoint_Advise(cp
, (IUnknown
*)&ret
->IDispatch_iface
, &ret
->cookie
);
1031 hres
= E_OUTOFMEMORY
;
1034 IConnectionPoint_Release(cp
);
1036 WARN("Advise failed: %08lx\n", hres
);
1043 static ITypeInfo
*get_eventiface_info(HTMLPluginContainer
*plugin_container
, ITypeInfo
*class_info
)
1045 int impl_types
, i
, impl_flags
;
1046 ITypeInfo
*ret
= NULL
;
1051 hres
= ITypeInfo_GetTypeAttr(class_info
, &typeattr
);
1055 if(typeattr
->typekind
!= TKIND_COCLASS
) {
1056 WARN("not coclass\n");
1057 ITypeInfo_ReleaseTypeAttr(class_info
, typeattr
);
1061 impl_types
= typeattr
->cImplTypes
;
1062 ITypeInfo_ReleaseTypeAttr(class_info
, typeattr
);
1064 for(i
=0; i
<impl_types
; i
++) {
1065 hres
= ITypeInfo_GetImplTypeFlags(class_info
, i
, &impl_flags
);
1069 if((impl_flags
& IMPLTYPEFLAG_FSOURCE
)) {
1070 if(!(impl_flags
& IMPLTYPEFLAG_FDEFAULT
)) {
1071 FIXME("Handle non-default source iface\n");
1075 hres
= ITypeInfo_GetRefTypeOfImplType(class_info
, i
, &ref
);
1079 hres
= ITypeInfo_GetRefTypeInfo(class_info
, ref
, &ret
);
1088 void bind_activex_event(HTMLDocumentNode
*doc
, HTMLPluginContainer
*plugin_container
, WCHAR
*event
, IDispatch
*disp
)
1090 PluginHost
*plugin_host
= plugin_container
->plugin_host
;
1091 ITypeInfo
*class_info
, *source_info
;
1095 TRACE("(%p %p %s %p)\n", doc
, plugin_host
, debugstr_w(event
), disp
);
1097 if(!plugin_host
|| !plugin_host
->plugin_unk
) {
1098 WARN("detached element %p\n", plugin_host
);
1102 if(plugin_host
->sink
) {
1103 source_info
= plugin_host
->sink
->typeinfo
;
1104 ITypeInfo_AddRef(source_info
);
1106 IProvideClassInfo
*provide_ci
;
1108 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IProvideClassInfo
, (void**)&provide_ci
);
1110 FIXME("No IProvideClassInfo, try GetTypeInfo?\n");
1114 hres
= IProvideClassInfo_GetClassInfo(provide_ci
, &class_info
);
1115 IProvideClassInfo_Release(provide_ci
);
1116 if(FAILED(hres
) || !class_info
) {
1117 WARN("GetClassInfo failed: %08lx\n", hres
);
1121 source_info
= get_eventiface_info(plugin_container
, class_info
);
1122 ITypeInfo_Release(class_info
);
1127 hres
= ITypeInfo_GetIDsOfNames(source_info
, &event
, 1, &id
);
1129 WARN("Could not get disp id: %08lx\n", hres
);
1130 else if(!plugin_host
->sink
)
1131 plugin_host
->sink
= create_event_sink(plugin_host
, source_info
);
1133 ITypeInfo_Release(source_info
);
1134 if(FAILED(hres
) || !plugin_host
->sink
)
1137 add_sink_handler(plugin_host
->sink
, id
, disp
);
1141 IOleInPlaceFrame IOleInPlaceFrame_iface
;
1145 static inline InPlaceFrame
*impl_from_IOleInPlaceFrame(IOleInPlaceFrame
*iface
)
1147 return CONTAINING_RECORD(iface
, InPlaceFrame
, IOleInPlaceFrame_iface
);
1150 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
,
1151 REFIID riid
, void **ppv
)
1153 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1155 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1157 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1158 *ppv
= &This
->IOleInPlaceFrame_iface
;
1159 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1160 *ppv
= &This
->IOleInPlaceFrame_iface
;
1161 }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow
, riid
)) {
1162 *ppv
= &This
->IOleInPlaceFrame_iface
;
1163 }else if(IsEqualGUID(&IID_IOleInPlaceFrame
, riid
)) {
1164 *ppv
= &This
->IOleInPlaceFrame_iface
;
1166 WARN("Unsopported interface %s\n", debugstr_mshtml_guid(riid
));
1168 return E_NOINTERFACE
;
1171 IUnknown_AddRef((IUnknown
*)*ppv
);
1175 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
1177 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1178 LONG ref
= InterlockedIncrement(&This
->ref
);
1180 TRACE("(%p) ref=%ld\n", This
, ref
);
1185 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
1187 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1188 LONG ref
= InterlockedDecrement(&This
->ref
);
1190 TRACE("(%p) ref=%ld\n", This
, ref
);
1198 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
1200 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1201 FIXME("(%p)->(%p)\n", This
, phwnd
);
1205 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
,
1208 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1209 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1213 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
1215 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1216 FIXME("(%p)->(%p)\n", This
, lprectBorder
);
1220 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
1221 LPCBORDERWIDTHS pborderwidths
)
1223 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1224 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1228 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
1229 LPCBORDERWIDTHS pborderwidths
)
1231 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1232 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1236 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
1237 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1239 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1240 FIXME("(%p)->(%p %s)\n", This
, pActiveObject
, debugstr_w(pszObjName
));
1244 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
1245 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
1247 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1248 FIXME("(%p)->(%p %p)\n", This
, hmenuShared
, lpMenuWidths
);
1252 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
1253 HOLEMENU holemenu
, HWND hwndActiveObject
)
1255 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1256 FIXME("(%p)->(%p %p %p)\n", This
, hmenuShared
, holemenu
, hwndActiveObject
);
1260 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
1262 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1263 FIXME("(%p)->(%p)\n", This
, hmenuShared
);
1267 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
,
1268 LPCOLESTR pszStatusText
)
1270 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1271 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszStatusText
));
1275 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
1277 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1278 FIXME("(%p)->(%x)\n", This
, fEnable
);
1282 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
,
1285 InPlaceFrame
*This
= impl_from_IOleInPlaceFrame(iface
);
1286 FIXME("(%p)->(%p %d)\n", This
, lpmsg
, wID
);
1290 static const IOleInPlaceFrameVtbl OleInPlaceFrameVtbl
= {
1291 InPlaceFrame_QueryInterface
,
1292 InPlaceFrame_AddRef
,
1293 InPlaceFrame_Release
,
1294 InPlaceFrame_GetWindow
,
1295 InPlaceFrame_ContextSensitiveHelp
,
1296 InPlaceFrame_GetBorder
,
1297 InPlaceFrame_RequestBorderSpace
,
1298 InPlaceFrame_SetBorderSpace
,
1299 InPlaceFrame_SetActiveObject
,
1300 InPlaceFrame_InsertMenus
,
1301 InPlaceFrame_SetMenu
,
1302 InPlaceFrame_RemoveMenus
,
1303 InPlaceFrame_SetStatusText
,
1304 InPlaceFrame_EnableModeless
,
1305 InPlaceFrame_TranslateAccelerator
1308 static HRESULT
create_ip_frame(IOleInPlaceFrame
**ret
)
1310 InPlaceFrame
*frame
;
1312 frame
= calloc(1, sizeof(*frame
));
1314 return E_OUTOFMEMORY
;
1316 frame
->IOleInPlaceFrame_iface
.lpVtbl
= &OleInPlaceFrameVtbl
;
1319 *ret
= &frame
->IOleInPlaceFrame_iface
;
1324 IOleInPlaceUIWindow IOleInPlaceUIWindow_iface
;
1328 static inline InPlaceUIWindow
*impl_from_IOleInPlaceUIWindow(IOleInPlaceUIWindow
*iface
)
1330 return CONTAINING_RECORD(iface
, InPlaceUIWindow
, IOleInPlaceUIWindow_iface
);
1333 static HRESULT WINAPI
InPlaceUIWindow_QueryInterface(IOleInPlaceUIWindow
*iface
, REFIID riid
, void **ppv
)
1335 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1337 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1339 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1340 *ppv
= &This
->IOleInPlaceUIWindow_iface
;
1341 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1342 *ppv
= &This
->IOleInPlaceUIWindow_iface
;
1343 }else if(IsEqualGUID(&IID_IOleInPlaceUIWindow
, riid
)) {
1344 *ppv
= &This
->IOleInPlaceUIWindow_iface
;
1346 WARN("Unsopported interface %s\n", debugstr_mshtml_guid(riid
));
1348 return E_NOINTERFACE
;
1351 IUnknown_AddRef((IUnknown
*)*ppv
);
1355 static ULONG WINAPI
InPlaceUIWindow_AddRef(IOleInPlaceUIWindow
*iface
)
1357 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1358 LONG ref
= InterlockedIncrement(&This
->ref
);
1360 TRACE("(%p) ref=%ld\n", This
, ref
);
1365 static ULONG WINAPI
InPlaceUIWindow_Release(IOleInPlaceUIWindow
*iface
)
1367 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1368 LONG ref
= InterlockedDecrement(&This
->ref
);
1370 TRACE("(%p) ref=%ld\n", This
, ref
);
1378 static HRESULT WINAPI
InPlaceUIWindow_GetWindow(IOleInPlaceUIWindow
*iface
, HWND
*phwnd
)
1380 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1381 FIXME("(%p)->(%p)\n", This
, phwnd
);
1385 static HRESULT WINAPI
InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceUIWindow
*iface
,
1388 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1389 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1393 static HRESULT WINAPI
InPlaceUIWindow_GetBorder(IOleInPlaceUIWindow
*iface
, LPRECT lprectBorder
)
1395 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1396 FIXME("(%p)->(%p)\n", This
, lprectBorder
);
1400 static HRESULT WINAPI
InPlaceUIWindow_RequestBorderSpace(IOleInPlaceUIWindow
*iface
,
1401 LPCBORDERWIDTHS pborderwidths
)
1403 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1404 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1408 static HRESULT WINAPI
InPlaceUIWindow_SetBorderSpace(IOleInPlaceUIWindow
*iface
,
1409 LPCBORDERWIDTHS pborderwidths
)
1411 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1412 FIXME("(%p)->(%p)\n", This
, pborderwidths
);
1416 static HRESULT WINAPI
InPlaceUIWindow_SetActiveObject(IOleInPlaceUIWindow
*iface
,
1417 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1419 InPlaceUIWindow
*This
= impl_from_IOleInPlaceUIWindow(iface
);
1420 FIXME("(%p)->(%p %s)\n", This
, pActiveObject
, debugstr_w(pszObjName
));
1424 static const IOleInPlaceUIWindowVtbl OleInPlaceUIWindowVtbl
= {
1425 InPlaceUIWindow_QueryInterface
,
1426 InPlaceUIWindow_AddRef
,
1427 InPlaceUIWindow_Release
,
1428 InPlaceUIWindow_GetWindow
,
1429 InPlaceUIWindow_ContextSensitiveHelp
,
1430 InPlaceUIWindow_GetBorder
,
1431 InPlaceUIWindow_RequestBorderSpace
,
1432 InPlaceUIWindow_SetBorderSpace
,
1433 InPlaceUIWindow_SetActiveObject
,
1436 static HRESULT
create_ip_window(IOleInPlaceUIWindow
**ret
)
1438 InPlaceUIWindow
*uiwindow
;
1440 uiwindow
= calloc(1, sizeof(*uiwindow
));
1442 return E_OUTOFMEMORY
;
1444 uiwindow
->IOleInPlaceUIWindow_iface
.lpVtbl
= &OleInPlaceUIWindowVtbl
;
1447 *ret
= &uiwindow
->IOleInPlaceUIWindow_iface
;
1451 static inline PluginHost
*impl_from_IOleClientSite(IOleClientSite
*iface
)
1453 return CONTAINING_RECORD(iface
, PluginHost
, IOleClientSite_iface
);
1456 static HRESULT WINAPI
PHClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
1458 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1460 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1461 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1462 *ppv
= &This
->IOleClientSite_iface
;
1463 }else if(IsEqualGUID(&IID_IOleClientSite
, riid
)) {
1464 TRACE("(%p)->(IID_IOleClientSite %p)\n", This
, ppv
);
1465 *ppv
= &This
->IOleClientSite_iface
;
1466 }else if(IsEqualGUID(&IID_IAdviseSink
, riid
)) {
1467 TRACE("(%p)->(IID_IAdviseSink %p)\n", This
, ppv
);
1468 *ppv
= &This
->IAdviseSinkEx_iface
;
1469 }else if(IsEqualGUID(&IID_IAdviseSinkEx
, riid
)) {
1470 TRACE("(%p)->(IID_IAdviseSinkEx %p)\n", This
, ppv
);
1471 *ppv
= &This
->IAdviseSinkEx_iface
;
1472 }else if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
1473 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This
, ppv
);
1474 *ppv
= &This
->IPropertyNotifySink_iface
;
1475 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1476 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1477 *ppv
= &This
->IDispatch_iface
;
1478 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
1479 TRACE("(%p)->(IID_IOleWindow %p)\n", This
, ppv
);
1480 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
1481 }else if(IsEqualGUID(&IID_IOleInPlaceSite
, riid
)) {
1482 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This
, ppv
);
1483 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
1484 }else if(IsEqualGUID(&IID_IOleInPlaceSiteEx
, riid
)) {
1485 TRACE("(%p)->(IID_IOleInPlaceSiteEx %p)\n", This
, ppv
);
1486 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
1487 }else if(IsEqualGUID(&IID_IOleControlSite
, riid
)) {
1488 TRACE("(%p)->(IID_IOleControlSite %p)\n", This
, ppv
);
1489 *ppv
= &This
->IOleControlSite_iface
;
1490 }else if(IsEqualGUID(&IID_IBindHost
, riid
)) {
1491 TRACE("(%p)->(IID_IBindHost %p)\n", This
, ppv
);
1492 *ppv
= &This
->IBindHost_iface
;
1493 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
1494 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
1495 *ppv
= &This
->IServiceProvider_iface
;
1497 WARN("Unsupported interface %s\n", debugstr_guid(riid
));
1499 return E_NOINTERFACE
;
1502 IUnknown_AddRef((IUnknown
*)*ppv
);
1506 static ULONG WINAPI
PHClientSite_AddRef(IOleClientSite
*iface
)
1508 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1509 LONG ref
= InterlockedIncrement(&This
->ref
);
1511 TRACE("(%p) ref=%ld\n", This
, ref
);
1516 static void release_plugin_ifaces(PluginHost
*This
)
1518 unlink_ref(&This
->disp
);
1519 unlink_ref(&This
->ip_object
);
1521 if(This
->plugin_unk
) {
1522 IUnknown
*unk
= This
->plugin_unk
;
1525 This
->plugin_unk
= NULL
;
1526 ref
= IUnknown_Release(unk
);
1528 TRACE("plugin ref = %ld\n", ref
);
1532 static ULONG WINAPI
PHClientSite_Release(IOleClientSite
*iface
)
1534 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1535 LONG ref
= InterlockedDecrement(&This
->ref
);
1537 TRACE("(%p) ref=%ld\n", This
, ref
);
1540 release_plugin_ifaces(This
);
1542 This
->sink
->host
= NULL
;
1543 IDispatch_Release(&This
->sink
->IDispatch_iface
);
1546 list_remove(&This
->entry
);
1548 This
->element
->plugin_host
= NULL
;
1555 static HRESULT WINAPI
PHClientSite_SaveObject(IOleClientSite
*iface
)
1557 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1558 FIXME("(%p)\n", This
);
1562 static HRESULT WINAPI
PHClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
,
1563 DWORD dwWhichMoniker
, IMoniker
**ppmk
)
1565 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1567 TRACE("(%p)->(%ld %ld %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
1569 switch(dwWhichMoniker
) {
1570 case OLEWHICHMK_CONTAINER
:
1571 if(!This
->doc
|| !This
->doc
->window
|| !This
->doc
->window
->mon
) {
1572 FIXME("no moniker\n");
1573 return E_UNEXPECTED
;
1576 *ppmk
= This
->doc
->window
->mon
;
1577 IMoniker_AddRef(*ppmk
);
1580 FIXME("which %ld\n", dwWhichMoniker
);
1587 static HRESULT WINAPI
PHClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
1589 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1591 TRACE("(%p)->(%p)\n", This
, ppContainer
);
1594 ERR("Called on detached object\n");
1595 return E_UNEXPECTED
;
1598 *ppContainer
= &This
->doc
->IOleContainer_iface
;
1599 IOleContainer_AddRef(*ppContainer
);
1603 static HRESULT WINAPI
PHClientSite_ShowObject(IOleClientSite
*iface
)
1605 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1607 TRACE("(%p)\n", This
);
1612 static HRESULT WINAPI
PHClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
1614 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1615 FIXME("(%p)->(%x)\n", This
, fShow
);
1619 static HRESULT WINAPI
PHClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
1621 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1622 FIXME("(%p)\n", This
);
1626 static const IOleClientSiteVtbl OleClientSiteVtbl
= {
1627 PHClientSite_QueryInterface
,
1628 PHClientSite_AddRef
,
1629 PHClientSite_Release
,
1630 PHClientSite_SaveObject
,
1631 PHClientSite_GetMoniker
,
1632 PHClientSite_GetContainer
,
1633 PHClientSite_ShowObject
,
1634 PHClientSite_OnShowWindow
,
1635 PHClientSite_RequestNewObjectLayout
1638 static inline PluginHost
*impl_from_IAdviseSinkEx(IAdviseSinkEx
*iface
)
1640 return CONTAINING_RECORD(iface
, PluginHost
, IAdviseSinkEx_iface
);
1643 static HRESULT WINAPI
PHAdviseSinkEx_QueryInterface(IAdviseSinkEx
*iface
, REFIID riid
, void **ppv
)
1645 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1646 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1649 static ULONG WINAPI
PHAdviseSinkEx_AddRef(IAdviseSinkEx
*iface
)
1651 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1652 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1655 static ULONG WINAPI
PHAdviseSinkEx_Release(IAdviseSinkEx
*iface
)
1657 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1658 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1661 static void WINAPI
PHAdviseSinkEx_OnDataChange(IAdviseSinkEx
*iface
, FORMATETC
*pFormatetc
, STGMEDIUM
*pStgMedium
)
1663 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1664 FIXME("(%p)->(%p %p)\n", This
, pFormatetc
, pStgMedium
);
1667 static void WINAPI
PHAdviseSinkEx_OnViewChange(IAdviseSinkEx
*iface
, DWORD dwAspect
, LONG lindex
)
1669 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1670 FIXME("(%p)->(%ld %ld)\n", This
, dwAspect
, lindex
);
1673 static void WINAPI
PHAdviseSinkEx_OnRename(IAdviseSinkEx
*iface
, IMoniker
*pmk
)
1675 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1676 FIXME("(%p)->(%p)\n", This
, pmk
);
1679 static void WINAPI
PHAdviseSinkEx_OnSave(IAdviseSinkEx
*iface
)
1681 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1682 FIXME("(%p)\n", This
);
1685 static void WINAPI
PHAdviseSinkEx_OnClose(IAdviseSinkEx
*iface
)
1687 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1688 FIXME("(%p)\n", This
);
1691 static void WINAPI
PHAdviseSinkEx_OnViewStatusChange(IAdviseSinkEx
*iface
, DWORD dwViewStatus
)
1693 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1694 FIXME("(%p)->(%ld)\n", This
, dwViewStatus
);
1697 static const IAdviseSinkExVtbl AdviseSinkExVtbl
= {
1698 PHAdviseSinkEx_QueryInterface
,
1699 PHAdviseSinkEx_AddRef
,
1700 PHAdviseSinkEx_Release
,
1701 PHAdviseSinkEx_OnDataChange
,
1702 PHAdviseSinkEx_OnViewChange
,
1703 PHAdviseSinkEx_OnRename
,
1704 PHAdviseSinkEx_OnSave
,
1705 PHAdviseSinkEx_OnClose
,
1706 PHAdviseSinkEx_OnViewStatusChange
1709 static inline PluginHost
*impl_from_IPropertyNotifySink(IPropertyNotifySink
*iface
)
1711 return CONTAINING_RECORD(iface
, PluginHost
, IPropertyNotifySink_iface
);
1714 static HRESULT WINAPI
PHPropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
, REFIID riid
, void **ppv
)
1716 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1717 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1720 static ULONG WINAPI
PHPropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
1722 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1723 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1726 static ULONG WINAPI
PHPropertyNotifySink_Release(IPropertyNotifySink
*iface
)
1728 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1729 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1732 static HRESULT WINAPI
PHPropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
1734 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1736 TRACE("(%p)->(%ld)\n", This
, dispID
);
1739 case DISPID_READYSTATE
:
1740 update_readystate(This
);
1743 FIXME("Unimplemented dispID %ld\n", dispID
);
1750 static HRESULT WINAPI
PHPropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1752 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1753 FIXME("(%p)->(%ld)\n", This
, dispID
);
1757 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1758 PHPropertyNotifySink_QueryInterface
,
1759 PHPropertyNotifySink_AddRef
,
1760 PHPropertyNotifySink_Release
,
1761 PHPropertyNotifySink_OnChanged
,
1762 PHPropertyNotifySink_OnRequestEdit
1765 static inline PluginHost
*impl_from_IDispatch(IDispatch
*iface
)
1767 return CONTAINING_RECORD(iface
, PluginHost
, IDispatch_iface
);
1770 static HRESULT WINAPI
PHDispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
1772 PluginHost
*This
= impl_from_IDispatch(iface
);
1773 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1776 static ULONG WINAPI
PHDispatch_AddRef(IDispatch
*iface
)
1778 PluginHost
*This
= impl_from_IDispatch(iface
);
1779 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1782 static ULONG WINAPI
PHDispatch_Release(IDispatch
*iface
)
1784 PluginHost
*This
= impl_from_IDispatch(iface
);
1785 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1788 static HRESULT WINAPI
PHDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1790 PluginHost
*This
= impl_from_IDispatch(iface
);
1791 FIXME("(%p)->(%p)\n", This
, pctinfo
);
1795 static HRESULT WINAPI
PHDispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1796 LCID lcid
, ITypeInfo
**ppTInfo
)
1798 PluginHost
*This
= impl_from_IDispatch(iface
);
1799 FIXME("(%p)->(%d %ld %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1803 static HRESULT WINAPI
PHDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1804 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1806 PluginHost
*This
= impl_from_IDispatch(iface
);
1807 FIXME("(%p)->(%s %p %d %ld %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
1811 static HRESULT WINAPI
PHDispatch_Invoke(IDispatch
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
,
1812 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1814 PluginHost
*This
= impl_from_IDispatch(iface
);
1815 FIXME("(%p)->(%ld %x %p %p)\n", This
, dispid
, wFlags
, pDispParams
, pVarResult
);
1819 static const IDispatchVtbl DispatchVtbl
= {
1820 PHDispatch_QueryInterface
,
1823 PHDispatch_GetTypeInfoCount
,
1824 PHDispatch_GetTypeInfo
,
1825 PHDispatch_GetIDsOfNames
,
1829 static inline PluginHost
*impl_from_IOleInPlaceSiteEx(IOleInPlaceSiteEx
*iface
)
1831 return CONTAINING_RECORD(iface
, PluginHost
, IOleInPlaceSiteEx_iface
);
1834 static HRESULT WINAPI
PHInPlaceSite_QueryInterface(IOleInPlaceSiteEx
*iface
, REFIID riid
, void **ppv
)
1836 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1837 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1840 static ULONG WINAPI
PHInPlaceSite_AddRef(IOleInPlaceSiteEx
*iface
)
1842 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1843 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1846 static ULONG WINAPI
PHInPlaceSite_Release(IOleInPlaceSiteEx
*iface
)
1848 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1849 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1852 static HRESULT WINAPI
PHInPlaceSite_GetWindow(IOleInPlaceSiteEx
*iface
, HWND
*phwnd
)
1854 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1856 TRACE("(%p)->(%p)\n", This
, phwnd
);
1858 *phwnd
= This
->hwnd
;
1862 static HRESULT WINAPI
PHInPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx
*iface
, BOOL fEnterMode
)
1864 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1865 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1869 static HRESULT WINAPI
PHInPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx
*iface
)
1871 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1873 TRACE("(%p)\n", This
);
1878 static HRESULT WINAPI
PHInPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx
*iface
)
1880 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1881 FIXME("(%p)\n", This
);
1885 static HRESULT WINAPI
PHInPlaceSite_OnUIActivate(IOleInPlaceSiteEx
*iface
)
1887 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1889 TRACE("(%p)\n", This
);
1891 if(!This
->plugin_unk
) {
1892 ERR("No plugin object\n");
1893 return E_UNEXPECTED
;
1896 This
->ui_active
= TRUE
;
1898 notif_enabled(This
);
1902 static HRESULT WINAPI
PHInPlaceSite_GetWindowContext(IOleInPlaceSiteEx
*iface
,
1903 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, RECT
*lprcPosRect
,
1904 RECT
*lprcClipRect
, OLEINPLACEFRAMEINFO
*frame_info
)
1906 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1907 IOleInPlaceUIWindow
*ip_window
;
1908 IOleInPlaceFrame
*ip_frame
;
1912 TRACE("(%p)->(%p %p %p %p %p)\n", This
, ppFrame
, ppDoc
, lprcPosRect
, lprcClipRect
, frame_info
);
1914 if(!This
->doc
|| !This
->doc
->doc_obj
|| !This
->doc
->doc_obj
->ipsite
) {
1915 FIXME("No ipsite\n");
1916 return E_UNEXPECTED
;
1919 hres
= IOleInPlaceSite_GetWindowContext(This
->doc
->doc_obj
->ipsite
, &ip_frame
, &ip_window
, &pr
, &cr
, frame_info
);
1921 WARN("GetWindowContext failed: %08lx\n", hres
);
1926 IOleInPlaceUIWindow_Release(ip_window
);
1928 IOleInPlaceFrame_Release(ip_frame
);
1930 hres
= create_ip_frame(&ip_frame
);
1934 hres
= create_ip_window(ppDoc
);
1936 IOleInPlaceFrame_Release(ip_frame
);
1940 *ppFrame
= ip_frame
;
1941 *lprcPosRect
= This
->rect
;
1942 *lprcClipRect
= This
->rect
;
1946 static HRESULT WINAPI
PHInPlaceSite_Scroll(IOleInPlaceSiteEx
*iface
, SIZE scrollExtent
)
1948 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1949 FIXME("(%p)->({%ld %ld})\n", This
, scrollExtent
.cx
, scrollExtent
.cy
);
1953 static HRESULT WINAPI
PHInPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx
*iface
, BOOL fUndoable
)
1955 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1956 FIXME("(%p)->(%x)\n", This
, fUndoable
);
1960 static HRESULT WINAPI
PHInPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx
*iface
)
1962 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1964 TRACE("(%p)\n", This
);
1966 unlink_ref(&This
->ip_object
);
1970 static HRESULT WINAPI
PHInPlaceSite_DiscardUndoState(IOleInPlaceSiteEx
*iface
)
1972 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1973 FIXME("(%p)\n", This
);
1977 static HRESULT WINAPI
PHInPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx
*iface
)
1979 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1980 FIXME("(%p)\n", This
);
1984 static HRESULT WINAPI
PHInPlaceSite_OnPosRectChange(IOleInPlaceSiteEx
*iface
, LPCRECT lprcPosRect
)
1986 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1987 FIXME("(%p)->(%p)\n", This
, lprcPosRect
);
1991 static HRESULT WINAPI
PHInPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx
*iface
, BOOL
*pfNoRedraw
, DWORD dwFlags
)
1993 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1997 TRACE("(%p)->(%p %lx)\n", This
, pfNoRedraw
, dwFlags
);
2002 hres
= IUnknown_QueryInterface(This
->plugin_unk
, &IID_IOleInPlaceObject
, (void**)&This
->ip_object
);
2006 hres
= IOleInPlaceObject_GetWindow(This
->ip_object
, &hwnd
);
2008 FIXME("Use hwnd %p\n", hwnd
);
2010 *pfNoRedraw
= FALSE
;
2014 static HRESULT WINAPI
PHInPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx
*iface
, BOOL fNoRedraw
)
2016 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
2017 FIXME("(%p)->(%x)\n", This
, fNoRedraw
);
2021 static HRESULT WINAPI
PHInPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx
*iface
)
2023 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
2024 FIXME("(%p)\n", This
);
2028 static const IOleInPlaceSiteExVtbl OleInPlaceSiteExVtbl
= {
2029 PHInPlaceSite_QueryInterface
,
2030 PHInPlaceSite_AddRef
,
2031 PHInPlaceSite_Release
,
2032 PHInPlaceSite_GetWindow
,
2033 PHInPlaceSite_ContextSensitiveHelp
,
2034 PHInPlaceSite_CanInPlaceActivate
,
2035 PHInPlaceSite_OnInPlaceActivate
,
2036 PHInPlaceSite_OnUIActivate
,
2037 PHInPlaceSite_GetWindowContext
,
2038 PHInPlaceSite_Scroll
,
2039 PHInPlaceSite_OnUIDeactivate
,
2040 PHInPlaceSite_OnInPlaceDeactivate
,
2041 PHInPlaceSite_DiscardUndoState
,
2042 PHInPlaceSite_DeactivateAndUndo
,
2043 PHInPlaceSite_OnPosRectChange
,
2044 PHInPlaceSiteEx_OnInPlaceActivateEx
,
2045 PHInPlaceSiteEx_OnInPlaceDeactivateEx
,
2046 PHInPlaceSiteEx_RequestUIActivate
2049 static inline PluginHost
*impl_from_IOleControlSite(IOleControlSite
*iface
)
2051 return CONTAINING_RECORD(iface
, PluginHost
, IOleControlSite_iface
);
2054 static HRESULT WINAPI
PHControlSite_QueryInterface(IOleControlSite
*iface
, REFIID riid
, void **ppv
)
2056 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2057 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2060 static ULONG WINAPI
PHControlSite_AddRef(IOleControlSite
*iface
)
2062 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2063 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
2066 static ULONG WINAPI
PHControlSite_Release(IOleControlSite
*iface
)
2068 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2069 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
2072 static HRESULT WINAPI
PHControlSite_OnControlInfoChanged(IOleControlSite
*iface
)
2074 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2075 FIXME("(%p)\n", This
);
2079 static HRESULT WINAPI
PHControlSite_LockInPlaceActive(IOleControlSite
*iface
, BOOL fLock
)
2081 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2082 FIXME("(%p)->(%x)\n", This
, fLock
);
2086 static HRESULT WINAPI
PHControlSite_GetExtendedControl(IOleControlSite
*iface
, IDispatch
**ppDisp
)
2088 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2089 FIXME("(%p)->(%p)\n", This
, ppDisp
);
2093 static HRESULT WINAPI
PHControlSite_TransformCoords(IOleControlSite
*iface
, POINTL
*pPtlHimetric
, POINTF
*pPtfContainer
, DWORD dwFlags
)
2095 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2096 FIXME("(%p)->(%p %p %lx)\n", This
, pPtlHimetric
, pPtfContainer
, dwFlags
);
2100 static HRESULT WINAPI
PHControlSite_TranslateAccelerator(IOleControlSite
*iface
, MSG
*pMsg
, DWORD grfModifiers
)
2102 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2103 FIXME("(%p)->(%lx)\n", This
, grfModifiers
);
2107 static HRESULT WINAPI
PHControlSite_OnFocus(IOleControlSite
*iface
, BOOL fGotFocus
)
2109 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2110 FIXME("(%p)->(%x)\n", This
, fGotFocus
);
2114 static HRESULT WINAPI
PHControlSite_ShowPropertyFrame(IOleControlSite
*iface
)
2116 PluginHost
*This
= impl_from_IOleControlSite(iface
);
2117 FIXME("(%p)\n", This
);
2121 static const IOleControlSiteVtbl OleControlSiteVtbl
= {
2122 PHControlSite_QueryInterface
,
2123 PHControlSite_AddRef
,
2124 PHControlSite_Release
,
2125 PHControlSite_OnControlInfoChanged
,
2126 PHControlSite_LockInPlaceActive
,
2127 PHControlSite_GetExtendedControl
,
2128 PHControlSite_TransformCoords
,
2129 PHControlSite_TranslateAccelerator
,
2130 PHControlSite_OnFocus
,
2131 PHControlSite_ShowPropertyFrame
2134 static inline PluginHost
*impl_from_IBindHost(IBindHost
*iface
)
2136 return CONTAINING_RECORD(iface
, PluginHost
, IBindHost_iface
);
2139 static HRESULT WINAPI
PHBindHost_QueryInterface(IBindHost
*iface
, REFIID riid
, void **ppv
)
2141 PluginHost
*This
= impl_from_IBindHost(iface
);
2142 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2145 static ULONG WINAPI
PHBindHost_AddRef(IBindHost
*iface
)
2147 PluginHost
*This
= impl_from_IBindHost(iface
);
2148 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
2151 static ULONG WINAPI
PHBindHost_Release(IBindHost
*iface
)
2153 PluginHost
*This
= impl_from_IBindHost(iface
);
2154 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
2157 static HRESULT WINAPI
PHBindHost_CreateMoniker(IBindHost
*iface
, LPOLESTR szName
, IBindCtx
*pBC
, IMoniker
**ppmk
, DWORD dwReserved
)
2159 PluginHost
*This
= impl_from_IBindHost(iface
);
2161 TRACE("(%p)->(%s %p %p %lx)\n", This
, debugstr_w(szName
), pBC
, ppmk
, dwReserved
);
2163 if(!This
->doc
|| !This
->doc
->window
|| !This
->doc
->window
->mon
) {
2164 FIXME("no moniker\n");
2165 return E_UNEXPECTED
;
2168 return CreateURLMoniker(This
->doc
->window
->mon
, szName
, ppmk
);
2171 static HRESULT WINAPI
PHBindHost_MonikerBindToStorage(IBindHost
*iface
, IMoniker
*pMk
, IBindCtx
*pBC
,
2172 IBindStatusCallback
*pBSC
, REFIID riid
, void **ppvObj
)
2174 PluginHost
*This
= impl_from_IBindHost(iface
);
2175 FIXME("(%p)->(%p %p %p %s %p)\n", This
, pMk
, pBC
, pBSC
, debugstr_guid(riid
), ppvObj
);
2179 static HRESULT WINAPI
PHBindHost_MonikerBindToObject(IBindHost
*iface
, IMoniker
*pMk
, IBindCtx
*pBC
,
2180 IBindStatusCallback
*pBSC
, REFIID riid
, void **ppvObj
)
2182 PluginHost
*This
= impl_from_IBindHost(iface
);
2183 FIXME("(%p)->(%p %p %p %s %p)\n", This
, pMk
, pBC
, pBSC
, debugstr_guid(riid
), ppvObj
);
2187 static const IBindHostVtbl BindHostVtbl
= {
2188 PHBindHost_QueryInterface
,
2191 PHBindHost_CreateMoniker
,
2192 PHBindHost_MonikerBindToStorage
,
2193 PHBindHost_MonikerBindToObject
2196 static inline PluginHost
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2198 return CONTAINING_RECORD(iface
, PluginHost
, IServiceProvider_iface
);
2201 static HRESULT WINAPI
PHServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2203 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2204 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2207 static ULONG WINAPI
PHServiceProvider_AddRef(IServiceProvider
*iface
)
2209 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2210 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
2213 static ULONG WINAPI
PHServiceProvider_Release(IServiceProvider
*iface
)
2215 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2216 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
2219 static HRESULT WINAPI
PHServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2221 PluginHost
*This
= impl_from_IServiceProvider(iface
);
2223 if(IsEqualGUID(guidService
, &SID_SBindHost
)) {
2224 TRACE("SID_SBindHost service\n");
2225 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
2228 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
2230 if(!This
->doc
|| !This
->doc
->outer_window
) {
2232 return E_NOINTERFACE
;
2235 return IServiceProvider_QueryService(&This
->doc
->outer_window
->base
.IServiceProvider_iface
,
2236 guidService
, riid
, ppv
);
2239 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2240 PHServiceProvider_QueryInterface
,
2241 PHServiceProvider_AddRef
,
2242 PHServiceProvider_Release
,
2243 PHServiceProvider_QueryService
2246 static BOOL
parse_classid(const PRUnichar
*classid
, CLSID
*clsid
)
2252 static const PRUnichar clsidW
[] = {'c','l','s','i','d',':'};
2254 if(wcsnicmp(classid
, clsidW
, ARRAY_SIZE(clsidW
)))
2257 ptr
= classid
+ ARRAY_SIZE(clsidW
);
2258 len
= lstrlenW(ptr
);
2261 hres
= CLSIDFromString(ptr
, clsid
);
2262 }else if(len
== 36) {
2266 memcpy(buf
+1, ptr
, len
*sizeof(WCHAR
));
2269 hres
= CLSIDFromString(buf
, clsid
);
2274 return SUCCEEDED(hres
);
2277 static BOOL
get_elem_clsid(nsIDOMElement
*elem
, CLSID
*clsid
)
2279 const PRUnichar
*val
;
2284 nsres
= get_elem_attr_value(elem
, L
"classid", &val_str
, &val
);
2285 if(NS_SUCCEEDED(nsres
)) {
2287 ret
= parse_classid(val
, clsid
);
2288 nsAString_Finish(&val_str
);
2295 IBindStatusCallback IBindStatusCallback_iface
;
2296 IWindowForBindingUI IWindowForBindingUI_iface
;
2300 static inline InstallCallback
*impl_from_IBindStatusCallback(IBindStatusCallback
*iface
)
2302 return CONTAINING_RECORD(iface
, InstallCallback
, IBindStatusCallback_iface
);
2305 static HRESULT WINAPI
InstallCallback_QueryInterface(IBindStatusCallback
*iface
,
2306 REFIID riid
, void **ppv
)
2308 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2310 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2311 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
2312 *ppv
= &This
->IBindStatusCallback_iface
;
2313 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
2314 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
2315 *ppv
= &This
->IBindStatusCallback_iface
;
2316 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
2317 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
2318 *ppv
= &This
->IWindowForBindingUI_iface
;
2320 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
2322 return E_NOINTERFACE
;
2325 IUnknown_AddRef((IUnknown
*)*ppv
);
2329 static ULONG WINAPI
InstallCallback_AddRef(IBindStatusCallback
*iface
)
2331 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2332 LONG ref
= InterlockedIncrement(&This
->ref
);
2334 TRACE("(%p) ref=%ld\n", This
, ref
);
2339 static ULONG WINAPI
InstallCallback_Release(IBindStatusCallback
*iface
)
2341 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2342 LONG ref
= InterlockedIncrement(&This
->ref
);
2344 TRACE("(%p) ref=%ld\n", This
, ref
);
2352 static HRESULT WINAPI
InstallCallback_OnStartBinding(IBindStatusCallback
*iface
,
2353 DWORD dwReserved
, IBinding
*pib
)
2355 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2356 TRACE("(%p)->(%lx %p)\n", This
, dwReserved
, pib
);
2360 static HRESULT WINAPI
InstallCallback_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
2362 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2363 TRACE("(%p)->(%p)\n", This
, pnPriority
);
2367 static HRESULT WINAPI
InstallCallback_OnLowResource(IBindStatusCallback
*iface
, DWORD dwReserved
)
2369 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2370 TRACE("(%p)->(%lx)\n", This
, dwReserved
);
2374 static HRESULT WINAPI
InstallCallback_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
2375 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
2377 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2378 TRACE("(%p)->(%lu %lu %lu %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
, debugstr_w(szStatusText
));
2382 static HRESULT WINAPI
InstallCallback_OnStopBinding(IBindStatusCallback
*iface
,
2383 HRESULT hresult
, LPCWSTR szError
)
2385 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2386 TRACE("(%p)->(%08lx %s)\n", This
, hresult
, debugstr_w(szError
));
2390 static HRESULT WINAPI
InstallCallback_GetBindInfo(IBindStatusCallback
*iface
,
2391 DWORD
* grfBINDF
, BINDINFO
* pbindinfo
)
2393 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2395 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
2397 *grfBINDF
= BINDF_ASYNCHRONOUS
;
2401 static HRESULT WINAPI
InstallCallback_OnDataAvailable(IBindStatusCallback
*iface
, DWORD grfBSCF
,
2402 DWORD dwSize
, FORMATETC
* pformatetc
, STGMEDIUM
* pstgmed
)
2404 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2405 ERR("(%p)\n", This
);
2409 static HRESULT WINAPI
InstallCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
2410 REFIID riid
, IUnknown
* punk
)
2412 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
2413 ERR("(%p)\n", This
);
2417 static IBindStatusCallbackVtbl InstallCallbackVtbl
= {
2418 InstallCallback_QueryInterface
,
2419 InstallCallback_AddRef
,
2420 InstallCallback_Release
,
2421 InstallCallback_OnStartBinding
,
2422 InstallCallback_GetPriority
,
2423 InstallCallback_OnLowResource
,
2424 InstallCallback_OnProgress
,
2425 InstallCallback_OnStopBinding
,
2426 InstallCallback_GetBindInfo
,
2427 InstallCallback_OnDataAvailable
,
2428 InstallCallback_OnObjectAvailable
2431 static inline InstallCallback
*impl_from_IWindowForBindingUI(IWindowForBindingUI
*iface
)
2433 return CONTAINING_RECORD(iface
, InstallCallback
, IWindowForBindingUI_iface
);
2436 static HRESULT WINAPI
WindowForBindingUI_QueryInterface(IWindowForBindingUI
*iface
, REFIID riid
, void **ppv
)
2438 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2439 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
2442 static ULONG WINAPI
WindowForBindingUI_AddRef(IWindowForBindingUI
*iface
)
2444 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2445 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
2448 static ULONG WINAPI
WindowForBindingUI_Release(IWindowForBindingUI
*iface
)
2450 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2451 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
2454 static HRESULT WINAPI
WindowForBindingUI_GetWindow(IWindowForBindingUI
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
2456 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
2457 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
2462 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl
= {
2463 WindowForBindingUI_QueryInterface
,
2464 WindowForBindingUI_AddRef
,
2465 WindowForBindingUI_Release
,
2466 WindowForBindingUI_GetWindow
2474 static struct list install_list
= LIST_INIT(install_list
);
2476 static CRITICAL_SECTION cs_install_list
;
2477 static CRITICAL_SECTION_DEBUG cs_install_list_dbg
=
2479 0, 0, &cs_install_list
,
2480 { &cs_install_list_dbg
.ProcessLocksList
, &cs_install_list_dbg
.ProcessLocksList
},
2481 0, 0, { (DWORD_PTR
)(__FILE__
": install_list") }
2483 static CRITICAL_SECTION cs_install_list
= { &cs_install_list_dbg
, -1, 0, 0, 0, 0 };
2485 static void install_codebase(const WCHAR
*url
)
2487 InstallCallback
*callback
;
2491 callback
= malloc(sizeof(*callback
));
2495 callback
->IBindStatusCallback_iface
.lpVtbl
= &InstallCallbackVtbl
;
2496 callback
->IWindowForBindingUI_iface
.lpVtbl
= &WindowForBindingUIVtbl
;
2499 hres
= CreateAsyncBindCtx(0, &callback
->IBindStatusCallback_iface
, NULL
, &bctx
);
2500 IBindStatusCallback_Release(&callback
->IBindStatusCallback_iface
);
2504 hres
= AsyncInstallDistributionUnit(NULL
, NULL
, NULL
, 0, 0, url
, bctx
, NULL
, 0);
2505 IBindCtx_Release(bctx
);
2507 WARN("FAILED: %08lx\n", hres
);
2510 static void check_codebase(HTMLInnerWindow
*window
, nsIDOMElement
*nselem
)
2512 BOOL is_on_list
= FALSE
;
2513 install_entry_t
*iter
;
2514 const PRUnichar
*val
;
2520 nsres
= get_elem_attr_value(nselem
, L
"codebase", &val_str
, &val
);
2521 if(NS_SUCCEEDED(nsres
)) {
2523 hres
= CoInternetCombineUrlEx(window
->base
.outer_window
->uri
, val
, 0, &uri
, 0);
2527 nsAString_Finish(&val_str
);
2533 EnterCriticalSection(&cs_install_list
);
2535 LIST_FOR_EACH_ENTRY(iter
, &install_list
, install_entry_t
, entry
) {
2538 hres
= IUri_IsEqual(uri
, iter
->uri
, &eq
);
2539 if(SUCCEEDED(hres
) && eq
) {
2540 TRACE("already proceeded\n");
2547 iter
= malloc(sizeof(*iter
));
2552 list_add_tail(&install_list
, &iter
->entry
);
2556 LeaveCriticalSection(&cs_install_list
);
2561 hres
= IUri_GetDisplayUri(uri
, &display_uri
);
2562 if(SUCCEEDED(hres
)) {
2563 install_codebase(display_uri
);
2564 SysFreeString(display_uri
);
2571 static IUnknown
*create_activex_object(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, CLSID
*clsid
)
2573 IClassFactoryEx
*cfex
;
2579 if(!get_elem_clsid(nselem
, clsid
)) {
2580 WARN("Could not determine element CLSID\n");
2584 TRACE("clsid %s\n", debugstr_guid(clsid
));
2587 hres
= IInternetHostSecurityManager_ProcessUrlAction(&doc
->IInternetHostSecurityManager_iface
,
2588 URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
, sizeof(policy
), (BYTE
*)clsid
, sizeof(GUID
), 0, 0);
2589 if(FAILED(hres
) || policy
!= URLPOLICY_ALLOW
) {
2590 WARN("ProcessUrlAction returned %08lx %lx\n", hres
, policy
);
2594 hres
= CoGetClassObject(clsid
, CLSCTX_INPROC_SERVER
|CLSCTX_LOCAL_SERVER
, NULL
, &IID_IClassFactory
, (void**)&cf
);
2595 if(hres
== REGDB_E_CLASSNOTREG
)
2596 check_codebase(doc
->window
, nselem
);
2600 hres
= IClassFactory_QueryInterface(cf
, &IID_IClassFactoryEx
, (void**)&cfex
);
2601 if(SUCCEEDED(hres
)) {
2602 FIXME("Use IClassFactoryEx\n");
2603 IClassFactoryEx_Release(cfex
);
2606 hres
= IClassFactory_CreateInstance(cf
, NULL
, &IID_IUnknown
, (void**)&obj
);
2607 IClassFactory_Release(cf
);
2614 void detach_plugin_host(PluginHost
*host
)
2618 TRACE("%p\n", host
);
2623 if(host
->ip_object
) {
2625 IOleInPlaceObject_UIDeactivate(host
->ip_object
);
2626 IOleInPlaceObject_InPlaceDeactivate(host
->ip_object
);
2629 if(host
->plugin_unk
) {
2630 IOleObject
*ole_obj
;
2632 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
2633 if(SUCCEEDED(hres
)) {
2634 if(!host
->ip_object
)
2635 IOleObject_Close(ole_obj
, OLECLOSE_NOSAVE
);
2636 IOleObject_SetClientSite(ole_obj
, NULL
);
2637 IOleObject_Release(ole_obj
);
2642 IConnectionPointContainer
*cp_container
;
2643 IConnectionPoint
*cp
;
2645 assert(host
->plugin_unk
!= NULL
);
2647 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
2648 if(SUCCEEDED(hres
)) {
2649 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &host
->sink
->iid
, &cp
);
2650 IConnectionPointContainer_Release(cp_container
);
2651 if(SUCCEEDED(hres
)) {
2652 IConnectionPoint_Unadvise(cp
, host
->sink
->cookie
);
2653 IConnectionPoint_Release(cp
);
2657 host
->sink
->host
= NULL
;
2658 IDispatch_Release(&host
->sink
->IDispatch_iface
);
2662 release_plugin_ifaces(host
);
2664 list_remove(&host
->entry
);
2665 list_init(&host
->entry
);
2669 nsIDOMElement
*nselem
= host
->element
->element
.dom_element
;
2670 nsIObjectLoadingContent
*olc
;
2672 host
->element
->plugin_host
= NULL
;
2673 host
->element
= NULL
;
2675 if(NS_SUCCEEDED(nsIDOMElement_QueryInterface(nselem
, &IID_nsIObjectLoadingContent
, (void**)&olc
))) {
2676 nsIObjectLoadingContent_StopPluginInstance(olc
);
2677 nsIObjectLoadingContent_Release(olc
);
2679 IOleClientSite_Release(&host
->IOleClientSite_iface
);
2683 HRESULT
create_plugin_host(HTMLDocumentNode
*doc
, HTMLPluginContainer
*container
)
2689 assert(!container
->plugin_host
);
2691 unk
= create_activex_object(doc
, container
->element
.dom_element
, &clsid
);
2695 host
= calloc(1, sizeof(*host
));
2697 IUnknown_Release(unk
);
2698 return E_OUTOFMEMORY
;
2701 host
->IOleClientSite_iface
.lpVtbl
= &OleClientSiteVtbl
;
2702 host
->IAdviseSinkEx_iface
.lpVtbl
= &AdviseSinkExVtbl
;
2703 host
->IPropertyNotifySink_iface
.lpVtbl
= &PropertyNotifySinkVtbl
;
2704 host
->IDispatch_iface
.lpVtbl
= &DispatchVtbl
;
2705 host
->IOleInPlaceSiteEx_iface
.lpVtbl
= &OleInPlaceSiteExVtbl
;
2706 host
->IOleControlSite_iface
.lpVtbl
= &OleControlSiteVtbl
;
2707 host
->IBindHost_iface
.lpVtbl
= &BindHostVtbl
;
2708 host
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2712 host
->plugin_unk
= unk
;
2713 host
->clsid
= clsid
;
2716 list_add_tail(&doc
->plugin_hosts
, &host
->entry
);
2718 container
->plugin_host
= host
;
2719 host
->element
= container
;
2721 initialize_plugin_object(host
);