2 * Copyright 2006-2010 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
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
40 #include "mshtml_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
44 #define CONTENT_LENGTH "Content-Length"
45 #define UTF16_STR "utf-16"
48 const nsIInputStreamVtbl
*lpInputStreamVtbl
;
56 #define NSINSTREAM(x) ((nsIInputStream*) &(x)->lpInputStreamVtbl)
59 void (*destroy
)(BSCallback
*);
60 HRESULT (*init_bindinfo
)(BSCallback
*);
61 HRESULT (*start_binding
)(BSCallback
*);
62 HRESULT (*stop_binding
)(BSCallback
*,HRESULT
);
63 HRESULT (*read_data
)(BSCallback
*,IStream
*);
64 HRESULT (*on_progress
)(BSCallback
*,ULONG
,LPCWSTR
);
65 HRESULT (*on_response
)(BSCallback
*,DWORD
,LPCWSTR
);
66 HRESULT (*beginning_transaction
)(BSCallback
*,WCHAR
**);
70 const IBindStatusCallbackVtbl
*lpBindStatusCallbackVtbl
;
71 const IServiceProviderVtbl
*lpServiceProviderVtbl
;
72 const IHttpNegotiate2Vtbl
*lpHttpNegotiate2Vtbl
;
73 const IInternetBindInfoVtbl
*lpInternetBindInfoVtbl
;
75 const BSCallbackVtbl
*vtbl
;
89 HTMLDocumentNode
*doc
;
94 #define NSINSTREAM_THIS(iface) DEFINE_THIS(nsProtocolStream, InputStream, iface)
96 static nsresult NSAPI
nsInputStream_QueryInterface(nsIInputStream
*iface
, nsIIDRef riid
,
99 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
103 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
104 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
105 *result
= NSINSTREAM(This
);
106 }else if(IsEqualGUID(&IID_nsIInputStream
, riid
)) {
107 TRACE("(%p)->(IID_nsIInputStream %p)\n", This
, result
);
108 *result
= NSINSTREAM(This
);
112 nsIInputStream_AddRef(NSINSTREAM(This
));
116 WARN("unsupported interface %s\n", debugstr_guid(riid
));
117 return NS_NOINTERFACE
;
120 static nsrefcnt NSAPI
nsInputStream_AddRef(nsIInputStream
*iface
)
122 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
123 LONG ref
= InterlockedIncrement(&This
->ref
);
125 TRACE("(%p) ref=%d\n", This
, ref
);
131 static nsrefcnt NSAPI
nsInputStream_Release(nsIInputStream
*iface
)
133 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
134 LONG ref
= InterlockedDecrement(&This
->ref
);
136 TRACE("(%p) ref=%d\n", This
, ref
);
144 static nsresult NSAPI
nsInputStream_Close(nsIInputStream
*iface
)
146 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
147 FIXME("(%p)\n", This
);
148 return NS_ERROR_NOT_IMPLEMENTED
;
151 static nsresult NSAPI
nsInputStream_Available(nsIInputStream
*iface
, PRUint32
*_retval
)
153 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
154 FIXME("(%p)->(%p)\n", This
, _retval
);
155 return NS_ERROR_NOT_IMPLEMENTED
;
158 static nsresult NSAPI
nsInputStream_Read(nsIInputStream
*iface
, char *aBuf
, PRUint32 aCount
,
161 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
164 TRACE("(%p)->(%p %d %p)\n", This
, aBuf
, aCount
, _retval
);
166 if(read
> This
->buf_size
)
167 read
= This
->buf_size
;
170 memcpy(aBuf
, This
->buf
, read
);
171 if(read
< This
->buf_size
)
172 memmove(This
->buf
, This
->buf
+read
, This
->buf_size
-read
);
173 This
->buf_size
-= read
;
180 static nsresult NSAPI
nsInputStream_ReadSegments(nsIInputStream
*iface
,
181 nsresult (WINAPI
*aWriter
)(nsIInputStream
*,void*,const char*,PRUint32
,PRUint32
,PRUint32
*),
182 void *aClousure
, PRUint32 aCount
, PRUint32
*_retval
)
184 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
185 PRUint32 written
= 0;
188 TRACE("(%p)->(%p %p %d %p)\n", This
, aWriter
, aClousure
, aCount
, _retval
);
193 if(aCount
> This
->buf_size
)
194 aCount
= This
->buf_size
;
196 nsres
= aWriter(NSINSTREAM(This
), aClousure
, This
->buf
, 0, aCount
, &written
);
198 TRACE("aWritter failed: %08x\n", nsres
);
199 else if(written
!= This
->buf_size
)
200 FIXME("written %d != buf_size %d\n", written
, This
->buf_size
);
202 This
->buf_size
-= written
;
208 static nsresult NSAPI
nsInputStream_IsNonBlocking(nsIInputStream
*iface
, PRBool
*_retval
)
210 nsProtocolStream
*This
= NSINSTREAM_THIS(iface
);
211 FIXME("(%p)->(%p)\n", This
, _retval
);
212 return NS_ERROR_NOT_IMPLEMENTED
;
215 #undef NSINSTREAM_THIS
217 static const nsIInputStreamVtbl nsInputStreamVtbl
= {
218 nsInputStream_QueryInterface
,
219 nsInputStream_AddRef
,
220 nsInputStream_Release
,
222 nsInputStream_Available
,
224 nsInputStream_ReadSegments
,
225 nsInputStream_IsNonBlocking
228 static nsProtocolStream
*create_nsprotocol_stream(void)
230 nsProtocolStream
*ret
= heap_alloc(sizeof(nsProtocolStream
));
232 ret
->lpInputStreamVtbl
= &nsInputStreamVtbl
;
239 #define STATUSCLB_THIS(iface) DEFINE_THIS(BSCallback, BindStatusCallback, iface)
241 static HRESULT WINAPI
BindStatusCallback_QueryInterface(IBindStatusCallback
*iface
,
242 REFIID riid
, void **ppv
)
244 BSCallback
*This
= STATUSCLB_THIS(iface
);
247 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
248 TRACE("(%p)->(IID_IUnknown, %p)\n", This
, ppv
);
249 *ppv
= STATUSCLB(This
);
250 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
251 TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This
, ppv
);
252 *ppv
= STATUSCLB(This
);
253 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
254 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
255 *ppv
= SERVPROV(This
);
256 }else if(IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
257 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This
, ppv
);
258 *ppv
= HTTPNEG(This
);
259 }else if(IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
260 TRACE("(%p)->(IID_IHttpNegotiate2 %p)\n", This
, ppv
);
261 *ppv
= HTTPNEG(This
);
262 }else if(IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
263 TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This
, ppv
);
264 *ppv
= BINDINFO(This
);
268 IBindStatusCallback_AddRef(STATUSCLB(This
));
272 TRACE("Unsupported riid = %s\n", debugstr_guid(riid
));
273 return E_NOINTERFACE
;
276 static ULONG WINAPI
BindStatusCallback_AddRef(IBindStatusCallback
*iface
)
278 BSCallback
*This
= STATUSCLB_THIS(iface
);
279 LONG ref
= InterlockedIncrement(&This
->ref
);
281 TRACE("(%p) ref = %d\n", This
, ref
);
286 static ULONG WINAPI
BindStatusCallback_Release(IBindStatusCallback
*iface
)
288 BSCallback
*This
= STATUSCLB_THIS(iface
);
289 LONG ref
= InterlockedDecrement(&This
->ref
);
291 TRACE("(%p) ref = %d\n", This
, ref
);
295 GlobalFree(This
->post_data
);
297 IMoniker_Release(This
->mon
);
299 IBinding_Release(This
->binding
);
300 list_remove(&This
->entry
);
301 heap_free(This
->headers
);
303 This
->vtbl
->destroy(This
);
309 static HRESULT WINAPI
BindStatusCallback_OnStartBinding(IBindStatusCallback
*iface
,
310 DWORD dwReserved
, IBinding
*pbind
)
312 BSCallback
*This
= STATUSCLB_THIS(iface
);
314 TRACE("(%p)->(%d %p)\n", This
, dwReserved
, pbind
);
316 IBinding_AddRef(pbind
);
317 This
->binding
= pbind
;
320 list_add_head(&This
->doc
->bindings
, &This
->entry
);
322 return This
->vtbl
->start_binding(This
);
325 static HRESULT WINAPI
BindStatusCallback_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
327 BSCallback
*This
= STATUSCLB_THIS(iface
);
328 FIXME("(%p)->(%p)\n", This
, pnPriority
);
332 static HRESULT WINAPI
BindStatusCallback_OnLowResource(IBindStatusCallback
*iface
, DWORD reserved
)
334 BSCallback
*This
= STATUSCLB_THIS(iface
);
335 FIXME("(%p)->(%d)\n", This
, reserved
);
339 static HRESULT WINAPI
BindStatusCallback_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
340 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
342 BSCallback
*This
= STATUSCLB_THIS(iface
);
344 TRACE("%p)->(%u %u %u %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
,
345 debugstr_w(szStatusText
));
347 return This
->vtbl
->on_progress(This
, ulStatusCode
, szStatusText
);
350 static HRESULT WINAPI
BindStatusCallback_OnStopBinding(IBindStatusCallback
*iface
,
351 HRESULT hresult
, LPCWSTR szError
)
353 BSCallback
*This
= STATUSCLB_THIS(iface
);
356 TRACE("(%p)->(%08x %s)\n", This
, hresult
, debugstr_w(szError
));
358 /* NOTE: IE7 calls GetBindResult here */
360 hres
= This
->vtbl
->stop_binding(This
, hresult
);
363 IBinding_Release(This
->binding
);
364 This
->binding
= NULL
;
367 list_remove(&This
->entry
);
373 static HRESULT WINAPI
BindStatusCallback_GetBindInfo(IBindStatusCallback
*iface
,
374 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
376 BSCallback
*This
= STATUSCLB_THIS(iface
);
379 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
381 if(!This
->bindinfo_ready
) {
384 hres
= This
->vtbl
->init_bindinfo(This
);
388 This
->bindinfo_ready
= TRUE
;
391 *grfBINDF
= This
->bindf
;
393 size
= pbindinfo
->cbSize
;
394 memset(pbindinfo
, 0, size
);
395 pbindinfo
->cbSize
= size
;
397 pbindinfo
->cbstgmedData
= This
->post_data_len
;
398 pbindinfo
->dwCodePage
= CP_UTF8
;
399 pbindinfo
->dwOptions
= 0x80000;
401 if(This
->post_data
) {
402 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
404 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
405 pbindinfo
->stgmedData
.u
.hGlobal
= This
->post_data
;
406 pbindinfo
->stgmedData
.pUnkForRelease
= (IUnknown
*)STATUSCLB(This
);
407 IBindStatusCallback_AddRef(STATUSCLB(This
));
413 static HRESULT WINAPI
BindStatusCallback_OnDataAvailable(IBindStatusCallback
*iface
,
414 DWORD grfBSCF
, DWORD dwSize
, FORMATETC
*pformatetc
, STGMEDIUM
*pstgmed
)
416 BSCallback
*This
= STATUSCLB_THIS(iface
);
418 TRACE("(%p)->(%08x %d %p %p)\n", This
, grfBSCF
, dwSize
, pformatetc
, pstgmed
);
420 return This
->vtbl
->read_data(This
, pstgmed
->u
.pstm
);
423 static HRESULT WINAPI
BindStatusCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
424 REFIID riid
, IUnknown
*punk
)
426 BSCallback
*This
= STATUSCLB_THIS(iface
);
427 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), punk
);
431 #undef STATUSCLB_THIS
433 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
434 BindStatusCallback_QueryInterface
,
435 BindStatusCallback_AddRef
,
436 BindStatusCallback_Release
,
437 BindStatusCallback_OnStartBinding
,
438 BindStatusCallback_GetPriority
,
439 BindStatusCallback_OnLowResource
,
440 BindStatusCallback_OnProgress
,
441 BindStatusCallback_OnStopBinding
,
442 BindStatusCallback_GetBindInfo
,
443 BindStatusCallback_OnDataAvailable
,
444 BindStatusCallback_OnObjectAvailable
447 #define HTTPNEG_THIS(iface) DEFINE_THIS(BSCallback, HttpNegotiate2, iface)
449 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
,
450 REFIID riid
, void **ppv
)
452 BSCallback
*This
= HTTPNEG_THIS(iface
);
453 return IBindStatusCallback_QueryInterface(STATUSCLB(This
), riid
, ppv
);
456 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
458 BSCallback
*This
= HTTPNEG_THIS(iface
);
459 return IBindStatusCallback_AddRef(STATUSCLB(This
));
462 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
464 BSCallback
*This
= HTTPNEG_THIS(iface
);
465 return IBindStatusCallback_Release(STATUSCLB(This
));
468 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
,
469 LPCWSTR szURL
, LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
471 BSCallback
*This
= HTTPNEG_THIS(iface
);
474 TRACE("(%p)->(%s %s %d %p)\n", This
, debugstr_w(szURL
), debugstr_w(szHeaders
),
475 dwReserved
, pszAdditionalHeaders
);
477 *pszAdditionalHeaders
= NULL
;
479 hres
= This
->vtbl
->beginning_transaction(This
, pszAdditionalHeaders
);
486 size
= (strlenW(This
->headers
)+1)*sizeof(WCHAR
);
487 *pszAdditionalHeaders
= CoTaskMemAlloc(size
);
488 if(!*pszAdditionalHeaders
)
489 return E_OUTOFMEMORY
;
490 memcpy(*pszAdditionalHeaders
, This
->headers
, size
);
496 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
497 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
499 BSCallback
*This
= HTTPNEG_THIS(iface
);
501 TRACE("(%p)->(%d %s %s %p)\n", This
, dwResponseCode
, debugstr_w(szResponseHeaders
),
502 debugstr_w(szRequestHeaders
), pszAdditionalRequestHeaders
);
504 return This
->vtbl
->on_response(This
, dwResponseCode
, szResponseHeaders
);
507 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
508 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
510 BSCallback
*This
= HTTPNEG_THIS(iface
);
511 FIXME("(%p)->(%p %p %ld)\n", This
, pbSecurityId
, pcbSecurityId
, dwReserved
);
517 static const IHttpNegotiate2Vtbl HttpNegotiate2Vtbl
= {
518 HttpNegotiate_QueryInterface
,
519 HttpNegotiate_AddRef
,
520 HttpNegotiate_Release
,
521 HttpNegotiate_BeginningTransaction
,
522 HttpNegotiate_OnResponse
,
523 HttpNegotiate_GetRootSecurityId
526 #define BINDINFO_THIS(iface) DEFINE_THIS(BSCallback, InternetBindInfo, iface)
528 static HRESULT WINAPI
InternetBindInfo_QueryInterface(IInternetBindInfo
*iface
,
529 REFIID riid
, void **ppv
)
531 BSCallback
*This
= BINDINFO_THIS(iface
);
532 return IBindStatusCallback_QueryInterface(STATUSCLB(This
), riid
, ppv
);
535 static ULONG WINAPI
InternetBindInfo_AddRef(IInternetBindInfo
*iface
)
537 BSCallback
*This
= BINDINFO_THIS(iface
);
538 return IBindStatusCallback_AddRef(STATUSCLB(This
));
541 static ULONG WINAPI
InternetBindInfo_Release(IInternetBindInfo
*iface
)
543 BSCallback
*This
= BINDINFO_THIS(iface
);
544 return IBindStatusCallback_Release(STATUSCLB(This
));
547 static HRESULT WINAPI
InternetBindInfo_GetBindInfo(IInternetBindInfo
*iface
,
548 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
550 BSCallback
*This
= BINDINFO_THIS(iface
);
551 FIXME("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
555 static HRESULT WINAPI
InternetBindInfo_GetBindString(IInternetBindInfo
*iface
,
556 ULONG ulStringType
, LPOLESTR
*ppwzStr
, ULONG cEl
, ULONG
*pcElFetched
)
558 BSCallback
*This
= BINDINFO_THIS(iface
);
559 FIXME("(%p)->(%u %p %u %p)\n", This
, ulStringType
, ppwzStr
, cEl
, pcElFetched
);
565 static const IInternetBindInfoVtbl InternetBindInfoVtbl
= {
566 InternetBindInfo_QueryInterface
,
567 InternetBindInfo_AddRef
,
568 InternetBindInfo_Release
,
569 InternetBindInfo_GetBindInfo
,
570 InternetBindInfo_GetBindString
573 #define SERVPROV_THIS(iface) DEFINE_THIS(BSCallback, ServiceProvider, iface)
575 static HRESULT WINAPI
BSCServiceProvider_QueryInterface(IServiceProvider
*iface
,
576 REFIID riid
, void **ppv
)
578 BSCallback
*This
= SERVPROV_THIS(iface
);
579 return IBindStatusCallback_QueryInterface(STATUSCLB(This
), riid
, ppv
);
582 static ULONG WINAPI
BSCServiceProvider_AddRef(IServiceProvider
*iface
)
584 BSCallback
*This
= SERVPROV_THIS(iface
);
585 return IBindStatusCallback_AddRef(STATUSCLB(This
));
588 static ULONG WINAPI
BSCServiceProvider_Release(IServiceProvider
*iface
)
590 BSCallback
*This
= SERVPROV_THIS(iface
);
591 return IBindStatusCallback_Release(STATUSCLB(This
));
594 static HRESULT WINAPI
BSCServiceProvider_QueryService(IServiceProvider
*iface
,
595 REFGUID guidService
, REFIID riid
, void **ppv
)
597 BSCallback
*This
= SERVPROV_THIS(iface
);
598 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
599 return E_NOINTERFACE
;
604 static const IServiceProviderVtbl ServiceProviderVtbl
= {
605 BSCServiceProvider_QueryInterface
,
606 BSCServiceProvider_AddRef
,
607 BSCServiceProvider_Release
,
608 BSCServiceProvider_QueryService
611 static void init_bscallback(BSCallback
*This
, const BSCallbackVtbl
*vtbl
, IMoniker
*mon
, DWORD bindf
)
613 This
->lpBindStatusCallbackVtbl
= &BindStatusCallbackVtbl
;
614 This
->lpServiceProviderVtbl
= &ServiceProviderVtbl
;
615 This
->lpHttpNegotiate2Vtbl
= &HttpNegotiate2Vtbl
;
616 This
->lpInternetBindInfoVtbl
= &InternetBindInfoVtbl
;
621 list_init(&This
->entry
);
624 IMoniker_AddRef(mon
);
628 /* Calls undocumented 84 cmd of CGID_ShellDocView */
629 static void call_docview_84(HTMLDocumentObj
*doc
)
631 IOleCommandTarget
*olecmd
;
638 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
643 hres
= IOleCommandTarget_Exec(olecmd
, &CGID_ShellDocView
, 84, 0, NULL
, &var
);
644 IOleCommandTarget_Release(olecmd
);
645 if(SUCCEEDED(hres
) && V_VT(&var
) != VT_NULL
)
646 FIXME("handle result\n");
649 static HRESULT
parse_headers(const WCHAR
*headers
, struct list
*headers_list
)
651 const WCHAR
*header
, *header_end
, *colon
, *value
;
656 if(header
[0] == '\r' && header
[1] == '\n' && !header
[2])
658 for(colon
= header
; *colon
&& *colon
!= ':' && *colon
!= '\r'; colon
++);
668 for(header_end
= value
+1; *header_end
&& *header_end
!= '\r'; header_end
++);
670 hres
= set_http_header(headers_list
, header
, colon
-header
, value
, header_end
-value
);
675 if(header
[0] == '\r' && header
[1] == '\n')
682 static HRESULT
read_post_data_stream(nsIInputStream
*stream
, HGLOBAL
*post_data
,
683 ULONG
*post_data_len
)
685 PRUint32 data_len
= 0, available
= 0;
689 nsres
= nsIInputStream_Available(stream
, &available
);
693 data
= GlobalAlloc(0, available
+1);
695 return E_OUTOFMEMORY
;
697 nsres
= nsIInputStream_Read(stream
, data
, available
, &data_len
);
698 if(NS_FAILED(nsres
)) {
705 *post_data_len
= data_len
;
709 static void parse_post_data(nsIInputStream
*post_data_stream
, LPWSTR
*headers_ret
,
710 HGLOBAL
*post_data_ret
, ULONG
*post_data_len_ret
)
713 HGLOBAL post_data
= NULL
;
714 LPWSTR headers
= NULL
;
715 DWORD headers_len
= 0, len
;
716 const char *ptr
, *ptr2
, *post_data_end
;
719 hres
= read_post_data_stream(post_data_stream
, &post_data
, &post_data_len
);
721 FIXME("read_post_data_stream failed: %08x\n", hres
);
725 ptr
= ptr2
= post_data
;
726 post_data_end
= (const char*)post_data
+post_data_len
;
728 while(ptr
< post_data_end
&& (*ptr
!= '\r' || ptr
[1] != '\n')) {
729 while(ptr
< post_data_end
&& (*ptr
!= '\r' || ptr
[1] != '\n'))
739 if(ptr
-ptr2
>= sizeof(CONTENT_LENGTH
)
740 && CompareStringA(LOCALE_SYSTEM_DEFAULT
, NORM_IGNORECASE
,
741 CONTENT_LENGTH
, sizeof(CONTENT_LENGTH
)-1,
742 ptr2
, sizeof(CONTENT_LENGTH
)-1) == CSTR_EQUAL
) {
747 len
= MultiByteToWideChar(CP_ACP
, 0, ptr2
, ptr
-ptr2
, NULL
, 0);
750 headers
= heap_realloc(headers
,(headers_len
+len
+1)*sizeof(WCHAR
));
752 headers
= heap_alloc((len
+1)*sizeof(WCHAR
));
754 len
= MultiByteToWideChar(CP_ACP
, 0, ptr2
, ptr
-ptr2
, headers
+headers_len
, len
);
760 headers
[headers_len
] = 0;
761 *headers_ret
= headers
;
763 if(ptr
>= post_data_end
-2) {
764 GlobalFree(post_data
);
771 post_data_len
-= ptr
-(const char*)post_data
;
772 memmove(post_data
, ptr
, post_data_len
);
773 post_data
= GlobalReAlloc(post_data
, post_data_len
+1, 0);
776 *post_data_ret
= post_data
;
777 *post_data_len_ret
= post_data_len
;
780 HRESULT
start_binding(HTMLWindow
*window
, HTMLDocumentNode
*doc
, BSCallback
*bscallback
, IBindCtx
*bctx
)
785 bscallback
->doc
= doc
;
787 /* NOTE: IE7 calls IsSystemMoniker here*/
790 if(bscallback
->mon
!= window
->mon
)
791 set_current_mon(window
, bscallback
->mon
);
792 call_docview_84(window
->doc_obj
);
796 RegisterBindStatusCallback(bctx
, STATUSCLB(bscallback
), NULL
, 0);
797 IBindCtx_AddRef(bctx
);
799 hres
= CreateAsyncBindCtx(0, STATUSCLB(bscallback
), NULL
, &bctx
);
801 WARN("CreateAsyncBindCtx failed: %08x\n", hres
);
802 bscallback
->vtbl
->stop_binding(bscallback
, hres
);
807 hres
= IMoniker_BindToStorage(bscallback
->mon
, bctx
, NULL
, &IID_IStream
, (void**)&str
);
808 IBindCtx_Release(bctx
);
810 WARN("BindToStorage failed: %08x\n", hres
);
811 bscallback
->vtbl
->stop_binding(bscallback
, hres
);
816 IStream_Release(str
);
818 IMoniker_Release(bscallback
->mon
);
819 bscallback
->mon
= NULL
;
832 #define BUFFERBSC_THIS(bsc) ((BufferBSC*) bsc)
834 static void BufferBSC_destroy(BSCallback
*bsc
)
836 BufferBSC
*This
= BUFFERBSC_THIS(bsc
);
838 heap_free(This
->buf
);
842 static HRESULT
BufferBSC_init_bindinfo(BSCallback
*bsc
)
847 static HRESULT
BufferBSC_start_binding(BSCallback
*bsc
)
852 static HRESULT
BufferBSC_stop_binding(BSCallback
*bsc
, HRESULT result
)
854 BufferBSC
*This
= BUFFERBSC_THIS(bsc
);
859 heap_free(This
->buf
);
867 static HRESULT
BufferBSC_read_data(BSCallback
*bsc
, IStream
*stream
)
869 BufferBSC
*This
= BUFFERBSC_THIS(bsc
);
875 This
->buf
= heap_alloc(This
->size
);
879 if(This
->bsc
.readed
== This
->size
) {
881 This
->buf
= heap_realloc(This
->buf
, This
->size
);
885 hres
= IStream_Read(stream
, This
->buf
+This
->bsc
.readed
, This
->size
-This
->bsc
.readed
, &readed
);
886 This
->bsc
.readed
+= readed
;
887 }while(hres
== S_OK
);
892 static HRESULT
BufferBSC_on_progress(BSCallback
*bsc
, ULONG status_code
, LPCWSTR status_text
)
897 static HRESULT
BufferBSC_on_response(BSCallback
*bsc
, DWORD response_code
,
898 LPCWSTR response_headers
)
903 static HRESULT
BufferBSC_beginning_transaction(BSCallback
*bsc
, WCHAR
**additional_headers
)
908 #undef BUFFERBSC_THIS
910 static const BSCallbackVtbl BufferBSCVtbl
= {
912 BufferBSC_init_bindinfo
,
913 BufferBSC_start_binding
,
914 BufferBSC_stop_binding
,
916 BufferBSC_on_progress
,
917 BufferBSC_on_response
,
918 BufferBSC_beginning_transaction
922 static BufferBSC
*create_bufferbsc(IMoniker
*mon
)
924 BufferBSC
*ret
= heap_alloc_zero(sizeof(*ret
));
926 init_bscallback(&ret
->bsc
, &BufferBSCVtbl
, mon
, 0);
932 HRESULT
bind_mon_to_buffer(HTMLDocumentNode
*doc
, IMoniker
*mon
, void **buf
, DWORD
*size
)
934 BufferBSC
*bsc
= create_bufferbsc(mon
);
939 hres
= start_binding(NULL
, doc
, &bsc
->bsc
, NULL
);
940 if(SUCCEEDED(hres
)) {
942 if(SUCCEEDED(hres
)) {
945 *size
= bsc
->bsc
.readed
;
950 IBindStatusCallback_Release(STATUSCLB(&bsc
->bsc
));
955 struct nsChannelBSC
{
960 nsChannel
*nschannel
;
961 nsIStreamListener
*nslistener
;
962 nsISupports
*nscontext
;
964 nsProtocolStream
*nsstream
;
967 static HRESULT
on_start_nsrequest(nsChannelBSC
*This
)
971 /* FIXME: it's needed for http connections from BindToObject. */
972 if(!This
->nschannel
->response_status
)
973 This
->nschannel
->response_status
= 200;
975 nsres
= nsIStreamListener_OnStartRequest(This
->nslistener
,
976 (nsIRequest
*)NSCHANNEL(This
->nschannel
), This
->nscontext
);
977 if(NS_FAILED(nsres
)) {
978 FIXME("OnStartRequest failed: %08x\n", nsres
);
983 update_window_doc(This
->window
);
984 if(This
->window
->doc
!= This
->bsc
.doc
)
985 This
->bsc
.doc
= This
->window
->doc
;
986 if(This
->window
->readystate
!= READYSTATE_LOADING
)
987 set_ready_state(This
->window
, READYSTATE_LOADING
);
993 static void on_stop_nsrequest(nsChannelBSC
*This
, HRESULT result
)
995 nsresult nsres
, request_result
;
999 request_result
= NS_OK
;
1002 request_result
= NS_BINDING_ABORTED
;
1005 request_result
= NS_ERROR_FAILURE
;
1008 if(!This
->bsc
.readed
&& SUCCEEDED(result
)) {
1009 TRACE("No data read! Calling OnStartRequest\n");
1010 on_start_nsrequest(This
);
1013 if(This
->nslistener
) {
1014 nsres
= nsIStreamListener_OnStopRequest(This
->nslistener
,
1015 (nsIRequest
*)NSCHANNEL(This
->nschannel
), This
->nscontext
, request_result
);
1016 if(NS_FAILED(nsres
))
1017 WARN("OnStopRequet failed: %08x\n", nsres
);
1020 if(This
->nschannel
->load_group
) {
1021 nsres
= nsILoadGroup_RemoveRequest(This
->nschannel
->load_group
,
1022 (nsIRequest
*)NSCHANNEL(This
->nschannel
), NULL
, request_result
);
1023 if(NS_FAILED(nsres
))
1024 ERR("RemoveRequest failed: %08x\n", nsres
);
1028 static HRESULT
read_stream_data(nsChannelBSC
*This
, IStream
*stream
)
1034 if(!This
->nslistener
) {
1039 hres
= IStream_Read(stream
, buf
, sizeof(buf
), &read
);
1040 }while(hres
== S_OK
&& read
);
1046 This
->nsstream
= create_nsprotocol_stream();
1050 hres
= IStream_Read(stream
, This
->nsstream
->buf
+This
->nsstream
->buf_size
,
1051 sizeof(This
->nsstream
->buf
)-This
->nsstream
->buf_size
, &read
);
1055 This
->nsstream
->buf_size
+= read
;
1057 if(!This
->bsc
.readed
) {
1058 if(This
->nsstream
->buf_size
>= 2
1059 && (BYTE
)This
->nsstream
->buf
[0] == 0xff
1060 && (BYTE
)This
->nsstream
->buf
[1] == 0xfe)
1061 This
->nschannel
->charset
= heap_strdupA(UTF16_STR
);
1063 if(!This
->nschannel
->content_type
) {
1066 hres
= FindMimeFromData(NULL
, NULL
, This
->nsstream
->buf
, This
->nsstream
->buf_size
, NULL
, 0, &mime
, 0);
1070 TRACE("Found MIME %s\n", debugstr_w(mime
));
1072 This
->nschannel
->content_type
= heap_strdupWtoA(mime
);
1073 CoTaskMemFree(mime
);
1074 if(!This
->nschannel
->content_type
)
1075 return E_OUTOFMEMORY
;
1078 on_start_nsrequest(This
);
1081 This
->bsc
.readed
+= This
->nsstream
->buf_size
;
1083 nsres
= nsIStreamListener_OnDataAvailable(This
->nslistener
,
1084 (nsIRequest
*)NSCHANNEL(This
->nschannel
), This
->nscontext
,
1085 NSINSTREAM(This
->nsstream
), This
->bsc
.readed
-This
->nsstream
->buf_size
,
1086 This
->nsstream
->buf_size
);
1087 if(NS_FAILED(nsres
))
1088 ERR("OnDataAvailable failed: %08x\n", nsres
);
1090 if(This
->nsstream
->buf_size
== sizeof(This
->nsstream
->buf
)) {
1091 ERR("buffer is full\n");
1094 }while(hres
== S_OK
);
1099 #define NSCHANNELBSC_THIS(bsc) ((nsChannelBSC*) bsc)
1101 static void nsChannelBSC_destroy(BSCallback
*bsc
)
1103 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1106 nsIChannel_Release(NSCHANNEL(This
->nschannel
));
1107 if(This
->nslistener
)
1108 nsIStreamListener_Release(This
->nslistener
);
1110 nsISupports_Release(This
->nscontext
);
1112 nsIInputStream_Release(NSINSTREAM(This
->nsstream
));
1116 static HRESULT
nsChannelBSC_start_binding(BSCallback
*bsc
)
1118 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1121 This
->window
->doc
->skip_mutation_notif
= FALSE
;
1126 static HRESULT
nsChannelBSC_init_bindinfo(BSCallback
*bsc
)
1128 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1131 if(This
->nschannel
&& This
->nschannel
->post_data_stream
) {
1132 if(This
->nschannel
->parse_stream
) {
1135 parse_post_data(This
->nschannel
->post_data_stream
, &headers
,
1136 &This
->bsc
.post_data
, &This
->bsc
.post_data_len
);
1138 hres
= parse_headers(headers
, &This
->nschannel
->request_headers
);
1143 hres
= read_post_data_stream(This
->nschannel
->post_data_stream
,
1144 &This
->bsc
.post_data
, &This
->bsc
.post_data_len
);
1149 TRACE("post_data = %s\n", debugstr_an(This
->bsc
.post_data
, This
->bsc
.post_data_len
));
1158 } stop_request_task_t
;
1160 static void stop_request_proc(task_t
*_task
)
1162 stop_request_task_t
*task
= (stop_request_task_t
*)_task
;
1164 TRACE("(%p)\n", task
->bsc
);
1166 on_stop_nsrequest(task
->bsc
, S_OK
);
1167 IBindStatusCallback_Release(STATUSCLB(&task
->bsc
->bsc
));
1170 static HRESULT
async_stop_request(nsChannelBSC
*This
)
1172 stop_request_task_t
*task
;
1174 task
= heap_alloc(sizeof(*task
));
1176 return E_OUTOFMEMORY
;
1178 IBindStatusCallback_AddRef(STATUSCLB(&This
->bsc
));
1180 push_task(&task
->header
, stop_request_proc
, This
->bsc
.doc
->basedoc
.doc_obj
->basedoc
.task_magic
);
1184 static HRESULT
nsChannelBSC_stop_binding(BSCallback
*bsc
, HRESULT result
)
1186 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1188 if(This
->window
&& SUCCEEDED(result
)) {
1189 result
= async_stop_request(This
);
1190 if(SUCCEEDED(result
))
1194 on_stop_nsrequest(This
, result
);
1198 static HRESULT
nsChannelBSC_read_data(BSCallback
*bsc
, IStream
*stream
)
1200 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1202 return read_stream_data(This
, stream
);
1205 static HRESULT
nsChannelBSC_on_progress(BSCallback
*bsc
, ULONG status_code
, LPCWSTR status_text
)
1207 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1209 switch(status_code
) {
1210 case BINDSTATUS_MIMETYPEAVAILABLE
:
1211 if(!This
->nschannel
)
1214 heap_free(This
->nschannel
->content_type
);
1215 This
->nschannel
->content_type
= heap_strdupWtoA(status_text
);
1217 case BINDSTATUS_REDIRECTING
:
1218 TRACE("redirect to %s\n", debugstr_w(status_text
));
1220 /* FIXME: We should find a better way to handle this */
1221 set_wine_url(This
->nschannel
->uri
, status_text
);
1227 static HRESULT
nsChannelBSC_on_response(BSCallback
*bsc
, DWORD response_code
,
1228 LPCWSTR response_headers
)
1230 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1233 This
->nschannel
->response_status
= response_code
;
1235 if(response_headers
) {
1236 const WCHAR
*headers
;
1238 headers
= strchrW(response_headers
, '\r');
1239 if(headers
&& headers
[1] == '\n') {
1241 hres
= parse_headers(headers
, &This
->nschannel
->response_headers
);
1243 WARN("parsing headers failed: %08x\n", hres
);
1252 static HRESULT
nsChannelBSC_beginning_transaction(BSCallback
*bsc
, WCHAR
**additional_headers
)
1254 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1255 http_header_t
*iter
;
1259 static const WCHAR content_lengthW
[] =
1260 {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0};
1262 if(!This
->nschannel
)
1265 LIST_FOR_EACH_ENTRY(iter
, &This
->nschannel
->request_headers
, http_header_t
, entry
) {
1266 if(strcmpW(iter
->header
, content_lengthW
))
1267 len
+= strlenW(iter
->header
) + 2 /* ": " */ + strlenW(iter
->data
) + 2 /* "\r\n" */;
1273 *additional_headers
= ptr
= CoTaskMemAlloc((len
+1)*sizeof(WCHAR
));
1275 return E_OUTOFMEMORY
;
1277 LIST_FOR_EACH_ENTRY(iter
, &This
->nschannel
->request_headers
, http_header_t
, entry
) {
1278 if(!strcmpW(iter
->header
, content_lengthW
))
1281 len
= strlenW(iter
->header
);
1282 memcpy(ptr
, iter
->header
, len
*sizeof(WCHAR
));
1288 len
= strlenW(iter
->data
);
1289 memcpy(ptr
, iter
->data
, len
*sizeof(WCHAR
));
1301 #undef NSCHANNELBSC_THIS
1303 static const BSCallbackVtbl nsChannelBSCVtbl
= {
1304 nsChannelBSC_destroy
,
1305 nsChannelBSC_init_bindinfo
,
1306 nsChannelBSC_start_binding
,
1307 nsChannelBSC_stop_binding
,
1308 nsChannelBSC_read_data
,
1309 nsChannelBSC_on_progress
,
1310 nsChannelBSC_on_response
,
1311 nsChannelBSC_beginning_transaction
1314 HRESULT
create_channelbsc(IMoniker
*mon
, WCHAR
*headers
, BYTE
*post_data
, DWORD post_data_size
, nsChannelBSC
**retval
)
1318 ret
= heap_alloc_zero(sizeof(*ret
));
1320 return E_OUTOFMEMORY
;
1322 init_bscallback(&ret
->bsc
, &nsChannelBSCVtbl
, mon
, BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
);
1325 ret
->bsc
.headers
= heap_strdupW(headers
);
1326 if(!ret
->bsc
.headers
) {
1327 IBindStatusCallback_Release(STATUSCLB(&ret
->bsc
));
1328 return E_OUTOFMEMORY
;
1333 ret
->bsc
.post_data
= GlobalAlloc(0, post_data_size
);
1334 if(!ret
->bsc
.post_data
) {
1335 heap_free(ret
->bsc
.headers
);
1336 IBindStatusCallback_Release(STATUSCLB(&ret
->bsc
));
1337 return E_OUTOFMEMORY
;
1340 memcpy(ret
->bsc
.post_data
, post_data
, post_data_size
);
1341 ret
->bsc
.post_data_len
= post_data_size
;
1348 IMoniker
*get_channelbsc_mon(nsChannelBSC
*This
)
1351 IMoniker_AddRef(This
->bsc
.mon
);
1352 return This
->bsc
.mon
;
1355 void set_window_bscallback(HTMLWindow
*window
, nsChannelBSC
*callback
)
1357 if(window
->bscallback
) {
1358 if(window
->bscallback
->bsc
.binding
)
1359 IBinding_Abort(window
->bscallback
->bsc
.binding
);
1360 window
->bscallback
->bsc
.doc
= NULL
;
1361 window
->bscallback
->window
= NULL
;
1362 IBindStatusCallback_Release(STATUSCLB(&window
->bscallback
->bsc
));
1365 window
->bscallback
= callback
;
1368 callback
->window
= window
;
1369 IBindStatusCallback_AddRef(STATUSCLB(&callback
->bsc
));
1370 callback
->bsc
.doc
= window
->doc
;
1377 nsChannelBSC
*bscallback
;
1378 } start_doc_binding_task_t
;
1380 static void start_doc_binding_proc(task_t
*_task
)
1382 start_doc_binding_task_t
*task
= (start_doc_binding_task_t
*)_task
;
1384 start_binding(task
->window
, NULL
, (BSCallback
*)task
->bscallback
, NULL
);
1385 IBindStatusCallback_Release(STATUSCLB(&task
->bscallback
->bsc
));
1388 HRESULT
async_start_doc_binding(HTMLWindow
*window
, nsChannelBSC
*bscallback
)
1390 start_doc_binding_task_t
*task
;
1392 task
= heap_alloc(sizeof(start_doc_binding_task_t
));
1394 return E_OUTOFMEMORY
;
1396 task
->window
= window
;
1397 task
->bscallback
= bscallback
;
1398 IBindStatusCallback_AddRef(STATUSCLB(&bscallback
->bsc
));
1400 push_task(&task
->header
, start_doc_binding_proc
, window
->task_magic
);
1404 void abort_document_bindings(HTMLDocumentNode
*doc
)
1408 LIST_FOR_EACH_ENTRY(iter
, &doc
->bindings
, BSCallback
, entry
) {
1410 IBinding_Abort(iter
->binding
);
1412 list_remove(&iter
->entry
);
1416 HRESULT
channelbsc_load_stream(nsChannelBSC
*bscallback
, IStream
*stream
)
1418 HRESULT hres
= S_OK
;
1420 if(!bscallback
->nschannel
) {
1421 ERR("NULL nschannel\n");
1425 bscallback
->nschannel
->content_type
= heap_strdupA("text/html");
1426 if(!bscallback
->nschannel
->content_type
)
1427 return E_OUTOFMEMORY
;
1430 hres
= read_stream_data(bscallback
, stream
);
1432 hres
= async_stop_request(bscallback
);
1434 IBindStatusCallback_OnStopBinding(STATUSCLB(&bscallback
->bsc
), hres
, ERROR_SUCCESS
);
1439 void channelbsc_set_channel(nsChannelBSC
*This
, nsChannel
*channel
, nsIStreamListener
*listener
, nsISupports
*context
)
1441 nsIChannel_AddRef(NSCHANNEL(channel
));
1442 This
->nschannel
= channel
;
1444 nsIStreamListener_AddRef(listener
);
1445 This
->nslistener
= listener
;
1448 nsISupports_AddRef(context
);
1449 This
->nscontext
= context
;
1452 if(This
->bsc
.headers
) {
1455 hres
= parse_headers(This
->bsc
.headers
, &channel
->request_headers
);
1456 heap_free(This
->bsc
.headers
);
1457 This
->bsc
.headers
= NULL
;
1459 WARN("parse_headers failed: %08x\n", hres
);
1463 HRESULT
hlink_frame_navigate(HTMLDocument
*doc
, LPCWSTR url
,
1464 nsIInputStream
*post_data_stream
, DWORD hlnf
, BOOL
*cancel
)
1466 IHlinkFrame
*hlink_frame
;
1467 nsChannelBSC
*callback
;
1468 IServiceProvider
*sp
;
1476 hres
= IOleClientSite_QueryInterface(doc
->doc_obj
->client
, &IID_IServiceProvider
,
1481 hres
= IServiceProvider_QueryService(sp
, &IID_IHlinkFrame
, &IID_IHlinkFrame
,
1482 (void**)&hlink_frame
);
1483 IServiceProvider_Release(sp
);
1487 hres
= create_channelbsc(NULL
, NULL
, NULL
, 0, &callback
);
1489 IHlinkFrame_Release(hlink_frame
);
1493 if(post_data_stream
) {
1494 parse_post_data(post_data_stream
, &callback
->bsc
.headers
, &callback
->bsc
.post_data
,
1495 &callback
->bsc
.post_data_len
);
1496 TRACE("headers = %s post_data = %s\n", debugstr_w(callback
->bsc
.headers
),
1497 debugstr_an(callback
->bsc
.post_data
, callback
->bsc
.post_data_len
));
1500 hres
= CreateAsyncBindCtx(0, STATUSCLB(&callback
->bsc
), NULL
, &bindctx
);
1502 hres
= CoCreateInstance(&CLSID_StdHlink
, NULL
, CLSCTX_INPROC_SERVER
,
1503 &IID_IHlink
, (LPVOID
*)&hlink
);
1506 hres
= CreateURLMoniker(NULL
, url
, &mon
);
1508 if(SUCCEEDED(hres
)) {
1509 IHlink_SetMonikerReference(hlink
, HLINKSETF_TARGET
, mon
, NULL
);
1511 if(hlnf
& HLNF_OPENINNEWWINDOW
) {
1512 static const WCHAR wszBlank
[] = {'_','b','l','a','n','k',0};
1513 IHlink_SetTargetFrameName(hlink
, wszBlank
); /* FIXME */
1516 hres
= IHlinkFrame_Navigate(hlink_frame
, hlnf
, bindctx
, STATUSCLB(&callback
->bsc
), hlink
);
1517 IMoniker_Release(mon
);
1518 *cancel
= hres
== S_OK
;
1522 IHlinkFrame_Release(hlink_frame
);
1523 IBindCtx_Release(bindctx
);
1524 IBindStatusCallback_Release(STATUSCLB(&callback
->bsc
));
1528 HRESULT
navigate_url(HTMLWindow
*window
, const WCHAR
*new_url
, const WCHAR
*base_url
)
1530 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
1536 }else if(base_url
) {
1539 hres
= CoInternetCombineUrl(base_url
, new_url
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
1540 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
1544 strcpyW(url
, new_url
);
1547 if(window
->doc_obj
&& window
->doc_obj
->hostui
) {
1548 OLECHAR
*translated_url
= NULL
;
1550 hres
= IDocHostUIHandler_TranslateUrl(window
->doc_obj
->hostui
, 0, url
,
1553 TRACE("%08x %s -> %s\n", hres
, debugstr_w(url
), debugstr_w(translated_url
));
1554 strcpyW(url
, translated_url
);
1555 CoTaskMemFree(translated_url
);
1559 if(window
->doc_obj
&& window
== window
->doc_obj
->basedoc
.window
) {
1562 hres
= hlink_frame_navigate(&window
->doc
->basedoc
, url
, NULL
, 0, &cancel
);
1567 TRACE("Navigation handled by hlink frame\n");
1572 hres
= create_doc_uri(window
, url
, &uri
);
1576 hres
= load_nsuri(window
, uri
, NULL
, LOAD_FLAGS_NONE
);
1577 nsISupports_Release((nsISupports
*)uri
);