2 * Copyright 2005-2006 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
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
29 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
31 #define DOCHOST_DOCCANNAVIGATE 0
33 /* Undocumented notification, see mshtml tests */
34 #define CMDID_EXPLORER_UPDATEHISTORY 38
36 static ATOM doc_view_atom = 0;
38 void push_dochost_task(DocHost *This, task_header_t *task, task_proc_t proc, task_destr_t destr, BOOL send)
45 is_empty = list_empty(&This->task_queue);
46 list_add_tail(&This->task_queue, &task->entry);
49 SendMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, 0);
51 PostMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, 0);
54 LRESULT process_dochost_tasks(DocHost *This)
58 while(!list_empty(&This->task_queue)) {
59 task = LIST_ENTRY(This->task_queue.next, task_header_t, entry);
60 list_remove(&task->entry);
62 task->proc(This, task);
69 void abort_dochost_tasks(DocHost *This, task_proc_t proc)
71 task_header_t *task, *cursor;
73 LIST_FOR_EACH_ENTRY_SAFE(task, cursor, &This->task_queue, task_header_t, entry) {
74 if(proc && proc != task->proc)
77 list_remove(&task->entry);
82 static void notif_complete(DocHost *This, DISPID dispid)
84 DISPPARAMS dispparams;
89 dispparams.cNamedArgs = 0;
90 dispparams.rgdispidNamedArgs = NULL;
91 dispparams.rgvarg = params;
93 V_VT(params) = (VT_BYREF|VT_VARIANT);
94 V_BYREF(params) = &url;
96 V_VT(params+1) = VT_DISPATCH;
97 V_DISPATCH(params+1) = (IDispatch*)This->wb;
100 V_BSTR(&url) = SysAllocString(This->url);
102 TRACE("%d >>>\n", dispid);
103 call_sink(This->cps.wbe2, dispid, &dispparams);
104 TRACE("%d <<<\n", dispid);
106 SysFreeString(V_BSTR(&url));
107 This->busy = VARIANT_FALSE;
110 static void object_available(DocHost *This)
115 TRACE("(%p)\n", This);
117 if(!This->document) {
118 WARN("document == NULL\n");
122 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
124 FIXME("Could not get IHlinkTarget interface\n");
128 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
129 IHlinkTarget_Release(hlink);
131 FIXME("Navigate failed\n");
134 static HRESULT get_doc_ready_state(DocHost *This, READYSTATE *ret)
136 DISPPARAMS dp = {NULL,NULL,0,0};
142 hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&disp);
146 hres = IDispatch_Invoke(disp, DISPID_READYSTATE, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
147 &dp, &var, &ei, NULL);
148 IDispatch_Release(disp);
150 WARN("Invoke(DISPID_READYSTATE failed: %08x\n", hres);
154 if(V_VT(&var) != VT_I4) {
155 WARN("V_VT(var) = %d\n", V_VT(&var));
164 static void advise_prop_notif(DocHost *This, BOOL set)
166 IConnectionPointContainer *cp_container;
167 IConnectionPoint *cp;
170 hres = IUnknown_QueryInterface(This->document, &IID_IConnectionPointContainer, (void**)&cp_container);
174 hres = IConnectionPointContainer_FindConnectionPoint(cp_container, &IID_IPropertyNotifySink, &cp);
175 IConnectionPointContainer_Release(cp_container);
180 hres = IConnectionPoint_Advise(cp, (IUnknown*)&This->IPropertyNotifySink_iface, &This->prop_notif_cookie);
182 hres = IConnectionPoint_Unadvise(cp, This->prop_notif_cookie);
183 IConnectionPoint_Release(cp);
186 This->is_prop_notif = set;
189 void set_doc_state(DocHost *This, READYSTATE doc_state)
191 This->doc_state = doc_state;
192 if(doc_state > This->ready_state)
193 This->ready_state = doc_state;
196 static void update_ready_state(DocHost *This, READYSTATE ready_state)
198 if(ready_state > READYSTATE_LOADING && This->doc_state <= READYSTATE_LOADING && !This->browser_service /* FIXME */)
199 notif_complete(This, DISPID_NAVIGATECOMPLETE2);
201 if(ready_state == READYSTATE_COMPLETE && This->doc_state < READYSTATE_COMPLETE) {
202 set_doc_state(This, READYSTATE_COMPLETE);
203 if(!This->browser_service) /* FIXME: Not fully correct */
204 notif_complete(This, DISPID_DOCUMENTCOMPLETE);
206 set_doc_state(This, ready_state);
211 task_header_t header;
213 READYSTATE ready_state;
214 } ready_state_task_t;
216 static void ready_state_task_destr(task_header_t *_task)
218 ready_state_task_t *task = (ready_state_task_t*)_task;
220 IUnknown_Release(task->doc);
224 static void ready_state_proc(DocHost *This, task_header_t *_task)
226 ready_state_task_t *task = (ready_state_task_t*)_task;
228 if(task->doc == This->document)
229 update_ready_state(This, task->ready_state);
232 static void push_ready_state_task(DocHost *This, READYSTATE ready_state)
234 ready_state_task_t *task = heap_alloc(sizeof(ready_state_task_t));
236 IUnknown_AddRef(This->document);
237 task->doc = This->document;
238 task->ready_state = ready_state;
240 push_dochost_task(This, &task->header, ready_state_proc, ready_state_task_destr, FALSE);
243 static void object_available_task_destr(task_header_t *task)
248 static void object_available_proc(DocHost *This, task_header_t *task)
250 object_available(This);
253 HRESULT dochost_object_available(DocHost *This, IUnknown *doc)
255 READYSTATE ready_state;
260 IUnknown_AddRef(doc);
261 This->document = doc;
263 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
264 if(SUCCEEDED(hres)) {
267 hres = IOleObject_GetUserClassID(oleobj, &clsid);
269 TRACE("Got clsid %s\n",
270 IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid));
272 hres = IOleObject_SetClientSite(oleobj, &This->IOleClientSite_iface);
274 FIXME("SetClientSite failed: %08x\n", hres);
276 IOleObject_Release(oleobj);
278 FIXME("Could not get IOleObject iface: %08x\n", hres);
281 /* FIXME: Call SetAdvise */
283 task = heap_alloc(sizeof(*task));
284 push_dochost_task(This, task, object_available_proc, object_available_task_destr, FALSE);
286 hres = get_doc_ready_state(This, &ready_state);
287 if(SUCCEEDED(hres)) {
288 if(ready_state == READYSTATE_COMPLETE)
289 push_ready_state_task(This, READYSTATE_COMPLETE);
290 if(ready_state != READYSTATE_COMPLETE || This->doc_navigate)
291 advise_prop_notif(This, TRUE);
297 static LRESULT resize_document(DocHost *This, LONG width, LONG height)
299 RECT rect = {0, 0, width, height};
301 TRACE("(%p)->(%d %d)\n", This, width, height);
304 IOleDocumentView_SetRect(This->view, &rect);
309 static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
313 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
315 if(msg == WM_CREATE) {
316 This = *(DocHost**)lParam;
317 SetPropW(hwnd, wszTHIS, This);
319 This = GetPropW(hwnd, wszTHIS);
324 return resize_document(This, LOWORD(lParam), HIWORD(lParam));
327 return DefWindowProcW(hwnd, msg, wParam, lParam);
330 static void update_travellog(DocHost *This)
332 travellog_entry_t *new_entry;
334 if(!This->travellog) {
335 This->travellog = heap_alloc(4 * sizeof(*This->travellog));
339 This->travellog_size = 4;
340 }else if(This->travellog_size < This->travellog_position+1) {
341 travellog_entry_t *new_travellog;
343 new_travellog = heap_realloc(This->travellog, This->travellog_size*2*sizeof(*This->travellog));
347 This->travellog = new_travellog;
348 This->travellog_size *= 2;
351 while(This->travellog_length > This->travellog_position)
352 heap_free(This->travellog[--This->travellog_length].url);
354 new_entry = This->travellog + This->travellog_position;
356 new_entry->url = heap_strdupW(This->url);
360 This->travellog_position++;
363 void create_doc_view_hwnd(DocHost *This)
367 static const WCHAR wszShell_DocObject_View[] =
368 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
371 static WNDCLASSEXW wndclass = {
375 0, 0 /* native uses 4*/, NULL, NULL, NULL,
376 (HBRUSH)(COLOR_WINDOW + 1), NULL,
377 wszShell_DocObject_View,
381 wndclass.hInstance = ieframe_instance;
383 doc_view_atom = RegisterClassExW(&wndclass);
386 This->container_vtbl->GetDocObjRect(This, &rect);
387 This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
388 wszShell_DocObject_View,
389 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
390 rect.left, rect.top, rect.right, rect.bottom, This->frame_hwnd,
391 NULL, ieframe_instance, This);
394 void deactivate_document(DocHost *This)
396 IOleInPlaceObjectWindowless *winobj;
397 IOleObject *oleobj = NULL;
398 IHlinkTarget *hlink = NULL;
401 if(!This->document) return;
403 if(This->doc_navigate) {
404 IUnknown_Release(This->doc_navigate);
405 This->doc_navigate = NULL;
408 if(This->is_prop_notif)
409 advise_prop_notif(This, FALSE);
412 IOleDocumentView_UIActivate(This->view, FALSE);
414 hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
416 if(SUCCEEDED(hres)) {
417 IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
418 IOleInPlaceObjectWindowless_Release(winobj);
422 IOleDocumentView_Show(This->view, FALSE);
423 IOleDocumentView_CloseView(This->view, 0);
424 IOleDocumentView_SetInPlaceSite(This->view, NULL);
425 IOleDocumentView_Release(This->view);
429 hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
431 IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
433 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
434 if(SUCCEEDED(hres)) {
435 IHlinkTarget_SetBrowseContext(hlink, NULL);
436 IHlinkTarget_Release(hlink);
440 IOleClientSite *client_site = NULL;
442 IOleObject_GetClientSite(oleobj, &client_site);
444 if(client_site == &This->IOleClientSite_iface)
445 IOleObject_SetClientSite(oleobj, NULL);
446 IOleClientSite_Release(client_site);
449 IOleObject_Release(oleobj);
452 IUnknown_Release(This->document);
453 This->document = NULL;
456 HRESULT refresh_document(DocHost *This)
458 IOleCommandTarget *cmdtrg;
462 if(!This->document) {
463 FIXME("no document\n");
467 hres = IUnknown_QueryInterface(This->document, &IID_IOleCommandTarget, (void**)&cmdtrg);
471 V_VT(&vin) = VT_EMPTY;
472 V_VT(&vout) = VT_EMPTY;
473 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_REFRESH, OLECMDEXECOPT_PROMPTUSER, &vin, &vout);
474 IOleCommandTarget_Release(cmdtrg);
482 void release_dochost_client(DocHost *This)
485 DestroyWindow(This->hwnd);
490 IDocHostUIHandler_Release(This->hostui);
494 if(This->client_disp) {
495 IDispatch_Release(This->client_disp);
496 This->client_disp = NULL;
500 IOleInPlaceFrame_Release(This->frame);
505 static inline DocHost *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
507 return CONTAINING_RECORD(iface, DocHost, IOleCommandTarget_iface);
510 static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
511 REFIID riid, void **ppv)
513 DocHost *This = impl_from_IOleCommandTarget(iface);
514 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
517 static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
519 DocHost *This = impl_from_IOleCommandTarget(iface);
520 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
523 static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface)
525 DocHost *This = impl_from_IOleCommandTarget(iface);
526 return IOleClientSite_Release(&This->IOleClientSite_iface);
529 static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
530 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
532 DocHost *This = impl_from_IOleCommandTarget(iface);
534 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
536 while (prgCmds && (cCmds > i)) {
537 FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf);
543 static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
544 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
547 DocHost *This = impl_from_IOleCommandTarget(iface);
549 TRACE("(%p)->(%s %d %d %s %s)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
550 debugstr_variant(pvaIn), debugstr_variant(pvaOut));
554 case OLECMDID_UPDATECOMMANDS:
555 case OLECMDID_SETDOWNLOADSTATE:
556 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
558 FIXME("Unimplemented cmdid %d\n", nCmdID);
563 if(IsEqualGUID(pguidCmdGroup, &CGID_DocHostCmdPriv)) {
565 case DOCHOST_DOCCANNAVIGATE:
566 if(!pvaIn || V_VT(pvaIn) != VT_UNKNOWN)
569 if(This->doc_navigate)
570 IUnknown_Release(This->doc_navigate);
571 IUnknown_AddRef(V_UNKNOWN(pvaIn));
572 This->doc_navigate = V_UNKNOWN(pvaIn);
577 SAFEARRAY *sa = V_ARRAY(pvaIn);
578 VARIANT status_code, url, htmlwindow;
582 if(V_VT(pvaIn) != VT_ARRAY || !sa || (SafeArrayGetDim(sa) != 1))
586 hres = SafeArrayGetElement(sa, &ind, &status_code);
587 if(FAILED(hres) || V_VT(&status_code)!=VT_I4)
591 hres = SafeArrayGetElement(sa, &ind, &url);
592 if(FAILED(hres) || V_VT(&url)!=VT_BSTR)
596 hres = SafeArrayGetElement(sa, &ind, &htmlwindow);
597 if(FAILED(hres) || V_VT(&htmlwindow)!=VT_UNKNOWN || !V_UNKNOWN(&htmlwindow))
600 hres = IUnknown_QueryInterface(V_UNKNOWN(&htmlwindow), &IID_IHTMLWindow2, (void**)&win2);
604 handle_navigation_error(This, V_I4(&status_code), V_BSTR(&url), win2);
605 IHTMLWindow2_Release(win2);
610 FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID);
615 if(IsEqualGUID(pguidCmdGroup, &CGID_Explorer)) {
617 case CMDID_EXPLORER_UPDATEHISTORY:
618 update_travellog(This);
622 FIXME("Unimplemented cmdid %d of CGID_Explorer\n", nCmdID);
627 if(IsEqualGUID(pguidCmdGroup, &CGID_ShellDocView)) {
630 FIXME("Unimplemented cmdid %d of CGID_ShellDocView\n", nCmdID);
635 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup))
636 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
638 FIXME("Unimplemented cmdid %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup));
642 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
643 ClOleCommandTarget_QueryInterface,
644 ClOleCommandTarget_AddRef,
645 ClOleCommandTarget_Release,
646 ClOleCommandTarget_QueryStatus,
647 ClOleCommandTarget_Exec
650 static inline DocHost *impl_from_IDocHostUIHandler2(IDocHostUIHandler2 *iface)
652 return CONTAINING_RECORD(iface, DocHost, IDocHostUIHandler2_iface);
655 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
656 REFIID riid, void **ppv)
658 DocHost *This = impl_from_IDocHostUIHandler2(iface);
659 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
662 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
664 DocHost *This = impl_from_IDocHostUIHandler2(iface);
665 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
668 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
670 DocHost *This = impl_from_IDocHostUIHandler2(iface);
671 return IOleClientSite_Release(&This->IOleClientSite_iface);
674 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
675 DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
677 DocHost *This = impl_from_IDocHostUIHandler2(iface);
680 TRACE("(%p)->(%d %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
683 hres = IDocHostUIHandler_ShowContextMenu(This->hostui, dwID, ppt, pcmdtReserved,
689 FIXME("default action not implemented\n");
693 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
694 DOCHOSTUIINFO *pInfo)
696 DocHost *This = impl_from_IDocHostUIHandler2(iface);
699 TRACE("(%p)->(%p)\n", This, pInfo);
702 hres = IDocHostUIHandler_GetHostInfo(This->hostui, pInfo);
707 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
708 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
709 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
713 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
714 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
715 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
717 DocHost *This = impl_from_IDocHostUIHandler2(iface);
718 FIXME("(%p)->(%d %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
723 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
725 DocHost *This = impl_from_IDocHostUIHandler2(iface);
726 FIXME("(%p)\n", This);
730 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
732 DocHost *This = impl_from_IDocHostUIHandler2(iface);
734 TRACE("(%p)\n", This);
739 return IDocHostUIHandler_UpdateUI(This->hostui);
742 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
745 DocHost *This = impl_from_IDocHostUIHandler2(iface);
746 FIXME("(%p)->(%x)\n", This, fEnable);
750 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
753 DocHost *This = impl_from_IDocHostUIHandler2(iface);
754 FIXME("(%p)->(%x)\n", This, fActivate);
758 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
761 DocHost *This = impl_from_IDocHostUIHandler2(iface);
762 FIXME("(%p)->(%x)\n", This, fActivate);
766 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
767 LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
769 DocHost *This = impl_from_IDocHostUIHandler2(iface);
770 FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
774 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
775 LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
777 DocHost *This = impl_from_IDocHostUIHandler2(iface);
778 HRESULT hr = S_FALSE;
779 TRACE("(%p)->(%p %p %d)\n", This, lpMsg, pguidCmdGroup, nCmdID);
782 hr = IDocHostUIHandler_TranslateAccelerator(This->hostui, lpMsg, pguidCmdGroup, nCmdID);
787 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
788 LPOLESTR *pchKey, DWORD dw)
790 DocHost *This = impl_from_IDocHostUIHandler2(iface);
792 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
795 return IDocHostUIHandler_GetOptionKeyPath(This->hostui, pchKey, dw);
800 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
801 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
803 DocHost *This = impl_from_IDocHostUIHandler2(iface);
804 FIXME("(%p)\n", This);
808 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
809 IDispatch **ppDispatch)
811 DocHost *This = impl_from_IDocHostUIHandler2(iface);
813 TRACE("(%p)->(%p)\n", This, ppDispatch);
816 return IDocHostUIHandler_GetExternal(This->hostui, ppDispatch);
818 if(!This->shell_ui_helper) {
821 hres = create_shell_ui_helper(&This->shell_ui_helper);
826 *ppDispatch = (IDispatch*)This->shell_ui_helper;
827 IDispatch_AddRef(*ppDispatch);
831 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
832 DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
834 DocHost *This = impl_from_IDocHostUIHandler2(iface);
836 TRACE("(%p)->(%d %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
839 return IDocHostUIHandler_TranslateUrl(This->hostui, dwTranslate,
840 pchURLIn, ppchURLOut);
845 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
846 IDataObject *pDO, IDataObject **ppDORet)
848 DocHost *This = impl_from_IDocHostUIHandler2(iface);
849 FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
853 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
854 LPOLESTR *pchKey, DWORD dw)
856 DocHost *This = impl_from_IDocHostUIHandler2(iface);
857 IDocHostUIHandler2 *handler;
860 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
865 hres = IDocHostUIHandler_QueryInterface(This->hostui, &IID_IDocHostUIHandler2,
867 if(SUCCEEDED(hres)) {
868 hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
869 IDocHostUIHandler2_Release(handler);
876 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
877 DocHostUIHandler_QueryInterface,
878 DocHostUIHandler_AddRef,
879 DocHostUIHandler_Release,
880 DocHostUIHandler_ShowContextMenu,
881 DocHostUIHandler_GetHostInfo,
882 DocHostUIHandler_ShowUI,
883 DocHostUIHandler_HideUI,
884 DocHostUIHandler_UpdateUI,
885 DocHostUIHandler_EnableModeless,
886 DocHostUIHandler_OnDocWindowActivate,
887 DocHostUIHandler_OnFrameWindowActivate,
888 DocHostUIHandler_ResizeBorder,
889 DocHostUIHandler_TranslateAccelerator,
890 DocHostUIHandler_GetOptionKeyPath,
891 DocHostUIHandler_GetDropTarget,
892 DocHostUIHandler_GetExternal,
893 DocHostUIHandler_TranslateUrl,
894 DocHostUIHandler_FilterDataObject,
895 DocHostUIHandler_GetOverrideKeyPath
898 static inline DocHost *impl_from_IPropertyNotifySink(IPropertyNotifySink *iface)
900 return CONTAINING_RECORD(iface, DocHost, IPropertyNotifySink_iface);
903 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
904 REFIID riid, void **ppv)
906 DocHost *This = impl_from_IPropertyNotifySink(iface);
907 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
910 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
912 DocHost *This = impl_from_IPropertyNotifySink(iface);
913 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
916 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
918 DocHost *This = impl_from_IPropertyNotifySink(iface);
919 return IOleClientSite_Release(&This->IOleClientSite_iface);
922 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
924 DocHost *This = impl_from_IPropertyNotifySink(iface);
926 TRACE("(%p)->(%d)\n", This, dispID);
929 case DISPID_READYSTATE: {
930 READYSTATE ready_state;
933 hres = get_doc_ready_state(This, &ready_state);
937 if(ready_state == READYSTATE_COMPLETE && !This->doc_navigate)
938 advise_prop_notif(This, FALSE);
940 update_ready_state(This, ready_state);
944 FIXME("unimplemented dispid %d\n", dispID);
951 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
953 DocHost *This = impl_from_IPropertyNotifySink(iface);
954 FIXME("(%p)->(%d)\n", This, dispID);
958 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
959 PropertyNotifySink_QueryInterface,
960 PropertyNotifySink_AddRef,
961 PropertyNotifySink_Release,
962 PropertyNotifySink_OnChanged,
963 PropertyNotifySink_OnRequestEdit
966 void DocHost_Init(DocHost *This, IWebBrowser2 *wb, const IDocHostContainerVtbl* container)
968 This->IDocHostUIHandler2_iface.lpVtbl = &DocHostUIHandler2Vtbl;
969 This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
970 This->IPropertyNotifySink_iface.lpVtbl = &PropertyNotifySinkVtbl;
973 This->container_vtbl = container;
975 This->ready_state = READYSTATE_UNINITIALIZED;
976 list_init(&This->task_queue);
978 DocHost_ClientSite_Init(This);
979 DocHost_Frame_Init(This);
981 ConnectionPointContainer_Init(&This->cps, (IUnknown*)wb);
982 IEHTMLWindow_Init(This);
983 NewWindowManager_Init(This);
986 void DocHost_Release(DocHost *This)
988 if(This->shell_ui_helper)
989 IShellUIHelper2_Release(This->shell_ui_helper);
991 abort_dochost_tasks(This, NULL);
992 release_dochost_client(This);
993 DocHost_ClientSite_Release(This);
995 ConnectionPointContainer_Destroy(&This->cps);
997 while(This->travellog_length)
998 heap_free(This->travellog[--This->travellog_length].url);
999 heap_free(This->travellog);
1001 heap_free(This->url);