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
33 #include "mshtml_private.h"
34 #include "pluginhost.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
40 static BOOL
check_load_safety(PluginHost
*host
)
42 DWORD policy_size
, policy
;
43 struct CONFIRMSAFETY cs
;
47 cs
.clsid
= host
->clsid
;
48 cs
.pUnk
= host
->plugin_unk
;
49 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
51 hres
= IInternetHostSecurityManager_QueryCustomPolicy(&host
->doc
->IInternetHostSecurityManager_iface
,
52 &GUID_CUSTOM_CONFIRMOBJECTSAFETY
, &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
56 policy
= *(DWORD
*)ppolicy
;
57 CoTaskMemFree(ppolicy
);
58 return policy
== URLPOLICY_ALLOW
;
61 static BOOL
check_script_safety(PluginHost
*host
)
63 DISPPARAMS params
= {NULL
,NULL
,0,0};
64 DWORD policy_size
, policy
;
65 struct CONFIRMSAFETY cs
;
71 cs
.clsid
= host
->clsid
;
72 cs
.pUnk
= host
->plugin_unk
;
75 hres
= IInternetHostSecurityManager_QueryCustomPolicy(&host
->doc
->IInternetHostSecurityManager_iface
,
76 &GUID_CUSTOM_CONFIRMOBJECTSAFETY
, &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
80 policy
= *(DWORD
*)ppolicy
;
81 CoTaskMemFree(ppolicy
);
83 if(policy
!= URLPOLICY_ALLOW
)
87 hres
= IDispatch_Invoke(host
->disp
, DISPID_SECURITYCTX
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &v
, NULL
, &err
);
89 FIXME("Handle security ctx %s\n", debugstr_variant(&v
));
96 static void update_readystate(PluginHost
*host
)
98 DISPPARAMS params
= {NULL
,NULL
,0,0};
105 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatchEx
, (void**)&dispex
);
106 if(SUCCEEDED(hres
)) {
107 FIXME("Use IDispatchEx\n");
108 IDispatchEx_Release(dispex
);
111 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
115 hres
= IDispatch_Invoke(disp
, DISPID_READYSTATE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &v
, NULL
, &err
);
116 IDispatch_Release(disp
);
117 if(SUCCEEDED(hres
)) {
118 /* FIXME: make plugin readystate affect document readystate */
119 TRACE("readystate = %s\n", debugstr_variant(&v
));
124 /* FIXME: We shouldn't need this function and we should embed plugin directly in the main document */
125 static void get_pos_rect(PluginHost
*host
, RECT
*ret
)
127 SetRect(ret
, 0, 0, host
->rect
.right
- host
->rect
.left
, host
->rect
.bottom
- host
->rect
.top
);
130 static void load_prop_bag(PluginHost
*host
, IPersistPropertyBag
*persist_prop_bag
)
132 IPropertyBag
*prop_bag
;
135 hres
= create_param_prop_bag(host
->element
->element
.nselem
, &prop_bag
);
139 if(prop_bag
&& !check_load_safety(host
)) {
140 IPropertyBag_Release(prop_bag
);
145 hres
= IPersistPropertyBag_Load(persist_prop_bag
, prop_bag
, NULL
);
146 IPropertyBag_Release(prop_bag
);
148 WARN("Load failed: %08x\n", hres
);
150 hres
= IPersistPropertyBag_InitNew(persist_prop_bag
);
152 WARN("InitNew failed: %08x\n", hres
);
156 static void load_plugin(PluginHost
*host
)
158 IPersistPropertyBag2
*persist_prop_bag2
;
159 IPersistPropertyBag
*persist_prop_bag
;
162 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IPersistPropertyBag2
, (void**)&persist_prop_bag2
);
163 if(SUCCEEDED(hres
)) {
164 FIXME("Use IPersistPropertyBag2 iface\n");
165 IPersistPropertyBag2_Release(persist_prop_bag2
);
169 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IPersistPropertyBag
, (void**)&persist_prop_bag
);
170 if(SUCCEEDED(hres
)) {
171 load_prop_bag(host
, persist_prop_bag
);
172 IPersistPropertyBag_Release(persist_prop_bag
);
176 FIXME("No IPersistPropertyBag iface\n");
179 static void initialize_plugin_object(PluginHost
*host
)
181 IClientSecurity
*client_security
;
182 IQuickActivate
*quick_activate
;
183 IOleObject
*ole_obj
= NULL
;
184 IOleCommandTarget
*cmdtrg
;
185 IViewObjectEx
*view_obj
;
190 /* Note native calls QI on plugin for an undocumented IID and CLSID_HTMLDocument */
192 /* FIXME: call FreezeEvents(TRUE) */
194 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IClientSecurity
, (void**)&client_security
);
195 if(SUCCEEDED(hres
)) {
196 FIXME("Handle IClientSecurity\n");
197 IClientSecurity_Release(client_security
);
201 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IQuickActivate
, (void**)&quick_activate
);
202 if(SUCCEEDED(hres
)) {
203 QACONTAINER container
= {sizeof(container
)};
204 QACONTROL control
= {sizeof(control
)};
206 TRACE("Using IQuickActivate\n");
208 container
.pClientSite
= &host
->IOleClientSite_iface
;
209 container
.dwAmbientFlags
= QACONTAINER_SUPPORTSMNEMONICS
|QACONTAINER_MESSAGEREFLECT
|QACONTAINER_USERMODE
;
210 container
.pAdviseSink
= &host
->IAdviseSinkEx_iface
;
211 container
.pPropertyNotifySink
= &host
->IPropertyNotifySink_iface
;
213 hres
= IQuickActivate_QuickActivate(quick_activate
, &container
, &control
);
214 IQuickActivate_Release(quick_activate
);
216 FIXME("QuickActivate failed: %08x\n", hres
);
220 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
221 if(SUCCEEDED(hres
)) {
222 hres
= IOleObject_GetMiscStatus(ole_obj
, DVASPECT_CONTENT
, &status
);
223 TRACE("GetMiscStatus returned %08x %x\n", hres
, status
);
225 hres
= IOleObject_SetClientSite(ole_obj
, &host
->IOleClientSite_iface
);
226 IOleObject_Release(ole_obj
);
228 FIXME("SetClientSite failed: %08x\n", hres
);
232 TRACE("Plugin does not support IOleObject\n");
239 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IViewObjectEx
, (void**)&view_obj
);
240 if(SUCCEEDED(hres
)) {
241 DWORD view_status
= 0;
243 hres
= IViewObjectEx_SetAdvise(view_obj
, DVASPECT_CONTENT
, 0, (IAdviseSink
*)&host
->IAdviseSinkEx_iface
);
245 WARN("SetAdvise failed: %08x\n", hres
);
247 hres
= IViewObjectEx_GetViewStatus(view_obj
, &view_status
);
248 IViewObjectEx_Release(view_obj
);
249 TRACE("GetViewStatus returned %08x %x\n", hres
, view_status
);
253 update_readystate(host
);
255 /* NOTE: Native QIs for IActiveScript, an undocumented IID, IOleControl and IRunnableObject */
257 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatchEx
, (void**)&dispex
);
258 if(SUCCEEDED(hres
)) {
259 FIXME("Use IDispatchEx\n");
260 host
->disp
= (IDispatch
*)dispex
;
262 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
266 TRACE("no IDispatch iface\n");
269 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
270 if(SUCCEEDED(hres
)) {
271 FIXME("Use IOleCommandTarget\n");
272 IOleCommandTarget_Release(cmdtrg
);
276 static void embed_plugin_object(PluginHost
*host
)
282 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
284 FIXME("Plugin does not support IOleObject\n");
288 get_pos_rect(host
, &rect
);
289 hres
= IOleObject_DoVerb(ole_obj
, OLEIVERB_INPLACEACTIVATE
, NULL
, &host
->IOleClientSite_iface
, 0, host
->hwnd
, &rect
);
290 IOleObject_Release(ole_obj
);
292 WARN("DoVerb failed: %08x\n", hres
);
294 if(host
->ip_object
) {
297 hres
= IOleInPlaceObject_GetWindow(host
->ip_object
, &hwnd
);
299 TRACE("hwnd %p\n", hwnd
);
303 void update_plugin_window(PluginHost
*host
, HWND hwnd
, const RECT
*rect
)
305 BOOL rect_changed
= FALSE
;
307 if(!hwnd
|| (host
->hwnd
&& host
->hwnd
!= hwnd
)) {
308 FIXME("unhandled hwnd\n");
312 TRACE("%p %s\n", hwnd
, wine_dbgstr_rect(rect
));
314 if(memcmp(rect
, &host
->rect
, sizeof(RECT
))) {
321 embed_plugin_object(host
);
324 if(rect_changed
&& host
->ip_object
)
325 IOleInPlaceObject_SetObjectRects(host
->ip_object
, &host
->rect
, &host
->rect
);
328 static void notif_enabled(PluginHost
*plugin_host
)
330 DISPPARAMS args
= {NULL
, NULL
, 0, 0};
336 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IDispatch
, (void**)&disp
);
338 FIXME("Could not get IDispatch iface: %08x\n", hres
);
342 V_VT(&res
) = VT_EMPTY
;
343 hres
= IDispatch_Invoke(disp
, DISPID_ENABLED
, &IID_NULL
, 0/*FIXME*/, DISPATCH_PROPERTYGET
, &args
, &res
, NULL
, &err
);
344 IDispatch_Release(disp
);
345 if(SUCCEEDED(hres
)) {
346 FIXME("Got enabled %s\n", debugstr_variant(&res
));
351 void notif_container_change(HTMLPluginContainer
*plugin_container
, DISPID dispid
)
353 IOleControl
*ole_control
;
356 if(!plugin_container
->plugin_host
|| !plugin_container
->plugin_host
->plugin_unk
)
359 notif_enabled(plugin_container
->plugin_host
);
361 hres
= IUnknown_QueryInterface(plugin_container
->plugin_host
->plugin_unk
, &IID_IOleControl
, (void**)&ole_control
);
362 if(SUCCEEDED(hres
)) {
363 IOleControl_OnAmbientPropertyChange(ole_control
, dispid
);
364 IOleControl_Release(ole_control
);
368 HRESULT
get_plugin_disp(HTMLPluginContainer
*plugin_container
, IDispatch
**ret
)
372 host
= plugin_container
->plugin_host
;
374 ERR("No plugin host\n");
383 if(!check_script_safety(host
)) {
384 FIXME("Insecure object\n");
388 IDispatch_AddRef(host
->disp
);
393 HRESULT
get_plugin_dispid(HTMLPluginContainer
*plugin_container
, WCHAR
*name
, DISPID
*ret
)
400 if(!plugin_container
->plugin_host
) {
401 WARN("no plugin host\n");
402 return DISP_E_UNKNOWNNAME
;
405 disp
= plugin_container
->plugin_host
->disp
;
407 return DISP_E_UNKNOWNNAME
;
409 hres
= IDispatch_GetIDsOfNames(disp
, &IID_NULL
, &name
, 1, 0, &id
);
411 TRACE("no prop %s\n", debugstr_w(name
));
412 return DISP_E_UNKNOWNNAME
;
415 for(i
=0; i
< plugin_container
->props_len
; i
++) {
416 if(id
== plugin_container
->props
[i
]) {
417 *ret
= MSHTML_DISPID_CUSTOM_MIN
+i
;
422 if(!plugin_container
->props
) {
423 plugin_container
->props
= heap_alloc(8*sizeof(DISPID
));
424 if(!plugin_container
->props
)
425 return E_OUTOFMEMORY
;
426 plugin_container
->props_size
= 8;
427 }else if(plugin_container
->props_len
== plugin_container
->props_size
) {
430 new_props
= heap_realloc(plugin_container
->props
, plugin_container
->props_size
*2*sizeof(DISPID
));
432 return E_OUTOFMEMORY
;
434 plugin_container
->props
= new_props
;
435 plugin_container
->props_size
*= 2;
438 plugin_container
->props
[plugin_container
->props_len
] = id
;
439 *ret
= MSHTML_DISPID_CUSTOM_MIN
+plugin_container
->props_len
;
440 plugin_container
->props_len
++;
444 HRESULT
invoke_plugin_prop(HTMLPluginContainer
*plugin_container
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
445 VARIANT
*res
, EXCEPINFO
*ei
)
449 host
= plugin_container
->plugin_host
;
450 if(!host
|| !host
->disp
) {
451 FIXME("Called with no disp\n");
455 if(!check_script_safety(host
)) {
456 FIXME("Insecure object\n");
460 if(id
< MSHTML_DISPID_CUSTOM_MIN
|| id
> MSHTML_DISPID_CUSTOM_MIN
+ plugin_container
->props_len
) {
465 return IDispatch_Invoke(host
->disp
, plugin_container
->props
[id
-MSHTML_DISPID_CUSTOM_MIN
], &IID_NULL
,
466 lcid
, flags
, params
, res
, ei
, NULL
);
475 IDispatch IDispatch_iface
;
485 sink_entry_t
*handlers
;
490 static sink_entry_t
*find_sink_entry(PHEventSink
*sink
, DISPID id
)
494 for(iter
= sink
->handlers
; iter
< sink
->handlers
+sink
->handlers_cnt
; iter
++) {
502 static void add_sink_handler(PHEventSink
*sink
, DISPID id
, IDispatch
*disp
)
504 sink_entry_t
*entry
= find_sink_entry(sink
, id
);
508 IDispatch_Release(entry
->disp
);
510 if(!sink
->handlers_size
) {
511 sink
->handlers
= heap_alloc(4*sizeof(*sink
->handlers
));
514 sink
->handlers_size
= 4;
515 }else if(sink
->handlers_cnt
== sink
->handlers_size
) {
516 sink_entry_t
*new_handlers
;
518 new_handlers
= heap_realloc(sink
->handlers
, 2*sink
->handlers_size
*sizeof(*sink
->handlers
));
521 sink
->handlers
= new_handlers
;
522 sink
->handlers_size
*= 2;
524 entry
= sink
->handlers
+ sink
->handlers_cnt
++;
528 IDispatch_AddRef(disp
);
532 static inline PHEventSink
*PHEventSink_from_IDispatch(IDispatch
*iface
)
534 return CONTAINING_RECORD(iface
, PHEventSink
, IDispatch_iface
);
537 static HRESULT WINAPI
PHEventSink_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
539 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
541 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
542 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
543 *ppv
= &This
->IDispatch_iface
;
544 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
545 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
546 *ppv
= &This
->IDispatch_iface
;
547 }else if(This
->is_dispiface
&& IsEqualGUID(riid
, &This
->iid
)) {
548 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
549 *ppv
= &This
->IDispatch_iface
;
551 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
553 return E_NOINTERFACE
;
556 IUnknown_AddRef((IUnknown
*)*ppv
);
560 static ULONG WINAPI
PHEventSink_AddRef(IDispatch
*iface
)
562 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
563 LONG ref
= InterlockedIncrement(&This
->ref
);
565 TRACE("(%p)\n", This
);
570 static ULONG WINAPI
PHEventSink_Release(IDispatch
*iface
)
572 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
573 LONG ref
= InterlockedDecrement(&This
->ref
);
575 TRACE("(%p)\n", This
);
582 for(i
=0; i
< This
->handlers_cnt
; i
++) {
583 if(This
->handlers
[i
].disp
)
584 IDispatch_Release(This
->handlers
[i
].disp
);
586 heap_free(This
->handlers
);
593 static HRESULT WINAPI
PHEventSink_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
595 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
596 FIXME("(%p)->(%p)\n", This
, pctinfo
);
600 static HRESULT WINAPI
PHEventSink_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
601 LCID lcid
, ITypeInfo
**ppTInfo
)
603 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
604 FIXME("(%p)->(%d %d %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
608 static HRESULT WINAPI
PHEventSink_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
609 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
611 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
612 FIXME("(%p)->(%s %p %u %d %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
616 static HRESULT WINAPI
PHEventSink_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
617 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
619 PHEventSink
*This
= PHEventSink_from_IDispatch(iface
);
624 TRACE("(%p)->(%d %s %d %x %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
), lcid
, wFlags
,
625 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
632 entry
= find_sink_entry(This
, dispIdMember
);
633 if(!entry
|| !entry
->disp
) {
634 WARN("No handler %d\n", dispIdMember
);
636 V_VT(pVarResult
) = VT_EMPTY
;
640 hres
= IDispatch_QueryInterface(entry
->disp
, &IID_IDispatchEx
, (void**)&dispex
);
642 TRACE("(%p) %d >>>\n", This
, entry
->id
);
643 if(SUCCEEDED(hres
)) {
644 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, NULL
);
645 IDispatchEx_Release(dispex
);
647 hres
= IDispatch_Invoke(entry
->disp
, DISPID_VALUE
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
650 TRACE("(%p) %d <<<\n", This
, entry
->id
);
652 WARN("(%p) %d <<< %08x\n", This
, entry
->id
, hres
);
656 static const IDispatchVtbl PHCPDispatchVtbl
= {
657 PHEventSink_QueryInterface
,
660 PHEventSink_GetTypeInfoCount
,
661 PHEventSink_GetTypeInfo
,
662 PHEventSink_GetIDsOfNames
,
666 static PHEventSink
*create_event_sink(PluginHost
*plugin_host
, ITypeInfo
*typeinfo
)
668 IConnectionPointContainer
*cp_container
;
670 IConnectionPoint
*cp
;
676 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &typeattr
);
680 typekind
= typeattr
->typekind
;
681 guid
= typeattr
->guid
;
682 ITypeInfo_ReleaseTypeAttr(typeinfo
, typeattr
);
684 TRACE("guid %s typekind %d\n", debugstr_guid(&guid
), typekind
);
686 if(typekind
!= TKIND_INTERFACE
&& typekind
!= TKIND_DISPATCH
) {
687 WARN("invalid typekind %d\n", typekind
);
691 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
693 WARN("Could not get IConnectionPointContainer iface: %08x\n", hres
);
697 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &guid
, &cp
);
698 IConnectionPointContainer_Release(cp_container
);
700 WARN("Could not find %s connection point\n", debugstr_guid(&guid
));
704 ret
= heap_alloc_zero(sizeof(*ret
));
706 ret
->IDispatch_iface
.lpVtbl
= &PHCPDispatchVtbl
;
708 ret
->host
= plugin_host
;
710 ret
->is_dispiface
= typekind
== TKIND_DISPATCH
;
712 ITypeInfo_AddRef(typeinfo
);
713 ret
->typeinfo
= typeinfo
;
715 hres
= IConnectionPoint_Advise(cp
, (IUnknown
*)&ret
->IDispatch_iface
, &ret
->cookie
);
717 hres
= E_OUTOFMEMORY
;
720 IConnectionPoint_Release(cp
);
722 WARN("Advise failed: %08x\n", hres
);
729 static ITypeInfo
*get_eventiface_info(HTMLPluginContainer
*plugin_container
, ITypeInfo
*class_info
)
731 int impl_types
, i
, impl_flags
;
732 ITypeInfo
*ret
= NULL
;
737 hres
= ITypeInfo_GetTypeAttr(class_info
, &typeattr
);
741 if(typeattr
->typekind
!= TKIND_COCLASS
) {
742 WARN("not coclass\n");
743 ITypeInfo_ReleaseTypeAttr(class_info
, typeattr
);
747 impl_types
= typeattr
->cImplTypes
;
748 ITypeInfo_ReleaseTypeAttr(class_info
, typeattr
);
750 for(i
=0; i
<impl_types
; i
++) {
751 hres
= ITypeInfo_GetImplTypeFlags(class_info
, i
, &impl_flags
);
755 if((impl_flags
& IMPLTYPEFLAG_FSOURCE
)) {
756 if(!(impl_flags
& IMPLTYPEFLAG_FDEFAULT
)) {
757 FIXME("Handle non-default source iface\n");
761 hres
= ITypeInfo_GetRefTypeOfImplType(class_info
, i
, &ref
);
765 hres
= ITypeInfo_GetRefTypeInfo(class_info
, ref
, &ret
);
774 void bind_activex_event(HTMLDocumentNode
*doc
, HTMLPluginContainer
*plugin_container
, WCHAR
*event
, IDispatch
*disp
)
776 PluginHost
*plugin_host
= plugin_container
->plugin_host
;
777 ITypeInfo
*class_info
, *source_info
;
781 TRACE("(%p %p %s %p)\n", doc
, plugin_host
, debugstr_w(event
), disp
);
783 if(!plugin_host
|| !plugin_host
->plugin_unk
) {
784 WARN("detached element %p\n", plugin_host
);
788 if(plugin_host
->sink
) {
789 source_info
= plugin_host
->sink
->typeinfo
;
790 ITypeInfo_AddRef(source_info
);
792 IProvideClassInfo
*provide_ci
;
794 hres
= IUnknown_QueryInterface(plugin_host
->plugin_unk
, &IID_IProvideClassInfo
, (void**)&provide_ci
);
796 FIXME("No IProvideClassInfo, try GetTypeInfo?\n");
800 hres
= IProvideClassInfo_GetClassInfo(provide_ci
, &class_info
);
801 IProvideClassInfo_Release(provide_ci
);
802 if(FAILED(hres
) || !class_info
) {
803 WARN("GetClassInfo failed: %08x\n", hres
);
807 source_info
= get_eventiface_info(plugin_container
, class_info
);
808 ITypeInfo_Release(class_info
);
813 hres
= ITypeInfo_GetIDsOfNames(source_info
, &event
, 1, &id
);
815 WARN("Could not get disp id: %08x\n", hres
);
816 else if(!plugin_host
->sink
)
817 plugin_host
->sink
= create_event_sink(plugin_host
, source_info
);
819 ITypeInfo_Release(source_info
);
820 if(FAILED(hres
) || !plugin_host
->sink
)
823 add_sink_handler(plugin_host
->sink
, id
, disp
);
826 static inline PluginHost
*impl_from_IOleClientSite(IOleClientSite
*iface
)
828 return CONTAINING_RECORD(iface
, PluginHost
, IOleClientSite_iface
);
831 static HRESULT WINAPI
PHClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
833 PluginHost
*This
= impl_from_IOleClientSite(iface
);
835 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
836 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
837 *ppv
= &This
->IOleClientSite_iface
;
838 }else if(IsEqualGUID(&IID_IOleClientSite
, riid
)) {
839 TRACE("(%p)->(IID_IOleClientSite %p)\n", This
, ppv
);
840 *ppv
= &This
->IOleClientSite_iface
;
841 }else if(IsEqualGUID(&IID_IAdviseSink
, riid
)) {
842 TRACE("(%p)->(IID_IAdviseSink %p)\n", This
, ppv
);
843 *ppv
= &This
->IAdviseSinkEx_iface
;
844 }else if(IsEqualGUID(&IID_IAdviseSinkEx
, riid
)) {
845 TRACE("(%p)->(IID_IAdviseSinkEx %p)\n", This
, ppv
);
846 *ppv
= &This
->IAdviseSinkEx_iface
;
847 }else if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
848 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This
, ppv
);
849 *ppv
= &This
->IPropertyNotifySink_iface
;
850 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
851 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
852 *ppv
= &This
->IDispatch_iface
;
853 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
854 TRACE("(%p)->(IID_IOleWindow %p)\n", This
, ppv
);
855 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
856 }else if(IsEqualGUID(&IID_IOleInPlaceSite
, riid
)) {
857 TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This
, ppv
);
858 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
859 }else if(IsEqualGUID(&IID_IOleInPlaceSiteEx
, riid
)) {
860 TRACE("(%p)->(IID_IOleInPlaceSiteEx %p)\n", This
, ppv
);
861 *ppv
= &This
->IOleInPlaceSiteEx_iface
;
862 }else if(IsEqualGUID(&IID_IOleControlSite
, riid
)) {
863 TRACE("(%p)->(IID_IOleControlSite %p)\n", This
, ppv
);
864 *ppv
= &This
->IOleControlSite_iface
;
865 }else if(IsEqualGUID(&IID_IBindHost
, riid
)) {
866 TRACE("(%p)->(IID_IBindHost %p)\n", This
, ppv
);
867 *ppv
= &This
->IBindHost_iface
;
868 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
869 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
870 *ppv
= &This
->IServiceProvider_iface
;
872 WARN("Unsupported interface %s\n", debugstr_guid(riid
));
874 return E_NOINTERFACE
;
877 IUnknown_AddRef((IUnknown
*)*ppv
);
881 static ULONG WINAPI
PHClientSite_AddRef(IOleClientSite
*iface
)
883 PluginHost
*This
= impl_from_IOleClientSite(iface
);
884 LONG ref
= InterlockedIncrement(&This
->ref
);
886 TRACE("(%p) ref=%d\n", This
, ref
);
891 static void release_plugin_ifaces(PluginHost
*This
)
894 IDispatch_Release(This
->disp
);
898 if(This
->ip_object
) {
899 IOleInPlaceObject_Release(This
->ip_object
);
900 This
->ip_object
= NULL
;
903 if(This
->plugin_unk
) {
904 IUnknown
*unk
= This
->plugin_unk
;
907 This
->plugin_unk
= NULL
;
908 ref
= IUnknown_Release(unk
);
910 TRACE("plugin ref = %d\n", ref
);
914 static ULONG WINAPI
PHClientSite_Release(IOleClientSite
*iface
)
916 PluginHost
*This
= impl_from_IOleClientSite(iface
);
917 LONG ref
= InterlockedDecrement(&This
->ref
);
919 TRACE("(%p) ref=%d\n", This
, ref
);
922 release_plugin_ifaces(This
);
924 This
->sink
->host
= NULL
;
925 IDispatch_Release(&This
->sink
->IDispatch_iface
);
928 list_remove(&This
->entry
);
930 This
->element
->plugin_host
= NULL
;
937 static HRESULT WINAPI
PHClientSite_SaveObject(IOleClientSite
*iface
)
939 PluginHost
*This
= impl_from_IOleClientSite(iface
);
940 FIXME("(%p)\n", This
);
944 static HRESULT WINAPI
PHClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
,
945 DWORD dwWhichMoniker
, IMoniker
**ppmk
)
947 PluginHost
*This
= impl_from_IOleClientSite(iface
);
949 TRACE("(%p)->(%d %d %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
951 switch(dwWhichMoniker
) {
952 case OLEWHICHMK_CONTAINER
:
953 if(!This
->doc
|| !This
->doc
->window
|| !This
->doc
->window
->mon
) {
954 FIXME("no moniker\n");
958 *ppmk
= This
->doc
->window
->mon
;
959 IMoniker_AddRef(*ppmk
);
962 FIXME("which %d\n", dwWhichMoniker
);
969 static HRESULT WINAPI
PHClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
971 PluginHost
*This
= impl_from_IOleClientSite(iface
);
973 TRACE("(%p)->(%p)\n", This
, ppContainer
);
976 ERR("Called on detached object\n");
980 *ppContainer
= &This
->doc
->basedoc
.IOleContainer_iface
;
981 IOleContainer_AddRef(*ppContainer
);
985 static HRESULT WINAPI
PHClientSite_ShowObject(IOleClientSite
*iface
)
987 PluginHost
*This
= impl_from_IOleClientSite(iface
);
989 TRACE("(%p)\n", This
);
994 static HRESULT WINAPI
PHClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
996 PluginHost
*This
= impl_from_IOleClientSite(iface
);
997 FIXME("(%p)->(%x)\n", This
, fShow
);
1001 static HRESULT WINAPI
PHClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
1003 PluginHost
*This
= impl_from_IOleClientSite(iface
);
1004 FIXME("(%p)\n", This
);
1008 static const IOleClientSiteVtbl OleClientSiteVtbl
= {
1009 PHClientSite_QueryInterface
,
1010 PHClientSite_AddRef
,
1011 PHClientSite_Release
,
1012 PHClientSite_SaveObject
,
1013 PHClientSite_GetMoniker
,
1014 PHClientSite_GetContainer
,
1015 PHClientSite_ShowObject
,
1016 PHClientSite_OnShowWindow
,
1017 PHClientSite_RequestNewObjectLayout
1020 static inline PluginHost
*impl_from_IAdviseSinkEx(IAdviseSinkEx
*iface
)
1022 return CONTAINING_RECORD(iface
, PluginHost
, IAdviseSinkEx_iface
);
1025 static HRESULT WINAPI
PHAdviseSinkEx_QueryInterface(IAdviseSinkEx
*iface
, REFIID riid
, void **ppv
)
1027 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1028 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1031 static ULONG WINAPI
PHAdviseSinkEx_AddRef(IAdviseSinkEx
*iface
)
1033 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1034 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1037 static ULONG WINAPI
PHAdviseSinkEx_Release(IAdviseSinkEx
*iface
)
1039 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1040 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1043 static void WINAPI
PHAdviseSinkEx_OnDataChange(IAdviseSinkEx
*iface
, FORMATETC
*pFormatetc
, STGMEDIUM
*pStgMedium
)
1045 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1046 FIXME("(%p)->(%p %p)\n", This
, pFormatetc
, pStgMedium
);
1049 static void WINAPI
PHAdviseSinkEx_OnViewChange(IAdviseSinkEx
*iface
, DWORD dwAspect
, LONG lindex
)
1051 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1052 FIXME("(%p)->(%d %d)\n", This
, dwAspect
, lindex
);
1055 static void WINAPI
PHAdviseSinkEx_OnRename(IAdviseSinkEx
*iface
, IMoniker
*pmk
)
1057 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1058 FIXME("(%p)->(%p)\n", This
, pmk
);
1061 static void WINAPI
PHAdviseSinkEx_OnSave(IAdviseSinkEx
*iface
)
1063 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1064 FIXME("(%p)\n", This
);
1067 static void WINAPI
PHAdviseSinkEx_OnClose(IAdviseSinkEx
*iface
)
1069 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1070 FIXME("(%p)\n", This
);
1073 static void WINAPI
PHAdviseSinkEx_OnViewStatusChange(IAdviseSinkEx
*iface
, DWORD dwViewStatus
)
1075 PluginHost
*This
= impl_from_IAdviseSinkEx(iface
);
1076 FIXME("(%p)->(%d)\n", This
, dwViewStatus
);
1079 static const IAdviseSinkExVtbl AdviseSinkExVtbl
= {
1080 PHAdviseSinkEx_QueryInterface
,
1081 PHAdviseSinkEx_AddRef
,
1082 PHAdviseSinkEx_Release
,
1083 PHAdviseSinkEx_OnDataChange
,
1084 PHAdviseSinkEx_OnViewChange
,
1085 PHAdviseSinkEx_OnRename
,
1086 PHAdviseSinkEx_OnSave
,
1087 PHAdviseSinkEx_OnClose
,
1088 PHAdviseSinkEx_OnViewStatusChange
1091 static inline PluginHost
*impl_from_IPropertyNotifySink(IPropertyNotifySink
*iface
)
1093 return CONTAINING_RECORD(iface
, PluginHost
, IPropertyNotifySink_iface
);
1096 static HRESULT WINAPI
PHPropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
, REFIID riid
, void **ppv
)
1098 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1099 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1102 static ULONG WINAPI
PHPropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
1104 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1105 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1108 static ULONG WINAPI
PHPropertyNotifySink_Release(IPropertyNotifySink
*iface
)
1110 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1111 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1114 static HRESULT WINAPI
PHPropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
1116 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1118 TRACE("(%p)->(%d)\n", This
, dispID
);
1121 case DISPID_READYSTATE
:
1122 update_readystate(This
);
1125 FIXME("Unimplemented dispID %d\n", dispID
);
1132 static HRESULT WINAPI
PHPropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1134 PluginHost
*This
= impl_from_IPropertyNotifySink(iface
);
1135 FIXME("(%p)->(%d)\n", This
, dispID
);
1139 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1140 PHPropertyNotifySink_QueryInterface
,
1141 PHPropertyNotifySink_AddRef
,
1142 PHPropertyNotifySink_Release
,
1143 PHPropertyNotifySink_OnChanged
,
1144 PHPropertyNotifySink_OnRequestEdit
1147 static inline PluginHost
*impl_from_IDispatch(IDispatch
*iface
)
1149 return CONTAINING_RECORD(iface
, PluginHost
, IDispatch_iface
);
1152 static HRESULT WINAPI
PHDispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
1154 PluginHost
*This
= impl_from_IDispatch(iface
);
1155 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1158 static ULONG WINAPI
PHDispatch_AddRef(IDispatch
*iface
)
1160 PluginHost
*This
= impl_from_IDispatch(iface
);
1161 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1164 static ULONG WINAPI
PHDispatch_Release(IDispatch
*iface
)
1166 PluginHost
*This
= impl_from_IDispatch(iface
);
1167 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1170 static HRESULT WINAPI
PHDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1172 PluginHost
*This
= impl_from_IDispatch(iface
);
1173 FIXME("(%p)->(%p)\n", This
, pctinfo
);
1177 static HRESULT WINAPI
PHDispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1178 LCID lcid
, ITypeInfo
**ppTInfo
)
1180 PluginHost
*This
= impl_from_IDispatch(iface
);
1181 FIXME("(%p)->(%d %d %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1185 static HRESULT WINAPI
PHDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1186 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1188 PluginHost
*This
= impl_from_IDispatch(iface
);
1189 FIXME("(%p)->(%s %p %d %d %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
1193 static HRESULT WINAPI
PHDispatch_Invoke(IDispatch
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
,
1194 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1196 PluginHost
*This
= impl_from_IDispatch(iface
);
1197 FIXME("(%p)->(%d %x %p %p)\n", This
, dispid
, wFlags
, pDispParams
, pVarResult
);
1201 static const IDispatchVtbl DispatchVtbl
= {
1202 PHDispatch_QueryInterface
,
1205 PHDispatch_GetTypeInfoCount
,
1206 PHDispatch_GetTypeInfo
,
1207 PHDispatch_GetIDsOfNames
,
1211 static inline PluginHost
*impl_from_IOleInPlaceSiteEx(IOleInPlaceSiteEx
*iface
)
1213 return CONTAINING_RECORD(iface
, PluginHost
, IOleInPlaceSiteEx_iface
);
1216 static HRESULT WINAPI
PHInPlaceSite_QueryInterface(IOleInPlaceSiteEx
*iface
, REFIID riid
, void **ppv
)
1218 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1219 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1222 static ULONG WINAPI
PHInPlaceSite_AddRef(IOleInPlaceSiteEx
*iface
)
1224 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1225 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1228 static ULONG WINAPI
PHInPlaceSite_Release(IOleInPlaceSiteEx
*iface
)
1230 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1231 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1234 static HRESULT WINAPI
PHInPlaceSite_GetWindow(IOleInPlaceSiteEx
*iface
, HWND
*phwnd
)
1236 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1238 TRACE("(%p)->(%p)\n", This
, phwnd
);
1240 *phwnd
= This
->hwnd
;
1244 static HRESULT WINAPI
PHInPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx
*iface
, BOOL fEnterMode
)
1246 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1247 FIXME("(%p)->(%x)\n", This
, fEnterMode
);
1251 static HRESULT WINAPI
PHInPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx
*iface
)
1253 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1255 TRACE("(%p)\n", This
);
1260 static HRESULT WINAPI
PHInPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx
*iface
)
1262 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1263 FIXME("(%p)\n", This
);
1267 static HRESULT WINAPI
PHInPlaceSite_OnUIActivate(IOleInPlaceSiteEx
*iface
)
1269 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1271 TRACE("(%p)\n", This
);
1273 if(!This
->plugin_unk
) {
1274 ERR("No plugin object\n");
1275 return E_UNEXPECTED
;
1278 This
->ui_active
= TRUE
;
1280 notif_enabled(This
);
1284 static HRESULT WINAPI
PHInPlaceSite_GetWindowContext(IOleInPlaceSiteEx
*iface
,
1285 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, RECT
*lprcPosRect
,
1286 RECT
*lprcClipRect
, OLEINPLACEFRAMEINFO
*frame_info
)
1288 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1289 IOleInPlaceUIWindow
*ip_window
;
1290 IOleInPlaceFrame
*ip_frame
;
1294 TRACE("(%p)->(%p %p %p %p %p)\n", This
, ppFrame
, ppDoc
, lprcPosRect
, lprcClipRect
, frame_info
);
1296 if(!This
->doc
|| !This
->doc
->basedoc
.doc_obj
|| !This
->doc
->basedoc
.doc_obj
->ipsite
) {
1297 FIXME("No ipsite\n");
1298 return E_UNEXPECTED
;
1301 hres
= IOleInPlaceSite_GetWindowContext(This
->doc
->basedoc
.doc_obj
->ipsite
, &ip_frame
, &ip_window
, &pr
, &cr
, frame_info
);
1303 WARN("GetWindowContext failed: %08x\n", hres
);
1308 IOleInPlaceUIWindow_Release(ip_window
);
1310 IOleInPlaceFrame_Release(ip_frame
);
1312 hres
= create_ip_frame(&ip_frame
);
1316 hres
= create_ip_window(ppDoc
);
1318 IOleInPlaceFrame_Release(ip_frame
);
1322 *ppFrame
= ip_frame
;
1323 *lprcPosRect
= This
->rect
;
1324 *lprcClipRect
= This
->rect
;
1328 static HRESULT WINAPI
PHInPlaceSite_Scroll(IOleInPlaceSiteEx
*iface
, SIZE scrollExtent
)
1330 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1331 FIXME("(%p)->({%d %d})\n", This
, scrollExtent
.cx
, scrollExtent
.cy
);
1335 static HRESULT WINAPI
PHInPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx
*iface
, BOOL fUndoable
)
1337 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1338 FIXME("(%p)->(%x)\n", This
, fUndoable
);
1342 static HRESULT WINAPI
PHInPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx
*iface
)
1344 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1346 TRACE("(%p)\n", This
);
1348 if(This
->ip_object
) {
1349 IOleInPlaceObject_Release(This
->ip_object
);
1350 This
->ip_object
= NULL
;
1356 static HRESULT WINAPI
PHInPlaceSite_DiscardUndoState(IOleInPlaceSiteEx
*iface
)
1358 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1359 FIXME("(%p)\n", This
);
1363 static HRESULT WINAPI
PHInPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx
*iface
)
1365 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1366 FIXME("(%p)\n", This
);
1370 static HRESULT WINAPI
PHInPlaceSite_OnPosRectChange(IOleInPlaceSiteEx
*iface
, LPCRECT lprcPosRect
)
1372 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1373 FIXME("(%p)->(%p)\n", This
, lprcPosRect
);
1377 static HRESULT WINAPI
PHInPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx
*iface
, BOOL
*pfNoRedraw
, DWORD dwFlags
)
1379 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1383 TRACE("(%p)->(%p %x)\n", This
, pfNoRedraw
, dwFlags
);
1388 hres
= IUnknown_QueryInterface(This
->plugin_unk
, &IID_IOleInPlaceObject
, (void**)&This
->ip_object
);
1392 hres
= IOleInPlaceObject_GetWindow(This
->ip_object
, &hwnd
);
1394 FIXME("Use hwnd %p\n", hwnd
);
1396 *pfNoRedraw
= FALSE
;
1400 static HRESULT WINAPI
PHInPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx
*iface
, BOOL fNoRedraw
)
1402 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1403 FIXME("(%p)->(%x)\n", This
, fNoRedraw
);
1407 static HRESULT WINAPI
PHInPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx
*iface
)
1409 PluginHost
*This
= impl_from_IOleInPlaceSiteEx(iface
);
1410 FIXME("(%p)\n", This
);
1414 static const IOleInPlaceSiteExVtbl OleInPlaceSiteExVtbl
= {
1415 PHInPlaceSite_QueryInterface
,
1416 PHInPlaceSite_AddRef
,
1417 PHInPlaceSite_Release
,
1418 PHInPlaceSite_GetWindow
,
1419 PHInPlaceSite_ContextSensitiveHelp
,
1420 PHInPlaceSite_CanInPlaceActivate
,
1421 PHInPlaceSite_OnInPlaceActivate
,
1422 PHInPlaceSite_OnUIActivate
,
1423 PHInPlaceSite_GetWindowContext
,
1424 PHInPlaceSite_Scroll
,
1425 PHInPlaceSite_OnUIDeactivate
,
1426 PHInPlaceSite_OnInPlaceDeactivate
,
1427 PHInPlaceSite_DiscardUndoState
,
1428 PHInPlaceSite_DeactivateAndUndo
,
1429 PHInPlaceSite_OnPosRectChange
,
1430 PHInPlaceSiteEx_OnInPlaceActivateEx
,
1431 PHInPlaceSiteEx_OnInPlaceDeactivateEx
,
1432 PHInPlaceSiteEx_RequestUIActivate
1435 static inline PluginHost
*impl_from_IOleControlSite(IOleControlSite
*iface
)
1437 return CONTAINING_RECORD(iface
, PluginHost
, IOleControlSite_iface
);
1440 static HRESULT WINAPI
PHControlSite_QueryInterface(IOleControlSite
*iface
, REFIID riid
, void **ppv
)
1442 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1443 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1446 static ULONG WINAPI
PHControlSite_AddRef(IOleControlSite
*iface
)
1448 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1449 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1452 static ULONG WINAPI
PHControlSite_Release(IOleControlSite
*iface
)
1454 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1455 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1458 static HRESULT WINAPI
PHControlSite_OnControlInfoChanged(IOleControlSite
*iface
)
1460 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1461 FIXME("(%p)\n", This
);
1465 static HRESULT WINAPI
PHControlSite_LockInPlaceActive(IOleControlSite
*iface
, BOOL fLock
)
1467 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1468 FIXME("(%p)->(%x)\n", This
, fLock
);
1472 static HRESULT WINAPI
PHControlSite_GetExtendedControl(IOleControlSite
*iface
, IDispatch
**ppDisp
)
1474 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1475 FIXME("(%p)->(%p)\n", This
, ppDisp
);
1479 static HRESULT WINAPI
PHControlSite_TransformCoords(IOleControlSite
*iface
, POINTL
*pPtlHimetric
, POINTF
*pPtfContainer
, DWORD dwFlags
)
1481 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1482 FIXME("(%p)->(%p %p %x)\n", This
, pPtlHimetric
, pPtfContainer
, dwFlags
);
1486 static HRESULT WINAPI
PHControlSite_TranslateAccelerator(IOleControlSite
*iface
, MSG
*pMsg
, DWORD grfModifiers
)
1488 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1489 FIXME("(%p)->(%x)\n", This
, grfModifiers
);
1493 static HRESULT WINAPI
PHControlSite_OnFocus(IOleControlSite
*iface
, BOOL fGotFocus
)
1495 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1496 FIXME("(%p)->(%x)\n", This
, fGotFocus
);
1500 static HRESULT WINAPI
PHControlSite_ShowPropertyFrame(IOleControlSite
*iface
)
1502 PluginHost
*This
= impl_from_IOleControlSite(iface
);
1503 FIXME("(%p)\n", This
);
1507 static const IOleControlSiteVtbl OleControlSiteVtbl
= {
1508 PHControlSite_QueryInterface
,
1509 PHControlSite_AddRef
,
1510 PHControlSite_Release
,
1511 PHControlSite_OnControlInfoChanged
,
1512 PHControlSite_LockInPlaceActive
,
1513 PHControlSite_GetExtendedControl
,
1514 PHControlSite_TransformCoords
,
1515 PHControlSite_TranslateAccelerator
,
1516 PHControlSite_OnFocus
,
1517 PHControlSite_ShowPropertyFrame
1520 static inline PluginHost
*impl_from_IBindHost(IBindHost
*iface
)
1522 return CONTAINING_RECORD(iface
, PluginHost
, IBindHost_iface
);
1525 static HRESULT WINAPI
PHBindHost_QueryInterface(IBindHost
*iface
, REFIID riid
, void **ppv
)
1527 PluginHost
*This
= impl_from_IBindHost(iface
);
1528 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1531 static ULONG WINAPI
PHBindHost_AddRef(IBindHost
*iface
)
1533 PluginHost
*This
= impl_from_IBindHost(iface
);
1534 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1537 static ULONG WINAPI
PHBindHost_Release(IBindHost
*iface
)
1539 PluginHost
*This
= impl_from_IBindHost(iface
);
1540 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1543 static HRESULT WINAPI
PHBindHost_CreateMoniker(IBindHost
*iface
, LPOLESTR szName
, IBindCtx
*pBC
, IMoniker
**ppmk
, DWORD dwReserved
)
1545 PluginHost
*This
= impl_from_IBindHost(iface
);
1547 TRACE("(%p)->(%s %p %p %x)\n", This
, debugstr_w(szName
), pBC
, ppmk
, dwReserved
);
1549 if(!This
->doc
|| !This
->doc
->window
|| !This
->doc
->window
->mon
) {
1550 FIXME("no moniker\n");
1551 return E_UNEXPECTED
;
1554 return CreateURLMoniker(This
->doc
->window
->mon
, szName
, ppmk
);
1557 static HRESULT WINAPI
PHBindHost_MonikerBindToStorage(IBindHost
*iface
, IMoniker
*pMk
, IBindCtx
*pBC
,
1558 IBindStatusCallback
*pBSC
, REFIID riid
, void **ppvObj
)
1560 PluginHost
*This
= impl_from_IBindHost(iface
);
1561 FIXME("(%p)->(%p %p %p %s %p)\n", This
, pMk
, pBC
, pBSC
, debugstr_guid(riid
), ppvObj
);
1565 static HRESULT WINAPI
PHBindHost_MonikerBindToObject(IBindHost
*iface
, IMoniker
*pMk
, IBindCtx
*pBC
,
1566 IBindStatusCallback
*pBSC
, REFIID riid
, void **ppvObj
)
1568 PluginHost
*This
= impl_from_IBindHost(iface
);
1569 FIXME("(%p)->(%p %p %p %s %p)\n", This
, pMk
, pBC
, pBSC
, debugstr_guid(riid
), ppvObj
);
1573 static const IBindHostVtbl BindHostVtbl
= {
1574 PHBindHost_QueryInterface
,
1577 PHBindHost_CreateMoniker
,
1578 PHBindHost_MonikerBindToStorage
,
1579 PHBindHost_MonikerBindToObject
1582 static inline PluginHost
*impl_from_IServiceProvider(IServiceProvider
*iface
)
1584 return CONTAINING_RECORD(iface
, PluginHost
, IServiceProvider_iface
);
1587 static HRESULT WINAPI
PHServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
1589 PluginHost
*This
= impl_from_IServiceProvider(iface
);
1590 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1593 static ULONG WINAPI
PHServiceProvider_AddRef(IServiceProvider
*iface
)
1595 PluginHost
*This
= impl_from_IServiceProvider(iface
);
1596 return IOleClientSite_AddRef(&This
->IOleClientSite_iface
);
1599 static ULONG WINAPI
PHServiceProvider_Release(IServiceProvider
*iface
)
1601 PluginHost
*This
= impl_from_IServiceProvider(iface
);
1602 return IOleClientSite_Release(&This
->IOleClientSite_iface
);
1605 static HRESULT WINAPI
PHServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
1607 PluginHost
*This
= impl_from_IServiceProvider(iface
);
1609 if(IsEqualGUID(guidService
, &SID_SBindHost
)) {
1610 TRACE("SID_SBindHost service\n");
1611 return IOleClientSite_QueryInterface(&This
->IOleClientSite_iface
, riid
, ppv
);
1614 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
1616 if(!This
->doc
|| !This
->doc
->basedoc
.window
) {
1618 return E_NOINTERFACE
;
1621 return IServiceProvider_QueryService(&This
->doc
->basedoc
.window
->base
.IServiceProvider_iface
,
1622 guidService
, riid
, ppv
);
1625 static const IServiceProviderVtbl ServiceProviderVtbl
= {
1626 PHServiceProvider_QueryInterface
,
1627 PHServiceProvider_AddRef
,
1628 PHServiceProvider_Release
,
1629 PHServiceProvider_QueryService
1632 static BOOL
parse_classid(const PRUnichar
*classid
, CLSID
*clsid
)
1638 static const PRUnichar clsidW
[] = {'c','l','s','i','d',':'};
1640 if(strncmpiW(classid
, clsidW
, sizeof(clsidW
)/sizeof(WCHAR
)))
1643 ptr
= classid
+ sizeof(clsidW
)/sizeof(WCHAR
);
1647 hres
= CLSIDFromString(ptr
, clsid
);
1648 }else if(len
== 36) {
1652 memcpy(buf
+1, ptr
, len
*sizeof(WCHAR
));
1655 hres
= CLSIDFromString(buf
, clsid
);
1660 return SUCCEEDED(hres
);
1663 static BOOL
get_elem_clsid(nsIDOMHTMLElement
*elem
, CLSID
*clsid
)
1665 const PRUnichar
*val
;
1670 static const PRUnichar classidW
[] = {'c','l','a','s','s','i','d',0};
1672 nsres
= get_elem_attr_value(elem
, classidW
, &val_str
, &val
);
1673 if(NS_SUCCEEDED(nsres
)) {
1675 ret
= parse_classid(val
, clsid
);
1676 nsAString_Finish(&val_str
);
1683 IBindStatusCallback IBindStatusCallback_iface
;
1684 IWindowForBindingUI IWindowForBindingUI_iface
;
1688 static inline InstallCallback
*impl_from_IBindStatusCallback(IBindStatusCallback
*iface
)
1690 return CONTAINING_RECORD(iface
, InstallCallback
, IBindStatusCallback_iface
);
1693 static HRESULT WINAPI
InstallCallback_QueryInterface(IBindStatusCallback
*iface
,
1694 REFIID riid
, void **ppv
)
1696 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1698 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1699 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1700 *ppv
= &This
->IBindStatusCallback_iface
;
1701 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
1702 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
1703 *ppv
= &This
->IBindStatusCallback_iface
;
1704 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
1705 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
1706 *ppv
= &This
->IWindowForBindingUI_iface
;
1708 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1710 return E_NOINTERFACE
;
1713 IUnknown_AddRef((IUnknown
*)*ppv
);
1717 static ULONG WINAPI
InstallCallback_AddRef(IBindStatusCallback
*iface
)
1719 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1720 LONG ref
= InterlockedIncrement(&This
->ref
);
1722 TRACE("(%p) ref=%d\n", This
, ref
);
1727 static ULONG WINAPI
InstallCallback_Release(IBindStatusCallback
*iface
)
1729 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1730 LONG ref
= InterlockedIncrement(&This
->ref
);
1732 TRACE("(%p) ref=%d\n", This
, ref
);
1740 static HRESULT WINAPI
InstallCallback_OnStartBinding(IBindStatusCallback
*iface
,
1741 DWORD dwReserved
, IBinding
*pib
)
1743 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1744 TRACE("(%p)->(%x %p)\n", This
, dwReserved
, pib
);
1748 static HRESULT WINAPI
InstallCallback_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
1750 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1751 TRACE("(%p)->(%p)\n", This
, pnPriority
);
1755 static HRESULT WINAPI
InstallCallback_OnLowResource(IBindStatusCallback
*iface
, DWORD dwReserved
)
1757 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1758 TRACE("(%p)->(%x)\n", This
, dwReserved
);
1762 static HRESULT WINAPI
InstallCallback_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
1763 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
1765 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1766 TRACE("(%p)->(%u %u %u %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
, debugstr_w(szStatusText
));
1770 static HRESULT WINAPI
InstallCallback_OnStopBinding(IBindStatusCallback
*iface
,
1771 HRESULT hresult
, LPCWSTR szError
)
1773 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1774 TRACE("(%p)->(%08x %s)\n", This
, hresult
, debugstr_w(szError
));
1778 static HRESULT WINAPI
InstallCallback_GetBindInfo(IBindStatusCallback
*iface
,
1779 DWORD
* grfBINDF
, BINDINFO
* pbindinfo
)
1781 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1783 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
1785 *grfBINDF
= BINDF_ASYNCHRONOUS
;
1789 static HRESULT WINAPI
InstallCallback_OnDataAvailable(IBindStatusCallback
*iface
, DWORD grfBSCF
,
1790 DWORD dwSize
, FORMATETC
* pformatetc
, STGMEDIUM
* pstgmed
)
1792 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1793 ERR("(%p)\n", This
);
1797 static HRESULT WINAPI
InstallCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
1798 REFIID riid
, IUnknown
* punk
)
1800 InstallCallback
*This
= impl_from_IBindStatusCallback(iface
);
1801 ERR("(%p)\n", This
);
1805 static IBindStatusCallbackVtbl InstallCallbackVtbl
= {
1806 InstallCallback_QueryInterface
,
1807 InstallCallback_AddRef
,
1808 InstallCallback_Release
,
1809 InstallCallback_OnStartBinding
,
1810 InstallCallback_GetPriority
,
1811 InstallCallback_OnLowResource
,
1812 InstallCallback_OnProgress
,
1813 InstallCallback_OnStopBinding
,
1814 InstallCallback_GetBindInfo
,
1815 InstallCallback_OnDataAvailable
,
1816 InstallCallback_OnObjectAvailable
1819 static inline InstallCallback
*impl_from_IWindowForBindingUI(IWindowForBindingUI
*iface
)
1821 return CONTAINING_RECORD(iface
, InstallCallback
, IWindowForBindingUI_iface
);
1824 static HRESULT WINAPI
WindowForBindingUI_QueryInterface(IWindowForBindingUI
*iface
, REFIID riid
, void **ppv
)
1826 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
1827 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
1830 static ULONG WINAPI
WindowForBindingUI_AddRef(IWindowForBindingUI
*iface
)
1832 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
1833 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
1836 static ULONG WINAPI
WindowForBindingUI_Release(IWindowForBindingUI
*iface
)
1838 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
1839 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
1842 static HRESULT WINAPI
WindowForBindingUI_GetWindow(IWindowForBindingUI
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
1844 InstallCallback
*This
= impl_from_IWindowForBindingUI(iface
);
1845 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
1850 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl
= {
1851 WindowForBindingUI_QueryInterface
,
1852 WindowForBindingUI_AddRef
,
1853 WindowForBindingUI_Release
,
1854 WindowForBindingUI_GetWindow
1862 static struct list install_list
= LIST_INIT(install_list
);
1864 static CRITICAL_SECTION cs_install_list
;
1865 static CRITICAL_SECTION_DEBUG cs_install_list_dbg
=
1867 0, 0, &cs_install_list
,
1868 { &cs_install_list_dbg
.ProcessLocksList
, &cs_install_list_dbg
.ProcessLocksList
},
1869 0, 0, { (DWORD_PTR
)(__FILE__
": install_list") }
1871 static CRITICAL_SECTION cs_install_list
= { &cs_install_list_dbg
, -1, 0, 0, 0, 0 };
1873 static void install_codebase(const WCHAR
*url
)
1875 InstallCallback
*callback
;
1879 callback
= heap_alloc(sizeof(*callback
));
1883 callback
->IBindStatusCallback_iface
.lpVtbl
= &InstallCallbackVtbl
;
1884 callback
->IWindowForBindingUI_iface
.lpVtbl
= &WindowForBindingUIVtbl
;
1887 hres
= CreateAsyncBindCtx(0, &callback
->IBindStatusCallback_iface
, NULL
, &bctx
);
1888 IBindStatusCallback_Release(&callback
->IBindStatusCallback_iface
);
1892 hres
= AsyncInstallDistributionUnit(NULL
, NULL
, NULL
, 0, 0, url
, bctx
, NULL
, 0);
1893 IBindCtx_Release(bctx
);
1895 WARN("FAILED: %08x\n", hres
);
1898 static void check_codebase(HTMLInnerWindow
*window
, nsIDOMHTMLElement
*nselem
)
1900 BOOL is_on_list
= FALSE
;
1901 install_entry_t
*iter
;
1902 const PRUnichar
*val
;
1908 static const PRUnichar codebaseW
[] = {'c','o','d','e','b','a','s','e',0};
1910 nsres
= get_elem_attr_value(nselem
, codebaseW
, &val_str
, &val
);
1911 if(NS_SUCCEEDED(nsres
)) {
1913 hres
= CoInternetCombineUrlEx(window
->base
.outer_window
->uri
, val
, 0, &uri
, 0);
1917 nsAString_Finish(&val_str
);
1923 EnterCriticalSection(&cs_install_list
);
1925 LIST_FOR_EACH_ENTRY(iter
, &install_list
, install_entry_t
, entry
) {
1928 hres
= IUri_IsEqual(uri
, iter
->uri
, &eq
);
1929 if(SUCCEEDED(hres
) && eq
) {
1930 TRACE("already proceeded\n");
1937 iter
= heap_alloc(sizeof(*iter
));
1942 list_add_tail(&install_list
, &iter
->entry
);
1946 LeaveCriticalSection(&cs_install_list
);
1951 hres
= IUri_GetDisplayUri(uri
, &display_uri
);
1952 if(SUCCEEDED(hres
)) {
1953 install_codebase(display_uri
);
1954 SysFreeString(display_uri
);
1961 static IUnknown
*create_activex_object(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, CLSID
*clsid
)
1963 IClassFactoryEx
*cfex
;
1969 if(!get_elem_clsid(nselem
, clsid
)) {
1970 WARN("Could not determine element CLSID\n");
1974 TRACE("clsid %s\n", debugstr_guid(clsid
));
1977 hres
= IInternetHostSecurityManager_ProcessUrlAction(&doc
->IInternetHostSecurityManager_iface
,
1978 URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
, sizeof(policy
), (BYTE
*)clsid
, sizeof(GUID
), 0, 0);
1979 if(FAILED(hres
) || policy
!= URLPOLICY_ALLOW
) {
1980 WARN("ProcessUrlAction returned %08x %x\n", hres
, policy
);
1984 hres
= CoGetClassObject(clsid
, CLSCTX_INPROC_SERVER
|CLSCTX_LOCAL_SERVER
, NULL
, &IID_IClassFactory
, (void**)&cf
);
1985 if(hres
== REGDB_E_CLASSNOTREG
)
1986 check_codebase(doc
->window
, nselem
);
1990 hres
= IClassFactory_QueryInterface(cf
, &IID_IClassFactoryEx
, (void**)&cfex
);
1991 if(SUCCEEDED(hres
)) {
1992 FIXME("Use IClassFactoryEx\n");
1993 IClassFactoryEx_Release(cfex
);
1996 hres
= IClassFactory_CreateInstance(cf
, NULL
, &IID_IUnknown
, (void**)&obj
);
1997 IClassFactory_Release(cf
);
2004 void detach_plugin_host(PluginHost
*host
)
2008 TRACE("%p\n", host
);
2013 if(host
->ip_object
) {
2015 IOleInPlaceObject_UIDeactivate(host
->ip_object
);
2016 IOleInPlaceObject_InPlaceDeactivate(host
->ip_object
);
2019 if(host
->plugin_unk
) {
2020 IOleObject
*ole_obj
;
2022 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IOleObject
, (void**)&ole_obj
);
2023 if(SUCCEEDED(hres
)) {
2024 if(!host
->ip_object
)
2025 IOleObject_Close(ole_obj
, OLECLOSE_NOSAVE
);
2026 IOleObject_SetClientSite(ole_obj
, NULL
);
2027 IOleObject_Release(ole_obj
);
2032 IConnectionPointContainer
*cp_container
;
2033 IConnectionPoint
*cp
;
2035 assert(host
->plugin_unk
!= NULL
);
2037 hres
= IUnknown_QueryInterface(host
->plugin_unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
2038 if(SUCCEEDED(hres
)) {
2039 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &host
->sink
->iid
, &cp
);
2040 IConnectionPointContainer_Release(cp_container
);
2041 if(SUCCEEDED(hres
)) {
2042 IConnectionPoint_Unadvise(cp
, host
->sink
->cookie
);
2043 IConnectionPoint_Release(cp
);
2047 host
->sink
->host
= NULL
;
2048 IDispatch_Release(&host
->sink
->IDispatch_iface
);
2052 release_plugin_ifaces(host
);
2055 host
->element
->plugin_host
= NULL
;
2056 host
->element
= NULL
;
2059 list_remove(&host
->entry
);
2060 list_init(&host
->entry
);
2064 HRESULT
create_plugin_host(HTMLDocumentNode
*doc
, HTMLPluginContainer
*container
)
2070 assert(!container
->plugin_host
);
2072 unk
= create_activex_object(doc
, container
->element
.nselem
, &clsid
);
2076 host
= heap_alloc_zero(sizeof(*host
));
2078 IUnknown_Release(unk
);
2079 return E_OUTOFMEMORY
;
2082 host
->IOleClientSite_iface
.lpVtbl
= &OleClientSiteVtbl
;
2083 host
->IAdviseSinkEx_iface
.lpVtbl
= &AdviseSinkExVtbl
;
2084 host
->IPropertyNotifySink_iface
.lpVtbl
= &PropertyNotifySinkVtbl
;
2085 host
->IDispatch_iface
.lpVtbl
= &DispatchVtbl
;
2086 host
->IOleInPlaceSiteEx_iface
.lpVtbl
= &OleInPlaceSiteExVtbl
;
2087 host
->IOleControlSite_iface
.lpVtbl
= &OleControlSiteVtbl
;
2088 host
->IBindHost_iface
.lpVtbl
= &BindHostVtbl
;
2089 host
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2093 host
->plugin_unk
= unk
;
2094 host
->clsid
= clsid
;
2097 list_add_tail(&doc
->plugin_hosts
, &host
->entry
);
2099 container
->plugin_host
= host
;
2100 host
->element
= container
;
2102 initialize_plugin_object(host
);