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
)
997 if(!This
->bsc
.readed
&& SUCCEEDED(result
)) {
998 TRACE("No data read! Calling OnStartRequest\n");
999 on_start_nsrequest(This
);
1002 if(This
->nslistener
) {
1003 nsres
= nsIStreamListener_OnStopRequest(This
->nslistener
,
1004 (nsIRequest
*)NSCHANNEL(This
->nschannel
),
1005 This
->nscontext
, SUCCEEDED(result
) ? NS_OK
: NS_ERROR_FAILURE
);
1006 if(NS_FAILED(nsres
))
1007 WARN("OnStopRequet failed: %08x\n", nsres
);
1010 if(This
->nschannel
->load_group
) {
1011 nsres
= nsILoadGroup_RemoveRequest(This
->nschannel
->load_group
,
1012 (nsIRequest
*)NSCHANNEL(This
->nschannel
), NULL
, NS_OK
);
1013 if(NS_FAILED(nsres
))
1014 ERR("RemoveRequest failed: %08x\n", nsres
);
1018 static HRESULT
read_stream_data(nsChannelBSC
*This
, IStream
*stream
)
1024 if(!This
->nslistener
) {
1029 hres
= IStream_Read(stream
, buf
, sizeof(buf
), &read
);
1030 }while(hres
== S_OK
&& read
);
1036 This
->nsstream
= create_nsprotocol_stream();
1040 hres
= IStream_Read(stream
, This
->nsstream
->buf
+This
->nsstream
->buf_size
,
1041 sizeof(This
->nsstream
->buf
)-This
->nsstream
->buf_size
, &read
);
1045 This
->nsstream
->buf_size
+= read
;
1047 if(!This
->bsc
.readed
) {
1048 if(This
->nsstream
->buf_size
>= 2
1049 && (BYTE
)This
->nsstream
->buf
[0] == 0xff
1050 && (BYTE
)This
->nsstream
->buf
[1] == 0xfe)
1051 This
->nschannel
->charset
= heap_strdupA(UTF16_STR
);
1053 if(!This
->nschannel
->content_type
) {
1056 hres
= FindMimeFromData(NULL
, NULL
, This
->nsstream
->buf
, This
->nsstream
->buf_size
, NULL
, 0, &mime
, 0);
1060 TRACE("Found MIME %s\n", debugstr_w(mime
));
1062 This
->nschannel
->content_type
= heap_strdupWtoA(mime
);
1063 CoTaskMemFree(mime
);
1064 if(!This
->nschannel
->content_type
)
1065 return E_OUTOFMEMORY
;
1068 on_start_nsrequest(This
);
1071 This
->bsc
.readed
+= This
->nsstream
->buf_size
;
1073 nsres
= nsIStreamListener_OnDataAvailable(This
->nslistener
,
1074 (nsIRequest
*)NSCHANNEL(This
->nschannel
), This
->nscontext
,
1075 NSINSTREAM(This
->nsstream
), This
->bsc
.readed
-This
->nsstream
->buf_size
,
1076 This
->nsstream
->buf_size
);
1077 if(NS_FAILED(nsres
))
1078 ERR("OnDataAvailable failed: %08x\n", nsres
);
1080 if(This
->nsstream
->buf_size
== sizeof(This
->nsstream
->buf
)) {
1081 ERR("buffer is full\n");
1084 }while(hres
== S_OK
);
1089 #define NSCHANNELBSC_THIS(bsc) ((nsChannelBSC*) bsc)
1091 static void nsChannelBSC_destroy(BSCallback
*bsc
)
1093 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1096 nsIChannel_Release(NSCHANNEL(This
->nschannel
));
1097 if(This
->nslistener
)
1098 nsIStreamListener_Release(This
->nslistener
);
1100 nsISupports_Release(This
->nscontext
);
1102 nsIInputStream_Release(NSINSTREAM(This
->nsstream
));
1106 static HRESULT
nsChannelBSC_start_binding(BSCallback
*bsc
)
1108 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1111 This
->window
->doc
->skip_mutation_notif
= FALSE
;
1116 static HRESULT
nsChannelBSC_init_bindinfo(BSCallback
*bsc
)
1118 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1121 if(This
->nschannel
&& This
->nschannel
->post_data_stream
) {
1122 if(This
->nschannel
->parse_stream
) {
1125 parse_post_data(This
->nschannel
->post_data_stream
, &headers
,
1126 &This
->bsc
.post_data
, &This
->bsc
.post_data_len
);
1128 hres
= parse_headers(headers
, &This
->nschannel
->request_headers
);
1133 hres
= read_post_data_stream(This
->nschannel
->post_data_stream
,
1134 &This
->bsc
.post_data
, &This
->bsc
.post_data_len
);
1139 TRACE("post_data = %s\n", debugstr_an(This
->bsc
.post_data
, This
->bsc
.post_data_len
));
1148 } stop_request_task_t
;
1150 static void stop_request_proc(task_t
*_task
)
1152 stop_request_task_t
*task
= (stop_request_task_t
*)_task
;
1154 TRACE("(%p)\n", task
->bsc
);
1156 on_stop_nsrequest(task
->bsc
, S_OK
);
1157 IBindStatusCallback_Release(STATUSCLB(&task
->bsc
->bsc
));
1160 static HRESULT
async_stop_request(nsChannelBSC
*This
)
1162 stop_request_task_t
*task
;
1164 task
= heap_alloc(sizeof(*task
));
1166 return E_OUTOFMEMORY
;
1168 IBindStatusCallback_AddRef(STATUSCLB(&This
->bsc
));
1170 push_task(&task
->header
, stop_request_proc
, This
->bsc
.doc
->basedoc
.doc_obj
->basedoc
.task_magic
);
1174 static HRESULT
nsChannelBSC_stop_binding(BSCallback
*bsc
, HRESULT result
)
1176 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1178 if(This
->window
&& SUCCEEDED(result
)) {
1179 result
= async_stop_request(This
);
1180 if(SUCCEEDED(result
))
1184 on_stop_nsrequest(This
, result
);
1188 static HRESULT
nsChannelBSC_read_data(BSCallback
*bsc
, IStream
*stream
)
1190 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1192 return read_stream_data(This
, stream
);
1195 static HRESULT
nsChannelBSC_on_progress(BSCallback
*bsc
, ULONG status_code
, LPCWSTR status_text
)
1197 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1199 switch(status_code
) {
1200 case BINDSTATUS_MIMETYPEAVAILABLE
:
1201 if(!This
->nschannel
)
1204 heap_free(This
->nschannel
->content_type
);
1205 This
->nschannel
->content_type
= heap_strdupWtoA(status_text
);
1207 case BINDSTATUS_REDIRECTING
:
1208 TRACE("redirect to %s\n", debugstr_w(status_text
));
1210 /* FIXME: We should find a better way to handle this */
1211 set_wine_url(This
->nschannel
->uri
, status_text
);
1217 static HRESULT
nsChannelBSC_on_response(BSCallback
*bsc
, DWORD response_code
,
1218 LPCWSTR response_headers
)
1220 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1223 This
->nschannel
->response_status
= response_code
;
1225 if(response_headers
) {
1226 const WCHAR
*headers
;
1228 headers
= strchrW(response_headers
, '\r');
1229 if(headers
&& headers
[1] == '\n') {
1231 hres
= parse_headers(headers
, &This
->nschannel
->response_headers
);
1233 WARN("parsing headers failed: %08x\n", hres
);
1242 static HRESULT
nsChannelBSC_beginning_transaction(BSCallback
*bsc
, WCHAR
**additional_headers
)
1244 nsChannelBSC
*This
= NSCHANNELBSC_THIS(bsc
);
1245 http_header_t
*iter
;
1249 static const WCHAR content_lengthW
[] =
1250 {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0};
1252 if(!This
->nschannel
)
1255 LIST_FOR_EACH_ENTRY(iter
, &This
->nschannel
->request_headers
, http_header_t
, entry
) {
1256 if(strcmpW(iter
->header
, content_lengthW
))
1257 len
+= strlenW(iter
->header
) + 2 /* ": " */ + strlenW(iter
->data
) + 2 /* "\r\n" */;
1263 *additional_headers
= ptr
= CoTaskMemAlloc((len
+1)*sizeof(WCHAR
));
1265 return E_OUTOFMEMORY
;
1267 LIST_FOR_EACH_ENTRY(iter
, &This
->nschannel
->request_headers
, http_header_t
, entry
) {
1268 if(!strcmpW(iter
->header
, content_lengthW
))
1271 len
= strlenW(iter
->header
);
1272 memcpy(ptr
, iter
->header
, len
*sizeof(WCHAR
));
1278 len
= strlenW(iter
->data
);
1279 memcpy(ptr
, iter
->data
, len
*sizeof(WCHAR
));
1291 #undef NSCHANNELBSC_THIS
1293 static const BSCallbackVtbl nsChannelBSCVtbl
= {
1294 nsChannelBSC_destroy
,
1295 nsChannelBSC_init_bindinfo
,
1296 nsChannelBSC_start_binding
,
1297 nsChannelBSC_stop_binding
,
1298 nsChannelBSC_read_data
,
1299 nsChannelBSC_on_progress
,
1300 nsChannelBSC_on_response
,
1301 nsChannelBSC_beginning_transaction
1304 HRESULT
create_channelbsc(IMoniker
*mon
, WCHAR
*headers
, BYTE
*post_data
, DWORD post_data_size
, nsChannelBSC
**retval
)
1308 ret
= heap_alloc_zero(sizeof(*ret
));
1310 return E_OUTOFMEMORY
;
1312 init_bscallback(&ret
->bsc
, &nsChannelBSCVtbl
, mon
, BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
);
1315 ret
->bsc
.headers
= heap_strdupW(headers
);
1316 if(!ret
->bsc
.headers
) {
1317 IBindStatusCallback_Release(STATUSCLB(&ret
->bsc
));
1318 return E_OUTOFMEMORY
;
1323 ret
->bsc
.post_data
= GlobalAlloc(0, post_data_size
);
1324 if(!ret
->bsc
.post_data
) {
1325 heap_free(ret
->bsc
.headers
);
1326 IBindStatusCallback_Release(STATUSCLB(&ret
->bsc
));
1327 return E_OUTOFMEMORY
;
1330 memcpy(ret
->bsc
.post_data
, post_data
, post_data_size
);
1331 ret
->bsc
.post_data_len
= post_data_size
;
1338 IMoniker
*get_channelbsc_mon(nsChannelBSC
*This
)
1341 IMoniker_AddRef(This
->bsc
.mon
);
1342 return This
->bsc
.mon
;
1345 void set_window_bscallback(HTMLWindow
*window
, nsChannelBSC
*callback
)
1347 if(window
->bscallback
) {
1348 if(window
->bscallback
->bsc
.binding
)
1349 IBinding_Abort(window
->bscallback
->bsc
.binding
);
1350 window
->bscallback
->bsc
.doc
= NULL
;
1351 window
->bscallback
->window
= NULL
;
1352 IBindStatusCallback_Release(STATUSCLB(&window
->bscallback
->bsc
));
1355 window
->bscallback
= callback
;
1358 callback
->window
= window
;
1359 IBindStatusCallback_AddRef(STATUSCLB(&callback
->bsc
));
1360 callback
->bsc
.doc
= window
->doc
;
1367 nsChannelBSC
*bscallback
;
1368 } start_doc_binding_task_t
;
1370 static void start_doc_binding_proc(task_t
*_task
)
1372 start_doc_binding_task_t
*task
= (start_doc_binding_task_t
*)_task
;
1374 start_binding(task
->window
, NULL
, (BSCallback
*)task
->bscallback
, NULL
);
1375 IBindStatusCallback_Release(STATUSCLB(&task
->bscallback
->bsc
));
1378 HRESULT
async_start_doc_binding(HTMLWindow
*window
, nsChannelBSC
*bscallback
)
1380 start_doc_binding_task_t
*task
;
1382 task
= heap_alloc(sizeof(start_doc_binding_task_t
));
1384 return E_OUTOFMEMORY
;
1386 task
->window
= window
;
1387 task
->bscallback
= bscallback
;
1388 IBindStatusCallback_AddRef(STATUSCLB(&bscallback
->bsc
));
1390 push_task(&task
->header
, start_doc_binding_proc
, window
->task_magic
);
1394 void abort_document_bindings(HTMLDocumentNode
*doc
)
1398 LIST_FOR_EACH_ENTRY(iter
, &doc
->bindings
, BSCallback
, entry
) {
1400 IBinding_Abort(iter
->binding
);
1402 list_remove(&iter
->entry
);
1406 HRESULT
channelbsc_load_stream(nsChannelBSC
*bscallback
, IStream
*stream
)
1408 HRESULT hres
= S_OK
;
1410 if(!bscallback
->nschannel
) {
1411 ERR("NULL nschannel\n");
1415 bscallback
->nschannel
->content_type
= heap_strdupA("text/html");
1416 if(!bscallback
->nschannel
->content_type
)
1417 return E_OUTOFMEMORY
;
1420 hres
= read_stream_data(bscallback
, stream
);
1422 hres
= async_stop_request(bscallback
);
1424 IBindStatusCallback_OnStopBinding(STATUSCLB(&bscallback
->bsc
), hres
, ERROR_SUCCESS
);
1429 void channelbsc_set_channel(nsChannelBSC
*This
, nsChannel
*channel
, nsIStreamListener
*listener
, nsISupports
*context
)
1431 nsIChannel_AddRef(NSCHANNEL(channel
));
1432 This
->nschannel
= channel
;
1434 nsIStreamListener_AddRef(listener
);
1435 This
->nslistener
= listener
;
1438 nsISupports_AddRef(context
);
1439 This
->nscontext
= context
;
1442 if(This
->bsc
.headers
) {
1445 hres
= parse_headers(This
->bsc
.headers
, &channel
->request_headers
);
1446 heap_free(This
->bsc
.headers
);
1447 This
->bsc
.headers
= NULL
;
1449 WARN("parse_headers failed: %08x\n", hres
);
1453 HRESULT
hlink_frame_navigate(HTMLDocument
*doc
, LPCWSTR url
,
1454 nsIInputStream
*post_data_stream
, DWORD hlnf
, BOOL
*cancel
)
1456 IHlinkFrame
*hlink_frame
;
1457 nsChannelBSC
*callback
;
1458 IServiceProvider
*sp
;
1466 hres
= IOleClientSite_QueryInterface(doc
->doc_obj
->client
, &IID_IServiceProvider
,
1471 hres
= IServiceProvider_QueryService(sp
, &IID_IHlinkFrame
, &IID_IHlinkFrame
,
1472 (void**)&hlink_frame
);
1473 IServiceProvider_Release(sp
);
1477 hres
= create_channelbsc(NULL
, NULL
, NULL
, 0, &callback
);
1479 IHlinkFrame_Release(hlink_frame
);
1483 if(post_data_stream
) {
1484 parse_post_data(post_data_stream
, &callback
->bsc
.headers
, &callback
->bsc
.post_data
,
1485 &callback
->bsc
.post_data_len
);
1486 TRACE("headers = %s post_data = %s\n", debugstr_w(callback
->bsc
.headers
),
1487 debugstr_an(callback
->bsc
.post_data
, callback
->bsc
.post_data_len
));
1490 hres
= CreateAsyncBindCtx(0, STATUSCLB(&callback
->bsc
), NULL
, &bindctx
);
1492 hres
= CoCreateInstance(&CLSID_StdHlink
, NULL
, CLSCTX_INPROC_SERVER
,
1493 &IID_IHlink
, (LPVOID
*)&hlink
);
1496 hres
= CreateURLMoniker(NULL
, url
, &mon
);
1498 if(SUCCEEDED(hres
)) {
1499 IHlink_SetMonikerReference(hlink
, HLINKSETF_TARGET
, mon
, NULL
);
1501 if(hlnf
& HLNF_OPENINNEWWINDOW
) {
1502 static const WCHAR wszBlank
[] = {'_','b','l','a','n','k',0};
1503 IHlink_SetTargetFrameName(hlink
, wszBlank
); /* FIXME */
1506 hres
= IHlinkFrame_Navigate(hlink_frame
, hlnf
, bindctx
, STATUSCLB(&callback
->bsc
), hlink
);
1507 IMoniker_Release(mon
);
1508 *cancel
= hres
== S_OK
;
1512 IHlinkFrame_Release(hlink_frame
);
1513 IBindCtx_Release(bindctx
);
1514 IBindStatusCallback_Release(STATUSCLB(&callback
->bsc
));
1518 HRESULT
navigate_url(HTMLWindow
*window
, const WCHAR
*new_url
, const WCHAR
*base_url
)
1520 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
1526 }else if(base_url
) {
1529 hres
= CoInternetCombineUrl(base_url
, new_url
, URL_ESCAPE_SPACES_ONLY
|URL_DONT_ESCAPE_EXTRA_INFO
,
1530 url
, sizeof(url
)/sizeof(WCHAR
), &len
, 0);
1534 strcpyW(url
, new_url
);
1537 if(window
->doc_obj
&& window
->doc_obj
->hostui
) {
1538 OLECHAR
*translated_url
= NULL
;
1540 hres
= IDocHostUIHandler_TranslateUrl(window
->doc_obj
->hostui
, 0, url
,
1543 TRACE("%08x %s -> %s\n", hres
, debugstr_w(url
), debugstr_w(translated_url
));
1544 strcpyW(url
, translated_url
);
1545 CoTaskMemFree(translated_url
);
1549 if(window
->doc_obj
&& window
== window
->doc_obj
->basedoc
.window
) {
1552 hres
= hlink_frame_navigate(&window
->doc
->basedoc
, url
, NULL
, 0, &cancel
);
1557 TRACE("Navigation handled by hlink frame\n");
1562 hres
= create_doc_uri(window
, url
, &uri
);
1566 hres
= load_nsuri(window
, uri
, NULL
, LOAD_FLAGS_NONE
);
1567 nsISupports_Release((nsISupports
*)uri
);