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 free_travellog_entry(travellog_entry_t *entry)
338 heap_free(entry->url);
341 static void update_travellog(DocHost *This)
343 travellog_entry_t *new_entry;
345 if(This->travellog.loading_pos == -1) {
346 /* Clear forward history. */
347 if(!This->travellog.log) {
348 This->travellog.log = heap_alloc(4 * sizeof(*This->travellog.log));
349 if(!This->travellog.log)
352 This->travellog.size = 4;
353 }else if(This->travellog.size < This->travellog.position+1) {
354 travellog_entry_t *new_travellog;
356 new_travellog = heap_realloc(This->travellog.log, This->travellog.size*2*sizeof(*This->travellog.log));
360 This->travellog.log = new_travellog;
361 This->travellog.size *= 2;
364 while(This->travellog.length > This->travellog.position)
365 free_travellog_entry(This->travellog.log + --This->travellog.length);
368 new_entry = This->travellog.log + This->travellog.position;
370 new_entry->url = heap_strdupW(This->url);
374 if(This->travellog.loading_pos == -1) {
375 This->travellog.position++;
377 This->travellog.position = This->travellog.loading_pos;
378 This->travellog.loading_pos = -1;
380 if(This->travellog.position > This->travellog.length)
381 This->travellog.length = This->travellog.position;
384 void create_doc_view_hwnd(DocHost *This)
388 static const WCHAR wszShell_DocObject_View[] =
389 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
392 static WNDCLASSEXW wndclass = {
396 0, 0 /* native uses 4*/, NULL, NULL, NULL,
397 (HBRUSH)(COLOR_WINDOW + 1), NULL,
398 wszShell_DocObject_View,
402 wndclass.hInstance = ieframe_instance;
404 doc_view_atom = RegisterClassExW(&wndclass);
407 This->container_vtbl->GetDocObjRect(This, &rect);
408 This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
409 wszShell_DocObject_View,
410 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
411 rect.left, rect.top, rect.right, rect.bottom, This->frame_hwnd,
412 NULL, ieframe_instance, This);
415 void deactivate_document(DocHost *This)
417 IOleInPlaceObjectWindowless *winobj;
418 IOleObject *oleobj = NULL;
419 IHlinkTarget *hlink = NULL;
422 if(!This->document) return;
424 if(This->doc_navigate) {
425 IUnknown_Release(This->doc_navigate);
426 This->doc_navigate = NULL;
429 if(This->is_prop_notif)
430 advise_prop_notif(This, FALSE);
433 IOleDocumentView_UIActivate(This->view, FALSE);
435 hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
437 if(SUCCEEDED(hres)) {
438 IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
439 IOleInPlaceObjectWindowless_Release(winobj);
443 IOleDocumentView_Show(This->view, FALSE);
444 IOleDocumentView_CloseView(This->view, 0);
445 IOleDocumentView_SetInPlaceSite(This->view, NULL);
446 IOleDocumentView_Release(This->view);
450 hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
452 IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
454 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
455 if(SUCCEEDED(hres)) {
456 IHlinkTarget_SetBrowseContext(hlink, NULL);
457 IHlinkTarget_Release(hlink);
461 IOleClientSite *client_site = NULL;
463 IOleObject_GetClientSite(oleobj, &client_site);
465 if(client_site == &This->IOleClientSite_iface)
466 IOleObject_SetClientSite(oleobj, NULL);
467 IOleClientSite_Release(client_site);
470 IOleObject_Release(oleobj);
473 IUnknown_Release(This->document);
474 This->document = NULL;
477 HRESULT refresh_document(DocHost *This)
479 IOleCommandTarget *cmdtrg;
483 if(!This->document) {
484 FIXME("no document\n");
488 hres = IUnknown_QueryInterface(This->document, &IID_IOleCommandTarget, (void**)&cmdtrg);
492 V_VT(&vin) = VT_EMPTY;
493 V_VT(&vout) = VT_EMPTY;
494 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_REFRESH, OLECMDEXECOPT_PROMPTUSER, &vin, &vout);
495 IOleCommandTarget_Release(cmdtrg);
503 void release_dochost_client(DocHost *This)
506 DestroyWindow(This->hwnd);
511 IDocHostUIHandler_Release(This->hostui);
515 if(This->client_disp) {
516 IDispatch_Release(This->client_disp);
517 This->client_disp = NULL;
521 IOleInPlaceFrame_Release(This->frame);
526 static inline DocHost *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
528 return CONTAINING_RECORD(iface, DocHost, IOleCommandTarget_iface);
531 static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
532 REFIID riid, void **ppv)
534 DocHost *This = impl_from_IOleCommandTarget(iface);
535 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
538 static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
540 DocHost *This = impl_from_IOleCommandTarget(iface);
541 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
544 static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface)
546 DocHost *This = impl_from_IOleCommandTarget(iface);
547 return IOleClientSite_Release(&This->IOleClientSite_iface);
550 static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
551 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
553 DocHost *This = impl_from_IOleCommandTarget(iface);
555 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
557 while (prgCmds && (cCmds > i)) {
558 FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf);
564 static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
565 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
568 DocHost *This = impl_from_IOleCommandTarget(iface);
570 TRACE("(%p)->(%s %d %d %s %s)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
571 debugstr_variant(pvaIn), debugstr_variant(pvaOut));
575 case OLECMDID_UPDATECOMMANDS:
576 case OLECMDID_SETDOWNLOADSTATE:
577 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
579 FIXME("Unimplemented cmdid %d\n", nCmdID);
584 if(IsEqualGUID(pguidCmdGroup, &CGID_DocHostCmdPriv)) {
586 case DOCHOST_DOCCANNAVIGATE:
587 if(!pvaIn || V_VT(pvaIn) != VT_UNKNOWN)
590 if(This->doc_navigate)
591 IUnknown_Release(This->doc_navigate);
592 IUnknown_AddRef(V_UNKNOWN(pvaIn));
593 This->doc_navigate = V_UNKNOWN(pvaIn);
598 SAFEARRAY *sa = V_ARRAY(pvaIn);
599 VARIANT status_code, url, htmlwindow;
603 if(V_VT(pvaIn) != VT_ARRAY || !sa || (SafeArrayGetDim(sa) != 1))
607 hres = SafeArrayGetElement(sa, &ind, &status_code);
608 if(FAILED(hres) || V_VT(&status_code)!=VT_I4)
612 hres = SafeArrayGetElement(sa, &ind, &url);
613 if(FAILED(hres) || V_VT(&url)!=VT_BSTR)
617 hres = SafeArrayGetElement(sa, &ind, &htmlwindow);
618 if(FAILED(hres) || V_VT(&htmlwindow)!=VT_UNKNOWN || !V_UNKNOWN(&htmlwindow))
621 hres = IUnknown_QueryInterface(V_UNKNOWN(&htmlwindow), &IID_IHTMLWindow2, (void**)&win2);
625 handle_navigation_error(This, V_I4(&status_code), V_BSTR(&url), win2);
626 IHTMLWindow2_Release(win2);
631 FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID);
636 if(IsEqualGUID(pguidCmdGroup, &CGID_Explorer)) {
638 case CMDID_EXPLORER_UPDATEHISTORY:
639 update_travellog(This);
643 FIXME("Unimplemented cmdid %d of CGID_Explorer\n", nCmdID);
648 if(IsEqualGUID(pguidCmdGroup, &CGID_ShellDocView)) {
651 FIXME("Unimplemented cmdid %d of CGID_ShellDocView\n", nCmdID);
656 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup))
657 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
659 FIXME("Unimplemented cmdid %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup));
663 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
664 ClOleCommandTarget_QueryInterface,
665 ClOleCommandTarget_AddRef,
666 ClOleCommandTarget_Release,
667 ClOleCommandTarget_QueryStatus,
668 ClOleCommandTarget_Exec
671 static inline DocHost *impl_from_IDocHostUIHandler2(IDocHostUIHandler2 *iface)
673 return CONTAINING_RECORD(iface, DocHost, IDocHostUIHandler2_iface);
676 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
677 REFIID riid, void **ppv)
679 DocHost *This = impl_from_IDocHostUIHandler2(iface);
680 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
683 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
685 DocHost *This = impl_from_IDocHostUIHandler2(iface);
686 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
689 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
691 DocHost *This = impl_from_IDocHostUIHandler2(iface);
692 return IOleClientSite_Release(&This->IOleClientSite_iface);
695 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
696 DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
698 DocHost *This = impl_from_IDocHostUIHandler2(iface);
701 TRACE("(%p)->(%d %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
704 hres = IDocHostUIHandler_ShowContextMenu(This->hostui, dwID, ppt, pcmdtReserved,
710 FIXME("default action not implemented\n");
714 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
715 DOCHOSTUIINFO *pInfo)
717 DocHost *This = impl_from_IDocHostUIHandler2(iface);
720 TRACE("(%p)->(%p)\n", This, pInfo);
723 hres = IDocHostUIHandler_GetHostInfo(This->hostui, pInfo);
728 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
729 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
730 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
734 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
735 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
736 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
738 DocHost *This = impl_from_IDocHostUIHandler2(iface);
739 FIXME("(%p)->(%d %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
744 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
746 DocHost *This = impl_from_IDocHostUIHandler2(iface);
747 FIXME("(%p)\n", This);
751 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
753 DocHost *This = impl_from_IDocHostUIHandler2(iface);
755 TRACE("(%p)\n", This);
760 return IDocHostUIHandler_UpdateUI(This->hostui);
763 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
766 DocHost *This = impl_from_IDocHostUIHandler2(iface);
767 FIXME("(%p)->(%x)\n", This, fEnable);
771 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
774 DocHost *This = impl_from_IDocHostUIHandler2(iface);
775 FIXME("(%p)->(%x)\n", This, fActivate);
779 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
782 DocHost *This = impl_from_IDocHostUIHandler2(iface);
783 FIXME("(%p)->(%x)\n", This, fActivate);
787 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
788 LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
790 DocHost *This = impl_from_IDocHostUIHandler2(iface);
791 FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
795 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
796 LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
798 DocHost *This = impl_from_IDocHostUIHandler2(iface);
799 HRESULT hr = S_FALSE;
800 TRACE("(%p)->(%p %p %d)\n", This, lpMsg, pguidCmdGroup, nCmdID);
803 hr = IDocHostUIHandler_TranslateAccelerator(This->hostui, lpMsg, pguidCmdGroup, nCmdID);
808 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
809 LPOLESTR *pchKey, DWORD dw)
811 DocHost *This = impl_from_IDocHostUIHandler2(iface);
813 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
816 return IDocHostUIHandler_GetOptionKeyPath(This->hostui, pchKey, dw);
821 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
822 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
824 DocHost *This = impl_from_IDocHostUIHandler2(iface);
825 FIXME("(%p)\n", This);
829 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
830 IDispatch **ppDispatch)
832 DocHost *This = impl_from_IDocHostUIHandler2(iface);
834 TRACE("(%p)->(%p)\n", This, ppDispatch);
837 return IDocHostUIHandler_GetExternal(This->hostui, ppDispatch);
839 if(!This->shell_ui_helper) {
842 hres = create_shell_ui_helper(&This->shell_ui_helper);
847 *ppDispatch = (IDispatch*)This->shell_ui_helper;
848 IDispatch_AddRef(*ppDispatch);
852 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
853 DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
855 DocHost *This = impl_from_IDocHostUIHandler2(iface);
857 TRACE("(%p)->(%d %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
860 return IDocHostUIHandler_TranslateUrl(This->hostui, dwTranslate,
861 pchURLIn, ppchURLOut);
866 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
867 IDataObject *pDO, IDataObject **ppDORet)
869 DocHost *This = impl_from_IDocHostUIHandler2(iface);
870 FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
874 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
875 LPOLESTR *pchKey, DWORD dw)
877 DocHost *This = impl_from_IDocHostUIHandler2(iface);
878 IDocHostUIHandler2 *handler;
881 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
886 hres = IDocHostUIHandler_QueryInterface(This->hostui, &IID_IDocHostUIHandler2,
888 if(SUCCEEDED(hres)) {
889 hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
890 IDocHostUIHandler2_Release(handler);
897 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
898 DocHostUIHandler_QueryInterface,
899 DocHostUIHandler_AddRef,
900 DocHostUIHandler_Release,
901 DocHostUIHandler_ShowContextMenu,
902 DocHostUIHandler_GetHostInfo,
903 DocHostUIHandler_ShowUI,
904 DocHostUIHandler_HideUI,
905 DocHostUIHandler_UpdateUI,
906 DocHostUIHandler_EnableModeless,
907 DocHostUIHandler_OnDocWindowActivate,
908 DocHostUIHandler_OnFrameWindowActivate,
909 DocHostUIHandler_ResizeBorder,
910 DocHostUIHandler_TranslateAccelerator,
911 DocHostUIHandler_GetOptionKeyPath,
912 DocHostUIHandler_GetDropTarget,
913 DocHostUIHandler_GetExternal,
914 DocHostUIHandler_TranslateUrl,
915 DocHostUIHandler_FilterDataObject,
916 DocHostUIHandler_GetOverrideKeyPath
919 static inline DocHost *impl_from_IPropertyNotifySink(IPropertyNotifySink *iface)
921 return CONTAINING_RECORD(iface, DocHost, IPropertyNotifySink_iface);
924 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
925 REFIID riid, void **ppv)
927 DocHost *This = impl_from_IPropertyNotifySink(iface);
928 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
931 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
933 DocHost *This = impl_from_IPropertyNotifySink(iface);
934 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
937 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
939 DocHost *This = impl_from_IPropertyNotifySink(iface);
940 return IOleClientSite_Release(&This->IOleClientSite_iface);
943 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
945 DocHost *This = impl_from_IPropertyNotifySink(iface);
947 TRACE("(%p)->(%d)\n", This, dispID);
950 case DISPID_READYSTATE: {
951 READYSTATE ready_state;
954 hres = get_doc_ready_state(This, &ready_state);
958 if(ready_state == READYSTATE_COMPLETE && !This->doc_navigate)
959 advise_prop_notif(This, FALSE);
961 update_ready_state(This, ready_state);
965 FIXME("unimplemented dispid %d\n", dispID);
972 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
974 DocHost *This = impl_from_IPropertyNotifySink(iface);
975 FIXME("(%p)->(%d)\n", This, dispID);
979 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
980 PropertyNotifySink_QueryInterface,
981 PropertyNotifySink_AddRef,
982 PropertyNotifySink_Release,
983 PropertyNotifySink_OnChanged,
984 PropertyNotifySink_OnRequestEdit
987 void DocHost_Init(DocHost *This, IWebBrowser2 *wb, const IDocHostContainerVtbl* container)
989 This->IDocHostUIHandler2_iface.lpVtbl = &DocHostUIHandler2Vtbl;
990 This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
991 This->IPropertyNotifySink_iface.lpVtbl = &PropertyNotifySinkVtbl;
994 This->container_vtbl = container;
996 This->ready_state = READYSTATE_UNINITIALIZED;
997 list_init(&This->task_queue);
999 This->travellog.loading_pos = -1;
1001 DocHost_ClientSite_Init(This);
1002 DocHost_Frame_Init(This);
1004 ConnectionPointContainer_Init(&This->cps, (IUnknown*)wb);
1005 IEHTMLWindow_Init(This);
1006 NewWindowManager_Init(This);
1009 void DocHost_Release(DocHost *This)
1011 if(This->shell_ui_helper)
1012 IShellUIHelper2_Release(This->shell_ui_helper);
1014 abort_dochost_tasks(This, NULL);
1015 release_dochost_client(This);
1016 DocHost_ClientSite_Release(This);
1018 ConnectionPointContainer_Destroy(&This->cps);
1020 while(This->travellog.length)
1021 free_travellog_entry(This->travellog.log + --This->travellog.length);
1022 heap_free(This->travellog.log);
1024 heap_free(This->url);