2 * Copyright 2006-2007 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
19 #define NONAMELESSUNION
20 #define NONAMELESSSTRUCT
22 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
32 static const WCHAR emptyW[] = {0};
35 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
36 const IHttpNegotiateVtbl *lpHttpNegotiateVtbl;
48 #define BINDSC(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
49 #define HTTPNEG(x) ((IHttpNegotiate*) &(x)->lpHttpNegotiateVtbl)
51 static void dump_BINDINFO(BINDINFO *bi)
53 static const char * const BINDINFOF_str[] = {
55 "BINDINFOF_URLENCODESTGMEDDATA",
56 "BINDINFOF_URLENCODEDEXTRAINFO"
59 static const char * const BINDVERB_str[] = {
79 bi->cbSize, debugstr_w(bi->szExtraInfo),
80 bi->stgmedData.tymed, bi->stgmedData.u.hGlobal, bi->stgmedData.pUnkForRelease,
81 bi->grfBindInfoF > BINDINFOF_URLENCODEDEXTRAINFO
82 ? "unknown" : BINDINFOF_str[bi->grfBindInfoF],
83 bi->dwBindVerb > BINDVERB_CUSTOM
84 ? "unknown" : BINDVERB_str[bi->dwBindVerb],
85 debugstr_w(bi->szCustomVerb),
86 bi->cbstgmedData, bi->dwOptions, bi->dwOptionsFlags, bi->dwCodePage,
87 bi->securityAttributes.nLength,
88 bi->securityAttributes.lpSecurityDescriptor,
89 bi->securityAttributes.bInheritHandle,
90 debugstr_guid(&bi->iid),
91 bi->pUnk, bi->dwReserved
95 static void set_status_text(BindStatusCallback *This, LPCWSTR str)
98 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
103 V_VT(&arg) = VT_BSTR;
104 V_BSTR(&arg) = str ? SysAllocString(str) : NULL;
105 call_sink(This->doc_host->cps.wbe2, DISPID_STATUSTEXTCHANGE, &dispparams);
108 if(This->doc_host->frame)
109 IOleInPlaceFrame_SetStatusText(This->doc_host->frame, str);
112 #define BINDSC_THIS(iface) DEFINE_THIS(BindStatusCallback, BindStatusCallback, iface)
114 static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
115 REFIID riid, void **ppv)
117 BindStatusCallback *This = BINDSC_THIS(iface);
121 if(IsEqualGUID(&IID_IUnknown, riid)) {
122 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
124 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
125 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This, ppv);
127 }else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
128 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv);
129 *ppv = HTTPNEG(This);
133 IBindStatusCallback_AddRef(BINDSC(This));
137 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
138 return E_NOINTERFACE;
141 static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
143 BindStatusCallback *This = BINDSC_THIS(iface);
144 LONG ref = InterlockedIncrement(&This->ref);
146 TRACE("(%p) ref=%d\n", This, ref);
151 static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
153 BindStatusCallback *This = BINDSC_THIS(iface);
154 LONG ref = InterlockedDecrement(&This->ref);
156 TRACE("(%p) ref=%d\n", This, ref);
160 IOleClientSite_Release(CLIENTSITE(This->doc_host));
162 GlobalFree(This->post_data);
164 SysFreeString(This->headers);
165 heap_free(This->url);
172 static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
173 DWORD dwReserved, IBinding *pbind)
175 BindStatusCallback *This = BINDSC_THIS(iface);
177 TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
182 static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface,
185 BindStatusCallback *This = BINDSC_THIS(iface);
186 FIXME("(%p)->(%p)\n", This, pnPriority);
190 static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface,
193 BindStatusCallback *This = BINDSC_THIS(iface);
194 FIXME("(%p)->(%d)\n", This, reserved);
198 static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface,
199 ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
201 BindStatusCallback *This = BINDSC_THIS(iface);
203 TRACE("(%p)->(%d %d %d %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
204 debugstr_w(szStatusText));
206 switch(ulStatusCode) {
207 case BINDSTATUS_BEGINDOWNLOADDATA:
208 set_status_text(This, szStatusText); /* FIXME: "Start downloading from site: %s" */
210 case BINDSTATUS_ENDDOWNLOADDATA:
211 set_status_text(This, szStatusText); /* FIXME: "Downloading from site: %s" */
213 case BINDSTATUS_CLASSIDAVAILABLE:
214 case BINDSTATUS_MIMETYPEAVAILABLE:
215 case BINDSTATUS_BEGINSYNCOPERATION:
216 case BINDSTATUS_ENDSYNCOPERATION:
219 FIXME("status code %u\n", ulStatusCode);
225 static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
226 HRESULT hresult, LPCWSTR szError)
228 BindStatusCallback *This = BINDSC_THIS(iface);
230 TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
232 set_status_text(This, emptyW);
235 IOleClientSite_Release(CLIENTSITE(This->doc_host));
236 This->doc_host = NULL;
242 static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
243 DWORD *grfBINDF, BINDINFO *pbindinfo)
245 BindStatusCallback *This = BINDSC_THIS(iface);
247 TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
249 *grfBINDF = BINDF_ASYNCHRONOUS;
251 if(This->post_data) {
252 pbindinfo->dwBindVerb = BINDVERB_POST;
254 pbindinfo->stgmedData.tymed = TYMED_HGLOBAL;
255 pbindinfo->stgmedData.u.hGlobal = This->post_data;
256 pbindinfo->cbstgmedData = This->post_data_len;
257 pbindinfo->stgmedData.pUnkForRelease = (IUnknown*)BINDSC(This);
258 IBindStatusCallback_AddRef(BINDSC(This));
264 static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
265 DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
267 BindStatusCallback *This = BINDSC_THIS(iface);
268 FIXME("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
272 static void object_available_proc(DocHost *This, task_header_t *task)
274 object_available(This);
277 static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
278 REFIID riid, IUnknown *punk)
280 BindStatusCallback *This = BINDSC_THIS(iface);
285 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
287 IUnknown_AddRef(punk);
288 This->doc_host->document = punk;
290 hres = IUnknown_QueryInterface(punk, &IID_IOleObject, (void**)&oleobj);
291 if(SUCCEEDED(hres)) {
294 hres = IOleObject_GetUserClassID(oleobj, &clsid);
296 TRACE("Got clsid %s\n",
297 IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid));
299 hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This->doc_host));
301 FIXME("SetClientSite failed: %08x\n", hres);
303 IOleObject_Release(oleobj);
305 FIXME("Could not get IOleObject iface: %08x\n", hres);
308 /* FIXME: Call SetAdvise */
309 /* FIXME: Call Invoke(DISPID_READYSTATE) */
311 task = heap_alloc(sizeof(*task));
312 push_dochost_task(This->doc_host, task, object_available_proc, FALSE);
319 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
320 BindStatusCallback_QueryInterface,
321 BindStatusCallback_AddRef,
322 BindStatusCallback_Release,
323 BindStatusCallback_OnStartBinding,
324 BindStatusCallback_GetPriority,
325 BindStatusCallback_OnLowResource,
326 BindStatusCallback_OnProgress,
327 BindStatusCallback_OnStopBinding,
328 BindStatusCallback_GetBindInfo,
329 BindStatusCallback_OnDataAvailable,
330 BindStatusCallback_OnObjectAvailable
333 #define HTTPNEG_THIS(iface) DEFINE_THIS(BindStatusCallback, HttpNegotiate, iface)
335 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate *iface,
336 REFIID riid, void **ppv)
338 BindStatusCallback *This = HTTPNEG_THIS(iface);
339 return IBindStatusCallback_QueryInterface(BINDSC(This), riid, ppv);
342 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate *iface)
344 BindStatusCallback *This = HTTPNEG_THIS(iface);
345 return IBindStatusCallback_AddRef(BINDSC(This));
348 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate *iface)
350 BindStatusCallback *This = HTTPNEG_THIS(iface);
351 return IBindStatusCallback_Release(BINDSC(This));
354 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate *iface,
355 LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
357 BindStatusCallback *This = HTTPNEG_THIS(iface);
359 FIXME("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders),
360 dwReserved, pszAdditionalHeaders);
363 int size = (strlenW(This->headers)+1)*sizeof(WCHAR);
364 *pszAdditionalHeaders = CoTaskMemAlloc(size);
365 memcpy(*pszAdditionalHeaders, This->headers, size);
371 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate *iface,
372 DWORD dwResponseCode, LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders,
373 LPWSTR *pszAdditionalRequestHeaders)
375 BindStatusCallback *This = HTTPNEG_THIS(iface);
376 FIXME("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
377 debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
383 static const IHttpNegotiateVtbl HttpNegotiateVtbl = {
384 HttpNegotiate_QueryInterface,
385 HttpNegotiate_AddRef,
386 HttpNegotiate_Release,
387 HttpNegotiate_BeginningTransaction,
388 HttpNegotiate_OnResponse
391 static BindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE post_data,
392 ULONG post_data_len, LPCWSTR headers)
394 BindStatusCallback *ret = heap_alloc(sizeof(BindStatusCallback));
396 ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl;
397 ret->lpHttpNegotiateVtbl = &HttpNegotiateVtbl;
400 ret->url = heap_strdupW(url);
401 ret->post_data = NULL;
402 ret->post_data_len = post_data_len;
403 ret->headers = headers ? SysAllocString(headers) : NULL;
405 ret->doc_host = doc_host;
406 IOleClientSite_AddRef(CLIENTSITE(doc_host));
409 ret->post_data = GlobalAlloc(0, post_data_len);
410 memcpy(ret->post_data, post_data, post_data_len);
416 static void on_before_navigate2(DocHost *This, LPCWSTR url, const BYTE *post_data,
417 ULONG post_data_len, LPWSTR headers, VARIANT_BOOL *cancel)
419 VARIANT var_url, var_flags, var_frame_name, var_post_data, var_post_data2, var_headers;
420 DISPPARAMS dispparams;
421 VARIANTARG params[7];
423 dispparams.cArgs = 7;
424 dispparams.cNamedArgs = 0;
425 dispparams.rgdispidNamedArgs = NULL;
426 dispparams.rgvarg = params;
428 V_VT(params) = VT_BOOL|VT_BYREF;
429 V_BOOLREF(params) = cancel;
431 V_VT(params+1) = (VT_BYREF|VT_VARIANT);
432 V_VARIANTREF(params+1) = &var_headers;
433 V_VT(&var_headers) = VT_BSTR;
434 V_BSTR(&var_headers) = headers;
436 V_VT(params+2) = (VT_BYREF|VT_VARIANT);
437 V_VARIANTREF(params+2) = &var_post_data2;
438 V_VT(&var_post_data2) = (VT_BYREF|VT_VARIANT);
439 V_VARIANTREF(&var_post_data2) = &var_post_data;
440 VariantInit(&var_post_data);
443 SAFEARRAYBOUND bound = {post_data_len, 0};
446 V_VT(&var_post_data) = VT_UI1|VT_ARRAY;
447 V_ARRAY(&var_post_data) = SafeArrayCreate(VT_UI1, 1, &bound);
449 SafeArrayAccessData(V_ARRAY(&var_post_data), &data);
450 memcpy(data, post_data, post_data_len);
451 SafeArrayUnaccessData(V_ARRAY(&var_post_data));
454 V_VT(params+3) = (VT_BYREF|VT_VARIANT);
455 V_VARIANTREF(params+3) = &var_frame_name;
456 V_VT(&var_frame_name) = VT_BSTR;
457 V_BSTR(&var_frame_name) = NULL;
459 V_VT(params+4) = (VT_BYREF|VT_VARIANT);
460 V_VARIANTREF(params+4) = &var_flags;
461 V_VT(&var_flags) = VT_I4;
462 V_I4(&var_flags) = 0;
464 V_VT(params+5) = (VT_BYREF|VT_VARIANT);
465 V_VARIANTREF(params+5) = &var_url;
466 V_VT(&var_url) = VT_BSTR;
467 V_BSTR(&var_url) = SysAllocString(url);
469 V_VT(params+6) = (VT_DISPATCH);
470 V_DISPATCH(params+6) = This->disp;
472 call_sink(This->cps.wbe2, DISPID_BEFORENAVIGATE2, &dispparams);
474 SysFreeString(V_BSTR(&var_url));
476 SafeArrayDestroy(V_ARRAY(&var_post_data));
479 /* FIXME: urlmon should handle it */
480 static BOOL try_application_url(LPCWSTR url)
482 SHELLEXECUTEINFOW exec_info;
488 static const WCHAR wszURLProtocol[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
490 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, app, sizeof(app)/sizeof(WCHAR), NULL, 0);
494 res = RegOpenKeyW(HKEY_CLASSES_ROOT, app, &hkey);
495 if(res != ERROR_SUCCESS)
498 res = RegQueryValueExW(hkey, wszURLProtocol, NULL, &type, NULL, NULL);
500 if(res != ERROR_SUCCESS || type != REG_SZ)
503 TRACE("openning application %s\n", debugstr_w(app));
505 memset(&exec_info, 0, sizeof(exec_info));
506 exec_info.cbSize = sizeof(exec_info);
507 exec_info.lpFile = url;
508 exec_info.nShow = SW_SHOW;
510 return ShellExecuteExW(&exec_info);
513 static HRESULT http_load_hack(DocHost *This, IMoniker *mon, IBindStatusCallback *callback, IBindCtx *bindctx)
515 IPersistMoniker *persist;
521 * We should use URLMoniker's BindToObject instead creating HTMLDocument here.
522 * This should be fixed when mshtml.dll and urlmon.dll will be good enough.
525 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL,
526 CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
527 &IID_IUnknown, (void**)&doc);
530 ERR("Could not create HTMLDocument: %08x\n", hres);
534 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist);
536 IUnknown_Release(doc);
540 hres = IPersistMoniker_Load(persist, FALSE, mon, bindctx, 0);
541 IPersistMoniker_Release(persist);
544 hres = IBindStatusCallback_OnObjectAvailable(callback, &IID_IUnknown, doc);
546 WARN("Load failed: %08x\n", hres);
548 IUnknown_Release(doc);
550 return IBindStatusCallback_OnStopBinding(callback, hres, NULL);
553 static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx,
554 IBindStatusCallback *callback)
560 static const WCHAR httpW[] = {'h','t','t','p',0};
561 static const WCHAR httpsW[] = {'h','t','t','p','s',0};
562 static const WCHAR ftpW[]= {'f','t','p',0};
565 IMoniker_AddRef(mon);
567 hres = CreateURLMoniker(NULL, url, &mon);
569 WARN("CreateURLMoniker failed: %08x\n", hres);
574 CoTaskMemFree(This->url);
575 hres = IMoniker_GetDisplayName(mon, 0, NULL, &This->url);
577 FIXME("GetDisplayName failed: %08x\n", hres);
579 IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM,
580 (IUnknown*)CLIENTSITE(This));
582 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
584 if(SUCCEEDED(hres) &&
585 (!strcmpW(schema, httpW) || !strcmpW(schema, httpsW) || !strcmpW(schema, ftpW))) {
586 hres = http_load_hack(This, mon, callback, bindctx);
588 IUnknown *unk = NULL;
590 hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk);
591 if(SUCCEEDED(hres)) {
594 IUnknown_Release(unk);
595 }else if(try_application_url(url)) {
598 FIXME("BindToObject failed: %08x\n", hres);
602 IMoniker_Release(mon);
606 static HRESULT navigate_bsc(DocHost *This, BindStatusCallback *bsc, IMoniker *mon)
609 VARIANT_BOOL cancel = VARIANT_FALSE;
612 on_before_navigate2(This, bsc->url, bsc->post_data, bsc->post_data_len, bsc->headers, &cancel);
614 FIXME("Navigation canceled\n");
619 deactivate_document(This);
621 CreateAsyncBindCtx(0, BINDSC(bsc), 0, &bindctx);
624 IOleInPlaceFrame_EnableModeless(This->frame, FALSE);
626 hres = bind_to_object(This, mon, bsc->url, bindctx, BINDSC(bsc));
629 IOleInPlaceFrame_EnableModeless(This->frame, TRUE);
631 IBindCtx_Release(bindctx);
637 task_header_t header;
638 BindStatusCallback *bsc;
639 } task_navigate_bsc_t;
641 static void navigate_bsc_proc(DocHost *This, task_header_t *t)
643 task_navigate_bsc_t *task = (task_navigate_bsc_t*)t;
646 create_doc_view_hwnd(This);
648 navigate_bsc(This, task->bsc, NULL);
650 IBindStatusCallback_Release(BINDSC(task->bsc));
654 HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags,
655 const VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
657 task_navigate_bsc_t *task;
658 PBYTE post_data = NULL;
659 ULONG post_data_len = 0;
660 LPWSTR headers = NULL;
662 TRACE("navigating to %s\n", debugstr_w(url));
664 if((Flags && V_VT(Flags) != VT_EMPTY)
665 || (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY))
666 FIXME("Unsupported args (Flags %p:%d; TargetFrameName %p:%d)\n",
667 Flags, Flags ? V_VT(Flags) : -1, TargetFrameName,
668 TargetFrameName ? V_VT(TargetFrameName) : -1);
671 TRACE("PostData vt=%d\n", V_VT(PostData));
673 if(V_VT(PostData) == (VT_ARRAY | VT_UI1)) {
674 SafeArrayAccessData(V_ARRAY(PostData), (void**)&post_data);
675 post_data_len = V_ARRAY(PostData)->rgsabound[0].cElements;
679 if(Headers && V_VT(Headers) != VT_EMPTY && V_VT(Headers) != VT_ERROR) {
680 if(V_VT(Headers) != VT_BSTR)
683 headers = V_BSTR(Headers);
684 TRACE("Headers: %s\n", debugstr_w(headers));
687 task = heap_alloc(sizeof(*task));
688 task->bsc = create_callback(This, url, post_data, post_data_len, headers);
691 SafeArrayUnaccessData(V_ARRAY(PostData));
693 push_dochost_task(This, &task->header, navigate_bsc_proc, This->url == NULL);
698 static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
699 IBindStatusCallback *callback)
701 IHttpNegotiate *http_negotiate;
702 BindStatusCallback *bsc;
703 PBYTE post_data = NULL;
704 ULONG post_data_len = 0;
705 LPWSTR headers = NULL, url;
710 hres = IBindStatusCallback_QueryInterface(callback, &IID_IHttpNegotiate,
711 (void**)&http_negotiate);
712 if(SUCCEEDED(hres)) {
713 static const WCHAR null_string[] = {0};
715 IHttpNegotiate_BeginningTransaction(http_negotiate, null_string, null_string, 0,
717 IHttpNegotiate_Release(http_negotiate);
720 memset(&bindinfo, 0, sizeof(bindinfo));
721 bindinfo.cbSize = sizeof(bindinfo);
723 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
724 dump_BINDINFO(&bindinfo);
725 if(bindinfo.dwBindVerb == BINDVERB_POST) {
726 post_data_len = bindinfo.cbstgmedData;
728 post_data = bindinfo.stgmedData.u.hGlobal;
731 hres = IMoniker_GetDisplayName(mon, 0, NULL, &url);
733 FIXME("GetDisplayName failed: %08x\n", hres);
735 bsc = create_callback(This, url, post_data, post_data_len, headers);
738 hres = navigate_bsc(This, bsc, mon);
740 IBindStatusCallback_Release(BINDSC(bsc));
741 CoTaskMemFree(headers);
742 ReleaseBindInfo(&bindinfo);
747 HRESULT go_home(DocHost *This)
749 static const WCHAR wszAboutBlank[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
753 return navigate_url(This, wszAboutBlank, NULL, NULL, NULL, NULL);
756 #define HLINKFRAME_THIS(iface) DEFINE_THIS(WebBrowser, HlinkFrame, iface)
758 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
760 WebBrowser *This = HLINKFRAME_THIS(iface);
761 return IWebBrowser2_QueryInterface(WEBBROWSER2(This), riid, ppv);
764 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
766 WebBrowser *This = HLINKFRAME_THIS(iface);
767 return IWebBrowser2_AddRef(WEBBROWSER2(This));
770 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
772 WebBrowser *This = HLINKFRAME_THIS(iface);
773 return IWebBrowser2_Release(WEBBROWSER2(This));
776 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
777 IHlinkBrowseContext *pihlbc)
779 WebBrowser *This = HLINKFRAME_THIS(iface);
780 FIXME("(%p)->(%p)\n", This, pihlbc);
784 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
785 IHlinkBrowseContext **ppihlbc)
787 WebBrowser *This = HLINKFRAME_THIS(iface);
788 FIXME("(%p)->(%p)\n", This, ppihlbc);
792 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
793 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
795 WebBrowser *This = HLINKFRAME_THIS(iface);
797 LPWSTR location = NULL;
799 TRACE("(%p)->(%08x %p %p %p)\n", This, grfHLNF, pbc, pibsc, pihlNavigate);
802 FIXME("unsupported grfHLNF=%08x\n", grfHLNF);
804 /* Windows calls GetTargetFrameName here. */
806 IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
809 FIXME("location = %s\n", debugstr_w(location));
810 CoTaskMemFree(location);
813 /* Windows calls GetHlinkSite here */
815 if(grfHLNF & HLNF_OPENINNEWWINDOW) {
816 FIXME("Not supported HLNF_OPENINNEWWINDOW\n");
820 return navigate_hlink(&This->doc_host, mon, pbc, pibsc);
823 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
824 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
826 WebBrowser *This = HLINKFRAME_THIS(iface);
827 FIXME("(%p)->(%08x %p %s %s %d)\n", This, grfHLNF, pimkTarget, debugstr_w(pwzLocation),
828 debugstr_w(pwzFriendlyName), dwreserved);
832 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
833 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
835 WebBrowser *This = HLINKFRAME_THIS(iface);
836 FIXME("(%p)->(%u %p %s %s)\n", This, uHLID, pimkTarget, debugstr_w(pwzLocation),
837 debugstr_w(pwzFriendlyName));
841 #undef HLINKFRAME_THIS
843 static const IHlinkFrameVtbl HlinkFrameVtbl = {
844 HlinkFrame_QueryInterface,
847 HlinkFrame_SetBrowseContext,
848 HlinkFrame_GetBrowseContext,
850 HlinkFrame_OnNavigate,
851 HlinkFrame_UpdateHlink
854 void WebBrowser_HlinkFrame_Init(WebBrowser *This)
856 This->lpHlinkFrameVtbl = &HlinkFrameVtbl;