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"
32 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
34 static const WCHAR emptyW
[] = {0};
37 const IBindStatusCallbackVtbl
*lpBindStatusCallbackVtbl
;
38 const IHttpNegotiateVtbl
*lpHttpNegotiateVtbl
;
50 #define BINDSC(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
51 #define HTTPNEG(x) ((IHttpNegotiate*) &(x)->lpHttpNegotiateVtbl)
53 static void dump_BINDINFO(BINDINFO
*bi
)
55 static const char * const BINDINFOF_str
[] = {
57 "BINDINFOF_URLENCODESTGMEDDATA",
58 "BINDINFOF_URLENCODEDEXTRAINFO"
61 static const char * const BINDVERB_str
[] = {
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
, LPCWSTR str
)
100 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
105 V_VT(&arg
) = VT_BSTR
;
106 V_BSTR(&arg
) = str
? SysAllocString(str
) : NULL
;
107 call_sink(This
->doc_host
->cps
.wbe2
, DISPID_STATUSTEXTCHANGE
, &dispparams
);
110 if(This
->doc_host
->frame
)
111 IOleInPlaceFrame_SetStatusText(This
->doc_host
->frame
, str
);
114 #define BINDSC_THIS(iface) DEFINE_THIS(BindStatusCallback, BindStatusCallback, iface)
116 static HRESULT WINAPI
BindStatusCallback_QueryInterface(IBindStatusCallback
*iface
,
117 REFIID riid
, void **ppv
)
119 BindStatusCallback
*This
= BINDSC_THIS(iface
);
123 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
124 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
126 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
127 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
129 }else if(IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
130 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This
, ppv
);
131 *ppv
= HTTPNEG(This
);
135 IBindStatusCallback_AddRef(BINDSC(This
));
139 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
140 return E_NOINTERFACE
;
143 static ULONG WINAPI
BindStatusCallback_AddRef(IBindStatusCallback
*iface
)
145 BindStatusCallback
*This
= BINDSC_THIS(iface
);
146 LONG ref
= InterlockedIncrement(&This
->ref
);
148 TRACE("(%p) ref=%d\n", This
, ref
);
153 static ULONG WINAPI
BindStatusCallback_Release(IBindStatusCallback
*iface
)
155 BindStatusCallback
*This
= BINDSC_THIS(iface
);
156 LONG ref
= InterlockedDecrement(&This
->ref
);
158 TRACE("(%p) ref=%d\n", This
, ref
);
162 IOleClientSite_Release(CLIENTSITE(This
->doc_host
));
164 GlobalFree(This
->post_data
);
166 SysFreeString(This
->headers
);
167 heap_free(This
->url
);
174 static HRESULT WINAPI
BindStatusCallback_OnStartBinding(IBindStatusCallback
*iface
,
175 DWORD dwReserved
, IBinding
*pbind
)
177 BindStatusCallback
*This
= BINDSC_THIS(iface
);
179 TRACE("(%p)->(%d %p)\n", This
, dwReserved
, pbind
);
184 static HRESULT WINAPI
BindStatusCallback_GetPriority(IBindStatusCallback
*iface
,
187 BindStatusCallback
*This
= BINDSC_THIS(iface
);
188 FIXME("(%p)->(%p)\n", This
, pnPriority
);
192 static HRESULT WINAPI
BindStatusCallback_OnLowResource(IBindStatusCallback
*iface
,
195 BindStatusCallback
*This
= BINDSC_THIS(iface
);
196 FIXME("(%p)->(%d)\n", This
, reserved
);
200 static HRESULT WINAPI
BindStatusCallback_OnProgress(IBindStatusCallback
*iface
,
201 ULONG ulProgress
, ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
203 BindStatusCallback
*This
= BINDSC_THIS(iface
);
205 TRACE("(%p)->(%d %d %d %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
,
206 debugstr_w(szStatusText
));
208 switch(ulStatusCode
) {
209 case BINDSTATUS_BEGINDOWNLOADDATA
:
210 set_status_text(This
, szStatusText
); /* FIXME: "Start downloading from site: %s" */
212 case BINDSTATUS_ENDDOWNLOADDATA
:
213 set_status_text(This
, szStatusText
); /* FIXME: "Downloading from site: %s" */
215 case BINDSTATUS_CLASSIDAVAILABLE
:
216 case BINDSTATUS_MIMETYPEAVAILABLE
:
217 case BINDSTATUS_BEGINSYNCOPERATION
:
218 case BINDSTATUS_ENDSYNCOPERATION
:
221 FIXME("status code %u\n", ulStatusCode
);
227 static HRESULT WINAPI
BindStatusCallback_OnStopBinding(IBindStatusCallback
*iface
,
228 HRESULT hresult
, LPCWSTR szError
)
230 BindStatusCallback
*This
= BINDSC_THIS(iface
);
232 TRACE("(%p)->(%08x %s)\n", This
, hresult
, debugstr_w(szError
));
234 set_status_text(This
, emptyW
);
237 IOleClientSite_Release(CLIENTSITE(This
->doc_host
));
238 This
->doc_host
= NULL
;
244 static HRESULT WINAPI
BindStatusCallback_GetBindInfo(IBindStatusCallback
*iface
,
245 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
247 BindStatusCallback
*This
= BINDSC_THIS(iface
);
249 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
251 *grfBINDF
= BINDF_ASYNCHRONOUS
;
253 if(This
->post_data
) {
254 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
256 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
257 pbindinfo
->stgmedData
.u
.hGlobal
= This
->post_data
;
258 pbindinfo
->cbstgmedData
= This
->post_data_len
;
259 pbindinfo
->stgmedData
.pUnkForRelease
= (IUnknown
*)BINDSC(This
);
260 IBindStatusCallback_AddRef(BINDSC(This
));
266 static HRESULT WINAPI
BindStatusCallback_OnDataAvailable(IBindStatusCallback
*iface
,
267 DWORD grfBSCF
, DWORD dwSize
, FORMATETC
*pformatetc
, STGMEDIUM
*pstgmed
)
269 BindStatusCallback
*This
= BINDSC_THIS(iface
);
270 FIXME("(%p)->(%08x %d %p %p)\n", This
, grfBSCF
, dwSize
, pformatetc
, pstgmed
);
274 static void object_available_proc(DocHost
*This
, task_header_t
*task
)
276 object_available(This
);
279 static HRESULT WINAPI
BindStatusCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
280 REFIID riid
, IUnknown
*punk
)
282 BindStatusCallback
*This
= BINDSC_THIS(iface
);
287 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), punk
);
289 IUnknown_AddRef(punk
);
290 This
->doc_host
->document
= punk
;
292 hres
= IUnknown_QueryInterface(punk
, &IID_IOleObject
, (void**)&oleobj
);
293 if(SUCCEEDED(hres
)) {
296 hres
= IOleObject_GetUserClassID(oleobj
, &clsid
);
298 TRACE("Got clsid %s\n",
299 IsEqualGUID(&clsid
, &CLSID_HTMLDocument
) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid
));
301 hres
= IOleObject_SetClientSite(oleobj
, CLIENTSITE(This
->doc_host
));
303 FIXME("SetClientSite failed: %08x\n", hres
);
305 IOleObject_Release(oleobj
);
307 FIXME("Could not get IOleObject iface: %08x\n", hres
);
310 /* FIXME: Call SetAdvise */
311 /* FIXME: Call Invoke(DISPID_READYSTATE) */
313 task
= heap_alloc(sizeof(*task
));
314 push_dochost_task(This
->doc_host
, task
, object_available_proc
, FALSE
);
321 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
322 BindStatusCallback_QueryInterface
,
323 BindStatusCallback_AddRef
,
324 BindStatusCallback_Release
,
325 BindStatusCallback_OnStartBinding
,
326 BindStatusCallback_GetPriority
,
327 BindStatusCallback_OnLowResource
,
328 BindStatusCallback_OnProgress
,
329 BindStatusCallback_OnStopBinding
,
330 BindStatusCallback_GetBindInfo
,
331 BindStatusCallback_OnDataAvailable
,
332 BindStatusCallback_OnObjectAvailable
335 #define HTTPNEG_THIS(iface) DEFINE_THIS(BindStatusCallback, HttpNegotiate, iface)
337 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate
*iface
,
338 REFIID riid
, void **ppv
)
340 BindStatusCallback
*This
= HTTPNEG_THIS(iface
);
341 return IBindStatusCallback_QueryInterface(BINDSC(This
), riid
, ppv
);
344 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate
*iface
)
346 BindStatusCallback
*This
= HTTPNEG_THIS(iface
);
347 return IBindStatusCallback_AddRef(BINDSC(This
));
350 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate
*iface
)
352 BindStatusCallback
*This
= HTTPNEG_THIS(iface
);
353 return IBindStatusCallback_Release(BINDSC(This
));
356 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate
*iface
,
357 LPCWSTR szURL
, LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
359 BindStatusCallback
*This
= HTTPNEG_THIS(iface
);
361 FIXME("(%p)->(%s %s %d %p)\n", This
, debugstr_w(szURL
), debugstr_w(szHeaders
),
362 dwReserved
, pszAdditionalHeaders
);
365 int size
= (strlenW(This
->headers
)+1)*sizeof(WCHAR
);
366 *pszAdditionalHeaders
= CoTaskMemAlloc(size
);
367 memcpy(*pszAdditionalHeaders
, This
->headers
, size
);
373 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate
*iface
,
374 DWORD dwResponseCode
, LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
,
375 LPWSTR
*pszAdditionalRequestHeaders
)
377 BindStatusCallback
*This
= HTTPNEG_THIS(iface
);
378 FIXME("(%p)->(%d %s %s %p)\n", This
, dwResponseCode
, debugstr_w(szResponseHeaders
),
379 debugstr_w(szRequestHeaders
), pszAdditionalRequestHeaders
);
385 static const IHttpNegotiateVtbl HttpNegotiateVtbl
= {
386 HttpNegotiate_QueryInterface
,
387 HttpNegotiate_AddRef
,
388 HttpNegotiate_Release
,
389 HttpNegotiate_BeginningTransaction
,
390 HttpNegotiate_OnResponse
393 static BindStatusCallback
*create_callback(DocHost
*doc_host
, LPCWSTR url
, PBYTE post_data
,
394 ULONG post_data_len
, LPCWSTR headers
)
396 BindStatusCallback
*ret
= heap_alloc(sizeof(BindStatusCallback
));
398 ret
->lpBindStatusCallbackVtbl
= &BindStatusCallbackVtbl
;
399 ret
->lpHttpNegotiateVtbl
= &HttpNegotiateVtbl
;
402 ret
->url
= heap_strdupW(url
);
403 ret
->post_data
= NULL
;
404 ret
->post_data_len
= post_data_len
;
405 ret
->headers
= headers
? SysAllocString(headers
) : NULL
;
407 ret
->doc_host
= doc_host
;
408 IOleClientSite_AddRef(CLIENTSITE(doc_host
));
411 ret
->post_data
= GlobalAlloc(0, post_data_len
);
412 memcpy(ret
->post_data
, post_data
, post_data_len
);
418 static void on_before_navigate2(DocHost
*This
, LPCWSTR url
, const BYTE
*post_data
,
419 ULONG post_data_len
, LPWSTR headers
, VARIANT_BOOL
*cancel
)
421 VARIANT var_url
, var_flags
, var_frame_name
, var_post_data
, var_post_data2
, var_headers
;
422 DISPPARAMS dispparams
;
423 VARIANTARG params
[7];
425 dispparams
.cArgs
= 7;
426 dispparams
.cNamedArgs
= 0;
427 dispparams
.rgdispidNamedArgs
= NULL
;
428 dispparams
.rgvarg
= params
;
430 This
->busy
= VARIANT_TRUE
;
432 V_VT(params
) = VT_BOOL
|VT_BYREF
;
433 V_BOOLREF(params
) = cancel
;
435 V_VT(params
+1) = (VT_BYREF
|VT_VARIANT
);
436 V_VARIANTREF(params
+1) = &var_headers
;
437 V_VT(&var_headers
) = VT_BSTR
;
438 V_BSTR(&var_headers
) = headers
;
440 V_VT(params
+2) = (VT_BYREF
|VT_VARIANT
);
441 V_VARIANTREF(params
+2) = &var_post_data2
;
442 V_VT(&var_post_data2
) = (VT_BYREF
|VT_VARIANT
);
443 V_VARIANTREF(&var_post_data2
) = &var_post_data
;
444 VariantInit(&var_post_data
);
447 SAFEARRAYBOUND bound
= {post_data_len
, 0};
450 V_VT(&var_post_data
) = VT_UI1
|VT_ARRAY
;
451 V_ARRAY(&var_post_data
) = SafeArrayCreate(VT_UI1
, 1, &bound
);
453 SafeArrayAccessData(V_ARRAY(&var_post_data
), &data
);
454 memcpy(data
, post_data
, post_data_len
);
455 SafeArrayUnaccessData(V_ARRAY(&var_post_data
));
458 V_VT(params
+3) = (VT_BYREF
|VT_VARIANT
);
459 V_VARIANTREF(params
+3) = &var_frame_name
;
460 V_VT(&var_frame_name
) = VT_BSTR
;
461 V_BSTR(&var_frame_name
) = NULL
;
463 V_VT(params
+4) = (VT_BYREF
|VT_VARIANT
);
464 V_VARIANTREF(params
+4) = &var_flags
;
465 V_VT(&var_flags
) = VT_I4
;
466 V_I4(&var_flags
) = 0;
468 V_VT(params
+5) = (VT_BYREF
|VT_VARIANT
);
469 V_VARIANTREF(params
+5) = &var_url
;
470 V_VT(&var_url
) = VT_BSTR
;
471 V_BSTR(&var_url
) = SysAllocString(url
);
473 V_VT(params
+6) = (VT_DISPATCH
);
474 V_DISPATCH(params
+6) = This
->disp
;
476 call_sink(This
->cps
.wbe2
, DISPID_BEFORENAVIGATE2
, &dispparams
);
478 SysFreeString(V_BSTR(&var_url
));
480 SafeArrayDestroy(V_ARRAY(&var_post_data
));
483 /* FIXME: urlmon should handle it */
484 static BOOL
try_application_url(LPCWSTR url
)
486 SHELLEXECUTEINFOW exec_info
;
492 static const WCHAR wszURLProtocol
[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
494 hres
= CoInternetParseUrl(url
, PARSE_SCHEMA
, 0, app
, sizeof(app
)/sizeof(WCHAR
), NULL
, 0);
498 res
= RegOpenKeyW(HKEY_CLASSES_ROOT
, app
, &hkey
);
499 if(res
!= ERROR_SUCCESS
)
502 res
= RegQueryValueExW(hkey
, wszURLProtocol
, NULL
, &type
, NULL
, NULL
);
504 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
507 TRACE("openning application %s\n", debugstr_w(app
));
509 memset(&exec_info
, 0, sizeof(exec_info
));
510 exec_info
.cbSize
= sizeof(exec_info
);
511 exec_info
.lpFile
= url
;
512 exec_info
.nShow
= SW_SHOW
;
514 return ShellExecuteExW(&exec_info
);
517 static HRESULT
http_load_hack(DocHost
*This
, IMoniker
*mon
, IBindStatusCallback
*callback
, IBindCtx
*bindctx
)
519 IPersistMoniker
*persist
;
525 * We should use URLMoniker's BindToObject instead creating HTMLDocument here.
526 * This should be fixed when mshtml.dll and urlmon.dll will be good enough.
529 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
,
530 CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
531 &IID_IUnknown
, (void**)&doc
);
534 ERR("Could not create HTMLDocument: %08x\n", hres
);
538 hres
= IUnknown_QueryInterface(doc
, &IID_IPersistMoniker
, (void**)&persist
);
540 IUnknown_Release(doc
);
544 hres
= IPersistMoniker_Load(persist
, FALSE
, mon
, bindctx
, 0);
545 IPersistMoniker_Release(persist
);
548 hres
= IBindStatusCallback_OnObjectAvailable(callback
, &IID_IUnknown
, doc
);
550 WARN("Load failed: %08x\n", hres
);
552 IUnknown_Release(doc
);
554 return IBindStatusCallback_OnStopBinding(callback
, hres
, NULL
);
557 static HRESULT
create_moniker(LPCWSTR url
, IMoniker
**mon
)
559 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
564 return CreateURLMoniker(NULL
, url
, mon
);
567 size
= sizeof(new_url
);
568 hres
= UrlCreateFromPathW(url
, new_url
, &size
, 0);
570 WARN("UrlCreateFromPathW failed: %08x\n", hres
);
574 size
= sizeof(new_url
);
575 hres
= UrlApplySchemeW(url
, new_url
, &size
, URL_APPLY_GUESSSCHEME
);
576 TRACE("got %s\n", debugstr_w(new_url
));
578 WARN("UrlApplyScheme failed: %08x\n", hres
);
583 return CreateURLMoniker(NULL
, new_url
, mon
);
586 static HRESULT
bind_to_object(DocHost
*This
, IMoniker
*mon
, LPCWSTR url
, IBindCtx
*bindctx
,
587 IBindStatusCallback
*callback
)
593 static const WCHAR httpW
[] = {'h','t','t','p',0};
594 static const WCHAR httpsW
[] = {'h','t','t','p','s',0};
595 static const WCHAR ftpW
[]= {'f','t','p',0};
598 IMoniker_AddRef(mon
);
600 hres
= create_moniker(url
, &mon
);
605 CoTaskMemFree(This
->url
);
606 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &This
->url
);
608 FIXME("GetDisplayName failed: %08x\n", hres
);
610 IBindCtx_RegisterObjectParam(bindctx
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
,
611 (IUnknown
*)CLIENTSITE(This
));
613 hres
= CoInternetParseUrl(This
->url
, PARSE_SCHEMA
, 0, schema
, sizeof(schema
)/sizeof(schema
[0]),
615 if(SUCCEEDED(hres
) &&
616 (!strcmpW(schema
, httpW
) || !strcmpW(schema
, httpsW
) || !strcmpW(schema
, ftpW
))) {
617 hres
= http_load_hack(This
, mon
, callback
, bindctx
);
619 IUnknown
*unk
= NULL
;
621 hres
= IMoniker_BindToObject(mon
, bindctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
622 if(SUCCEEDED(hres
)) {
625 IUnknown_Release(unk
);
626 }else if(try_application_url(url
)) {
629 FIXME("BindToObject failed: %08x\n", hres
);
633 IMoniker_Release(mon
);
637 static HRESULT
navigate_bsc(DocHost
*This
, BindStatusCallback
*bsc
, IMoniker
*mon
)
640 VARIANT_BOOL cancel
= VARIANT_FALSE
;
643 on_before_navigate2(This
, bsc
->url
, bsc
->post_data
, bsc
->post_data_len
, bsc
->headers
, &cancel
);
645 FIXME("Navigation canceled\n");
650 deactivate_document(This
);
652 CreateAsyncBindCtx(0, BINDSC(bsc
), 0, &bindctx
);
655 IOleInPlaceFrame_EnableModeless(This
->frame
, FALSE
);
657 hres
= bind_to_object(This
, mon
, bsc
->url
, bindctx
, BINDSC(bsc
));
660 IOleInPlaceFrame_EnableModeless(This
->frame
, TRUE
);
662 IBindCtx_Release(bindctx
);
668 task_header_t header
;
669 BindStatusCallback
*bsc
;
670 } task_navigate_bsc_t
;
672 static void navigate_bsc_proc(DocHost
*This
, task_header_t
*t
)
674 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
677 create_doc_view_hwnd(This
);
679 navigate_bsc(This
, task
->bsc
, NULL
);
681 IBindStatusCallback_Release(BINDSC(task
->bsc
));
685 HRESULT
navigate_url(DocHost
*This
, LPCWSTR url
, const VARIANT
*Flags
,
686 const VARIANT
*TargetFrameName
, VARIANT
*PostData
, VARIANT
*Headers
)
688 task_navigate_bsc_t
*task
;
689 PBYTE post_data
= NULL
;
690 ULONG post_data_len
= 0;
691 LPWSTR headers
= NULL
;
693 TRACE("navigating to %s\n", debugstr_w(url
));
695 if((Flags
&& V_VT(Flags
) != VT_EMPTY
)
696 || (TargetFrameName
&& V_VT(TargetFrameName
) != VT_EMPTY
))
697 FIXME("Unsupported args (Flags %p:%d; TargetFrameName %p:%d)\n",
698 Flags
, Flags
? V_VT(Flags
) : -1, TargetFrameName
,
699 TargetFrameName
? V_VT(TargetFrameName
) : -1);
702 TRACE("PostData vt=%d\n", V_VT(PostData
));
704 if(V_VT(PostData
) == (VT_ARRAY
| VT_UI1
)) {
705 SafeArrayAccessData(V_ARRAY(PostData
), (void**)&post_data
);
706 post_data_len
= V_ARRAY(PostData
)->rgsabound
[0].cElements
;
710 if(Headers
&& V_VT(Headers
) != VT_EMPTY
&& V_VT(Headers
) != VT_ERROR
) {
711 if(V_VT(Headers
) != VT_BSTR
)
714 headers
= V_BSTR(Headers
);
715 TRACE("Headers: %s\n", debugstr_w(headers
));
718 task
= heap_alloc(sizeof(*task
));
719 task
->bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
722 SafeArrayUnaccessData(V_ARRAY(PostData
));
724 push_dochost_task(This
, &task
->header
, navigate_bsc_proc
, This
->url
== NULL
);
729 static HRESULT
navigate_hlink(DocHost
*This
, IMoniker
*mon
, IBindCtx
*bindctx
,
730 IBindStatusCallback
*callback
)
732 IHttpNegotiate
*http_negotiate
;
733 BindStatusCallback
*bsc
;
734 PBYTE post_data
= NULL
;
735 ULONG post_data_len
= 0;
736 LPWSTR headers
= NULL
, url
;
741 hres
= IBindStatusCallback_QueryInterface(callback
, &IID_IHttpNegotiate
,
742 (void**)&http_negotiate
);
743 if(SUCCEEDED(hres
)) {
744 static const WCHAR null_string
[] = {0};
746 IHttpNegotiate_BeginningTransaction(http_negotiate
, null_string
, null_string
, 0,
748 IHttpNegotiate_Release(http_negotiate
);
751 memset(&bindinfo
, 0, sizeof(bindinfo
));
752 bindinfo
.cbSize
= sizeof(bindinfo
);
754 hres
= IBindStatusCallback_GetBindInfo(callback
, &bindf
, &bindinfo
);
755 dump_BINDINFO(&bindinfo
);
756 if(bindinfo
.dwBindVerb
== BINDVERB_POST
) {
757 post_data_len
= bindinfo
.cbstgmedData
;
759 post_data
= bindinfo
.stgmedData
.u
.hGlobal
;
762 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &url
);
764 FIXME("GetDisplayName failed: %08x\n", hres
);
766 bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
769 hres
= navigate_bsc(This
, bsc
, mon
);
771 IBindStatusCallback_Release(BINDSC(bsc
));
772 CoTaskMemFree(headers
);
773 ReleaseBindInfo(&bindinfo
);
778 HRESULT
go_home(DocHost
*This
)
780 static const WCHAR wszAboutBlank
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
784 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
787 #define HLINKFRAME_THIS(iface) DEFINE_THIS(WebBrowser, HlinkFrame, iface)
789 static HRESULT WINAPI
HlinkFrame_QueryInterface(IHlinkFrame
*iface
, REFIID riid
, void **ppv
)
791 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
792 return IWebBrowser2_QueryInterface(WEBBROWSER2(This
), riid
, ppv
);
795 static ULONG WINAPI
HlinkFrame_AddRef(IHlinkFrame
*iface
)
797 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
798 return IWebBrowser2_AddRef(WEBBROWSER2(This
));
801 static ULONG WINAPI
HlinkFrame_Release(IHlinkFrame
*iface
)
803 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
804 return IWebBrowser2_Release(WEBBROWSER2(This
));
807 static HRESULT WINAPI
HlinkFrame_SetBrowseContext(IHlinkFrame
*iface
,
808 IHlinkBrowseContext
*pihlbc
)
810 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
811 FIXME("(%p)->(%p)\n", This
, pihlbc
);
815 static HRESULT WINAPI
HlinkFrame_GetBrowseContext(IHlinkFrame
*iface
,
816 IHlinkBrowseContext
**ppihlbc
)
818 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
819 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
823 static HRESULT WINAPI
HlinkFrame_Navigate(IHlinkFrame
*iface
, DWORD grfHLNF
, LPBC pbc
,
824 IBindStatusCallback
*pibsc
, IHlink
*pihlNavigate
)
826 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
828 LPWSTR location
= NULL
;
830 TRACE("(%p)->(%08x %p %p %p)\n", This
, grfHLNF
, pbc
, pibsc
, pihlNavigate
);
833 FIXME("unsupported grfHLNF=%08x\n", grfHLNF
);
835 /* Windows calls GetTargetFrameName here. */
837 IHlink_GetMonikerReference(pihlNavigate
, 1, &mon
, &location
);
840 FIXME("location = %s\n", debugstr_w(location
));
841 CoTaskMemFree(location
);
844 /* Windows calls GetHlinkSite here */
846 if(grfHLNF
& HLNF_OPENINNEWWINDOW
) {
847 FIXME("Not supported HLNF_OPENINNEWWINDOW\n");
851 return navigate_hlink(&This
->doc_host
, mon
, pbc
, pibsc
);
854 static HRESULT WINAPI
HlinkFrame_OnNavigate(IHlinkFrame
*iface
, DWORD grfHLNF
,
855 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
, DWORD dwreserved
)
857 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
858 FIXME("(%p)->(%08x %p %s %s %d)\n", This
, grfHLNF
, pimkTarget
, debugstr_w(pwzLocation
),
859 debugstr_w(pwzFriendlyName
), dwreserved
);
863 static HRESULT WINAPI
HlinkFrame_UpdateHlink(IHlinkFrame
*iface
, ULONG uHLID
,
864 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
)
866 WebBrowser
*This
= HLINKFRAME_THIS(iface
);
867 FIXME("(%p)->(%u %p %s %s)\n", This
, uHLID
, pimkTarget
, debugstr_w(pwzLocation
),
868 debugstr_w(pwzFriendlyName
));
872 #undef HLINKFRAME_THIS
874 static const IHlinkFrameVtbl HlinkFrameVtbl
= {
875 HlinkFrame_QueryInterface
,
878 HlinkFrame_SetBrowseContext
,
879 HlinkFrame_GetBrowseContext
,
881 HlinkFrame_OnNavigate
,
882 HlinkFrame_UpdateHlink
885 void WebBrowser_HlinkFrame_Init(WebBrowser
*This
)
887 This
->lpHlinkFrameVtbl
= &HlinkFrameVtbl
;