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->travellog.loading_pos != -1) {
199 WARN("histupdate not notified\n");
200 This->travellog.position = This->travellog.loading_pos;
201 This->travellog.loading_pos = -1;
204 if(ready_state > READYSTATE_LOADING && This->doc_state <= READYSTATE_LOADING && !This->browser_service /* FIXME */)
205 notif_complete(This, DISPID_NAVIGATECOMPLETE2);
207 if(ready_state == READYSTATE_COMPLETE && This->doc_state < READYSTATE_COMPLETE) {
208 set_doc_state(This, READYSTATE_COMPLETE);
209 if(!This->browser_service) /* FIXME: Not fully correct */
210 notif_complete(This, DISPID_DOCUMENTCOMPLETE);
212 set_doc_state(This, ready_state);
217 task_header_t header;
219 READYSTATE ready_state;
220 } ready_state_task_t;
222 static void ready_state_task_destr(task_header_t *_task)
224 ready_state_task_t *task = (ready_state_task_t*)_task;
226 IUnknown_Release(task->doc);
230 static void ready_state_proc(DocHost *This, task_header_t *_task)
232 ready_state_task_t *task = (ready_state_task_t*)_task;
234 if(task->doc == This->document)
235 update_ready_state(This, task->ready_state);
238 static void push_ready_state_task(DocHost *This, READYSTATE ready_state)
240 ready_state_task_t *task = heap_alloc(sizeof(ready_state_task_t));
242 IUnknown_AddRef(This->document);
243 task->doc = This->document;
244 task->ready_state = ready_state;
246 push_dochost_task(This, &task->header, ready_state_proc, ready_state_task_destr, FALSE);
249 static void object_available_task_destr(task_header_t *task)
254 static void object_available_proc(DocHost *This, task_header_t *task)
256 object_available(This);
259 HRESULT dochost_object_available(DocHost *This, IUnknown *doc)
261 READYSTATE ready_state;
266 IUnknown_AddRef(doc);
267 This->document = doc;
269 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
270 if(SUCCEEDED(hres)) {
273 hres = IOleObject_GetUserClassID(oleobj, &clsid);
275 TRACE("Got clsid %s\n",
276 IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid));
278 hres = IOleObject_SetClientSite(oleobj, &This->IOleClientSite_iface);
280 FIXME("SetClientSite failed: %08x\n", hres);
282 IOleObject_Release(oleobj);
284 FIXME("Could not get IOleObject iface: %08x\n", hres);
287 /* FIXME: Call SetAdvise */
289 task = heap_alloc(sizeof(*task));
290 push_dochost_task(This, task, object_available_proc, object_available_task_destr, FALSE);
292 hres = get_doc_ready_state(This, &ready_state);
293 if(SUCCEEDED(hres)) {
294 if(ready_state == READYSTATE_COMPLETE)
295 push_ready_state_task(This, READYSTATE_COMPLETE);
296 if(ready_state != READYSTATE_COMPLETE || This->doc_navigate)
297 advise_prop_notif(This, TRUE);
303 static LRESULT resize_document(DocHost *This, LONG width, LONG height)
305 RECT rect = {0, 0, width, height};
307 TRACE("(%p)->(%d %d)\n", This, width, height);
310 IOleDocumentView_SetRect(This->view, &rect);
315 static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
319 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
321 if(msg == WM_CREATE) {
322 This = *(DocHost**)lParam;
323 SetPropW(hwnd, wszTHIS, This);
325 This = GetPropW(hwnd, wszTHIS);
330 return resize_document(This, LOWORD(lParam), HIWORD(lParam));
333 return DefWindowProcW(hwnd, msg, wParam, lParam);
336 static void update_travellog(DocHost *This)
338 travellog_entry_t *new_entry;
340 if(This->travellog.loading_pos == -1) {
341 /* Clear forward history. */
342 if(!This->travellog.log) {
343 This->travellog.log = heap_alloc(4 * sizeof(*This->travellog.log));
344 if(!This->travellog.log)
347 This->travellog.size = 4;
348 }else if(This->travellog.size < This->travellog.position+1) {
349 travellog_entry_t *new_travellog;
351 new_travellog = heap_realloc(This->travellog.log, This->travellog.size*2*sizeof(*This->travellog.log));
355 This->travellog.log = new_travellog;
356 This->travellog.size *= 2;
359 while(This->travellog.length > This->travellog.position)
360 heap_free(This->travellog.log[--This->travellog.length].url);
363 new_entry = This->travellog.log + This->travellog.position;
365 new_entry->url = heap_strdupW(This->url);
369 if(This->travellog.loading_pos == -1) {
370 This->travellog.position++;
372 This->travellog.position = This->travellog.loading_pos;
373 This->travellog.loading_pos = -1;
375 if(This->travellog.position > This->travellog.length)
376 This->travellog.length = This->travellog.position;
379 void create_doc_view_hwnd(DocHost *This)
383 static const WCHAR wszShell_DocObject_View[] =
384 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
387 static WNDCLASSEXW wndclass = {
391 0, 0 /* native uses 4*/, NULL, NULL, NULL,
392 (HBRUSH)(COLOR_WINDOW + 1), NULL,
393 wszShell_DocObject_View,
397 wndclass.hInstance = ieframe_instance;
399 doc_view_atom = RegisterClassExW(&wndclass);
402 This->container_vtbl->GetDocObjRect(This, &rect);
403 This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
404 wszShell_DocObject_View,
405 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
406 rect.left, rect.top, rect.right, rect.bottom, This->frame_hwnd,
407 NULL, ieframe_instance, This);
410 void deactivate_document(DocHost *This)
412 IOleInPlaceObjectWindowless *winobj;
413 IOleObject *oleobj = NULL;
414 IHlinkTarget *hlink = NULL;
417 if(!This->document) return;
419 if(This->doc_navigate) {
420 IUnknown_Release(This->doc_navigate);
421 This->doc_navigate = NULL;
424 if(This->is_prop_notif)
425 advise_prop_notif(This, FALSE);
428 IOleDocumentView_UIActivate(This->view, FALSE);
430 hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
432 if(SUCCEEDED(hres)) {
433 IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
434 IOleInPlaceObjectWindowless_Release(winobj);
438 IOleDocumentView_Show(This->view, FALSE);
439 IOleDocumentView_CloseView(This->view, 0);
440 IOleDocumentView_SetInPlaceSite(This->view, NULL);
441 IOleDocumentView_Release(This->view);
445 hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
447 IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
449 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
450 if(SUCCEEDED(hres)) {
451 IHlinkTarget_SetBrowseContext(hlink, NULL);
452 IHlinkTarget_Release(hlink);
456 IOleClientSite *client_site = NULL;
458 IOleObject_GetClientSite(oleobj, &client_site);
460 if(client_site == &This->IOleClientSite_iface)
461 IOleObject_SetClientSite(oleobj, NULL);
462 IOleClientSite_Release(client_site);
465 IOleObject_Release(oleobj);
468 IUnknown_Release(This->document);
469 This->document = NULL;
472 HRESULT refresh_document(DocHost *This)
474 IOleCommandTarget *cmdtrg;
478 if(!This->document) {
479 FIXME("no document\n");
483 hres = IUnknown_QueryInterface(This->document, &IID_IOleCommandTarget, (void**)&cmdtrg);
487 V_VT(&vin) = VT_EMPTY;
488 V_VT(&vout) = VT_EMPTY;
489 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_REFRESH, OLECMDEXECOPT_PROMPTUSER, &vin, &vout);
490 IOleCommandTarget_Release(cmdtrg);
498 void release_dochost_client(DocHost *This)
501 DestroyWindow(This->hwnd);
506 IDocHostUIHandler_Release(This->hostui);
510 if(This->client_disp) {
511 IDispatch_Release(This->client_disp);
512 This->client_disp = NULL;
516 IOleInPlaceFrame_Release(This->frame);
521 static inline DocHost *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
523 return CONTAINING_RECORD(iface, DocHost, IOleCommandTarget_iface);
526 static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
527 REFIID riid, void **ppv)
529 DocHost *This = impl_from_IOleCommandTarget(iface);
530 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
533 static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
535 DocHost *This = impl_from_IOleCommandTarget(iface);
536 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
539 static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface)
541 DocHost *This = impl_from_IOleCommandTarget(iface);
542 return IOleClientSite_Release(&This->IOleClientSite_iface);
545 static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
546 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
548 DocHost *This = impl_from_IOleCommandTarget(iface);
550 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
552 while (prgCmds && (cCmds > i)) {
553 FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf);
559 static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
560 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
563 DocHost *This = impl_from_IOleCommandTarget(iface);
565 TRACE("(%p)->(%s %d %d %s %s)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
566 debugstr_variant(pvaIn), debugstr_variant(pvaOut));
570 case OLECMDID_UPDATECOMMANDS:
571 case OLECMDID_SETDOWNLOADSTATE:
572 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
574 FIXME("Unimplemented cmdid %d\n", nCmdID);
579 if(IsEqualGUID(pguidCmdGroup, &CGID_DocHostCmdPriv)) {
581 case DOCHOST_DOCCANNAVIGATE:
582 if(!pvaIn || V_VT(pvaIn) != VT_UNKNOWN)
585 if(This->doc_navigate)
586 IUnknown_Release(This->doc_navigate);
587 IUnknown_AddRef(V_UNKNOWN(pvaIn));
588 This->doc_navigate = V_UNKNOWN(pvaIn);
593 SAFEARRAY *sa = V_ARRAY(pvaIn);
594 VARIANT status_code, url, htmlwindow;
598 if(V_VT(pvaIn) != VT_ARRAY || !sa || (SafeArrayGetDim(sa) != 1))
602 hres = SafeArrayGetElement(sa, &ind, &status_code);
603 if(FAILED(hres) || V_VT(&status_code)!=VT_I4)
607 hres = SafeArrayGetElement(sa, &ind, &url);
608 if(FAILED(hres) || V_VT(&url)!=VT_BSTR)
612 hres = SafeArrayGetElement(sa, &ind, &htmlwindow);
613 if(FAILED(hres) || V_VT(&htmlwindow)!=VT_UNKNOWN || !V_UNKNOWN(&htmlwindow))
616 hres = IUnknown_QueryInterface(V_UNKNOWN(&htmlwindow), &IID_IHTMLWindow2, (void**)&win2);
620 handle_navigation_error(This, V_I4(&status_code), V_BSTR(&url), win2);
621 IHTMLWindow2_Release(win2);
626 FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID);
631 if(IsEqualGUID(pguidCmdGroup, &CGID_Explorer)) {
633 case CMDID_EXPLORER_UPDATEHISTORY:
634 update_travellog(This);
638 FIXME("Unimplemented cmdid %d of CGID_Explorer\n", nCmdID);
643 if(IsEqualGUID(pguidCmdGroup, &CGID_ShellDocView)) {
646 FIXME("Unimplemented cmdid %d of CGID_ShellDocView\n", nCmdID);
651 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup))
652 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
654 FIXME("Unimplemented cmdid %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup));
658 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
659 ClOleCommandTarget_QueryInterface,
660 ClOleCommandTarget_AddRef,
661 ClOleCommandTarget_Release,
662 ClOleCommandTarget_QueryStatus,
663 ClOleCommandTarget_Exec
666 static inline DocHost *impl_from_IDocHostUIHandler2(IDocHostUIHandler2 *iface)
668 return CONTAINING_RECORD(iface, DocHost, IDocHostUIHandler2_iface);
671 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
672 REFIID riid, void **ppv)
674 DocHost *This = impl_from_IDocHostUIHandler2(iface);
675 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
678 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
680 DocHost *This = impl_from_IDocHostUIHandler2(iface);
681 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
684 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
686 DocHost *This = impl_from_IDocHostUIHandler2(iface);
687 return IOleClientSite_Release(&This->IOleClientSite_iface);
690 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
691 DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
693 DocHost *This = impl_from_IDocHostUIHandler2(iface);
696 TRACE("(%p)->(%d %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
699 hres = IDocHostUIHandler_ShowContextMenu(This->hostui, dwID, ppt, pcmdtReserved,
705 FIXME("default action not implemented\n");
709 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
710 DOCHOSTUIINFO *pInfo)
712 DocHost *This = impl_from_IDocHostUIHandler2(iface);
715 TRACE("(%p)->(%p)\n", This, pInfo);
718 hres = IDocHostUIHandler_GetHostInfo(This->hostui, pInfo);
723 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
724 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
725 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
729 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
730 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
731 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
733 DocHost *This = impl_from_IDocHostUIHandler2(iface);
734 FIXME("(%p)->(%d %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
739 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
741 DocHost *This = impl_from_IDocHostUIHandler2(iface);
742 FIXME("(%p)\n", This);
746 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
748 DocHost *This = impl_from_IDocHostUIHandler2(iface);
750 TRACE("(%p)\n", This);
755 return IDocHostUIHandler_UpdateUI(This->hostui);
758 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
761 DocHost *This = impl_from_IDocHostUIHandler2(iface);
762 FIXME("(%p)->(%x)\n", This, fEnable);
766 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
769 DocHost *This = impl_from_IDocHostUIHandler2(iface);
770 FIXME("(%p)->(%x)\n", This, fActivate);
774 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
777 DocHost *This = impl_from_IDocHostUIHandler2(iface);
778 FIXME("(%p)->(%x)\n", This, fActivate);
782 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
783 LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
785 DocHost *This = impl_from_IDocHostUIHandler2(iface);
786 FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
790 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
791 LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
793 DocHost *This = impl_from_IDocHostUIHandler2(iface);
794 HRESULT hr = S_FALSE;
795 TRACE("(%p)->(%p %p %d)\n", This, lpMsg, pguidCmdGroup, nCmdID);
798 hr = IDocHostUIHandler_TranslateAccelerator(This->hostui, lpMsg, pguidCmdGroup, nCmdID);
803 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
804 LPOLESTR *pchKey, DWORD dw)
806 DocHost *This = impl_from_IDocHostUIHandler2(iface);
808 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
811 return IDocHostUIHandler_GetOptionKeyPath(This->hostui, pchKey, dw);
816 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
817 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
819 DocHost *This = impl_from_IDocHostUIHandler2(iface);
820 FIXME("(%p)\n", This);
824 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
825 IDispatch **ppDispatch)
827 DocHost *This = impl_from_IDocHostUIHandler2(iface);
829 TRACE("(%p)->(%p)\n", This, ppDispatch);
832 return IDocHostUIHandler_GetExternal(This->hostui, ppDispatch);
834 if(!This->shell_ui_helper) {
837 hres = create_shell_ui_helper(&This->shell_ui_helper);
842 *ppDispatch = (IDispatch*)This->shell_ui_helper;
843 IDispatch_AddRef(*ppDispatch);
847 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
848 DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
850 DocHost *This = impl_from_IDocHostUIHandler2(iface);
852 TRACE("(%p)->(%d %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
855 return IDocHostUIHandler_TranslateUrl(This->hostui, dwTranslate,
856 pchURLIn, ppchURLOut);
861 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
862 IDataObject *pDO, IDataObject **ppDORet)
864 DocHost *This = impl_from_IDocHostUIHandler2(iface);
865 FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
869 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
870 LPOLESTR *pchKey, DWORD dw)
872 DocHost *This = impl_from_IDocHostUIHandler2(iface);
873 IDocHostUIHandler2 *handler;
876 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
881 hres = IDocHostUIHandler_QueryInterface(This->hostui, &IID_IDocHostUIHandler2,
883 if(SUCCEEDED(hres)) {
884 hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
885 IDocHostUIHandler2_Release(handler);
892 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
893 DocHostUIHandler_QueryInterface,
894 DocHostUIHandler_AddRef,
895 DocHostUIHandler_Release,
896 DocHostUIHandler_ShowContextMenu,
897 DocHostUIHandler_GetHostInfo,
898 DocHostUIHandler_ShowUI,
899 DocHostUIHandler_HideUI,
900 DocHostUIHandler_UpdateUI,
901 DocHostUIHandler_EnableModeless,
902 DocHostUIHandler_OnDocWindowActivate,
903 DocHostUIHandler_OnFrameWindowActivate,
904 DocHostUIHandler_ResizeBorder,
905 DocHostUIHandler_TranslateAccelerator,
906 DocHostUIHandler_GetOptionKeyPath,
907 DocHostUIHandler_GetDropTarget,
908 DocHostUIHandler_GetExternal,
909 DocHostUIHandler_TranslateUrl,
910 DocHostUIHandler_FilterDataObject,
911 DocHostUIHandler_GetOverrideKeyPath
914 static inline DocHost *impl_from_IPropertyNotifySink(IPropertyNotifySink *iface)
916 return CONTAINING_RECORD(iface, DocHost, IPropertyNotifySink_iface);
919 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
920 REFIID riid, void **ppv)
922 DocHost *This = impl_from_IPropertyNotifySink(iface);
923 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
926 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
928 DocHost *This = impl_from_IPropertyNotifySink(iface);
929 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
932 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
934 DocHost *This = impl_from_IPropertyNotifySink(iface);
935 return IOleClientSite_Release(&This->IOleClientSite_iface);
938 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
940 DocHost *This = impl_from_IPropertyNotifySink(iface);
942 TRACE("(%p)->(%d)\n", This, dispID);
945 case DISPID_READYSTATE: {
946 READYSTATE ready_state;
949 hres = get_doc_ready_state(This, &ready_state);
953 if(ready_state == READYSTATE_COMPLETE && !This->doc_navigate)
954 advise_prop_notif(This, FALSE);
956 update_ready_state(This, ready_state);
960 FIXME("unimplemented dispid %d\n", dispID);
967 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
969 DocHost *This = impl_from_IPropertyNotifySink(iface);
970 FIXME("(%p)->(%d)\n", This, dispID);
974 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
975 PropertyNotifySink_QueryInterface,
976 PropertyNotifySink_AddRef,
977 PropertyNotifySink_Release,
978 PropertyNotifySink_OnChanged,
979 PropertyNotifySink_OnRequestEdit
982 void DocHost_Init(DocHost *This, IWebBrowser2 *wb, const IDocHostContainerVtbl* container)
984 This->IDocHostUIHandler2_iface.lpVtbl = &DocHostUIHandler2Vtbl;
985 This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
986 This->IPropertyNotifySink_iface.lpVtbl = &PropertyNotifySinkVtbl;
989 This->container_vtbl = container;
991 This->ready_state = READYSTATE_UNINITIALIZED;
992 list_init(&This->task_queue);
994 This->travellog.loading_pos = -1;
996 DocHost_ClientSite_Init(This);
997 DocHost_Frame_Init(This);
999 ConnectionPointContainer_Init(&This->cps, (IUnknown*)wb);
1000 IEHTMLWindow_Init(This);
1001 NewWindowManager_Init(This);
1004 void DocHost_Release(DocHost *This)
1006 if(This->shell_ui_helper)
1007 IShellUIHelper2_Release(This->shell_ui_helper);
1009 abort_dochost_tasks(This, NULL);
1010 release_dochost_client(This);
1011 DocHost_ClientSite_Release(This);
1013 ConnectionPointContainer_Destroy(&This->cps);
1015 while(This->travellog.length)
1016 heap_free(This->travellog.log[--This->travellog.length].url);
1017 heap_free(This->travellog.log);
1019 heap_free(This->url);