regedit: Make key names editable also with native comctl32.
[wine/multimedia.git] / dlls / ieframe / navigate.c
blobdac10778fc895b9af9d4e9226063c4e27096e23a
1 /*
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 "ieframe.h"
24 #include "exdispid.h"
25 #include "shellapi.h"
26 #include "winreg.h"
27 #include "shlwapi.h"
28 #include "wininet.h"
29 #include "mshtml.h"
30 #include "resource.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
36 static const WCHAR emptyW[] = {0};
38 typedef struct {
39 IBindStatusCallback IBindStatusCallback_iface;
40 IHttpNegotiate IHttpNegotiate_iface;
42 LONG ref;
44 DocHost *doc_host;
45 IBinding *binding;
47 LPWSTR url;
48 HGLOBAL post_data;
49 BSTR headers;
50 ULONG post_data_len;
51 } BindStatusCallback;
53 static void dump_BINDINFO(BINDINFO *bi)
55 static const char * const BINDINFOF_str[] = {
56 "#0",
57 "BINDINFOF_URLENCODESTGMEDDATA",
58 "BINDINFOF_URLENCODEDEXTRAINFO"
61 static const char * const BINDVERB_str[] = {
62 "BINDVERB_GET",
63 "BINDVERB_POST",
64 "BINDVERB_PUT",
65 "BINDVERB_CUSTOM"
68 TRACE("\n"
69 "BINDINFO = {\n"
70 " %d, %s,\n"
71 " {%d, %p, %p},\n"
72 " %s,\n"
73 " %s,\n"
74 " %s,\n"
75 " %d, %08x, %d, %d\n"
76 " {%d %p %x},\n"
77 " %s\n"
78 " %p, %d\n"
79 "}\n",
81 bi->cbSize, debugstr_w(bi->szExtraInfo),
82 bi->stgmedData.tymed, bi->stgmedData.u.hGlobal, bi->stgmedData.pUnkForRelease,
83 bi->grfBindInfoF > BINDINFOF_URLENCODEDEXTRAINFO
84 ? "unknown" : BINDINFOF_str[bi->grfBindInfoF],
85 bi->dwBindVerb > BINDVERB_CUSTOM
86 ? "unknown" : BINDVERB_str[bi->dwBindVerb],
87 debugstr_w(bi->szCustomVerb),
88 bi->cbstgmedData, bi->dwOptions, bi->dwOptionsFlags, bi->dwCodePage,
89 bi->securityAttributes.nLength,
90 bi->securityAttributes.lpSecurityDescriptor,
91 bi->securityAttributes.bInheritHandle,
92 debugstr_guid(&bi->iid),
93 bi->pUnk, bi->dwReserved
97 static void set_status_text(BindStatusCallback *This, ULONG statuscode, LPCWSTR str)
99 VARIANTARG arg;
100 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
101 WCHAR fmt[IDS_STATUSFMT_MAXLEN];
102 WCHAR buffer[IDS_STATUSFMT_MAXLEN + INTERNET_MAX_URL_LENGTH];
104 if(!This->doc_host)
105 return;
107 TRACE("(%p, %d, %s)\n", This, statuscode, debugstr_w(str));
108 buffer[0] = 0;
109 if (statuscode && str && *str) {
110 fmt[0] = 0;
111 /* the format string must have one "%s" for the str */
112 LoadStringW(ieframe_instance, IDS_STATUSFMT_FIRST + statuscode, fmt, IDS_STATUSFMT_MAXLEN);
113 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), fmt, str);
116 V_VT(&arg) = VT_BSTR;
117 V_BSTR(&arg) = str ? SysAllocString(buffer) : NULL;
118 TRACE("=> %s\n", debugstr_w(V_BSTR(&arg)));
120 call_sink(This->doc_host->cps.wbe2, DISPID_STATUSTEXTCHANGE, &dispparams);
122 if(This->doc_host->frame)
123 IOleInPlaceFrame_SetStatusText(This->doc_host->frame, buffer);
125 VariantClear(&arg);
129 HRESULT set_dochost_url(DocHost *This, const WCHAR *url)
131 WCHAR *new_url;
133 if(url) {
134 new_url = heap_strdupW(url);
135 if(!new_url)
136 return E_OUTOFMEMORY;
137 }else {
138 new_url = NULL;
141 heap_free(This->url);
142 This->url = new_url;
144 This->container_vtbl->SetURL(This, This->url);
145 return S_OK;
148 static inline BindStatusCallback *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
150 return CONTAINING_RECORD(iface, BindStatusCallback, IBindStatusCallback_iface);
153 static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
154 REFIID riid, void **ppv)
156 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
158 if(IsEqualGUID(&IID_IUnknown, riid)) {
159 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
160 *ppv = &This->IBindStatusCallback_iface;
161 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
162 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This, ppv);
163 *ppv = &This->IBindStatusCallback_iface;
164 }else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
165 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv);
166 *ppv = &This->IHttpNegotiate_iface;
167 }else {
168 *ppv = NULL;
169 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
170 return E_NOINTERFACE;
173 IUnknown_AddRef((IUnknown*)*ppv);
174 return S_OK;
177 static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
179 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
180 LONG ref = InterlockedIncrement(&This->ref);
182 TRACE("(%p) ref=%d\n", This, ref);
184 return ref;
187 static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
189 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
190 LONG ref = InterlockedDecrement(&This->ref);
192 TRACE("(%p) ref=%d\n", This, ref);
194 if(!ref) {
195 if(This->doc_host)
196 IOleClientSite_Release(&This->doc_host->IOleClientSite_iface);
197 if(This->binding)
198 IBinding_Release(This->binding);
199 if(This->post_data)
200 GlobalFree(This->post_data);
201 SysFreeString(This->headers);
202 heap_free(This->url);
203 heap_free(This);
206 return ref;
209 static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
210 DWORD dwReserved, IBinding *pbind)
212 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
214 TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
216 This->binding = pbind;
217 IBinding_AddRef(This->binding);
219 return S_OK;
222 static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface,
223 LONG *pnPriority)
225 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
226 FIXME("(%p)->(%p)\n", This, pnPriority);
227 return E_NOTIMPL;
230 static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface,
231 DWORD reserved)
233 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
234 FIXME("(%p)->(%d)\n", This, reserved);
235 return E_NOTIMPL;
238 static DWORD get_http_status_code(IBinding *binding)
240 IWinInetHttpInfo *http_info;
241 DWORD status, size = sizeof(DWORD);
242 HRESULT hres;
244 hres = IBinding_QueryInterface(binding, &IID_IWinInetHttpInfo, (void**)&http_info);
245 if(FAILED(hres))
246 return HTTP_STATUS_OK;
248 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
249 &status, &size, NULL, NULL);
250 IWinInetHttpInfo_Release(http_info);
252 if(FAILED(hres))
253 return HTTP_STATUS_OK;
254 return status;
257 static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface,
258 ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
260 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
261 DWORD status_code;
263 TRACE("(%p)->(%d %d %d %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
264 debugstr_w(szStatusText));
266 switch(ulStatusCode) {
267 case BINDSTATUS_REDIRECTING:
268 return set_dochost_url(This->doc_host, szStatusText);
269 case BINDSTATUS_BEGINDOWNLOADDATA:
270 set_status_text(This, ulStatusCode, szStatusText);
271 status_code = get_http_status_code(This->binding);
272 if(status_code != HTTP_STATUS_OK)
273 handle_navigation_error(This->doc_host, status_code, This->url, NULL);
274 return S_OK;
276 case BINDSTATUS_FINDINGRESOURCE:
277 case BINDSTATUS_ENDDOWNLOADDATA:
278 case BINDSTATUS_SENDINGREQUEST:
279 set_status_text(This, ulStatusCode, szStatusText);
280 return S_OK;
282 case BINDSTATUS_CONNECTING:
283 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
284 case BINDSTATUS_CLASSIDAVAILABLE:
285 case BINDSTATUS_MIMETYPEAVAILABLE:
286 case BINDSTATUS_BEGINSYNCOPERATION:
287 case BINDSTATUS_ENDSYNCOPERATION:
288 return S_OK;
289 default:
290 FIXME("status code %u\n", ulStatusCode);
293 return S_OK;
296 void handle_navigation_error(DocHost* doc_host, HRESULT hres, BSTR url, IHTMLWindow2 *win2)
298 VARIANT var_status_code, var_frame_name, var_url;
299 DISPPARAMS dispparams;
300 VARIANTARG params[5];
301 VARIANT_BOOL cancel = VARIANT_FALSE;
303 dispparams.cArgs = 5;
304 dispparams.cNamedArgs = 0;
305 dispparams.rgdispidNamedArgs = NULL;
306 dispparams.rgvarg = params;
308 V_VT(params) = VT_BOOL|VT_BYREF;
309 V_BOOLREF(params) = &cancel;
311 V_VT(params+1) = VT_VARIANT|VT_BYREF;
312 V_VARIANTREF(params+1) = &var_status_code;
313 V_VT(&var_status_code) = VT_I4;
314 V_I4(&var_status_code) = hres;
316 V_VT(params+2) = VT_VARIANT|VT_BYREF;
317 V_VARIANTREF(params+2) = &var_frame_name;
318 V_VT(&var_frame_name) = VT_BSTR;
319 if(win2) {
320 hres = IHTMLWindow2_get_name(win2, &V_BSTR(&var_frame_name));
321 if(FAILED(hres))
322 V_BSTR(&var_frame_name) = NULL;
323 } else
324 V_BSTR(&var_frame_name) = NULL;
326 V_VT(params+3) = VT_VARIANT|VT_BYREF;
327 V_VARIANTREF(params+3) = &var_url;
328 V_VT(&var_url) = VT_BSTR;
329 V_BSTR(&var_url) = url;
331 V_VT(params+4) = VT_DISPATCH;
332 V_DISPATCH(params+4) = (IDispatch*)doc_host->wb;
334 call_sink(doc_host->cps.wbe2, DISPID_NAVIGATEERROR, &dispparams);
335 SysFreeString(V_BSTR(&var_frame_name));
337 if(!cancel)
338 FIXME("Navigate to error page\n");
341 static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
342 HRESULT hresult, LPCWSTR szError)
344 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
346 TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
348 set_status_text(This, 0, emptyW);
350 if(!This->doc_host)
351 return S_OK;
353 if(FAILED(hresult))
354 handle_navigation_error(This->doc_host, hresult, This->url, NULL);
356 IOleClientSite_Release(&This->doc_host->IOleClientSite_iface);
357 This->doc_host = NULL;
359 IBinding_Release(This->binding);
360 This->binding = NULL;
362 return S_OK;
365 static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
366 DWORD *grfBINDF, BINDINFO *pbindinfo)
368 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
370 TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
372 *grfBINDF = BINDF_ASYNCHRONOUS;
374 if(This->post_data) {
375 pbindinfo->dwBindVerb = BINDVERB_POST;
377 pbindinfo->stgmedData.tymed = TYMED_HGLOBAL;
378 pbindinfo->stgmedData.u.hGlobal = This->post_data;
379 pbindinfo->cbstgmedData = This->post_data_len;
380 pbindinfo->stgmedData.pUnkForRelease = (IUnknown*)&This->IBindStatusCallback_iface;
381 IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
384 return S_OK;
387 static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
388 DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
390 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
391 FIXME("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
392 return E_NOTIMPL;
395 static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
396 REFIID riid, IUnknown *punk)
398 BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
400 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
402 return dochost_object_available(This->doc_host, punk);
405 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
406 BindStatusCallback_QueryInterface,
407 BindStatusCallback_AddRef,
408 BindStatusCallback_Release,
409 BindStatusCallback_OnStartBinding,
410 BindStatusCallback_GetPriority,
411 BindStatusCallback_OnLowResource,
412 BindStatusCallback_OnProgress,
413 BindStatusCallback_OnStopBinding,
414 BindStatusCallback_GetBindInfo,
415 BindStatusCallback_OnDataAvailable,
416 BindStatusCallback_OnObjectAvailable
419 static inline BindStatusCallback *impl_from_IHttpNegotiate(IHttpNegotiate *iface)
421 return CONTAINING_RECORD(iface, BindStatusCallback, IHttpNegotiate_iface);
424 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate *iface,
425 REFIID riid, void **ppv)
427 BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
428 return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
431 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate *iface)
433 BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
434 return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
437 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate *iface)
439 BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
440 return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
443 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate *iface,
444 LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
446 BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
448 TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders),
449 dwReserved, pszAdditionalHeaders);
451 if(This->headers) {
452 int size = (strlenW(This->headers)+1)*sizeof(WCHAR);
453 *pszAdditionalHeaders = CoTaskMemAlloc(size);
454 memcpy(*pszAdditionalHeaders, This->headers, size);
457 return S_OK;
460 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate *iface,
461 DWORD dwResponseCode, LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders,
462 LPWSTR *pszAdditionalRequestHeaders)
464 BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
465 TRACE("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
466 debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
467 return S_OK;
470 static const IHttpNegotiateVtbl HttpNegotiateVtbl = {
471 HttpNegotiate_QueryInterface,
472 HttpNegotiate_AddRef,
473 HttpNegotiate_Release,
474 HttpNegotiate_BeginningTransaction,
475 HttpNegotiate_OnResponse
478 static BindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE post_data,
479 ULONG post_data_len, LPCWSTR headers)
481 BindStatusCallback *ret = heap_alloc(sizeof(BindStatusCallback));
483 ret->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl;
484 ret->IHttpNegotiate_iface.lpVtbl = &HttpNegotiateVtbl;
486 ret->ref = 1;
487 ret->url = heap_strdupW(url);
488 ret->post_data = NULL;
489 ret->post_data_len = post_data_len;
490 ret->headers = headers ? SysAllocString(headers) : NULL;
492 ret->doc_host = doc_host;
493 IOleClientSite_AddRef(&doc_host->IOleClientSite_iface);
495 ret->binding = NULL;
497 if(post_data) {
498 ret->post_data = GlobalAlloc(0, post_data_len);
499 memcpy(ret->post_data, post_data, post_data_len);
502 return ret;
505 static void on_before_navigate2(DocHost *This, LPCWSTR url, SAFEARRAY *post_data, LPWSTR headers, VARIANT_BOOL *cancel)
507 VARIANT var_url, var_flags, var_frame_name, var_post_data, var_post_data2, var_headers;
508 DISPPARAMS dispparams;
509 VARIANTARG params[7];
511 dispparams.cArgs = 7;
512 dispparams.cNamedArgs = 0;
513 dispparams.rgdispidNamedArgs = NULL;
514 dispparams.rgvarg = params;
516 This->busy = VARIANT_TRUE;
518 V_VT(params) = VT_BOOL|VT_BYREF;
519 V_BOOLREF(params) = cancel;
521 V_VT(params+1) = (VT_BYREF|VT_VARIANT);
522 V_VARIANTREF(params+1) = &var_headers;
523 V_VT(&var_headers) = VT_BSTR;
524 V_BSTR(&var_headers) = headers;
526 V_VT(params+2) = (VT_BYREF|VT_VARIANT);
527 V_VARIANTREF(params+2) = &var_post_data2;
528 V_VT(&var_post_data2) = (VT_BYREF|VT_VARIANT);
529 V_VARIANTREF(&var_post_data2) = &var_post_data;
531 if(post_data) {
532 V_VT(&var_post_data) = VT_UI1|VT_ARRAY;
533 V_ARRAY(&var_post_data) = post_data;
534 }else {
535 V_VT(&var_post_data) = VT_EMPTY;
538 V_VT(params+3) = (VT_BYREF|VT_VARIANT);
539 V_VARIANTREF(params+3) = &var_frame_name;
540 V_VT(&var_frame_name) = VT_BSTR;
541 V_BSTR(&var_frame_name) = NULL;
543 V_VT(params+4) = (VT_BYREF|VT_VARIANT);
544 V_VARIANTREF(params+4) = &var_flags;
545 V_VT(&var_flags) = VT_I4;
546 V_I4(&var_flags) = 0;
548 V_VT(params+5) = (VT_BYREF|VT_VARIANT);
549 V_VARIANTREF(params+5) = &var_url;
550 V_VT(&var_url) = VT_BSTR;
551 V_BSTR(&var_url) = SysAllocString(url);
553 V_VT(params+6) = (VT_DISPATCH);
554 V_DISPATCH(params+6) = (IDispatch*)This->wb;
556 call_sink(This->cps.wbe2, DISPID_BEFORENAVIGATE2, &dispparams);
558 SysFreeString(V_BSTR(&var_url));
561 /* FIXME: urlmon should handle it */
562 static BOOL try_application_url(LPCWSTR url)
564 SHELLEXECUTEINFOW exec_info;
565 WCHAR app[64];
566 HKEY hkey;
567 DWORD res, type;
568 HRESULT hres;
570 static const WCHAR wszURLProtocol[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
572 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, app, sizeof(app)/sizeof(WCHAR), NULL, 0);
573 if(FAILED(hres))
574 return FALSE;
576 res = RegOpenKeyW(HKEY_CLASSES_ROOT, app, &hkey);
577 if(res != ERROR_SUCCESS)
578 return FALSE;
580 res = RegQueryValueExW(hkey, wszURLProtocol, NULL, &type, NULL, NULL);
581 RegCloseKey(hkey);
582 if(res != ERROR_SUCCESS || type != REG_SZ)
583 return FALSE;
585 TRACE("opening application %s\n", debugstr_w(app));
587 memset(&exec_info, 0, sizeof(exec_info));
588 exec_info.cbSize = sizeof(exec_info);
589 exec_info.lpFile = url;
590 exec_info.nShow = SW_SHOW;
592 return ShellExecuteExW(&exec_info);
595 static HRESULT create_moniker(LPCWSTR url, IMoniker **mon)
597 WCHAR new_url[INTERNET_MAX_URL_LENGTH];
598 DWORD size;
599 HRESULT hres;
601 if(PathIsURLW(url))
602 return CreateURLMoniker(NULL, url, mon);
604 size = sizeof(new_url)/sizeof(WCHAR);
605 hres = UrlApplySchemeW(url, new_url, &size, URL_APPLY_GUESSSCHEME | URL_APPLY_GUESSFILE);
606 TRACE("was %s got %s\n", debugstr_w(url), debugstr_w(new_url));
607 if(FAILED(hres)) {
608 WARN("UrlApplyScheme failed: %08x\n", hres);
609 return hres;
612 return CreateURLMoniker(NULL, new_url, mon);
615 static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx,
616 IBindStatusCallback *callback)
618 IUnknown *unk = NULL;
619 WCHAR *display_name;
620 HRESULT hres;
622 if(mon) {
623 IMoniker_AddRef(mon);
624 }else {
625 hres = create_moniker(url, &mon);
626 if(FAILED(hres))
627 return hres;
630 hres = IMoniker_GetDisplayName(mon, 0, NULL, &display_name);
631 if(FAILED(hres)) {
632 FIXME("GetDisplayName failed: %08x\n", hres);
633 return hres;
636 hres = set_dochost_url(This, display_name);
637 CoTaskMemFree(display_name);
638 if(FAILED(hres))
639 return hres;
641 IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM,
642 (IUnknown*)&This->IOleClientSite_iface);
644 hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk);
645 if(SUCCEEDED(hres)) {
646 hres = S_OK;
647 if(unk)
648 IUnknown_Release(unk);
649 }else if(try_application_url(url)) {
650 hres = S_OK;
651 }else {
652 FIXME("BindToObject failed: %08x\n", hres);
655 IMoniker_Release(mon);
656 return S_OK;
659 static void html_window_navigate(DocHost *This, IHTMLPrivateWindow *window, BSTR url, BSTR headers, SAFEARRAY *post_data)
661 VARIANT headers_var, post_data_var;
662 BSTR empty_str;
663 HRESULT hres;
665 hres = set_dochost_url(This, url);
666 if(FAILED(hres))
667 return;
669 empty_str = SysAllocStringLen(NULL, 0);
671 if(headers) {
672 V_VT(&headers_var) = VT_BSTR;
673 V_BSTR(&headers_var) = headers;
674 }else {
675 V_VT(&headers_var) = VT_EMPTY;
678 if(post_data) {
679 V_VT(&post_data_var) = VT_UI1|VT_ARRAY;
680 V_ARRAY(&post_data_var) = post_data;
681 }else {
682 V_VT(&post_data_var) = VT_EMPTY;
685 set_doc_state(This, READYSTATE_LOADING);
686 hres = IHTMLPrivateWindow_SuperNavigate(window, url, empty_str, NULL, NULL, &post_data_var, &headers_var, 0);
687 SysFreeString(empty_str);
688 if(FAILED(hres))
689 WARN("SuprtNavigate failed: %08x\n", hres);
692 typedef struct {
693 task_header_t header;
694 BSTR url;
695 BSTR headers;
696 SAFEARRAY *post_data;
697 BOOL async_notif;
698 } task_doc_navigate_t;
700 static void doc_navigate_task_destr(task_header_t *t)
702 task_doc_navigate_t *task = (task_doc_navigate_t*)t;
704 SysFreeString(task->url);
705 SysFreeString(task->headers);
706 if(task->post_data)
707 SafeArrayDestroy(task->post_data);
708 heap_free(task);
711 static void doc_navigate_proc(DocHost *This, task_header_t *t)
713 task_doc_navigate_t *task = (task_doc_navigate_t*)t;
714 IHTMLPrivateWindow *priv_window;
715 HRESULT hres;
717 if(!This->doc_navigate) {
718 ERR("Skip nav\n");
719 return;
722 if(task->async_notif) {
723 VARIANT_BOOL cancel = VARIANT_FALSE;
724 on_before_navigate2(This, task->url, task->post_data, task->headers, &cancel);
725 if(cancel) {
726 TRACE("Navigation canceled\n");
727 return;
731 hres = IUnknown_QueryInterface(This->doc_navigate, &IID_IHTMLPrivateWindow, (void**)&priv_window);
732 if(SUCCEEDED(hres)) {
733 html_window_navigate(This, priv_window, task->url, task->headers, task->post_data);
734 IHTMLPrivateWindow_Release(priv_window);
735 }else {
736 WARN("Could not get IHTMLPrivateWindow iface: %08x\n", hres);
740 static HRESULT async_doc_navigate(DocHost *This, LPCWSTR url, LPCWSTR headers, PBYTE post_data, ULONG post_data_size,
741 BOOL async_notif)
743 task_doc_navigate_t *task;
745 TRACE("%s\n", debugstr_w(url));
747 task = heap_alloc_zero(sizeof(*task));
748 if(!task)
749 return E_OUTOFMEMORY;
751 task->url = SysAllocString(url);
752 if(!task->url) {
753 doc_navigate_task_destr(&task->header);
754 return E_OUTOFMEMORY;
757 if(headers) {
758 task->headers = SysAllocString(headers);
759 if(!task->headers) {
760 doc_navigate_task_destr(&task->header);
761 return E_OUTOFMEMORY;
765 if(post_data) {
766 task->post_data = SafeArrayCreateVector(VT_UI1, 0, post_data_size);
767 if(!task->post_data) {
768 doc_navigate_task_destr(&task->header);
769 return E_OUTOFMEMORY;
772 memcpy(task->post_data->pvData, post_data, post_data_size);
775 if(!async_notif) {
776 VARIANT_BOOL cancel = VARIANT_FALSE;
778 on_before_navigate2(This, task->url, task->post_data, task->headers, &cancel);
779 if(cancel) {
780 TRACE("Navigation canceled\n");
781 doc_navigate_task_destr(&task->header);
782 return S_OK;
786 task->async_notif = async_notif;
787 abort_dochost_tasks(This, doc_navigate_proc);
788 push_dochost_task(This, &task->header, doc_navigate_proc, doc_navigate_task_destr, FALSE);
789 return S_OK;
792 static HRESULT navigate_bsc(DocHost *This, BindStatusCallback *bsc, IMoniker *mon)
794 VARIANT_BOOL cancel = VARIANT_FALSE;
795 SAFEARRAY *post_data = NULL;
796 IBindCtx *bindctx;
797 HRESULT hres;
799 set_doc_state(This, READYSTATE_LOADING);
801 if(bsc->post_data) {
802 post_data = SafeArrayCreateVector(VT_UI1, 0, bsc->post_data_len);
803 memcpy(post_data->pvData, post_data, bsc->post_data_len);
806 on_before_navigate2(This, bsc->url, post_data, bsc->headers, &cancel);
807 if(post_data)
808 SafeArrayDestroy(post_data);
809 if(cancel) {
810 FIXME("Navigation canceled\n");
811 return S_OK;
814 if(This->document)
815 deactivate_document(This);
817 CreateAsyncBindCtx(0, &bsc->IBindStatusCallback_iface, 0, &bindctx);
819 if(This->frame)
820 IOleInPlaceFrame_EnableModeless(This->frame, FALSE);
822 hres = bind_to_object(This, mon, bsc->url, bindctx, &bsc->IBindStatusCallback_iface);
824 if(This->frame)
825 IOleInPlaceFrame_EnableModeless(This->frame, TRUE);
827 IBindCtx_Release(bindctx);
829 return hres;
832 typedef struct {
833 task_header_t header;
834 BindStatusCallback *bsc;
835 } task_navigate_bsc_t;
837 static void navigate_bsc_task_destr(task_header_t *t)
839 task_navigate_bsc_t *task = (task_navigate_bsc_t*)t;
841 IBindStatusCallback_Release(&task->bsc->IBindStatusCallback_iface);
842 heap_free(task);
845 static void navigate_bsc_proc(DocHost *This, task_header_t *t)
847 task_navigate_bsc_t *task = (task_navigate_bsc_t*)t;
849 if(!This->hwnd)
850 create_doc_view_hwnd(This);
852 navigate_bsc(This, task->bsc, NULL);
856 HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags,
857 const VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
859 PBYTE post_data = NULL;
860 ULONG post_data_len = 0;
861 LPWSTR headers = NULL;
862 HRESULT hres = S_OK;
864 TRACE("navigating to %s\n", debugstr_w(url));
866 if((Flags && V_VT(Flags) != VT_EMPTY)
867 || (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY))
868 FIXME("Unsupported args (Flags %p:%d; TargetFrameName %p:%d)\n",
869 Flags, Flags ? V_VT(Flags) : -1, TargetFrameName,
870 TargetFrameName ? V_VT(TargetFrameName) : -1);
872 if(PostData && V_VT(PostData) == (VT_ARRAY | VT_UI1) && V_ARRAY(PostData)) {
873 SafeArrayAccessData(V_ARRAY(PostData), (void**)&post_data);
874 post_data_len = V_ARRAY(PostData)->rgsabound[0].cElements;
877 if(Headers && V_VT(Headers) == VT_BSTR) {
878 headers = V_BSTR(Headers);
879 TRACE("Headers: %s\n", debugstr_w(headers));
882 set_doc_state(This, READYSTATE_LOADING);
883 This->ready_state = READYSTATE_LOADING;
885 if(This->doc_navigate) {
886 WCHAR new_url[INTERNET_MAX_URL_LENGTH];
888 if(PathIsURLW(url)) {
889 new_url[0] = 0;
890 }else {
891 DWORD size;
893 size = sizeof(new_url)/sizeof(WCHAR);
894 hres = UrlApplySchemeW(url, new_url, &size,
895 URL_APPLY_GUESSSCHEME | URL_APPLY_GUESSFILE | URL_APPLY_DEFAULT);
896 if(FAILED(hres)) {
897 WARN("UrlApplyScheme failed: %08x\n", hres);
898 new_url[0] = 0;
902 hres = async_doc_navigate(This, *new_url ? new_url : url, headers, post_data,
903 post_data_len, TRUE);
904 }else {
905 task_navigate_bsc_t *task;
907 task = heap_alloc(sizeof(*task));
908 task->bsc = create_callback(This, url, post_data, post_data_len, headers);
909 push_dochost_task(This, &task->header, navigate_bsc_proc, navigate_bsc_task_destr, This->url == NULL);
912 if(post_data)
913 SafeArrayUnaccessData(V_ARRAY(PostData));
915 return hres;
918 static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
919 IBindStatusCallback *callback)
921 IHttpNegotiate *http_negotiate;
922 BindStatusCallback *bsc;
923 PBYTE post_data = NULL;
924 ULONG post_data_len = 0;
925 LPWSTR headers = NULL, url;
926 BINDINFO bindinfo;
927 DWORD bindf = 0;
928 HRESULT hres;
930 TRACE("\n");
932 hres = IMoniker_GetDisplayName(mon, 0, NULL, &url);
933 if(FAILED(hres))
934 FIXME("GetDisplayName failed: %08x\n", hres);
936 hres = IBindStatusCallback_QueryInterface(callback, &IID_IHttpNegotiate,
937 (void**)&http_negotiate);
938 if(SUCCEEDED(hres)) {
939 static const WCHAR null_string[] = {0};
941 IHttpNegotiate_BeginningTransaction(http_negotiate, null_string, null_string, 0,
942 &headers);
943 IHttpNegotiate_Release(http_negotiate);
946 memset(&bindinfo, 0, sizeof(bindinfo));
947 bindinfo.cbSize = sizeof(bindinfo);
949 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
950 dump_BINDINFO(&bindinfo);
951 if(bindinfo.dwBindVerb == BINDVERB_POST) {
952 post_data_len = bindinfo.cbstgmedData;
953 if(post_data_len)
954 post_data = bindinfo.stgmedData.u.hGlobal;
957 if(This->doc_navigate) {
958 hres = async_doc_navigate(This, url, headers, post_data, post_data_len, FALSE);
959 }else {
960 bsc = create_callback(This, url, post_data, post_data_len, headers);
961 hres = navigate_bsc(This, bsc, mon);
962 IBindStatusCallback_Release(&bsc->IBindStatusCallback_iface);
965 CoTaskMemFree(url);
966 CoTaskMemFree(headers);
967 ReleaseBindInfo(&bindinfo);
969 return hres;
972 HRESULT go_home(DocHost *This)
974 HKEY hkey;
975 DWORD res, type, size;
976 WCHAR wszPageName[MAX_PATH];
977 static const WCHAR wszAboutBlank[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
978 static const WCHAR wszStartPage[] = {'S','t','a','r','t',' ','P','a','g','e',0};
979 static const WCHAR wszSubKey[] = {'S','o','f','t','w','a','r','e','\\',
980 'M','i','c','r','o','s','o','f','t','\\',
981 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
982 'M','a','i','n',0};
984 res = RegOpenKeyW(HKEY_CURRENT_USER, wszSubKey, &hkey);
985 if (res != ERROR_SUCCESS)
986 return navigate_url(This, wszAboutBlank, NULL, NULL, NULL, NULL);
988 size = sizeof(wszPageName);
989 res = RegQueryValueExW(hkey, wszStartPage, NULL, &type, (LPBYTE)wszPageName, &size);
990 RegCloseKey(hkey);
991 if (res != ERROR_SUCCESS || type != REG_SZ)
992 return navigate_url(This, wszAboutBlank, NULL, NULL, NULL, NULL);
994 return navigate_url(This, wszPageName, NULL, NULL, NULL, NULL);
997 HRESULT go_back(DocHost *This)
999 WCHAR *url;
1000 HRESULT hres;
1002 if(!This->travellog_position) {
1003 WARN("No history available\n");
1004 return E_FAIL;
1007 url = This->travellog[--This->travellog_position].url;
1009 if(This->doc_navigate) {
1010 hres = async_doc_navigate(This, url, NULL, NULL, 0, FALSE);
1011 }else {
1012 FIXME("unsupported doc_navigate FALSE\n");
1013 hres = E_NOTIMPL;
1016 heap_free(url);
1017 return hres;
1020 HRESULT get_location_url(DocHost *This, BSTR *ret)
1022 FIXME("semi-stub\n");
1024 *ret = This->url ? SysAllocString(This->url) : SysAllocStringLen(NULL, 0);
1025 if(!*ret)
1026 return E_OUTOFMEMORY;
1028 return This->url ? S_OK : S_FALSE;
1031 static inline HlinkFrame *impl_from_IHlinkFrame(IHlinkFrame *iface)
1033 return CONTAINING_RECORD(iface, HlinkFrame, IHlinkFrame_iface);
1036 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
1038 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1039 return IUnknown_QueryInterface(This->outer, riid, ppv);
1042 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
1044 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1045 return IUnknown_AddRef(This->outer);
1048 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
1050 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1051 return IUnknown_Release(This->outer);
1054 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
1055 IHlinkBrowseContext *pihlbc)
1057 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1058 FIXME("(%p)->(%p)\n", This, pihlbc);
1059 return E_NOTIMPL;
1062 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
1063 IHlinkBrowseContext **ppihlbc)
1065 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1066 FIXME("(%p)->(%p)\n", This, ppihlbc);
1067 return E_NOTIMPL;
1070 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
1071 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
1073 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1074 IMoniker *mon;
1075 LPWSTR location = NULL;
1077 TRACE("(%p)->(%08x %p %p %p)\n", This, grfHLNF, pbc, pibsc, pihlNavigate);
1079 if(grfHLNF)
1080 FIXME("unsupported grfHLNF=%08x\n", grfHLNF);
1082 /* Windows calls GetTargetFrameName here. */
1084 IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
1086 if(location) {
1087 FIXME("location = %s\n", debugstr_w(location));
1088 CoTaskMemFree(location);
1091 /* Windows calls GetHlinkSite here */
1093 if(grfHLNF & HLNF_OPENINNEWWINDOW) {
1094 FIXME("Not supported HLNF_OPENINNEWWINDOW\n");
1095 return E_NOTIMPL;
1098 return navigate_hlink(This->doc_host, mon, pbc, pibsc);
1101 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
1102 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
1104 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1105 FIXME("(%p)->(%08x %p %s %s %d)\n", This, grfHLNF, pimkTarget, debugstr_w(pwzLocation),
1106 debugstr_w(pwzFriendlyName), dwreserved);
1107 return E_NOTIMPL;
1110 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
1111 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
1113 HlinkFrame *This = impl_from_IHlinkFrame(iface);
1114 FIXME("(%p)->(%u %p %s %s)\n", This, uHLID, pimkTarget, debugstr_w(pwzLocation),
1115 debugstr_w(pwzFriendlyName));
1116 return E_NOTIMPL;
1119 static const IHlinkFrameVtbl HlinkFrameVtbl = {
1120 HlinkFrame_QueryInterface,
1121 HlinkFrame_AddRef,
1122 HlinkFrame_Release,
1123 HlinkFrame_SetBrowseContext,
1124 HlinkFrame_GetBrowseContext,
1125 HlinkFrame_Navigate,
1126 HlinkFrame_OnNavigate,
1127 HlinkFrame_UpdateHlink
1130 static inline HlinkFrame *impl_from_ITargetFrame2(ITargetFrame2 *iface)
1132 return CONTAINING_RECORD(iface, HlinkFrame, IHlinkFrame_iface);
1135 static HRESULT WINAPI TargetFrame2_QueryInterface(ITargetFrame2 *iface, REFIID riid, void **ppv)
1137 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1138 return IUnknown_QueryInterface(This->outer, riid, ppv);
1141 static ULONG WINAPI TargetFrame2_AddRef(ITargetFrame2 *iface)
1143 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1144 return IUnknown_AddRef(This->outer);
1147 static ULONG WINAPI TargetFrame2_Release(ITargetFrame2 *iface)
1149 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1150 return IUnknown_Release(This->outer);
1153 static HRESULT WINAPI TargetFrame2_SetFrameName(ITargetFrame2 *iface, LPCWSTR pszFrameName)
1155 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1156 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFrameName));
1157 return E_NOTIMPL;
1160 static HRESULT WINAPI TargetFrame2_GetFrameName(ITargetFrame2 *iface, LPWSTR *ppszFrameName)
1162 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1163 FIXME("(%p)->(%p)\n", This, ppszFrameName);
1164 return E_NOTIMPL;
1167 static HRESULT WINAPI TargetFrame2_GetParentFrame(ITargetFrame2 *iface, IUnknown **ppunkParent)
1169 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1170 FIXME("(%p)->(%p)\n", This, ppunkParent);
1171 return E_NOTIMPL;
1174 static HRESULT WINAPI TargetFrame2_SetFrameSrc(ITargetFrame2 *iface, LPCWSTR pszFrameSrc)
1176 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1177 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFrameSrc));
1178 return E_NOTIMPL;
1181 static HRESULT WINAPI TargetFrame2_GetFrameSrc(ITargetFrame2 *iface, LPWSTR *ppszFrameSrc)
1183 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1184 FIXME("(%p)->()\n", This);
1185 return E_NOTIMPL;
1188 static HRESULT WINAPI TargetFrame2_GetFramesContainer(ITargetFrame2 *iface, IOleContainer **ppContainer)
1190 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1191 FIXME("(%p)->(%p)\n", This, ppContainer);
1192 return E_NOTIMPL;
1195 static HRESULT WINAPI TargetFrame2_SetFrameOptions(ITargetFrame2 *iface, DWORD dwFlags)
1197 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1198 FIXME("(%p)->(%x)\n", This, dwFlags);
1199 return E_NOTIMPL;
1202 static HRESULT WINAPI TargetFrame2_GetFrameOptions(ITargetFrame2 *iface, DWORD *pdwFlags)
1204 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1205 FIXME("(%p)->(%p)\n", This, pdwFlags);
1206 return E_NOTIMPL;
1209 static HRESULT WINAPI TargetFrame2_SetFrameMargins(ITargetFrame2 *iface, DWORD dwWidth, DWORD dwHeight)
1211 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1212 FIXME("(%p)->(%d %d)\n", This, dwWidth, dwHeight);
1213 return E_NOTIMPL;
1216 static HRESULT WINAPI TargetFrame2_GetFrameMargins(ITargetFrame2 *iface, DWORD *pdwWidth, DWORD *pdwHeight)
1218 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1219 FIXME("(%p)->(%p %p)\n", This, pdwWidth, pdwHeight);
1220 return E_NOTIMPL;
1223 static HRESULT WINAPI TargetFrame2_FindFrame(ITargetFrame2 *iface, LPCWSTR pszTargetName, DWORD dwFlags, IUnknown **ppunkTargetFrame)
1225 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1226 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(pszTargetName), dwFlags, ppunkTargetFrame);
1227 return E_NOTIMPL;
1230 static HRESULT WINAPI TargetFrame2_GetTargetAlias(ITargetFrame2 *iface, LPCWSTR pszTargetName, LPWSTR *ppszTargetAlias)
1232 HlinkFrame *This = impl_from_ITargetFrame2(iface);
1233 FIXME("(%p)->(%s %p)\n", This, debugstr_w(pszTargetName), ppszTargetAlias);
1234 return E_NOTIMPL;
1237 static const ITargetFrame2Vtbl TargetFrame2Vtbl = {
1238 TargetFrame2_QueryInterface,
1239 TargetFrame2_AddRef,
1240 TargetFrame2_Release,
1241 TargetFrame2_SetFrameName,
1242 TargetFrame2_GetFrameName,
1243 TargetFrame2_GetParentFrame,
1244 TargetFrame2_SetFrameSrc,
1245 TargetFrame2_GetFrameSrc,
1246 TargetFrame2_GetFramesContainer,
1247 TargetFrame2_SetFrameOptions,
1248 TargetFrame2_GetFrameOptions,
1249 TargetFrame2_SetFrameMargins,
1250 TargetFrame2_GetFrameMargins,
1251 TargetFrame2_FindFrame,
1252 TargetFrame2_GetTargetAlias
1255 static inline HlinkFrame *impl_from_ITargetFramePriv2(ITargetFramePriv2 *iface)
1257 return CONTAINING_RECORD(iface, HlinkFrame, ITargetFramePriv2_iface);
1260 static HRESULT WINAPI TargetFramePriv2_QueryInterface(ITargetFramePriv2 *iface, REFIID riid, void **ppv)
1262 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1263 return IUnknown_QueryInterface(This->outer, riid, ppv);
1266 static ULONG WINAPI TargetFramePriv2_AddRef(ITargetFramePriv2 *iface)
1268 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1269 return IUnknown_AddRef(This->outer);
1272 static ULONG WINAPI TargetFramePriv2_Release(ITargetFramePriv2 *iface)
1274 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1275 return IUnknown_Release(This->outer);
1278 static HRESULT WINAPI TargetFramePriv2_FindFrameDownwards(ITargetFramePriv2 *iface,
1279 LPCWSTR pszTargetName, DWORD dwFlags, IUnknown **ppunkTargetFrame)
1281 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1282 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(pszTargetName), dwFlags, ppunkTargetFrame);
1283 return E_NOTIMPL;
1286 static HRESULT WINAPI TargetFramePriv2_FindFrameInContext(ITargetFramePriv2 *iface,
1287 LPCWSTR pszTargetName, IUnknown *punkContextFrame, DWORD dwFlags, IUnknown **ppunkTargetFrame)
1289 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1290 FIXME("(%p)->(%s %p %x %p)\n", This, debugstr_w(pszTargetName), punkContextFrame, dwFlags, ppunkTargetFrame);
1291 return E_NOTIMPL;
1294 static HRESULT WINAPI TargetFramePriv2_OnChildFrameActivate(ITargetFramePriv2 *iface, IUnknown *pUnkChildFrame)
1296 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1297 FIXME("(%p)->(%p)\n", This, pUnkChildFrame);
1298 return E_NOTIMPL;
1301 static HRESULT WINAPI TargetFramePriv2_OnChildFrameDeactivate(ITargetFramePriv2 *iface, IUnknown *pUnkChildFrame)
1303 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1304 FIXME("(%p)->(%p)\n", This, pUnkChildFrame);
1305 return E_NOTIMPL;
1308 static HRESULT WINAPI TargetFramePriv2_NavigateHack(ITargetFramePriv2 *iface, DWORD grfHLNF, LPBC pbc,
1309 IBindStatusCallback *pibsc, LPCWSTR pszTargetName, LPCWSTR pszUrl, LPCWSTR pszLocation)
1311 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1312 FIXME("(%p)->(%x %p %p %s %s %s)\n", This, grfHLNF, pbc, pibsc, debugstr_w(pszTargetName),
1313 debugstr_w(pszUrl), debugstr_w(pszLocation));
1314 return E_NOTIMPL;
1317 static HRESULT WINAPI TargetFramePriv2_FindBrowserByIndex(ITargetFramePriv2 *iface, DWORD dwID, IUnknown **ppunkBrowser)
1319 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1320 FIXME("(%p)->(%d %p)\n", This, dwID, ppunkBrowser);
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI TargetFramePriv2_AggregatedNavigation2(ITargetFramePriv2 *iface, DWORD grfHLNF, LPBC pbc,
1325 IBindStatusCallback *pibsc, LPCWSTR pszTargetName, IUri *pUri, LPCWSTR pszLocation)
1327 HlinkFrame *This = impl_from_ITargetFramePriv2(iface);
1328 IMoniker *mon;
1329 HRESULT hres;
1331 TRACE("(%p)->(%x %p %p %s %p %s)\n", This, grfHLNF, pbc, pibsc, debugstr_w(pszTargetName),
1332 pUri, debugstr_w(pszLocation));
1335 * NOTE: This is an undocumented function. It seems to be working the way it's implemented,
1336 * but I couldn't get its tests working. It's used by mshtml to load content in a new
1337 * instance of browser.
1340 hres = CreateURLMonikerEx2(NULL, pUri, &mon, 0);
1341 if(FAILED(hres))
1342 return hres;
1344 hres = navigate_hlink(This->doc_host, mon, pbc, pibsc);
1345 IMoniker_Release(mon);
1346 return hres;
1349 static const ITargetFramePriv2Vtbl TargetFramePriv2Vtbl = {
1350 TargetFramePriv2_QueryInterface,
1351 TargetFramePriv2_AddRef,
1352 TargetFramePriv2_Release,
1353 TargetFramePriv2_FindFrameDownwards,
1354 TargetFramePriv2_FindFrameInContext,
1355 TargetFramePriv2_OnChildFrameActivate,
1356 TargetFramePriv2_OnChildFrameDeactivate,
1357 TargetFramePriv2_NavigateHack,
1358 TargetFramePriv2_FindBrowserByIndex,
1359 TargetFramePriv2_AggregatedNavigation2
1362 BOOL HlinkFrame_QI(HlinkFrame *This, REFIID riid, void **ppv)
1364 if(IsEqualGUID(&IID_IHlinkFrame, riid)) {
1365 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This, ppv);
1366 *ppv = &This->IHlinkFrame_iface;
1367 }else if(IsEqualGUID(&IID_ITargetFrame2, riid)) {
1368 TRACE("(%p)->(IID_ITargetFrame2 %p)\n", This, ppv);
1369 *ppv = &This->ITargetFrame2_iface;
1370 }else if(IsEqualGUID(&IID_ITargetFramePriv, riid)) {
1371 TRACE("(%p)->(IID_ITargetFramePriv %p)\n", This, ppv);
1372 *ppv = &This->ITargetFramePriv2_iface;
1373 }else if(IsEqualGUID(&IID_ITargetFramePriv2, riid)) {
1374 TRACE("(%p)->(IID_ITargetFramePriv2 %p)\n", This, ppv);
1375 *ppv = &This->ITargetFramePriv2_iface;
1376 }else {
1377 return FALSE;
1380 IUnknown_AddRef((IUnknown*)*ppv);
1381 return TRUE;
1384 void HlinkFrame_Init(HlinkFrame *This, IUnknown *outer, DocHost *doc_host)
1386 This->IHlinkFrame_iface.lpVtbl = &HlinkFrameVtbl;
1387 This->ITargetFrame2_iface.lpVtbl = &TargetFrame2Vtbl;
1388 This->ITargetFramePriv2_iface.lpVtbl = &TargetFramePriv2Vtbl;
1390 This->outer = outer;
1391 This->doc_host = doc_host;