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
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
30 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
32 #define DOCHOST_DOCCANNAVIGATE 0
34 /* Undocumented notification, see mshtml tests */
35 #define CMDID_EXPLORER_UPDATEHISTORY 38
37 static ATOM doc_view_atom = 0;
39 void push_dochost_task(DocHost *This, task_header_t *task, task_proc_t proc, task_destr_t destr, BOOL send)
46 is_empty = list_empty(&This->task_queue);
47 list_add_tail(&This->task_queue, &task->entry);
50 SendMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, 0);
52 PostMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, 0);
55 LRESULT process_dochost_tasks(DocHost *This)
59 while(!list_empty(&This->task_queue)) {
60 task = LIST_ENTRY(This->task_queue.next, task_header_t, entry);
61 list_remove(&task->entry);
63 task->proc(This, task);
70 void abort_dochost_tasks(DocHost *This, task_proc_t proc)
72 task_header_t *task, *cursor;
74 LIST_FOR_EACH_ENTRY_SAFE(task, cursor, &This->task_queue, task_header_t, entry) {
75 if(proc && proc != task->proc)
78 list_remove(&task->entry);
83 static void notif_complete(DocHost *This, DISPID dispid)
85 DISPPARAMS dispparams;
90 dispparams.cNamedArgs = 0;
91 dispparams.rgdispidNamedArgs = NULL;
92 dispparams.rgvarg = params;
94 V_VT(params) = (VT_BYREF|VT_VARIANT);
95 V_BYREF(params) = &url;
97 V_VT(params+1) = VT_DISPATCH;
98 V_DISPATCH(params+1) = (IDispatch*)This->wb;
100 V_VT(&url) = VT_BSTR;
101 V_BSTR(&url) = SysAllocString(This->url);
103 TRACE("%d >>>\n", dispid);
104 call_sink(This->cps.wbe2, dispid, &dispparams);
105 TRACE("%d <<<\n", dispid);
107 SysFreeString(V_BSTR(&url));
108 This->busy = VARIANT_FALSE;
111 static void object_available(DocHost *This)
116 TRACE("(%p)\n", This);
118 if(!This->document) {
119 WARN("document == NULL\n");
123 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
125 FIXME("Could not get IHlinkTarget interface\n");
129 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
130 IHlinkTarget_Release(hlink);
132 FIXME("Navigate failed\n");
135 static HRESULT get_doc_ready_state(DocHost *This, READYSTATE *ret)
137 DISPPARAMS dp = {NULL,NULL,0,0};
143 hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&disp);
147 hres = IDispatch_Invoke(disp, DISPID_READYSTATE, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
148 &dp, &var, &ei, NULL);
149 IDispatch_Release(disp);
151 WARN("Invoke(DISPID_READYSTATE failed: %08x\n", hres);
155 if(V_VT(&var) != VT_I4) {
156 WARN("V_VT(var) = %d\n", V_VT(&var));
165 static void advise_prop_notif(DocHost *This, BOOL set)
167 IConnectionPointContainer *cp_container;
168 IConnectionPoint *cp;
171 hres = IUnknown_QueryInterface(This->document, &IID_IConnectionPointContainer, (void**)&cp_container);
175 hres = IConnectionPointContainer_FindConnectionPoint(cp_container, &IID_IPropertyNotifySink, &cp);
176 IConnectionPointContainer_Release(cp_container);
181 hres = IConnectionPoint_Advise(cp, (IUnknown*)&This->IPropertyNotifySink_iface, &This->prop_notif_cookie);
183 hres = IConnectionPoint_Unadvise(cp, This->prop_notif_cookie);
184 IConnectionPoint_Release(cp);
187 This->is_prop_notif = set;
190 void set_doc_state(DocHost *This, READYSTATE doc_state)
192 This->doc_state = doc_state;
193 if(doc_state > This->ready_state)
194 This->ready_state = doc_state;
197 static void update_ready_state(DocHost *This, READYSTATE ready_state)
199 if(ready_state > READYSTATE_LOADING && This->travellog.loading_pos != -1) {
200 WARN("histupdate not notified\n");
201 This->travellog.position = This->travellog.loading_pos;
202 This->travellog.loading_pos = -1;
205 if(ready_state > READYSTATE_LOADING && This->doc_state <= READYSTATE_LOADING && !This->browser_service /* FIXME */)
206 notif_complete(This, DISPID_NAVIGATECOMPLETE2);
208 if(ready_state == READYSTATE_COMPLETE && This->doc_state < READYSTATE_COMPLETE) {
209 set_doc_state(This, READYSTATE_COMPLETE);
210 if(!This->browser_service) /* FIXME: Not fully correct */
211 notif_complete(This, DISPID_DOCUMENTCOMPLETE);
213 set_doc_state(This, ready_state);
218 task_header_t header;
220 READYSTATE ready_state;
221 } ready_state_task_t;
223 static void ready_state_task_destr(task_header_t *_task)
225 ready_state_task_t *task = (ready_state_task_t*)_task;
227 IUnknown_Release(task->doc);
231 static void ready_state_proc(DocHost *This, task_header_t *_task)
233 ready_state_task_t *task = (ready_state_task_t*)_task;
235 if(task->doc == This->document)
236 update_ready_state(This, task->ready_state);
239 static void push_ready_state_task(DocHost *This, READYSTATE ready_state)
241 ready_state_task_t *task = heap_alloc(sizeof(ready_state_task_t));
243 IUnknown_AddRef(This->document);
244 task->doc = This->document;
245 task->ready_state = ready_state;
247 push_dochost_task(This, &task->header, ready_state_proc, ready_state_task_destr, FALSE);
250 static void object_available_task_destr(task_header_t *task)
255 static void object_available_proc(DocHost *This, task_header_t *task)
257 object_available(This);
260 HRESULT dochost_object_available(DocHost *This, IUnknown *doc)
262 READYSTATE ready_state;
267 IUnknown_AddRef(doc);
268 This->document = doc;
270 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
271 if(SUCCEEDED(hres)) {
274 hres = IOleObject_GetUserClassID(oleobj, &clsid);
276 TRACE("Got clsid %s\n",
277 IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid));
279 hres = IOleObject_SetClientSite(oleobj, &This->IOleClientSite_iface);
281 FIXME("SetClientSite failed: %08x\n", hres);
283 IOleObject_Release(oleobj);
285 FIXME("Could not get IOleObject iface: %08x\n", hres);
288 /* FIXME: Call SetAdvise */
290 task = heap_alloc(sizeof(*task));
291 push_dochost_task(This, task, object_available_proc, object_available_task_destr, FALSE);
293 hres = get_doc_ready_state(This, &ready_state);
294 if(SUCCEEDED(hres)) {
295 if(ready_state == READYSTATE_COMPLETE)
296 push_ready_state_task(This, READYSTATE_COMPLETE);
297 if(ready_state != READYSTATE_COMPLETE || This->doc_navigate)
298 advise_prop_notif(This, TRUE);
304 static LRESULT resize_document(DocHost *This, LONG width, LONG height)
306 RECT rect = {0, 0, width, height};
308 TRACE("(%p)->(%d %d)\n", This, width, height);
311 IOleDocumentView_SetRect(This->view, &rect);
316 static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
320 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
322 if(msg == WM_CREATE) {
323 This = *(DocHost**)lParam;
324 SetPropW(hwnd, wszTHIS, This);
326 This = GetPropW(hwnd, wszTHIS);
331 return resize_document(This, LOWORD(lParam), HIWORD(lParam));
334 return DefWindowProcW(hwnd, msg, wParam, lParam);
337 static void free_travellog_entry(travellog_entry_t *entry)
340 IStream_Release(entry->stream);
341 heap_free(entry->url);
344 static IStream *get_travellog_stream(DocHost *This)
346 IPersistHistory *persist_history;
350 hres = IUnknown_QueryInterface(This->document, &IID_IPersistHistory, (void**)&persist_history);
354 hres = CreateStreamOnHGlobal(NULL, TRUE, &stream);
356 hres = IPersistHistory_SaveHistory(persist_history, stream);
357 IPersistHistory_Release(persist_history);
359 IStream_Release(stream);
366 static void update_travellog(DocHost *This)
368 travellog_entry_t *new_entry;
370 if(This->travellog.loading_pos == -1) {
371 /* Clear forward history. */
372 if(!This->travellog.log) {
373 This->travellog.log = heap_alloc(4 * sizeof(*This->travellog.log));
374 if(!This->travellog.log)
377 This->travellog.size = 4;
378 }else if(This->travellog.size < This->travellog.position+1) {
379 travellog_entry_t *new_travellog;
381 new_travellog = heap_realloc(This->travellog.log, This->travellog.size*2*sizeof(*This->travellog.log));
385 This->travellog.log = new_travellog;
386 This->travellog.size *= 2;
389 while(This->travellog.length > This->travellog.position)
390 free_travellog_entry(This->travellog.log + --This->travellog.length);
393 new_entry = This->travellog.log + This->travellog.position;
395 new_entry->url = heap_strdupW(This->url);
396 TRACE("Adding %s at %d\n", debugstr_w(This->url), This->travellog.position);
400 new_entry->stream = get_travellog_stream(This);
402 if(This->travellog.loading_pos == -1) {
403 This->travellog.position++;
405 This->travellog.position = This->travellog.loading_pos;
406 This->travellog.loading_pos = -1;
408 if(This->travellog.position > This->travellog.length)
409 This->travellog.length = This->travellog.position;
412 void create_doc_view_hwnd(DocHost *This)
416 static const WCHAR wszShell_DocObject_View[] =
417 {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
420 static WNDCLASSEXW wndclass = {
424 0, 0 /* native uses 4*/, NULL, NULL, NULL,
425 (HBRUSH)(COLOR_WINDOW + 1), NULL,
426 wszShell_DocObject_View,
430 wndclass.hInstance = ieframe_instance;
432 doc_view_atom = RegisterClassExW(&wndclass);
435 This->container_vtbl->GetDocObjRect(This, &rect);
436 This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
437 wszShell_DocObject_View,
438 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
439 rect.left, rect.top, rect.right, rect.bottom, This->frame_hwnd,
440 NULL, ieframe_instance, This);
443 void deactivate_document(DocHost *This)
445 IOleInPlaceObjectWindowless *winobj;
446 IOleObject *oleobj = NULL;
447 IHlinkTarget *hlink = NULL;
450 if(!This->document) return;
452 if(This->doc_navigate) {
453 IUnknown_Release(This->doc_navigate);
454 This->doc_navigate = NULL;
457 if(This->is_prop_notif)
458 advise_prop_notif(This, FALSE);
461 IOleDocumentView_UIActivate(This->view, FALSE);
463 hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
465 if(SUCCEEDED(hres)) {
466 IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
467 IOleInPlaceObjectWindowless_Release(winobj);
471 IOleDocumentView_Show(This->view, FALSE);
472 IOleDocumentView_CloseView(This->view, 0);
473 IOleDocumentView_SetInPlaceSite(This->view, NULL);
474 IOleDocumentView_Release(This->view);
478 hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
480 IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
482 hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
483 if(SUCCEEDED(hres)) {
484 IHlinkTarget_SetBrowseContext(hlink, NULL);
485 IHlinkTarget_Release(hlink);
489 IOleClientSite *client_site = NULL;
491 IOleObject_GetClientSite(oleobj, &client_site);
493 if(client_site == &This->IOleClientSite_iface)
494 IOleObject_SetClientSite(oleobj, NULL);
495 IOleClientSite_Release(client_site);
498 IOleObject_Release(oleobj);
501 IUnknown_Release(This->document);
502 This->document = NULL;
505 HRESULT refresh_document(DocHost *This)
507 IOleCommandTarget *cmdtrg;
511 if(!This->document) {
512 FIXME("no document\n");
516 hres = IUnknown_QueryInterface(This->document, &IID_IOleCommandTarget, (void**)&cmdtrg);
520 V_VT(&vin) = VT_EMPTY;
521 V_VT(&vout) = VT_EMPTY;
522 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_REFRESH, OLECMDEXECOPT_PROMPTUSER, &vin, &vout);
523 IOleCommandTarget_Release(cmdtrg);
531 void release_dochost_client(DocHost *This)
534 DestroyWindow(This->hwnd);
539 IDocHostUIHandler_Release(This->hostui);
543 if(This->client_disp) {
544 IDispatch_Release(This->client_disp);
545 This->client_disp = NULL;
549 IOleInPlaceFrame_Release(This->frame);
554 static inline DocHost *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
556 return CONTAINING_RECORD(iface, DocHost, IOleCommandTarget_iface);
559 static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
560 REFIID riid, void **ppv)
562 DocHost *This = impl_from_IOleCommandTarget(iface);
563 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
566 static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
568 DocHost *This = impl_from_IOleCommandTarget(iface);
569 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
572 static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface)
574 DocHost *This = impl_from_IOleCommandTarget(iface);
575 return IOleClientSite_Release(&This->IOleClientSite_iface);
578 static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
579 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
581 DocHost *This = impl_from_IOleCommandTarget(iface);
583 FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
585 while (prgCmds && (cCmds > i)) {
586 FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf);
592 static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
593 const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
596 DocHost *This = impl_from_IOleCommandTarget(iface);
598 TRACE("(%p)->(%s %d %d %s %s)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
599 debugstr_variant(pvaIn), debugstr_variant(pvaOut));
603 case OLECMDID_UPDATECOMMANDS:
604 case OLECMDID_SETDOWNLOADSTATE:
605 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
607 FIXME("Unimplemented cmdid %d\n", nCmdID);
612 if(IsEqualGUID(pguidCmdGroup, &CGID_DocHostCmdPriv)) {
614 case DOCHOST_DOCCANNAVIGATE:
615 if(!pvaIn || V_VT(pvaIn) != VT_UNKNOWN)
618 if(This->doc_navigate)
619 IUnknown_Release(This->doc_navigate);
620 IUnknown_AddRef(V_UNKNOWN(pvaIn));
621 This->doc_navigate = V_UNKNOWN(pvaIn);
626 SAFEARRAY *sa = V_ARRAY(pvaIn);
627 VARIANT status_code, url, htmlwindow;
631 if(V_VT(pvaIn) != VT_ARRAY || !sa || (SafeArrayGetDim(sa) != 1))
635 hres = SafeArrayGetElement(sa, &ind, &status_code);
636 if(FAILED(hres) || V_VT(&status_code)!=VT_I4)
640 hres = SafeArrayGetElement(sa, &ind, &url);
641 if(FAILED(hres) || V_VT(&url)!=VT_BSTR)
645 hres = SafeArrayGetElement(sa, &ind, &htmlwindow);
646 if(FAILED(hres) || V_VT(&htmlwindow)!=VT_UNKNOWN || !V_UNKNOWN(&htmlwindow))
649 hres = IUnknown_QueryInterface(V_UNKNOWN(&htmlwindow), &IID_IHTMLWindow2, (void**)&win2);
653 handle_navigation_error(This, V_I4(&status_code), V_BSTR(&url), win2);
654 IHTMLWindow2_Release(win2);
659 FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID);
664 if(IsEqualGUID(pguidCmdGroup, &CGID_Explorer)) {
666 case CMDID_EXPLORER_UPDATEHISTORY:
667 update_travellog(This);
671 FIXME("Unimplemented cmdid %d of CGID_Explorer\n", nCmdID);
676 if(IsEqualGUID(pguidCmdGroup, &CGID_ShellDocView)) {
679 FIXME("Unimplemented cmdid %d of CGID_ShellDocView\n", nCmdID);
684 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup))
685 return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
687 FIXME("Unimplemented cmdid %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup));
691 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
692 ClOleCommandTarget_QueryInterface,
693 ClOleCommandTarget_AddRef,
694 ClOleCommandTarget_Release,
695 ClOleCommandTarget_QueryStatus,
696 ClOleCommandTarget_Exec
699 static inline DocHost *impl_from_IDocHostUIHandler2(IDocHostUIHandler2 *iface)
701 return CONTAINING_RECORD(iface, DocHost, IDocHostUIHandler2_iface);
704 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
705 REFIID riid, void **ppv)
707 DocHost *This = impl_from_IDocHostUIHandler2(iface);
708 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
711 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
713 DocHost *This = impl_from_IDocHostUIHandler2(iface);
714 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
717 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
719 DocHost *This = impl_from_IDocHostUIHandler2(iface);
720 return IOleClientSite_Release(&This->IOleClientSite_iface);
723 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
724 DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
726 DocHost *This = impl_from_IDocHostUIHandler2(iface);
729 TRACE("(%p)->(%d %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
732 hres = IDocHostUIHandler_ShowContextMenu(This->hostui, dwID, ppt, pcmdtReserved,
738 FIXME("default action not implemented\n");
742 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
743 DOCHOSTUIINFO *pInfo)
745 DocHost *This = impl_from_IDocHostUIHandler2(iface);
748 TRACE("(%p)->(%p)\n", This, pInfo);
751 hres = IDocHostUIHandler_GetHostInfo(This->hostui, pInfo);
756 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
757 | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
758 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
762 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
763 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
764 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
766 DocHost *This = impl_from_IDocHostUIHandler2(iface);
767 FIXME("(%p)->(%d %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
772 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
774 DocHost *This = impl_from_IDocHostUIHandler2(iface);
775 FIXME("(%p)\n", This);
779 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
781 DocHost *This = impl_from_IDocHostUIHandler2(iface);
783 TRACE("(%p)\n", This);
788 return IDocHostUIHandler_UpdateUI(This->hostui);
791 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
794 DocHost *This = impl_from_IDocHostUIHandler2(iface);
795 FIXME("(%p)->(%x)\n", This, fEnable);
799 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
802 DocHost *This = impl_from_IDocHostUIHandler2(iface);
803 FIXME("(%p)->(%x)\n", This, fActivate);
807 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
810 DocHost *This = impl_from_IDocHostUIHandler2(iface);
811 FIXME("(%p)->(%x)\n", This, fActivate);
815 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
816 LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
818 DocHost *This = impl_from_IDocHostUIHandler2(iface);
819 FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
823 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
824 LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
826 DocHost *This = impl_from_IDocHostUIHandler2(iface);
827 HRESULT hr = S_FALSE;
828 TRACE("(%p)->(%p %p %d)\n", This, lpMsg, pguidCmdGroup, nCmdID);
831 hr = IDocHostUIHandler_TranslateAccelerator(This->hostui, lpMsg, pguidCmdGroup, nCmdID);
836 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
837 LPOLESTR *pchKey, DWORD dw)
839 DocHost *This = impl_from_IDocHostUIHandler2(iface);
841 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
844 return IDocHostUIHandler_GetOptionKeyPath(This->hostui, pchKey, dw);
849 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
850 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
852 DocHost *This = impl_from_IDocHostUIHandler2(iface);
853 FIXME("(%p)\n", This);
857 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
858 IDispatch **ppDispatch)
860 DocHost *This = impl_from_IDocHostUIHandler2(iface);
862 TRACE("(%p)->(%p)\n", This, ppDispatch);
865 return IDocHostUIHandler_GetExternal(This->hostui, ppDispatch);
867 if(!This->shell_ui_helper) {
870 hres = create_shell_ui_helper(&This->shell_ui_helper);
875 *ppDispatch = (IDispatch*)This->shell_ui_helper;
876 IDispatch_AddRef(*ppDispatch);
880 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
881 DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
883 DocHost *This = impl_from_IDocHostUIHandler2(iface);
885 TRACE("(%p)->(%d %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
888 return IDocHostUIHandler_TranslateUrl(This->hostui, dwTranslate,
889 pchURLIn, ppchURLOut);
894 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
895 IDataObject *pDO, IDataObject **ppDORet)
897 DocHost *This = impl_from_IDocHostUIHandler2(iface);
898 FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
902 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
903 LPOLESTR *pchKey, DWORD dw)
905 DocHost *This = impl_from_IDocHostUIHandler2(iface);
906 IDocHostUIHandler2 *handler;
909 TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
914 hres = IDocHostUIHandler_QueryInterface(This->hostui, &IID_IDocHostUIHandler2,
916 if(SUCCEEDED(hres)) {
917 hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
918 IDocHostUIHandler2_Release(handler);
925 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
926 DocHostUIHandler_QueryInterface,
927 DocHostUIHandler_AddRef,
928 DocHostUIHandler_Release,
929 DocHostUIHandler_ShowContextMenu,
930 DocHostUIHandler_GetHostInfo,
931 DocHostUIHandler_ShowUI,
932 DocHostUIHandler_HideUI,
933 DocHostUIHandler_UpdateUI,
934 DocHostUIHandler_EnableModeless,
935 DocHostUIHandler_OnDocWindowActivate,
936 DocHostUIHandler_OnFrameWindowActivate,
937 DocHostUIHandler_ResizeBorder,
938 DocHostUIHandler_TranslateAccelerator,
939 DocHostUIHandler_GetOptionKeyPath,
940 DocHostUIHandler_GetDropTarget,
941 DocHostUIHandler_GetExternal,
942 DocHostUIHandler_TranslateUrl,
943 DocHostUIHandler_FilterDataObject,
944 DocHostUIHandler_GetOverrideKeyPath
947 static inline DocHost *impl_from_IPropertyNotifySink(IPropertyNotifySink *iface)
949 return CONTAINING_RECORD(iface, DocHost, IPropertyNotifySink_iface);
952 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
953 REFIID riid, void **ppv)
955 DocHost *This = impl_from_IPropertyNotifySink(iface);
956 return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppv);
959 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
961 DocHost *This = impl_from_IPropertyNotifySink(iface);
962 return IOleClientSite_AddRef(&This->IOleClientSite_iface);
965 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
967 DocHost *This = impl_from_IPropertyNotifySink(iface);
968 return IOleClientSite_Release(&This->IOleClientSite_iface);
971 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
973 DocHost *This = impl_from_IPropertyNotifySink(iface);
975 TRACE("(%p)->(%d)\n", This, dispID);
978 case DISPID_READYSTATE: {
979 READYSTATE ready_state;
982 hres = get_doc_ready_state(This, &ready_state);
986 if(ready_state == READYSTATE_COMPLETE && !This->doc_navigate)
987 advise_prop_notif(This, FALSE);
989 update_ready_state(This, ready_state);
993 FIXME("unimplemented dispid %d\n", dispID);
1000 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
1002 DocHost *This = impl_from_IPropertyNotifySink(iface);
1003 FIXME("(%p)->(%d)\n", This, dispID);
1007 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
1008 PropertyNotifySink_QueryInterface,
1009 PropertyNotifySink_AddRef,
1010 PropertyNotifySink_Release,
1011 PropertyNotifySink_OnChanged,
1012 PropertyNotifySink_OnRequestEdit
1015 void DocHost_Init(DocHost *This, IWebBrowser2 *wb, const IDocHostContainerVtbl* container)
1017 This->IDocHostUIHandler2_iface.lpVtbl = &DocHostUIHandler2Vtbl;
1018 This->IOleCommandTarget_iface.lpVtbl = &OleCommandTargetVtbl;
1019 This->IPropertyNotifySink_iface.lpVtbl = &PropertyNotifySinkVtbl;
1022 This->container_vtbl = container;
1024 This->ready_state = READYSTATE_UNINITIALIZED;
1025 list_init(&This->task_queue);
1027 This->travellog.loading_pos = -1;
1029 DocHost_ClientSite_Init(This);
1030 DocHost_Frame_Init(This);
1032 ConnectionPointContainer_Init(&This->cps, (IUnknown*)wb);
1033 IEHTMLWindow_Init(This);
1034 NewWindowManager_Init(This);
1037 void DocHost_Release(DocHost *This)
1039 if(This->shell_ui_helper)
1040 IShellUIHelper2_Release(This->shell_ui_helper);
1042 abort_dochost_tasks(This, NULL);
1043 release_dochost_client(This);
1044 DocHost_ClientSite_Release(This);
1046 ConnectionPointContainer_Destroy(&This->cps);
1048 while(This->travellog.length)
1049 free_travellog_entry(This->travellog.log + --This->travellog.length);
1050 heap_free(This->travellog.log);
1052 heap_free(This->url);