2006-02-13 13:26:00 +01:00
|
|
|
/*
|
2010-08-03 21:40:56 +02:00
|
|
|
* Copyright 2006-2010 Jacek Caban for CodeWeavers
|
2006-02-13 13:26:00 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-13 13:26:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2009-11-30 18:00:38 +01:00
|
|
|
#include "winreg.h"
|
2006-02-13 13:26:00 +01:00
|
|
|
#include "ole2.h"
|
2007-06-12 11:26:50 +02:00
|
|
|
#include "hlguids.h"
|
2007-11-05 21:45:07 +01:00
|
|
|
#include "shlguid.h"
|
2009-11-30 18:00:38 +01:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "shlwapi.h"
|
2012-01-09 17:56:54 +01:00
|
|
|
#include "htiface.h"
|
|
|
|
#include "shdeprecated.h"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2012-10-16 17:07:29 +02:00
|
|
|
#include "htmlscript.h"
|
2011-07-23 12:50:11 +02:00
|
|
|
#include "binding.h"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
#define CONTENT_LENGTH "Content-Length"
|
2012-03-09 10:51:48 +01:00
|
|
|
#define UTF8_STR "utf-8"
|
2007-04-12 21:25:08 +02:00
|
|
|
#define UTF16_STR "utf-16"
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2011-07-23 12:50:11 +02:00
|
|
|
struct nsProtocolStream {
|
2011-01-05 00:41:05 +01:00
|
|
|
nsIInputStream nsIInputStream_iface;
|
2008-03-23 02:16:18 +01:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
DWORD buf_size;
|
2011-07-23 12:50:11 +02:00
|
|
|
};
|
2008-03-23 02:16:18 +01:00
|
|
|
|
2011-01-05 00:41:05 +01:00
|
|
|
static inline nsProtocolStream *impl_from_nsIInputStream(nsIInputStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsProtocolStream, nsIInputStream_iface);
|
|
|
|
}
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_QueryInterface(nsIInputStream *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2011-01-05 00:41:05 +01:00
|
|
|
*result = &This->nsIInputStream_iface;
|
2006-06-03 01:26:00 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIInputStream, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIInputStream %p)\n", This, result);
|
2011-01-05 00:41:05 +01:00
|
|
|
*result = &This->nsIInputStream_iface;
|
2006-06-03 01:26:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*result) {
|
2011-01-05 00:41:05 +01:00
|
|
|
nsIInputStream_AddRef(&This->nsIInputStream_iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInputStream_AddRef(nsIInputStream *iface)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInputStream_Release(nsIInputStream *iface)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
if(!ref)
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_Close(nsIInputStream *iface)
|
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:56 +01:00
|
|
|
static nsresult NSAPI nsInputStream_Available(nsIInputStream *iface, UINT64 *_retval)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
static nsresult NSAPI nsInputStream_Read(nsIInputStream *iface, char *aBuf, UINT32 aCount,
|
|
|
|
UINT32 *_retval)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2009-05-11 23:08:24 +02:00
|
|
|
DWORD read = aCount;
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %d %p)\n", This, aBuf, aCount, _retval);
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2009-05-11 23:08:24 +02:00
|
|
|
if(read > This->buf_size)
|
|
|
|
read = This->buf_size;
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2009-05-11 23:08:24 +02:00
|
|
|
if(read) {
|
|
|
|
memcpy(aBuf, This->buf, read);
|
|
|
|
if(read < This->buf_size)
|
|
|
|
memmove(This->buf, This->buf+read, This->buf_size-read);
|
|
|
|
This->buf_size -= read;
|
|
|
|
}
|
2006-08-03 21:38:08 +02:00
|
|
|
|
2009-05-11 23:08:24 +02:00
|
|
|
*_retval = read;
|
2006-08-03 21:38:08 +02:00
|
|
|
return NS_OK;
|
2006-06-03 01:26:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInputStream_ReadSegments(nsIInputStream *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
nsresult (WINAPI *aWriter)(nsIInputStream*,void*,const char*,UINT32,UINT32,UINT32*),
|
|
|
|
void *aClousure, UINT32 aCount, UINT32 *_retval)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 written = 0;
|
2006-06-03 01:26:00 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%p %p %d %p)\n", This, aWriter, aClousure, aCount, _retval);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
if(!This->buf_size)
|
|
|
|
return S_OK;
|
|
|
|
|
2008-12-18 14:08:47 +01:00
|
|
|
if(aCount > This->buf_size)
|
|
|
|
aCount = This->buf_size;
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2011-01-05 00:41:05 +01:00
|
|
|
nsres = aWriter(&This->nsIInputStream_iface, aClousure, This->buf, 0, aCount, &written);
|
2006-06-03 01:26:00 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2013-10-29 15:57:31 +01:00
|
|
|
TRACE("aWriter failed: %08x\n", nsres);
|
2007-03-07 00:05:52 +01:00
|
|
|
else if(written != This->buf_size)
|
|
|
|
FIXME("written %d != buf_size %d\n", written, This->buf_size);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
|
|
|
This->buf_size -= written;
|
|
|
|
|
2007-03-07 00:05:52 +01:00
|
|
|
*_retval = written;
|
2006-06-03 01:26:00 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:55:01 +01:00
|
|
|
static nsresult NSAPI nsInputStream_IsNonBlocking(nsIInputStream *iface, cpp_bool *_retval)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2011-01-05 00:41:05 +01:00
|
|
|
nsProtocolStream *This = impl_from_nsIInputStream(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIInputStreamVtbl nsInputStreamVtbl = {
|
|
|
|
nsInputStream_QueryInterface,
|
|
|
|
nsInputStream_AddRef,
|
|
|
|
nsInputStream_Release,
|
|
|
|
nsInputStream_Close,
|
|
|
|
nsInputStream_Available,
|
|
|
|
nsInputStream_Read,
|
|
|
|
nsInputStream_ReadSegments,
|
|
|
|
nsInputStream_IsNonBlocking
|
|
|
|
};
|
|
|
|
|
2007-05-11 13:13:16 +02:00
|
|
|
static nsProtocolStream *create_nsprotocol_stream(void)
|
2006-06-03 01:26:00 +02:00
|
|
|
{
|
2012-10-19 11:58:15 +02:00
|
|
|
nsProtocolStream *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(nsProtocolStream));
|
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2011-01-05 00:41:05 +01:00
|
|
|
ret->nsIInputStream_iface.lpVtbl = &nsInputStreamVtbl;
|
2006-06-03 01:26:00 +02:00
|
|
|
ret->ref = 1;
|
|
|
|
ret->buf_size = 0;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
static void release_request_data(request_data_t *request_data)
|
|
|
|
{
|
2015-02-02 13:43:49 +01:00
|
|
|
if(request_data->post_stream)
|
|
|
|
nsIInputStream_Release(request_data->post_stream);
|
2013-09-26 17:34:49 +02:00
|
|
|
heap_free(request_data->headers);
|
|
|
|
if(request_data->post_data)
|
|
|
|
GlobalFree(request_data->post_data);
|
|
|
|
}
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
static inline BSCallback *impl_from_IBindStatusCallback(IBindStatusCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IBindStatusCallback_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_QueryInterface(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IBindStatusCallback_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindStatusCallback, %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IBindStatusCallback_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
|
2010-12-27 01:43:10 +01:00
|
|
|
*ppv = &This->IServiceProvider_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IHttpNegotiate2_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHttpNegotiate2 %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IHttpNegotiate2_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv);
|
2011-01-03 01:13:16 +01:00
|
|
|
*ppv = &This->IInternetBindInfo_iface;
|
2017-06-07 16:10:49 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IBindCallbackRedirect, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IBindCallbackRedirect %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IBindCallbackRedirect_iface;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Unsupported riid = %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindStatusCallback_AddRef(IBindStatusCallback *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref = %d\n", This, ref);
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref = %d\n", This, ref);
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
if(!ref) {
|
2013-09-26 17:34:49 +02:00
|
|
|
release_request_data(&This->request_data);
|
2006-08-09 16:37:48 +02:00
|
|
|
if(This->mon)
|
|
|
|
IMoniker_Release(This->mon);
|
2006-09-24 23:12:23 +02:00
|
|
|
if(This->binding)
|
|
|
|
IBinding_Release(This->binding);
|
2007-11-05 21:45:07 +01:00
|
|
|
list_remove(&This->entry);
|
2011-01-31 20:28:10 +01:00
|
|
|
list_init(&This->entry);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
This->vtbl->destroy(This);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnStartBinding(IBindStatusCallback *iface,
|
|
|
|
DWORD dwReserved, IBinding *pbind)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-09-24 23:12:23 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, dwReserved, pbind);
|
2006-09-24 23:12:23 +02:00
|
|
|
|
|
|
|
IBinding_AddRef(pbind);
|
|
|
|
This->binding = pbind;
|
|
|
|
|
2012-07-11 13:51:00 +02:00
|
|
|
if(This->window)
|
|
|
|
list_add_head(&This->window->bindings, &This->entry);
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return This->vtbl->start_binding(This);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, pnPriority);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%d)\n", This, reserved);
|
2006-02-13 13:26:00 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress,
|
|
|
|
ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-06-03 00:48:13 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("%p)->(%u %u %u %s)\n", This, ulProgress, ulProgressMax, ulStatusCode,
|
2006-02-13 13:26:00 +01:00
|
|
|
debugstr_w(szStatusText));
|
2006-06-03 00:48:13 +02:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return This->vtbl->on_progress(This, ulStatusCode, szStatusText);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnStopBinding(IBindStatusCallback *iface,
|
|
|
|
HRESULT hresult, LPCWSTR szError)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2009-08-10 19:17:05 +02:00
|
|
|
HRESULT hres;
|
2006-06-25 14:13:11 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));
|
2006-06-25 14:13:11 +02:00
|
|
|
|
2008-09-17 03:24:25 +02:00
|
|
|
/* NOTE: IE7 calls GetBindResult here */
|
|
|
|
|
2009-08-10 19:17:05 +02:00
|
|
|
hres = This->vtbl->stop_binding(This, hresult);
|
|
|
|
|
2007-05-11 13:14:14 +02:00
|
|
|
if(This->binding) {
|
|
|
|
IBinding_Release(This->binding);
|
|
|
|
This->binding = NULL;
|
|
|
|
}
|
2006-09-24 23:12:23 +02:00
|
|
|
|
2013-09-19 16:12:42 +02:00
|
|
|
if(This->mon) {
|
|
|
|
IMoniker_Release(This->mon);
|
|
|
|
This->mon = NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-05 21:45:07 +01:00
|
|
|
list_remove(&This->entry);
|
2011-01-31 20:28:10 +01:00
|
|
|
list_init(&This->entry);
|
2012-07-11 13:51:00 +02:00
|
|
|
This->window = NULL;
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2009-08-10 19:17:05 +02:00
|
|
|
return hres;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_GetBindInfo(IBindStatusCallback *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
|
2009-08-19 20:40:00 +02:00
|
|
|
if(!This->bindinfo_ready) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = This->vtbl->init_bindinfo(This);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
This->bindinfo_ready = TRUE;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
*grfBINDF = This->bindf;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
size = pbindinfo->cbSize;
|
|
|
|
memset(pbindinfo, 0, size);
|
|
|
|
pbindinfo->cbSize = size;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
pbindinfo->cbstgmedData = This->request_data.post_data_len;
|
2006-02-13 13:26:00 +01:00
|
|
|
pbindinfo->dwCodePage = CP_UTF8;
|
2017-06-07 16:10:51 +02:00
|
|
|
pbindinfo->dwOptions = This->bindinfo_options;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
if(This->request_data.post_data_len) {
|
2006-02-13 13:26:00 +01:00
|
|
|
pbindinfo->dwBindVerb = BINDVERB_POST;
|
|
|
|
|
|
|
|
pbindinfo->stgmedData.tymed = TYMED_HGLOBAL;
|
2013-09-26 17:34:49 +02:00
|
|
|
pbindinfo->stgmedData.u.hGlobal = This->request_data.post_data;
|
2011-01-03 01:13:16 +01:00
|
|
|
pbindinfo->stgmedData.pUnkForRelease = (IUnknown*)&This->IBindStatusCallback_iface;
|
|
|
|
IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnDataAvailable(IBindStatusCallback *iface,
|
|
|
|
DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
|
2006-06-03 01:26:00 +02:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return This->vtbl->read_data(This, pstgmed->u.pstm);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface,
|
|
|
|
REFIID riid, IUnknown *punk)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IBindStatusCallback(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), punk);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindStatusCallbackVtbl BindStatusCallbackVtbl = {
|
|
|
|
BindStatusCallback_QueryInterface,
|
|
|
|
BindStatusCallback_AddRef,
|
|
|
|
BindStatusCallback_Release,
|
|
|
|
BindStatusCallback_OnStartBinding,
|
|
|
|
BindStatusCallback_GetPriority,
|
|
|
|
BindStatusCallback_OnLowResource,
|
|
|
|
BindStatusCallback_OnProgress,
|
|
|
|
BindStatusCallback_OnStopBinding,
|
|
|
|
BindStatusCallback_GetBindInfo,
|
|
|
|
BindStatusCallback_OnDataAvailable,
|
|
|
|
BindStatusCallback_OnObjectAvailable
|
|
|
|
};
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
static inline BSCallback *impl_from_IHttpNegotiate2(IHttpNegotiate2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IHttpNegotiate2_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface,
|
|
|
|
LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
2010-08-03 21:39:04 +02:00
|
|
|
HRESULT hres;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(szURL), debugstr_w(szHeaders),
|
2006-02-13 13:26:00 +01:00
|
|
|
dwReserved, pszAdditionalHeaders);
|
|
|
|
|
2010-08-03 21:39:04 +02:00
|
|
|
*pszAdditionalHeaders = NULL;
|
|
|
|
|
|
|
|
hres = This->vtbl->beginning_transaction(This, pszAdditionalHeaders);
|
|
|
|
if(hres != S_FALSE)
|
|
|
|
return hres;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
if(This->request_data.headers) {
|
2010-08-03 21:39:04 +02:00
|
|
|
DWORD size;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
size = (lstrlenW(This->request_data.headers)+1)*sizeof(WCHAR);
|
2010-08-03 21:39:04 +02:00
|
|
|
*pszAdditionalHeaders = CoTaskMemAlloc(size);
|
|
|
|
if(!*pszAdditionalHeaders)
|
|
|
|
return E_OUTOFMEMORY;
|
2013-09-26 17:34:49 +02:00
|
|
|
memcpy(*pszAdditionalHeaders, This->request_data.headers, size);
|
2010-08-03 21:39:04 +02:00
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
|
|
|
|
LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
2009-08-11 19:15:07 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %s %p)\n", This, dwResponseCode, debugstr_w(szResponseHeaders),
|
2006-02-13 13:26:00 +01:00
|
|
|
debugstr_w(szRequestHeaders), pszAdditionalRequestHeaders);
|
2009-08-11 19:15:07 +02:00
|
|
|
|
2010-04-03 00:31:45 +02:00
|
|
|
return This->vtbl->on_response(This, dwResponseCode, szResponseHeaders);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
|
|
|
|
BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IHttpNegotiate2(iface);
|
2016-12-01 15:17:28 +01:00
|
|
|
TRACE("(%p)->(%p %p %ld)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
|
|
|
|
return E_NOTIMPL; /* FIXME */
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHttpNegotiate2Vtbl HttpNegotiate2Vtbl = {
|
|
|
|
HttpNegotiate_QueryInterface,
|
|
|
|
HttpNegotiate_AddRef,
|
|
|
|
HttpNegotiate_Release,
|
|
|
|
HttpNegotiate_BeginningTransaction,
|
|
|
|
HttpNegotiate_OnResponse,
|
|
|
|
HttpNegotiate_GetRootSecurityId
|
|
|
|
};
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
static inline BSCallback *impl_from_IInternetBindInfo(IInternetBindInfo *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IInternetBindInfo_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_QueryInterface(IInternetBindInfo *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_AddRef(IInternetBindInfo *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI InternetBindInfo_Release(IInternetBindInfo *iface)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindInfo(IInternetBindInfo *iface,
|
|
|
|
DWORD *grfBINDF, BINDINFO *pbindinfo)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", This, grfBINDF, pbindinfo);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI InternetBindInfo_GetBindString(IInternetBindInfo *iface,
|
|
|
|
ULONG ulStringType, LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
|
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
BSCallback *This = impl_from_IInternetBindInfo(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("(%p)->(%u %p %u %p)\n", This, ulStringType, ppwzStr, cEl, pcElFetched);
|
2006-02-13 13:26:00 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IInternetBindInfoVtbl InternetBindInfoVtbl = {
|
|
|
|
InternetBindInfo_QueryInterface,
|
|
|
|
InternetBindInfo_AddRef,
|
|
|
|
InternetBindInfo_Release,
|
|
|
|
InternetBindInfo_GetBindInfo,
|
|
|
|
InternetBindInfo_GetBindString
|
|
|
|
};
|
|
|
|
|
2017-06-07 16:10:49 +02:00
|
|
|
static inline BSCallback *impl_from_IBindCallbackRedirect(IBindCallbackRedirect *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IBindCallbackRedirect_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindCallbackRedirect_QueryInterface(IBindCallbackRedirect *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
BSCallback *This = impl_from_IBindCallbackRedirect(iface);
|
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindCallbackRedirect_AddRef(IBindCallbackRedirect *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = impl_from_IBindCallbackRedirect(iface);
|
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BindCallbackRedirect_Release(IBindCallbackRedirect *iface)
|
|
|
|
{
|
|
|
|
BSCallback *This = impl_from_IBindCallbackRedirect(iface);
|
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BindCallbackRedirect_Redirect(IBindCallbackRedirect *iface, const WCHAR *url, VARIANT_BOOL *vbCancel)
|
|
|
|
{
|
|
|
|
BSCallback *This = impl_from_IBindCallbackRedirect(iface);
|
2019-03-14 14:13:36 +01:00
|
|
|
GeckoBrowser *browser;
|
2017-06-07 16:10:49 +02:00
|
|
|
BOOL cancel = FALSE;
|
|
|
|
BSTR frame_name = NULL;
|
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(url), vbCancel);
|
|
|
|
|
2019-03-14 14:13:36 +01:00
|
|
|
if(This->window && This->window->base.outer_window && (browser = This->window->base.outer_window->browser)
|
|
|
|
&& browser->doc->doc_object_service) {
|
|
|
|
if(is_main_content_window(This->window->base.outer_window)) {
|
2017-06-07 16:10:49 +02:00
|
|
|
hres = IHTMLWindow2_get_name(&This->window->base.IHTMLWindow2_iface, &frame_name);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:13:36 +01:00
|
|
|
hres = IDocObjectService_FireBeforeNavigate2(browser->doc->doc_object_service, NULL, url, 0x40,
|
2017-06-07 16:10:49 +02:00
|
|
|
frame_name, NULL, 0, NULL, TRUE, &cancel);
|
|
|
|
SysFreeString(frame_name);
|
|
|
|
}
|
|
|
|
|
2017-11-02 16:48:02 +01:00
|
|
|
*vbCancel = variant_bool(cancel);
|
2017-06-07 16:10:49 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBindCallbackRedirectVtbl BindCallbackRedirectVtbl = {
|
|
|
|
BindCallbackRedirect_QueryInterface,
|
|
|
|
BindCallbackRedirect_AddRef,
|
|
|
|
BindCallbackRedirect_Release,
|
|
|
|
BindCallbackRedirect_Redirect
|
|
|
|
};
|
|
|
|
|
2010-12-27 01:43:10 +01:00
|
|
|
static inline BSCallback *impl_from_IServiceProvider(IServiceProvider *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, BSCallback, IServiceProvider_iface);
|
|
|
|
}
|
2006-02-13 13:26:00 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryInterface(IServiceProvider *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2011-01-03 01:13:16 +01:00
|
|
|
return IBindStatusCallback_QueryInterface(&This->IBindStatusCallback_iface, riid, ppv);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_AddRef(IServiceProvider *iface)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2011-01-03 01:13:16 +01:00
|
|
|
return IBindStatusCallback_AddRef(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI BSCServiceProvider_Release(IServiceProvider *iface)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2011-01-03 01:13:16 +01:00
|
|
|
return IBindStatusCallback_Release(&This->IBindStatusCallback_iface);
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface,
|
|
|
|
REFGUID guidService, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 01:43:10 +01:00
|
|
|
BSCallback *This = impl_from_IServiceProvider(iface);
|
2012-05-30 15:49:28 +02:00
|
|
|
|
2007-11-20 01:51:41 +01:00
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
|
2012-05-30 15:49:28 +02:00
|
|
|
|
2012-07-11 13:51:00 +02:00
|
|
|
if(This->window && IsEqualGUID(guidService, &IID_IWindowForBindingUI))
|
|
|
|
return IServiceProvider_QueryService(&This->window->base.IServiceProvider_iface, guidService, riid, ppv);
|
2007-11-20 01:51:41 +01:00
|
|
|
return E_NOINTERFACE;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IServiceProviderVtbl ServiceProviderVtbl = {
|
|
|
|
BSCServiceProvider_QueryInterface,
|
|
|
|
BSCServiceProvider_AddRef,
|
|
|
|
BSCServiceProvider_Release,
|
|
|
|
BSCServiceProvider_QueryService
|
|
|
|
};
|
|
|
|
|
2014-10-09 16:08:01 +02:00
|
|
|
void init_bscallback(BSCallback *This, const BSCallbackVtbl *vtbl, IMoniker *mon, DWORD bindf)
|
2006-02-13 13:26:00 +01:00
|
|
|
{
|
2011-01-03 01:13:16 +01:00
|
|
|
This->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl;
|
2010-12-27 01:43:10 +01:00
|
|
|
This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
|
2011-01-03 01:13:16 +01:00
|
|
|
This->IHttpNegotiate2_iface.lpVtbl = &HttpNegotiate2Vtbl;
|
|
|
|
This->IInternetBindInfo_iface.lpVtbl = &InternetBindInfoVtbl;
|
2017-06-07 16:10:49 +02:00
|
|
|
This->IBindCallbackRedirect_iface.lpVtbl = &BindCallbackRedirectVtbl;
|
2008-03-23 02:17:17 +01:00
|
|
|
This->vtbl = vtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
This->bindf = bindf;
|
2017-06-07 16:10:51 +02:00
|
|
|
This->bindinfo_options = BINDINFO_OPTIONS_USE_IE_ENCODING;
|
2012-07-27 10:51:39 +02:00
|
|
|
This->bom = BOM_NONE;
|
2006-02-13 13:26:00 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
list_init(&This->entry);
|
2007-11-05 21:45:07 +01:00
|
|
|
|
2006-08-09 16:37:48 +02:00
|
|
|
if(mon)
|
|
|
|
IMoniker_AddRef(mon);
|
2008-03-23 02:17:17 +01:00
|
|
|
This->mon = mon;
|
2006-02-13 13:26:00 +01:00
|
|
|
}
|
|
|
|
|
2014-10-09 16:08:01 +02:00
|
|
|
HRESULT read_stream(BSCallback *This, IStream *stream, void *buf, DWORD size, DWORD *ret_size)
|
2012-07-27 10:51:11 +02:00
|
|
|
{
|
2012-07-27 10:51:39 +02:00
|
|
|
DWORD read_size = 0, skip=0;
|
|
|
|
BYTE *data = buf;
|
2012-07-27 10:51:11 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IStream_Read(stream, buf, size, &read_size);
|
2012-07-27 10:51:39 +02:00
|
|
|
|
2019-10-21 06:22:36 +02:00
|
|
|
if(!This->read && This->bom == BOM_NONE) {
|
2012-07-27 10:51:39 +02:00
|
|
|
if(read_size >= 2 && data[0] == 0xff && data[1] == 0xfe) {
|
|
|
|
This->bom = BOM_UTF16;
|
|
|
|
skip = 2;
|
|
|
|
}else if(read_size >= 3 && data[0] == 0xef && data[1] == 0xbb && data[2] == 0xbf) {
|
|
|
|
This->bom = BOM_UTF8;
|
|
|
|
skip = 3;
|
|
|
|
}
|
|
|
|
if(skip) {
|
|
|
|
read_size -= skip;
|
|
|
|
if(read_size)
|
|
|
|
memmove(data, data+skip, read_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-21 06:22:36 +02:00
|
|
|
This->read += read_size;
|
2012-07-27 10:51:39 +02:00
|
|
|
*ret_size = read_size;
|
2012-07-27 10:51:11 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:19:05 +01:00
|
|
|
static void parse_content_type(nsChannelBSC *This, const WCHAR *value)
|
|
|
|
{
|
|
|
|
const WCHAR *ptr;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
static const WCHAR charsetW[] = {'c','h','a','r','s','e','t','='};
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(value, ';');
|
2011-11-23 16:19:05 +01:00
|
|
|
if(!ptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ptr++;
|
2019-06-13 08:34:29 +02:00
|
|
|
while(*ptr && iswspace(*ptr))
|
2011-11-23 16:19:05 +01:00
|
|
|
ptr++;
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
len = lstrlenW(value);
|
|
|
|
if(ptr + ARRAY_SIZE(charsetW) < value+len && !wcsnicmp(ptr, charsetW, ARRAY_SIZE(charsetW))) {
|
2011-11-23 16:19:05 +01:00
|
|
|
size_t charset_len, lena;
|
|
|
|
nsACString charset_str;
|
|
|
|
const WCHAR *charset;
|
|
|
|
char *charseta;
|
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
ptr += ARRAY_SIZE(charsetW);
|
2011-11-23 16:19:05 +01:00
|
|
|
|
|
|
|
if(*ptr == '\'') {
|
|
|
|
FIXME("Quoted value\n");
|
|
|
|
return;
|
|
|
|
}else {
|
|
|
|
charset = ptr;
|
|
|
|
while(*ptr && *ptr != ',')
|
|
|
|
ptr++;
|
|
|
|
charset_len = ptr-charset;
|
|
|
|
}
|
|
|
|
|
|
|
|
lena = WideCharToMultiByte(CP_ACP, 0, charset, charset_len, NULL, 0, NULL, NULL);
|
|
|
|
charseta = heap_alloc(lena+1);
|
|
|
|
if(!charseta)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, charset, charset_len, charseta, lena, NULL, NULL);
|
|
|
|
charseta[lena] = 0;
|
|
|
|
|
|
|
|
nsACString_InitDepend(&charset_str, charseta);
|
|
|
|
nsIHttpChannel_SetContentCharset(&This->nschannel->nsIHttpChannel_iface, &charset_str);
|
|
|
|
nsACString_Finish(&charset_str);
|
|
|
|
heap_free(charseta);
|
|
|
|
}else {
|
|
|
|
FIXME("unhandled: %s\n", debugstr_wn(ptr, len - (ptr-value)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:38:53 +02:00
|
|
|
static HRESULT parse_headers(const WCHAR *headers, struct list *headers_list)
|
|
|
|
{
|
|
|
|
const WCHAR *header, *header_end, *colon, *value;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
header = headers;
|
|
|
|
while(*header) {
|
|
|
|
if(header[0] == '\r' && header[1] == '\n' && !header[2])
|
|
|
|
break;
|
|
|
|
for(colon = header; *colon && *colon != ':' && *colon != '\r'; colon++);
|
|
|
|
if(*colon != ':')
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
value = colon+1;
|
|
|
|
while(*value == ' ')
|
|
|
|
value++;
|
|
|
|
if(!*value)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
for(header_end = value+1; *header_end && *header_end != '\r'; header_end++);
|
|
|
|
|
|
|
|
hres = set_http_header(headers_list, header, colon-header, value, header_end-value);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
header = header_end;
|
|
|
|
if(header[0] == '\r' && header[1] == '\n')
|
|
|
|
header += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-23 16:19:05 +01:00
|
|
|
static HRESULT process_response_headers(nsChannelBSC *This, const WCHAR *headers)
|
|
|
|
{
|
|
|
|
http_header_t *iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = parse_headers(headers, &This->nschannel->response_headers);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->nschannel->response_headers, http_header_t, entry) {
|
2020-11-24 23:29:19 +01:00
|
|
|
if(!wcsicmp(iter->header, L"content-type"))
|
2011-11-23 16:19:05 +01:00
|
|
|
parse_content_type(This, iter->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-13 12:29:30 +02:00
|
|
|
static void query_http_info(nsChannelBSC *This, IWinInetHttpInfo *wininet_info)
|
|
|
|
{
|
|
|
|
const WCHAR *ptr;
|
|
|
|
DWORD len = 0;
|
|
|
|
WCHAR *buf;
|
|
|
|
|
|
|
|
IWinInetHttpInfo_QueryInfo(wininet_info, HTTP_QUERY_RAW_HEADERS_CRLF, NULL, &len, NULL, NULL);
|
|
|
|
if(!len)
|
|
|
|
return;
|
|
|
|
|
|
|
|
buf = heap_alloc(len);
|
|
|
|
if(!buf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IWinInetHttpInfo_QueryInfo(wininet_info, HTTP_QUERY_RAW_HEADERS_CRLF, buf, &len, NULL, NULL);
|
2012-09-16 15:22:29 +02:00
|
|
|
if(!len) {
|
|
|
|
heap_free(buf);
|
2012-09-13 12:29:30 +02:00
|
|
|
return;
|
2012-09-16 15:22:29 +02:00
|
|
|
}
|
2012-09-13 12:29:30 +02:00
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(buf, '\r');
|
2012-09-13 12:29:30 +02:00
|
|
|
if(ptr && ptr[1] == '\n') {
|
|
|
|
ptr += 2;
|
|
|
|
process_response_headers(This, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(buf);
|
|
|
|
}
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
HRESULT start_binding(HTMLInnerWindow *inner_window, BSCallback *bscallback, IBindCtx *bctx)
|
2006-06-03 00:41:48 +02:00
|
|
|
{
|
|
|
|
IStream *str = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
TRACE("(%p %p %p)\n", inner_window, bscallback, bctx);
|
2011-06-16 16:42:12 +02:00
|
|
|
|
2012-07-11 13:51:00 +02:00
|
|
|
bscallback->window = inner_window;
|
2008-09-17 03:24:25 +02:00
|
|
|
|
|
|
|
/* NOTE: IE7 calls IsSystemMoniker here*/
|
|
|
|
|
2007-12-24 12:48:43 +01:00
|
|
|
if(bctx) {
|
2012-11-27 12:16:34 +01:00
|
|
|
hres = RegisterBindStatusCallback(bctx, &bscallback->IBindStatusCallback_iface, NULL, 0);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
IBindCtx_AddRef(bctx);
|
2007-12-24 12:48:43 +01:00
|
|
|
}else {
|
2011-01-03 01:13:16 +01:00
|
|
|
hres = CreateAsyncBindCtx(0, &bscallback->IBindStatusCallback_iface, NULL, &bctx);
|
2012-11-27 12:16:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
2014-10-29 18:00:49 +01:00
|
|
|
bscallback->window = NULL;
|
2012-11-27 12:16:34 +01:00
|
|
|
return hres;
|
2006-06-03 00:41:48 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 16:37:48 +02:00
|
|
|
hres = IMoniker_BindToStorage(bscallback->mon, bctx, NULL, &IID_IStream, (void**)&str);
|
2006-06-03 00:41:48 +02:00
|
|
|
IBindCtx_Release(bctx);
|
|
|
|
if(FAILED(hres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("BindToStorage failed: %08x\n", hres);
|
2014-10-29 18:00:49 +01:00
|
|
|
bscallback->window = NULL;
|
2006-06-03 00:41:48 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(str)
|
|
|
|
IStream_Release(str);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-09-24 23:39:55 +02:00
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
static HRESULT read_post_data_stream(nsIInputStream *stream, BOOL contains_headers, struct list *headers_list,
|
|
|
|
request_data_t *request_data)
|
2011-04-05 15:23:25 +02:00
|
|
|
{
|
2015-02-02 13:43:49 +01:00
|
|
|
nsISeekableStream *seekable_stream;
|
2013-01-23 18:44:56 +01:00
|
|
|
UINT64 available = 0;
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 data_len = 0;
|
2011-04-05 15:23:25 +02:00
|
|
|
char *data, *post_data;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
if(!stream)
|
2011-04-05 15:23:25 +02:00
|
|
|
return S_OK;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
nsres = nsIInputStream_Available(stream, &available);
|
2011-04-05 15:23:25 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2013-09-26 17:35:13 +02:00
|
|
|
post_data = data = GlobalAlloc(0, available+1);
|
2011-04-05 15:23:25 +02:00
|
|
|
if(!data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
nsres = nsIInputStream_Read(stream, data, available, &data_len);
|
2011-04-05 15:23:25 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
GlobalFree(data);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
if(contains_headers) {
|
2011-04-15 19:36:49 +02:00
|
|
|
if(data_len >= 2 && data[0] == '\r' && data[1] == '\n') {
|
2011-04-05 15:23:25 +02:00
|
|
|
post_data = data+2;
|
|
|
|
data_len -= 2;
|
|
|
|
}else {
|
|
|
|
WCHAR *headers;
|
|
|
|
DWORD size;
|
2011-04-15 19:36:49 +02:00
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
post_data += data_len;
|
|
|
|
for(ptr = data; ptr+4 < data+data_len; ptr++) {
|
|
|
|
if(!memcmp(ptr, "\r\n\r\n", 4)) {
|
2013-09-26 17:34:49 +02:00
|
|
|
ptr += 2;
|
|
|
|
post_data = ptr+2;
|
2011-04-15 19:36:49 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-04-05 15:23:25 +02:00
|
|
|
|
|
|
|
data_len -= post_data-data;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
size = MultiByteToWideChar(CP_ACP, 0, data, ptr-data, NULL, 0);
|
2011-04-05 15:23:25 +02:00
|
|
|
headers = heap_alloc((size+1)*sizeof(WCHAR));
|
|
|
|
if(headers) {
|
2013-09-26 17:34:49 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, data, ptr-data, headers, size);
|
2011-04-05 15:23:25 +02:00
|
|
|
headers[size] = 0;
|
2013-09-26 17:34:49 +02:00
|
|
|
if(headers_list)
|
|
|
|
hres = parse_headers(headers, headers_list);
|
2011-04-05 15:23:25 +02:00
|
|
|
if(SUCCEEDED(hres))
|
2013-09-26 17:34:49 +02:00
|
|
|
request_data->headers = headers;
|
2011-04-05 15:23:25 +02:00
|
|
|
else
|
|
|
|
heap_free(headers);
|
|
|
|
}else {
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
GlobalFree(data);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!data_len) {
|
|
|
|
GlobalFree(data);
|
|
|
|
post_data = NULL;
|
|
|
|
}else if(post_data != data) {
|
|
|
|
char *new_data;
|
|
|
|
|
2013-09-26 17:35:13 +02:00
|
|
|
new_data = GlobalAlloc(0, data_len+1);
|
2011-04-05 15:23:25 +02:00
|
|
|
if(new_data)
|
|
|
|
memcpy(new_data, post_data, data_len);
|
|
|
|
GlobalFree(data);
|
|
|
|
if(!new_data)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
post_data = new_data;
|
|
|
|
}
|
|
|
|
|
2014-11-20 17:59:42 +01:00
|
|
|
if(post_data)
|
|
|
|
post_data[data_len] = 0;
|
2013-09-26 17:34:49 +02:00
|
|
|
request_data->post_data = post_data;
|
|
|
|
request_data->post_data_len = data_len;
|
2015-02-02 13:43:49 +01:00
|
|
|
|
|
|
|
nsres = nsIInputStream_QueryInterface(stream, &IID_nsISeekableStream, (void**)&seekable_stream);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
nsres = nsISeekableStream_Seek(seekable_stream, NS_SEEK_SET, 0);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
nsISeekableStream_Release(seekable_stream);
|
|
|
|
|
|
|
|
nsIInputStream_AddRef(stream);
|
|
|
|
request_data->post_stream = stream;
|
2013-09-26 17:34:49 +02:00
|
|
|
TRACE("post_data = %s\n", debugstr_an(request_data->post_data, request_data->post_data_len));
|
2011-04-05 15:23:25 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:38:48 +02:00
|
|
|
static HRESULT on_start_nsrequest(nsChannelBSC *This)
|
2009-08-30 01:01:16 +02:00
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
2015-12-21 14:31:29 +01:00
|
|
|
This->nschannel->binding = This;
|
|
|
|
|
2009-08-30 01:01:16 +02:00
|
|
|
/* FIXME: it's needed for http connections from BindToObject. */
|
|
|
|
if(!This->nschannel->response_status)
|
|
|
|
This->nschannel->response_status = 200;
|
|
|
|
|
|
|
|
nsres = nsIStreamListener_OnStartRequest(This->nslistener,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext);
|
2010-08-18 13:38:48 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2009-08-30 01:01:16 +02:00
|
|
|
FIXME("OnStartRequest failed: %08x\n", nsres);
|
2010-08-18 13:38:48 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
if(This->is_doc_channel) {
|
2018-02-26 18:21:11 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2015-08-14 17:25:07 +02:00
|
|
|
if(!This->bsc.window)
|
|
|
|
return E_ABORT; /* Binding aborted in OnStartRequest call. */
|
2018-02-26 18:21:11 +01:00
|
|
|
hres = update_window_doc(This->bsc.window);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(This->bsc.binding)
|
|
|
|
process_document_response_headers(This->bsc.window->doc, This->bsc.binding);
|
2012-07-12 14:26:13 +02:00
|
|
|
if(This->bsc.window->base.outer_window->readystate != READYSTATE_LOADING)
|
|
|
|
set_ready_state(This->bsc.window->base.outer_window, READYSTATE_LOADING);
|
2010-08-18 13:38:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-08-30 01:01:16 +02:00
|
|
|
}
|
|
|
|
|
2009-09-14 00:35:20 +02:00
|
|
|
static void on_stop_nsrequest(nsChannelBSC *This, HRESULT result)
|
2009-08-30 01:01:16 +02:00
|
|
|
{
|
2010-10-06 21:35:22 +02:00
|
|
|
nsresult nsres, request_result;
|
|
|
|
|
|
|
|
switch(result) {
|
|
|
|
case S_OK:
|
|
|
|
request_result = NS_OK;
|
|
|
|
break;
|
|
|
|
case E_ABORT:
|
|
|
|
request_result = NS_BINDING_ABORTED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
request_result = NS_ERROR_FAILURE;
|
|
|
|
}
|
2009-08-30 01:01:16 +02:00
|
|
|
|
2010-08-18 13:38:30 +02:00
|
|
|
if(This->nslistener) {
|
|
|
|
nsres = nsIStreamListener_OnStopRequest(This->nslistener,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext,
|
|
|
|
request_result);
|
2010-08-18 13:38:30 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2012-01-09 22:28:21 +01:00
|
|
|
WARN("OnStopRequest failed: %08x\n", nsres);
|
2010-08-18 13:38:30 +02:00
|
|
|
}
|
|
|
|
|
2015-12-21 14:31:29 +01:00
|
|
|
if(This->nschannel) {
|
|
|
|
if(This->nschannel->load_group) {
|
|
|
|
nsres = nsILoadGroup_RemoveRequest(This->nschannel->load_group,
|
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, NULL, request_result);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("RemoveRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
if(This->nschannel->binding == This)
|
|
|
|
This->nschannel->binding = NULL;
|
2010-08-18 13:38:30 +02:00
|
|
|
}
|
2009-08-30 01:01:16 +02:00
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
|
|
|
|
{
|
2009-08-11 19:14:48 +02:00
|
|
|
DWORD read;
|
2008-03-23 02:17:17 +01:00
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-09-13 12:29:30 +02:00
|
|
|
if(!This->response_processed) {
|
|
|
|
IWinInetHttpInfo *wininet_info;
|
|
|
|
|
|
|
|
This->response_processed = TRUE;
|
|
|
|
if(This->bsc.binding) {
|
|
|
|
hres = IBinding_QueryInterface(This->bsc.binding, &IID_IWinInetHttpInfo, (void**)&wininet_info);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
query_http_info(This, wininet_info);
|
|
|
|
IWinInetHttpInfo_Release(wininet_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-19 16:12:51 +02:00
|
|
|
if(!This->nschannel)
|
|
|
|
return S_OK;
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
if(!This->nslistener) {
|
|
|
|
BYTE buf[1024];
|
|
|
|
|
|
|
|
do {
|
2012-07-27 10:51:11 +02:00
|
|
|
hres = read_stream(&This->bsc, stream, buf, sizeof(buf), &read);
|
2008-03-23 02:17:17 +01:00
|
|
|
}while(hres == S_OK && read);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-19 11:58:15 +02:00
|
|
|
if(!This->nsstream) {
|
2008-03-23 02:17:17 +01:00
|
|
|
This->nsstream = create_nsprotocol_stream();
|
2012-10-19 11:58:15 +02:00
|
|
|
if(!This->nsstream)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
do {
|
2019-10-21 06:22:36 +02:00
|
|
|
BOOL first_read = !This->bsc.read;
|
2012-07-27 10:51:11 +02:00
|
|
|
|
|
|
|
hres = read_stream(&This->bsc, stream, This->nsstream->buf+This->nsstream->buf_size,
|
2009-08-11 19:14:48 +02:00
|
|
|
sizeof(This->nsstream->buf)-This->nsstream->buf_size, &read);
|
|
|
|
if(!read)
|
2008-03-23 02:17:17 +01:00
|
|
|
break;
|
|
|
|
|
2009-08-11 19:14:48 +02:00
|
|
|
This->nsstream->buf_size += read;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2012-07-27 10:51:11 +02:00
|
|
|
if(first_read) {
|
2012-07-27 10:51:39 +02:00
|
|
|
switch(This->bsc.bom) {
|
|
|
|
case BOM_UTF8:
|
2012-03-09 10:51:48 +01:00
|
|
|
This->nschannel->charset = heap_strdupA(UTF8_STR);
|
2012-07-27 10:51:39 +02:00
|
|
|
break;
|
|
|
|
case BOM_UTF16:
|
|
|
|
This->nschannel->charset = heap_strdupA(UTF16_STR);
|
2014-10-09 16:07:33 +02:00
|
|
|
case BOM_NONE:
|
|
|
|
/* FIXME: Get charset from HTTP headers */;
|
2012-07-27 10:51:39 +02:00
|
|
|
}
|
2009-08-11 19:14:48 +02:00
|
|
|
|
2009-12-28 21:19:29 +01:00
|
|
|
if(!This->nschannel->content_type) {
|
|
|
|
WCHAR *mime;
|
|
|
|
|
2012-03-08 13:02:05 +01:00
|
|
|
hres = FindMimeFromData(NULL, NULL, This->nsstream->buf, This->nsstream->buf_size,
|
2020-11-24 23:29:19 +01:00
|
|
|
This->is_doc_channel ? L"text/html" : NULL, 0, &mime, 0);
|
2009-12-28 21:19:29 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
TRACE("Found MIME %s\n", debugstr_w(mime));
|
|
|
|
|
|
|
|
This->nschannel->content_type = heap_strdupWtoA(mime);
|
|
|
|
CoTaskMemFree(mime);
|
|
|
|
if(!This->nschannel->content_type)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2015-08-14 17:25:07 +02:00
|
|
|
hres = on_start_nsrequest(This);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIStreamListener_OnDataAvailable(This->nslistener,
|
2010-12-30 01:43:11 +01:00
|
|
|
(nsIRequest*)&This->nschannel->nsIHttpChannel_iface, This->nscontext,
|
2019-10-21 06:22:36 +02:00
|
|
|
&This->nsstream->nsIInputStream_iface, This->bsc.read-This->nsstream->buf_size,
|
2008-03-23 02:17:17 +01:00
|
|
|
This->nsstream->buf_size);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("OnDataAvailable failed: %08x\n", nsres);
|
|
|
|
|
2009-08-11 19:14:48 +02:00
|
|
|
if(This->nsstream->buf_size == sizeof(This->nsstream->buf)) {
|
|
|
|
ERR("buffer is full\n");
|
|
|
|
break;
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
}while(hres == S_OK);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
typedef struct {
|
|
|
|
nsIAsyncVerifyRedirectCallback nsIAsyncVerifyRedirectCallback_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsChannel *nschannel;
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
} nsRedirectCallback;
|
|
|
|
|
|
|
|
static nsRedirectCallback *impl_from_nsIAsyncVerifyRedirectCallback(nsIAsyncVerifyRedirectCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsRedirectCallback, nsIAsyncVerifyRedirectCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsAsyncVerifyRedirectCallback_QueryInterface(nsIAsyncVerifyRedirectCallback *iface,
|
|
|
|
nsIIDRef riid, void **result)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
2013-01-05 16:17:18 +01:00
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
2011-04-15 19:36:36 +02:00
|
|
|
*result = &This->nsIAsyncVerifyRedirectCallback_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIAsyncVerifyRedirectCallback, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIAsyncVerifyRedirectCallback %p)\n", This, result);
|
|
|
|
*result = &This->nsIAsyncVerifyRedirectCallback_iface;
|
|
|
|
}else {
|
|
|
|
*result = NULL;
|
2011-05-09 09:03:40 +02:00
|
|
|
WARN("unimplemented iface %s\n", debugstr_guid(riid));
|
2011-04-15 19:36:36 +02:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsAsyncVerifyRedirectCallback_AddRef(nsIAsyncVerifyRedirectCallback *iface)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsAsyncVerifyRedirectCallback_Release(nsIAsyncVerifyRedirectCallback *iface)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
IBindStatusCallback_Release(&This->bsc->bsc.IBindStatusCallback_iface);
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_Release(&This->nschannel->nsIHttpChannel_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2015-10-05 15:50:34 +02:00
|
|
|
static nsresult NSAPI nsAsyncVerifyRedirectCallback_OnRedirectVerifyCallback(nsIAsyncVerifyRedirectCallback *iface, nsresult result)
|
2011-04-15 19:36:36 +02:00
|
|
|
{
|
|
|
|
nsRedirectCallback *This = impl_from_nsIAsyncVerifyRedirectCallback(iface);
|
2012-04-05 13:57:26 +02:00
|
|
|
nsChannel *old_nschannel;
|
|
|
|
nsresult nsres;
|
2011-04-15 19:36:36 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%08x)\n", This, result);
|
|
|
|
|
2012-04-05 13:57:26 +02:00
|
|
|
old_nschannel = This->bsc->nschannel;
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_AddRef(&This->nschannel->nsIHttpChannel_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
This->bsc->nschannel = This->nschannel;
|
|
|
|
|
|
|
|
if(This->nschannel->load_group) {
|
|
|
|
nsres = nsILoadGroup_AddRequest(This->nschannel->load_group, (nsIRequest*)&This->nschannel->nsIHttpChannel_iface,
|
|
|
|
NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("AddRequest failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2018-03-20 22:39:01 +01:00
|
|
|
if(This->bsc->is_doc_channel && This->bsc->bsc.window && This->bsc->bsc.window->base.outer_window) {
|
2011-11-16 12:52:43 +01:00
|
|
|
IUri *uri = nsuri_get_uri(This->nschannel->uri);
|
|
|
|
|
|
|
|
if(uri) {
|
2012-07-12 14:26:13 +02:00
|
|
|
set_current_uri(This->bsc->bsc.window->base.outer_window, uri);
|
2011-11-16 12:52:43 +01:00
|
|
|
IUri_Release(uri);
|
|
|
|
}else {
|
|
|
|
WARN("Could not get IUri from nsWineURI\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-05 13:57:26 +02:00
|
|
|
if(old_nschannel) {
|
2012-09-07 13:56:25 +02:00
|
|
|
if(old_nschannel->load_group) {
|
|
|
|
nsres = nsILoadGroup_RemoveRequest(old_nschannel->load_group,
|
|
|
|
(nsIRequest*)&old_nschannel->nsIHttpChannel_iface, NULL, NS_OK);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("RemoveRequest failed: %08x\n", nsres);
|
|
|
|
}
|
2012-04-05 13:57:26 +02:00
|
|
|
nsIHttpChannel_Release(&old_nschannel->nsIHttpChannel_iface);
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIAsyncVerifyRedirectCallbackVtbl nsAsyncVerifyRedirectCallbackVtbl = {
|
|
|
|
nsAsyncVerifyRedirectCallback_QueryInterface,
|
|
|
|
nsAsyncVerifyRedirectCallback_AddRef,
|
|
|
|
nsAsyncVerifyRedirectCallback_Release,
|
2015-10-05 15:50:34 +02:00
|
|
|
nsAsyncVerifyRedirectCallback_OnRedirectVerifyCallback
|
2011-04-15 19:36:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_redirect_callback(nsChannel *nschannel, nsChannelBSC *bsc, nsRedirectCallback **ret)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *callback;
|
|
|
|
|
|
|
|
callback = heap_alloc(sizeof(*callback));
|
|
|
|
if(!callback)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
callback->nsIAsyncVerifyRedirectCallback_iface.lpVtbl = &nsAsyncVerifyRedirectCallbackVtbl;
|
|
|
|
callback->ref = 1;
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_AddRef(&nschannel->nsIHttpChannel_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
callback->nschannel = nschannel;
|
|
|
|
|
|
|
|
IBindStatusCallback_AddRef(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
callback->bsc = bsc;
|
|
|
|
|
|
|
|
*ret = callback;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-07 14:22:51 +01:00
|
|
|
static inline nsChannelBSC *nsChannelBSC_from_BSCallback(BSCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsChannelBSC, bsc);
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
static void nsChannelBSC_destroy(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2015-12-21 14:31:29 +01:00
|
|
|
if(This->nschannel) {
|
|
|
|
if(This->nschannel->binding == This)
|
|
|
|
This->nschannel->binding = NULL;
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_Release(&This->nschannel->nsIHttpChannel_iface);
|
2015-12-21 14:31:29 +01:00
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
if(This->nslistener)
|
|
|
|
nsIStreamListener_Release(This->nslistener);
|
|
|
|
if(This->nscontext)
|
|
|
|
nsISupports_Release(This->nscontext);
|
|
|
|
if(This->nsstream)
|
2011-01-05 00:41:05 +01:00
|
|
|
nsIInputStream_Release(&This->nsstream->nsIInputStream_iface);
|
2008-03-23 02:17:17 +01:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_start_binding(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-18 13:39:04 +02:00
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
if(This->is_doc_channel)
|
|
|
|
This->bsc.window->base.outer_window->base.inner_window->doc->skip_mutation_notif = FALSE;
|
2010-08-18 13:39:04 +02:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-08-19 20:40:00 +02:00
|
|
|
static HRESULT nsChannelBSC_init_bindinfo(BSCallback *bsc)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2013-09-26 17:34:49 +02:00
|
|
|
nsChannel *nschannel = This->nschannel;
|
2019-03-14 14:13:45 +01:00
|
|
|
GeckoBrowser *browser;
|
2010-08-03 21:40:56 +02:00
|
|
|
HRESULT hres;
|
2009-08-19 20:40:00 +02:00
|
|
|
|
2017-06-07 16:10:51 +02:00
|
|
|
if(This->is_doc_channel && This->bsc.window && This->bsc.window->base.outer_window
|
2019-03-14 14:13:45 +01:00
|
|
|
&& (browser = This->bsc.window->base.outer_window->browser)) {
|
|
|
|
if(browser->doc->hostinfo.dwFlags & DOCHOSTUIFLAG_ENABLE_REDIRECT_NOTIFICATION)
|
2017-06-07 16:10:51 +02:00
|
|
|
This->bsc.bindinfo_options |= BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS;
|
|
|
|
}
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
if(nschannel && nschannel->post_data_stream) {
|
|
|
|
hres = read_post_data_stream(nschannel->post_data_stream, nschannel->post_data_contains_headers,
|
|
|
|
&nschannel->request_headers, &This->bsc.request_data);
|
2010-10-27 23:19:10 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2009-08-19 20:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
} stop_request_task_t;
|
|
|
|
|
|
|
|
static void stop_request_proc(task_t *_task)
|
2008-03-23 02:17:17 +01:00
|
|
|
{
|
2010-08-18 13:39:15 +02:00
|
|
|
stop_request_task_t *task = (stop_request_task_t*)_task;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
TRACE("(%p)\n", task->bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2011-01-31 20:28:10 +01:00
|
|
|
list_remove(&task->bsc->bsc.entry);
|
|
|
|
list_init(&task->bsc->bsc.entry);
|
2010-08-18 13:39:15 +02:00
|
|
|
on_stop_nsrequest(task->bsc, S_OK);
|
2011-08-03 12:35:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void stop_request_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
stop_request_task_t *task = (stop_request_task_t*)_task;
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&task->bsc->bsc.IBindStatusCallback_iface);
|
2011-08-03 12:35:47 +02:00
|
|
|
heap_free(task);
|
2010-08-18 13:39:15 +02:00
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
static HRESULT async_stop_request(nsChannelBSC *This)
|
|
|
|
{
|
|
|
|
stop_request_task_t *task;
|
|
|
|
|
2019-10-21 06:22:36 +02:00
|
|
|
if(!This->bsc.read) {
|
2011-06-16 16:42:12 +02:00
|
|
|
TRACE("No data read, calling OnStartRequest\n");
|
|
|
|
on_start_nsrequest(This);
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
task = heap_alloc(sizeof(*task));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_AddRef(&This->bsc.IBindStatusCallback_iface);
|
2010-08-18 13:39:15 +02:00
|
|
|
task->bsc = This;
|
2012-07-12 14:25:43 +02:00
|
|
|
|
2012-10-19 11:56:59 +02:00
|
|
|
return push_task(&task->header, stop_request_proc, stop_request_task_destr, This->bsc.window->task_magic);
|
2010-08-18 13:39:15 +02:00
|
|
|
}
|
|
|
|
|
2011-03-28 23:35:34 +02:00
|
|
|
static void handle_navigation_error(nsChannelBSC *This, DWORD result)
|
|
|
|
{
|
2012-07-12 14:26:13 +02:00
|
|
|
HTMLOuterWindow *outer_window;
|
2011-03-28 23:35:34 +02:00
|
|
|
HTMLDocumentObj *doc;
|
|
|
|
BOOL is_error_url;
|
|
|
|
SAFEARRAY *sa;
|
|
|
|
SAFEARRAYBOUND bound;
|
|
|
|
VARIANT var, varOut;
|
|
|
|
LONG ind;
|
2011-11-10 14:35:11 +01:00
|
|
|
BSTR unk;
|
2011-03-28 23:35:34 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2019-03-14 14:13:54 +01:00
|
|
|
if(!This->is_doc_channel || !This->bsc.window || !This->bsc.window->base.outer_window
|
|
|
|
|| !This->bsc.window->base.outer_window->browser)
|
2011-03-28 23:35:34 +02:00
|
|
|
return;
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
outer_window = This->bsc.window->base.outer_window;
|
2019-03-14 14:13:54 +01:00
|
|
|
doc = outer_window->browser->doc;
|
|
|
|
if(!doc->doc_object_service || !doc->client)
|
2011-03-28 23:35:34 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IDocObjectService_IsErrorUrl(doc->doc_object_service,
|
2012-07-12 14:26:13 +02:00
|
|
|
outer_window->url, &is_error_url);
|
2011-03-28 23:35:34 +02:00
|
|
|
if(FAILED(hres) || is_error_url)
|
|
|
|
return;
|
|
|
|
|
2012-11-12 12:58:27 +01:00
|
|
|
if(!doc->client_cmdtrg)
|
2011-03-28 23:35:34 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
bound.lLbound = 0;
|
|
|
|
bound.cElements = 8;
|
|
|
|
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
|
2012-11-12 12:58:27 +01:00
|
|
|
if(!sa)
|
2011-03-28 23:35:34 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
ind = 0;
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = result;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 1;
|
|
|
|
V_VT(&var) = VT_BSTR;
|
2012-07-12 14:26:13 +02:00
|
|
|
V_BSTR(&var) = outer_window->url;
|
2011-03-28 23:35:34 +02:00
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 3;
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
2012-07-12 14:26:13 +02:00
|
|
|
V_UNKNOWN(&var) = (IUnknown*)&outer_window->base.IHTMLWindow2_iface;
|
2011-03-28 23:35:34 +02:00
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
/* FIXME: what are the following fields for? */
|
|
|
|
ind = 2;
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = NULL;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 4;
|
|
|
|
V_VT(&var) = VT_BOOL;
|
|
|
|
V_BOOL(&var) = FALSE;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 5;
|
|
|
|
V_VT(&var) = VT_BOOL;
|
|
|
|
V_BOOL(&var) = FALSE;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 6;
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
unk = SysAllocString(NULL);
|
|
|
|
V_BSTR(&var) = unk;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
ind = 7;
|
|
|
|
V_VT(&var) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN(&var) = NULL;
|
|
|
|
SafeArrayPutElement(sa, &ind, &var);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_ARRAY;
|
|
|
|
V_ARRAY(&var) = sa;
|
|
|
|
V_VT(&varOut) = VT_BOOL;
|
|
|
|
V_BOOL(&varOut) = VARIANT_TRUE;
|
2012-11-12 12:58:27 +01:00
|
|
|
IOleCommandTarget_Exec(doc->client_cmdtrg, &CGID_DocHostCmdPriv, 1, 0, &var, FAILED(hres)?NULL:&varOut);
|
2011-03-28 23:35:34 +02:00
|
|
|
|
|
|
|
SysFreeString(unk);
|
|
|
|
SafeArrayDestroy(sa);
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
static HRESULT nsChannelBSC_stop_binding(BSCallback *bsc, HRESULT result)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-18 13:39:15 +02:00
|
|
|
|
2016-05-27 13:43:32 +02:00
|
|
|
if(result != E_ABORT && This->is_doc_channel && This->bsc.window) {
|
2011-05-13 18:18:12 +02:00
|
|
|
if(FAILED(result))
|
|
|
|
handle_navigation_error(This, result);
|
2016-05-27 13:43:32 +02:00
|
|
|
else if(This->nschannel) {
|
2011-05-13 18:18:12 +02:00
|
|
|
result = async_stop_request(This);
|
|
|
|
if(SUCCEEDED(result))
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:15 +02:00
|
|
|
on_stop_nsrequest(This, result);
|
2008-03-23 02:17:17 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT nsChannelBSC_read_data(BSCallback *bsc, IStream *stream)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
return read_stream_data(This, stream);
|
|
|
|
}
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
static HRESULT handle_redirect(nsChannelBSC *This, const WCHAR *new_url)
|
|
|
|
{
|
|
|
|
nsRedirectCallback *callback;
|
|
|
|
nsIChannelEventSink *sink;
|
|
|
|
nsChannel *new_channel;
|
2016-10-07 16:04:49 +02:00
|
|
|
IMoniker *mon;
|
2011-04-15 19:36:36 +02:00
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(new_url));
|
|
|
|
|
2016-10-07 16:04:49 +02:00
|
|
|
hres = CreateURLMoniker(NULL, new_url, &mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
IMoniker_Release(This->bsc.mon);
|
|
|
|
This->bsc.mon = mon;
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
if(!This->nschannel || !This->nschannel->notif_callback)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
nsres = nsIInterfaceRequestor_GetInterface(This->nschannel->notif_callback, &IID_nsIChannelEventSink, (void**)&sink);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hres = create_redirect_nschannel(new_url, This->nschannel, &new_channel);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2012-04-05 13:57:26 +02:00
|
|
|
TRACE("%p %p->%p\n", This, This->nschannel, new_channel);
|
|
|
|
|
2011-04-15 19:36:36 +02:00
|
|
|
hres = create_redirect_callback(new_channel, This, &callback);
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_Release(&new_channel->nsIHttpChannel_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
nsres = nsIChannelEventSink_AsyncOnChannelRedirect(sink, (nsIChannel*)&This->nschannel->nsIHttpChannel_iface,
|
|
|
|
(nsIChannel*)&callback->nschannel->nsIHttpChannel_iface, REDIRECT_TEMPORARY, /* FIXME */
|
|
|
|
&callback->nsIAsyncVerifyRedirectCallback_iface);
|
|
|
|
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
FIXME("AsyncOnChannelRedirect failed: %08x\n", hres);
|
|
|
|
else if(This->nschannel != callback->nschannel)
|
|
|
|
FIXME("nschannel not updated\n");
|
2011-04-26 03:20:20 +02:00
|
|
|
|
|
|
|
nsIAsyncVerifyRedirectCallback_Release(&callback->nsIAsyncVerifyRedirectCallback_iface);
|
2011-04-15 19:36:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIChannelEventSink_Release(sink);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2013-09-19 16:12:51 +02:00
|
|
|
static BOOL is_supported_doc_mime(const WCHAR *mime)
|
|
|
|
{
|
|
|
|
char *nscat, *mimea;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
mimea = heap_strdupWtoA(mime);
|
|
|
|
if(!mimea)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
nscat = get_nscategory_entry("Gecko-Content-Viewers", mimea);
|
|
|
|
|
|
|
|
ret = nscat != NULL && !strcmp(nscat, "@mozilla.org/content/document-loader-factory;1");
|
|
|
|
|
|
|
|
heap_free(mimea);
|
|
|
|
nsfree(nscat);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-19 16:13:06 +02:00
|
|
|
static IUri *get_moniker_uri(IMoniker *mon)
|
|
|
|
{
|
|
|
|
IUriContainer *uri_container;
|
|
|
|
IUri *ret = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IUriContainer_GetIUri(uri_container, &ret);
|
|
|
|
IUriContainer_Release(uri_container);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
}else {
|
|
|
|
FIXME("No IUriContainer\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void handle_extern_mime_navigation(nsChannelBSC *This)
|
|
|
|
{
|
2014-03-13 14:13:11 +01:00
|
|
|
IWebBrowserPriv2IE9 *webbrowser_priv;
|
2013-09-19 16:13:06 +02:00
|
|
|
IOleCommandTarget *cmdtrg;
|
|
|
|
HTMLDocumentObj *doc_obj;
|
|
|
|
IBindCtx *bind_ctx;
|
|
|
|
IUri *uri;
|
|
|
|
VARIANT flags;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2019-03-14 14:13:54 +01:00
|
|
|
if(!This->bsc.window || !This->bsc.window->base.outer_window || !This->bsc.window->base.outer_window->browser)
|
2013-09-19 16:13:06 +02:00
|
|
|
return;
|
|
|
|
|
2019-03-14 14:13:54 +01:00
|
|
|
doc_obj = This->bsc.window->base.outer_window->browser->doc;
|
2013-09-19 16:13:06 +02:00
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(doc_obj->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 62, 0, NULL, NULL);
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_document_navigation(doc_obj, FALSE);
|
|
|
|
|
|
|
|
if(!doc_obj->webbrowser) {
|
|
|
|
FIXME("unimplemented in non-webbrowser mode\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uri = get_moniker_uri(This->bsc.mon);
|
|
|
|
if(!uri)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = CreateBindCtx(0, &bind_ctx);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IUri_Release(uri);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(&flags) = VT_I4;
|
|
|
|
V_I4(&flags) = navHyperlink;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(doc_obj->webbrowser, &IID_IWebBrowserPriv2IE8, (void**)&webbrowser_priv);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2014-03-13 14:13:11 +01:00
|
|
|
hres = IWebBrowserPriv2IE9_NavigateWithBindCtx2(webbrowser_priv, uri, &flags, NULL, NULL, NULL, bind_ctx, NULL, 0);
|
|
|
|
IWebBrowserPriv2IE9_Release(webbrowser_priv);
|
2013-09-19 16:13:06 +02:00
|
|
|
}else {
|
|
|
|
IWebBrowserPriv *webbrowser_priv_old;
|
|
|
|
VARIANT uriv;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(doc_obj->webbrowser, &IID_IWebBrowserPriv, (void**)&webbrowser_priv_old);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
V_VT(&uriv) = VT_BSTR;
|
|
|
|
IUri_GetDisplayUri(uri, &V_BSTR(&uriv));
|
|
|
|
|
|
|
|
hres = IWebBrowserPriv_NavigateWithBindCtx(webbrowser_priv_old, &uriv, &flags, NULL, NULL, NULL, bind_ctx, NULL);
|
|
|
|
|
|
|
|
SysFreeString(V_BSTR(&uriv));
|
|
|
|
IWebBrowserPriv_Release(webbrowser_priv_old);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IUri_Release(uri);
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCWSTR status_text)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2008-03-23 02:17:17 +01:00
|
|
|
|
|
|
|
switch(status_code) {
|
2008-03-26 15:24:03 +01:00
|
|
|
case BINDSTATUS_MIMETYPEAVAILABLE:
|
2013-09-19 16:12:51 +02:00
|
|
|
if(This->is_doc_channel && !is_supported_doc_mime(status_text)) {
|
|
|
|
FIXME("External MIME: %s\n", debugstr_w(status_text));
|
|
|
|
|
2013-09-19 16:13:06 +02:00
|
|
|
handle_extern_mime_navigation(This);
|
|
|
|
|
2013-09-19 16:12:51 +02:00
|
|
|
This->nschannel = NULL;
|
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
if(!This->nschannel)
|
|
|
|
return S_OK;
|
|
|
|
|
2008-03-26 15:24:03 +01:00
|
|
|
heap_free(This->nschannel->content_type);
|
|
|
|
This->nschannel->content_type = heap_strdupWtoA(status_text);
|
2009-12-15 21:16:59 +01:00
|
|
|
break;
|
|
|
|
case BINDSTATUS_REDIRECTING:
|
2011-04-15 19:36:36 +02:00
|
|
|
return handle_redirect(This, status_text);
|
2011-03-28 23:35:34 +02:00
|
|
|
case BINDSTATUS_BEGINDOWNLOADDATA: {
|
|
|
|
IWinInetHttpInfo *http_info;
|
|
|
|
DWORD status, size = sizeof(DWORD);
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!This->bsc.binding)
|
|
|
|
break;
|
|
|
|
|
|
|
|
hres = IBinding_QueryInterface(This->bsc.binding, &IID_IWinInetHttpInfo, (void**)&http_info);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
|
|
|
|
hres = IWinInetHttpInfo_QueryInfo(http_info,
|
|
|
|
HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL, NULL);
|
|
|
|
IWinInetHttpInfo_Release(http_info);
|
|
|
|
if(FAILED(hres) || status == HTTP_STATUS_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
handle_navigation_error(This, status);
|
|
|
|
}
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-22 17:34:12 +02:00
|
|
|
static HRESULT process_response_status_text(const WCHAR *header, const WCHAR *header_end, char **status_text)
|
|
|
|
{
|
2019-06-13 08:34:29 +02:00
|
|
|
header = wcschr(header + 1, ' ');
|
2015-07-22 17:34:12 +02:00
|
|
|
if(!header || header >= header_end)
|
|
|
|
return E_FAIL;
|
2019-06-13 08:34:29 +02:00
|
|
|
header = wcschr(header + 1, ' ');
|
2015-07-22 17:34:12 +02:00
|
|
|
if(!header || header >= header_end)
|
|
|
|
return E_FAIL;
|
|
|
|
++header;
|
|
|
|
|
|
|
|
*status_text = heap_strndupWtoU(header, header_end - header);
|
|
|
|
|
|
|
|
if(!*status_text)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-04-03 00:31:45 +02:00
|
|
|
static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
|
|
|
|
LPCWSTR response_headers)
|
2009-08-11 19:15:07 +02:00
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2015-07-22 17:34:12 +02:00
|
|
|
char *str;
|
2010-08-03 21:38:37 +02:00
|
|
|
HRESULT hres;
|
2009-08-11 19:15:07 +02:00
|
|
|
|
2012-09-13 12:29:30 +02:00
|
|
|
This->response_processed = TRUE;
|
2009-08-11 19:15:07 +02:00
|
|
|
This->nschannel->response_status = response_code;
|
2010-04-03 00:31:45 +02:00
|
|
|
|
|
|
|
if(response_headers) {
|
2010-08-03 21:38:53 +02:00
|
|
|
const WCHAR *headers;
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
headers = wcschr(response_headers, '\r');
|
2015-07-22 17:34:12 +02:00
|
|
|
hres = process_response_status_text(response_headers, headers, &str);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("parsing headers failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(This->nschannel->response_status_text);
|
|
|
|
This->nschannel->response_status_text = str;
|
|
|
|
|
2010-08-03 21:38:53 +02:00
|
|
|
if(headers && headers[1] == '\n') {
|
|
|
|
headers += 2;
|
2011-11-23 16:19:05 +01:00
|
|
|
hres = process_response_headers(This, headers);
|
2010-08-03 21:38:53 +02:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
WARN("parsing headers failed: %08x\n", hres);
|
2010-08-03 21:38:37 +02:00
|
|
|
return hres;
|
2010-08-03 21:38:53 +02:00
|
|
|
}
|
2010-04-03 00:31:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:15:07 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-03 21:39:04 +02:00
|
|
|
static HRESULT nsChannelBSC_beginning_transaction(BSCallback *bsc, WCHAR **additional_headers)
|
|
|
|
{
|
2011-01-07 14:22:51 +01:00
|
|
|
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
|
2010-08-03 21:39:34 +02:00
|
|
|
http_header_t *iter;
|
|
|
|
DWORD len = 0;
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
if(!This->nschannel)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->nschannel->request_headers, http_header_t, entry) {
|
2020-11-24 23:29:19 +01:00
|
|
|
if(wcscmp(iter->header, L"Content-Length"))
|
2019-06-13 08:34:29 +02:00
|
|
|
len += lstrlenW(iter->header) + 2 /* ": " */ + lstrlenW(iter->data) + 2 /* "\r\n" */;
|
2010-08-03 21:39:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!len)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
*additional_headers = ptr = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
|
|
|
|
if(!ptr)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->nschannel->request_headers, http_header_t, entry) {
|
2020-11-24 23:29:19 +01:00
|
|
|
if(!wcscmp(iter->header, L"Content-Length"))
|
2010-08-03 21:39:34 +02:00
|
|
|
continue;
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
len = lstrlenW(iter->header);
|
2010-08-03 21:39:34 +02:00
|
|
|
memcpy(ptr, iter->header, len*sizeof(WCHAR));
|
|
|
|
ptr += len;
|
|
|
|
|
|
|
|
*ptr++ = ':';
|
|
|
|
*ptr++ = ' ';
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
len = lstrlenW(iter->data);
|
2010-08-03 21:39:34 +02:00
|
|
|
memcpy(ptr, iter->data, len*sizeof(WCHAR));
|
|
|
|
ptr += len;
|
|
|
|
|
|
|
|
*ptr++ = '\r';
|
|
|
|
*ptr++ = '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
*ptr = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
2010-08-03 21:39:04 +02:00
|
|
|
}
|
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
static const BSCallbackVtbl nsChannelBSCVtbl = {
|
|
|
|
nsChannelBSC_destroy,
|
2009-08-19 20:40:00 +02:00
|
|
|
nsChannelBSC_init_bindinfo,
|
2008-03-23 02:17:17 +01:00
|
|
|
nsChannelBSC_start_binding,
|
|
|
|
nsChannelBSC_stop_binding,
|
|
|
|
nsChannelBSC_read_data,
|
|
|
|
nsChannelBSC_on_progress,
|
2010-08-03 21:39:04 +02:00
|
|
|
nsChannelBSC_on_response,
|
|
|
|
nsChannelBSC_beginning_transaction
|
2008-03-23 02:17:17 +01:00
|
|
|
};
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
HRESULT create_channelbsc(IMoniker *mon, const WCHAR *headers, BYTE *post_data, DWORD post_data_size,
|
|
|
|
BOOL is_doc_binding, nsChannelBSC **retval)
|
2008-03-23 02:17:17 +01:00
|
|
|
{
|
2010-03-03 14:53:49 +01:00
|
|
|
nsChannelBSC *ret;
|
2013-09-26 17:34:59 +02:00
|
|
|
DWORD bindf;
|
2010-03-03 14:53:49 +01:00
|
|
|
|
|
|
|
ret = heap_alloc_zero(sizeof(*ret));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2013-09-26 17:34:59 +02:00
|
|
|
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
|
|
|
|
if(post_data_size)
|
|
|
|
bindf |= BINDF_FORMS_SUBMIT | BINDF_PRAGMA_NO_CACHE | BINDF_HYPERLINK | BINDF_GETNEWESTVERSION;
|
|
|
|
|
|
|
|
init_bscallback(&ret->bsc, &nsChannelBSCVtbl, mon, bindf);
|
2012-07-12 14:26:13 +02:00
|
|
|
ret->is_doc_channel = is_doc_binding;
|
2008-03-23 02:17:17 +01:00
|
|
|
|
2010-03-03 14:53:49 +01:00
|
|
|
if(headers) {
|
2013-09-26 17:34:49 +02:00
|
|
|
ret->bsc.request_data.headers = heap_strdupW(headers);
|
|
|
|
if(!ret->bsc.request_data.headers) {
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&ret->bsc.IBindStatusCallback_iface);
|
2010-03-03 14:53:49 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(post_data) {
|
2013-09-26 17:35:13 +02:00
|
|
|
ret->bsc.request_data.post_data = GlobalAlloc(0, post_data_size+1);
|
2013-09-26 17:34:49 +02:00
|
|
|
if(!ret->bsc.request_data.post_data) {
|
|
|
|
release_request_data(&ret->bsc.request_data);
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&ret->bsc.IBindStatusCallback_iface);
|
2010-03-03 14:53:49 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
memcpy(ret->bsc.request_data.post_data, post_data, post_data_size);
|
2013-09-26 17:35:13 +02:00
|
|
|
((BYTE*)ret->bsc.request_data.post_data)[post_data_size] = 0;
|
2013-09-26 17:34:49 +02:00
|
|
|
ret->bsc.request_data.post_data_len = post_data_size;
|
2010-03-03 14:53:49 +01:00
|
|
|
}
|
|
|
|
|
2013-07-25 14:15:54 +02:00
|
|
|
TRACE("created %p\n", ret);
|
2010-03-03 14:53:49 +01:00
|
|
|
*retval = ret;
|
|
|
|
return S_OK;
|
2008-03-23 02:17:17 +01:00
|
|
|
}
|
|
|
|
|
2010-03-03 14:53:32 +01:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window;
|
2012-07-12 14:25:43 +02:00
|
|
|
HTMLInnerWindow *pending_window;
|
2010-03-03 14:53:32 +01:00
|
|
|
} start_doc_binding_task_t;
|
|
|
|
|
|
|
|
static void start_doc_binding_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task;
|
|
|
|
|
2012-11-12 12:57:48 +01:00
|
|
|
set_current_mon(task->window, task->pending_window->bscallback->bsc.mon, BINDING_NAVIGATED);
|
2012-07-12 14:26:13 +02:00
|
|
|
start_binding(task->pending_window, &task->pending_window->bscallback->bsc, NULL);
|
2011-08-03 12:36:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void start_doc_binding_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
start_doc_binding_task_t *task = (start_doc_binding_task_t*)_task;
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
IHTMLWindow2_Release(&task->pending_window->base.IHTMLWindow2_iface);
|
2011-08-03 12:36:10 +02:00
|
|
|
heap_free(task);
|
2010-03-03 14:53:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
HRESULT async_start_doc_binding(HTMLOuterWindow *window, HTMLInnerWindow *pending_window)
|
2010-03-03 14:53:32 +01:00
|
|
|
{
|
|
|
|
start_doc_binding_task_t *task;
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
TRACE("%p\n", pending_window);
|
2011-11-15 13:29:43 +01:00
|
|
|
|
2010-03-03 14:53:32 +01:00
|
|
|
task = heap_alloc(sizeof(start_doc_binding_task_t));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
task->window = window;
|
2012-07-12 14:25:43 +02:00
|
|
|
task->pending_window = pending_window;
|
|
|
|
IHTMLWindow2_AddRef(&pending_window->base.IHTMLWindow2_iface);
|
2010-03-03 14:53:32 +01:00
|
|
|
|
2012-10-19 11:56:59 +02:00
|
|
|
return push_task(&task->header, start_doc_binding_proc, start_doc_binding_task_destr, pending_window->task_magic);
|
2010-03-03 14:53:32 +01:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:51:00 +02:00
|
|
|
void abort_window_bindings(HTMLInnerWindow *window)
|
2009-10-26 23:05:37 +01:00
|
|
|
{
|
2012-07-12 14:25:43 +02:00
|
|
|
BSCallback *iter;
|
|
|
|
|
2012-07-12 14:25:58 +02:00
|
|
|
remove_target_tasks(window->task_magic);
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
while(!list_empty(&window->bindings)) {
|
|
|
|
iter = LIST_ENTRY(window->bindings.next, BSCallback, entry);
|
2011-01-31 20:28:10 +01:00
|
|
|
|
2011-05-13 18:18:23 +02:00
|
|
|
TRACE("Aborting %p\n", iter);
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
IBindStatusCallback_AddRef(&iter->IBindStatusCallback_iface);
|
|
|
|
|
2009-10-26 23:05:37 +01:00
|
|
|
if(iter->binding)
|
|
|
|
IBinding_Abort(iter->binding);
|
2012-07-12 14:25:43 +02:00
|
|
|
else
|
2011-05-13 18:18:23 +02:00
|
|
|
iter->vtbl->stop_binding(iter, E_ABORT);
|
2011-01-31 20:28:10 +01:00
|
|
|
|
2012-07-11 13:51:00 +02:00
|
|
|
iter->window = NULL;
|
2012-07-12 14:25:43 +02:00
|
|
|
list_remove(&iter->entry);
|
|
|
|
list_init(&iter->entry);
|
|
|
|
|
|
|
|
IBindStatusCallback_Release(&iter->IBindStatusCallback_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(window->bscallback) {
|
|
|
|
IBindStatusCallback_Release(&window->bscallback->bsc.IBindStatusCallback_iface);
|
|
|
|
window->bscallback = NULL;
|
2006-09-24 23:39:55 +02:00
|
|
|
}
|
2012-08-14 11:28:37 +02:00
|
|
|
|
|
|
|
if(window->mon) {
|
|
|
|
IMoniker_Release(window->mon);
|
|
|
|
window->mon = NULL;
|
|
|
|
}
|
2006-09-24 23:39:55 +02:00
|
|
|
}
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2013-09-26 17:34:40 +02:00
|
|
|
HRESULT channelbsc_load_stream(HTMLInnerWindow *pending_window, IMoniker *mon, IStream *stream)
|
2007-05-11 13:17:41 +02:00
|
|
|
{
|
2012-07-12 14:25:43 +02:00
|
|
|
nsChannelBSC *bscallback = pending_window->bscallback;
|
2010-08-18 13:39:15 +02:00
|
|
|
HRESULT hres = S_OK;
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2009-11-12 14:51:43 +01:00
|
|
|
if(!bscallback->nschannel) {
|
|
|
|
ERR("NULL nschannel\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2009-11-12 14:51:43 +01:00
|
|
|
bscallback->nschannel->content_type = heap_strdupA("text/html");
|
|
|
|
if(!bscallback->nschannel->content_type)
|
|
|
|
return E_OUTOFMEMORY;
|
2007-05-11 13:17:41 +02:00
|
|
|
|
2013-09-26 17:34:40 +02:00
|
|
|
set_current_mon(pending_window->base.outer_window, mon, 0);
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
bscallback->bsc.window = pending_window;
|
2010-08-18 13:39:15 +02:00
|
|
|
if(stream)
|
|
|
|
hres = read_stream_data(bscallback, stream);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = async_stop_request(bscallback);
|
|
|
|
if(FAILED(hres))
|
2016-04-28 20:54:52 +02:00
|
|
|
IBindStatusCallback_OnStopBinding(&bscallback->bsc.IBindStatusCallback_iface, hres, NULL);
|
2007-05-11 13:17:41 +02:00
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
2008-03-23 02:15:20 +01:00
|
|
|
|
2008-03-23 02:17:17 +01:00
|
|
|
void channelbsc_set_channel(nsChannelBSC *This, nsChannel *channel, nsIStreamListener *listener, nsISupports *context)
|
2008-03-23 02:15:20 +01:00
|
|
|
{
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIHttpChannel_AddRef(&channel->nsIHttpChannel_iface);
|
2008-03-23 02:15:20 +01:00
|
|
|
This->nschannel = channel;
|
|
|
|
|
|
|
|
nsIStreamListener_AddRef(listener);
|
|
|
|
This->nslistener = listener;
|
|
|
|
|
|
|
|
if(context) {
|
|
|
|
nsISupports_AddRef(context);
|
|
|
|
This->nscontext = context;
|
|
|
|
}
|
2010-08-03 21:39:34 +02:00
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
if(This->bsc.request_data.headers) {
|
2010-08-03 21:39:34 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2013-09-26 17:34:49 +02:00
|
|
|
hres = parse_headers(This->bsc.request_data.headers, &channel->request_headers);
|
|
|
|
heap_free(This->bsc.request_data.headers);
|
|
|
|
This->bsc.request_data.headers = NULL;
|
2010-08-03 21:39:34 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
WARN("parse_headers failed: %08x\n", hres);
|
|
|
|
}
|
2008-03-23 02:15:20 +01:00
|
|
|
}
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window;
|
2011-11-15 13:29:43 +01:00
|
|
|
IUri *uri;
|
|
|
|
} navigate_javascript_task_t;
|
|
|
|
|
|
|
|
static void navigate_javascript_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_javascript_task_t *task = (navigate_javascript_task_t*)_task;
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window = task->window;
|
2011-11-15 13:29:43 +01:00
|
|
|
VARIANT v;
|
|
|
|
BSTR code;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
task->window->readystate = READYSTATE_COMPLETE;
|
|
|
|
|
|
|
|
hres = IUri_GetPath(task->uri, &code);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
2012-07-23 14:03:45 +02:00
|
|
|
hres = UrlUnescapeW(code, NULL, NULL, URL_UNESCAPE_INPLACE);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SysFreeString(code);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:14:00 +01:00
|
|
|
set_download_state(window->browser->doc, 1);
|
2011-11-15 13:29:43 +01:00
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
2020-11-24 23:29:19 +01:00
|
|
|
hres = exec_script(window->base.inner_window, code, L"jscript", &v);
|
2011-11-15 13:29:43 +01:00
|
|
|
SysFreeString(code);
|
|
|
|
if(SUCCEEDED(hres) && V_VT(&v) != VT_EMPTY) {
|
|
|
|
FIXME("javascirpt URL returned %s\n", debugstr_variant(&v));
|
|
|
|
VariantClear(&v);
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:14:00 +01:00
|
|
|
if(window->browser->doc->view_sink)
|
|
|
|
IAdviseSink_OnViewChange(window->browser->doc->view_sink, DVASPECT_CONTENT, -1);
|
2011-11-15 13:29:43 +01:00
|
|
|
|
2019-03-14 14:14:00 +01:00
|
|
|
set_download_state(window->browser->doc, 0);
|
2011-11-15 13:29:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void navigate_javascript_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_javascript_task_t *task = (navigate_javascript_task_t*)_task;
|
|
|
|
|
|
|
|
IUri_Release(task->uri);
|
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
task_t header;
|
2012-06-25 14:04:59 +02:00
|
|
|
HTMLOuterWindow *window;
|
2011-11-15 13:29:43 +01:00
|
|
|
nsChannelBSC *bscallback;
|
2012-11-12 12:57:48 +01:00
|
|
|
DWORD flags;
|
2011-11-15 13:29:43 +01:00
|
|
|
IMoniker *mon;
|
2012-11-08 18:16:59 +01:00
|
|
|
IUri *uri;
|
2011-11-15 13:29:43 +01:00
|
|
|
} navigate_task_t;
|
|
|
|
|
|
|
|
static void navigate_proc(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_task_t *task = (navigate_task_t*)_task;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2013-07-25 14:15:54 +02:00
|
|
|
hres = set_moniker(task->window, task->mon, task->uri, NULL, task->bscallback, TRUE);
|
2012-07-12 14:26:13 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
2012-11-12 12:57:48 +01:00
|
|
|
set_current_mon(task->window, task->bscallback->bsc.mon, task->flags);
|
2012-11-08 18:16:59 +01:00
|
|
|
set_current_uri(task->window, task->uri);
|
2012-07-12 14:26:13 +02:00
|
|
|
start_binding(task->window->pending_window, &task->bscallback->bsc, NULL);
|
|
|
|
}
|
2011-11-15 13:29:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void navigate_task_destr(task_t *_task)
|
|
|
|
{
|
|
|
|
navigate_task_t *task = (navigate_task_t*)_task;
|
|
|
|
|
2012-07-12 14:25:43 +02:00
|
|
|
IBindStatusCallback_Release(&task->bscallback->bsc.IBindStatusCallback_iface);
|
2011-11-15 13:29:43 +01:00
|
|
|
IMoniker_Release(task->mon);
|
2012-11-08 18:16:59 +01:00
|
|
|
IUri_Release(task->uri);
|
2011-11-15 13:29:43 +01:00
|
|
|
heap_free(task);
|
|
|
|
}
|
|
|
|
|
2012-06-25 14:04:59 +02:00
|
|
|
static HRESULT navigate_fragment(HTMLOuterWindow *window, IUri *uri)
|
2011-11-15 13:30:28 +01:00
|
|
|
{
|
|
|
|
nsIDOMLocation *nslocation;
|
|
|
|
nsAString nsfrag_str;
|
2012-09-10 14:42:39 +02:00
|
|
|
WCHAR *selector;
|
2011-11-15 13:30:28 +01:00
|
|
|
BSTR frag;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
2020-11-24 23:29:19 +01:00
|
|
|
static const WCHAR selector_formatW[] = L"a[id=\"%s\"]";
|
2012-09-10 14:42:39 +02:00
|
|
|
|
2011-11-15 13:30:28 +01:00
|
|
|
set_current_uri(window, uri);
|
|
|
|
|
|
|
|
nsres = nsIDOMWindow_GetLocation(window->nswindow, &nslocation);
|
|
|
|
if(FAILED(nsres) || !nslocation)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
hres = IUri_GetFragment(uri, &frag);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
nsIDOMLocation_Release(nslocation);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_InitDepend(&nsfrag_str, frag);
|
|
|
|
nsres = nsIDOMLocation_SetHash(nslocation, &nsfrag_str);
|
|
|
|
nsAString_Finish(&nsfrag_str);
|
|
|
|
nsIDOMLocation_Release(nslocation);
|
2012-09-10 14:42:39 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2011-11-15 13:30:28 +01:00
|
|
|
ERR("SetHash failed: %08x\n", nsres);
|
2012-09-10 14:42:39 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IE supports scrolling to anchor elements with "#hash" ids (note that '#' is part of the id),
|
|
|
|
* while Gecko scrolls only to elements with "hash" ids. We scroll the page ourselves if
|
|
|
|
* a[id="#hash"] element can be found.
|
|
|
|
*/
|
|
|
|
selector = heap_alloc(sizeof(selector_formatW)+SysStringLen(frag)*sizeof(WCHAR));
|
|
|
|
if(selector) {
|
|
|
|
nsIDOMElement *nselem = NULL;
|
|
|
|
nsAString selector_str;
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
swprintf(selector, ARRAY_SIZE(selector_formatW)+SysStringLen(frag), selector_formatW, frag);
|
2012-09-10 14:42:39 +02:00
|
|
|
nsAString_InitDepend(&selector_str, selector);
|
|
|
|
/* NOTE: Gecko doesn't set result to NULL if there is no match, so nselem must be initialized */
|
2014-11-03 12:39:59 +01:00
|
|
|
nsres = nsIDOMHTMLDocument_QuerySelector(window->base.inner_window->doc->nsdoc, &selector_str, &nselem);
|
2012-09-10 14:42:39 +02:00
|
|
|
nsAString_Finish(&selector_str);
|
|
|
|
heap_free(selector);
|
|
|
|
if(NS_SUCCEEDED(nsres) && nselem) {
|
|
|
|
nsIDOMHTMLElement *html_elem;
|
|
|
|
|
|
|
|
nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLElement, (void**)&html_elem);
|
|
|
|
nsIDOMElement_Release(nselem);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMHTMLElement_ScrollIntoView(html_elem, TRUE, 1);
|
|
|
|
nsIDOMHTMLElement_Release(html_elem);
|
|
|
|
}
|
|
|
|
}
|
2011-11-15 13:30:28 +01:00
|
|
|
}
|
|
|
|
|
2012-09-10 14:42:39 +02:00
|
|
|
SysFreeString(frag);
|
|
|
|
|
2019-03-14 14:14:00 +01:00
|
|
|
if(window->browser->doc->doc_object_service) {
|
|
|
|
IDocObjectService_FireNavigateComplete2(window->browser->doc->doc_object_service, &window->base.IHTMLWindow2_iface, 0x10);
|
|
|
|
IDocObjectService_FireDocumentComplete(window->browser->doc->doc_object_service, &window->base.IHTMLWindow2_iface, 0);
|
2011-11-15 13:30:28 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-08 18:17:35 +01:00
|
|
|
HRESULT super_navigate(HTMLOuterWindow *window, IUri *uri, DWORD flags, const WCHAR *headers, BYTE *post_data, DWORD post_data_size)
|
2011-11-15 13:29:43 +01:00
|
|
|
{
|
|
|
|
nsChannelBSC *bsc;
|
2012-11-08 18:17:12 +01:00
|
|
|
IUri *uri_nofrag;
|
2011-11-15 13:29:43 +01:00
|
|
|
IMoniker *mon;
|
|
|
|
DWORD scheme;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-11-08 18:17:12 +01:00
|
|
|
uri_nofrag = get_uri_nofrag(uri);
|
|
|
|
if(!uri_nofrag)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2019-03-14 14:14:08 +01:00
|
|
|
if(window->browser->doc->client && !(flags & BINDING_REFRESH)) {
|
2011-11-15 13:29:43 +01:00
|
|
|
IOleCommandTarget *cmdtrg;
|
|
|
|
|
2019-03-14 14:14:08 +01:00
|
|
|
hres = IOleClientSite_QueryInterface(window->browser->doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
|
2011-11-15 13:29:43 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
VARIANT in, out;
|
|
|
|
BSTR url_str;
|
|
|
|
|
2012-11-08 18:17:12 +01:00
|
|
|
hres = IUri_GetDisplayUri(uri_nofrag, &url_str);
|
2011-11-15 13:29:43 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
V_VT(&in) = VT_BSTR;
|
|
|
|
V_BSTR(&in) = url_str;
|
|
|
|
V_VT(&out) = VT_BOOL;
|
|
|
|
V_BOOL(&out) = VARIANT_TRUE;
|
|
|
|
hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 67, 0, &in, &out);
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
VariantClear(&out);
|
|
|
|
SysFreeString(url_str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:48:31 +01:00
|
|
|
if(!(flags & BINDING_NOFRAG) && window->uri_nofrag && !post_data_size) {
|
2012-11-08 18:17:12 +01:00
|
|
|
BOOL eq;
|
|
|
|
|
|
|
|
hres = IUri_IsEqual(uri_nofrag, window->uri_nofrag, &eq);
|
|
|
|
if(SUCCEEDED(hres) && eq) {
|
|
|
|
IUri_Release(uri_nofrag);
|
|
|
|
TRACE("fragment navigate\n");
|
|
|
|
return navigate_fragment(window, uri);
|
|
|
|
}
|
2011-11-15 13:30:28 +01:00
|
|
|
}
|
|
|
|
|
2012-11-08 18:17:12 +01:00
|
|
|
hres = CreateURLMonikerEx2(NULL, uri_nofrag, &mon, URL_MK_UNIFORM);
|
|
|
|
IUri_Release(uri_nofrag);
|
2011-11-15 13:29:43 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/* FIXME: Why not set_ready_state? */
|
|
|
|
window->readystate = READYSTATE_UNINITIALIZED;
|
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
hres = create_channelbsc(mon, headers, post_data, post_data_size, TRUE, &bsc);
|
2011-11-15 13:29:43 +01:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:14:08 +01:00
|
|
|
prepare_for_binding(&window->browser->doc->basedoc, mon, flags);
|
2011-11-15 13:29:43 +01:00
|
|
|
|
|
|
|
hres = IUri_GetScheme(uri, &scheme);
|
2013-09-27 15:22:30 +02:00
|
|
|
if(SUCCEEDED(hres) && scheme == URL_SCHEME_JAVASCRIPT) {
|
|
|
|
navigate_javascript_task_t *task;
|
|
|
|
|
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(*task));
|
|
|
|
if(!task)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
/* Why silently? */
|
|
|
|
window->readystate = READYSTATE_COMPLETE;
|
|
|
|
if(!(flags & BINDING_FROMHIST))
|
2019-03-14 14:14:08 +01:00
|
|
|
call_docview_84(window->browser->doc);
|
2013-09-27 15:22:30 +02:00
|
|
|
|
|
|
|
IUri_AddRef(uri);
|
|
|
|
task->window = window;
|
|
|
|
task->uri = uri;
|
|
|
|
hres = push_task(&task->header, navigate_javascript_proc, navigate_javascript_task_destr, window->task_magic);
|
|
|
|
}else if(flags & BINDING_SUBMIT) {
|
|
|
|
hres = set_moniker(window, mon, uri, NULL, bsc, TRUE);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = start_binding(window->pending_window, &bsc->bsc, NULL);
|
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}else {
|
2011-11-15 13:29:43 +01:00
|
|
|
navigate_task_t *task;
|
|
|
|
|
|
|
|
task = heap_alloc(sizeof(*task));
|
|
|
|
if(!task) {
|
2012-07-12 14:25:43 +02:00
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
2011-11-15 13:29:43 +01:00
|
|
|
IMoniker_Release(mon);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2012-05-29 14:38:04 +02:00
|
|
|
/* Silently and repeated when real loading starts? */
|
|
|
|
window->readystate = READYSTATE_LOADING;
|
2012-11-12 12:58:41 +01:00
|
|
|
if(!(flags & (BINDING_FROMHIST|BINDING_REFRESH)))
|
2019-03-14 14:14:08 +01:00
|
|
|
call_docview_84(window->browser->doc);
|
2012-05-29 14:38:04 +02:00
|
|
|
|
2011-11-15 13:29:43 +01:00
|
|
|
task->window = window;
|
|
|
|
task->bscallback = bsc;
|
2012-11-12 12:57:48 +01:00
|
|
|
task->flags = flags;
|
2011-11-15 13:29:43 +01:00
|
|
|
task->mon = mon;
|
2012-11-08 18:16:59 +01:00
|
|
|
|
|
|
|
IUri_AddRef(uri);
|
|
|
|
task->uri = uri;
|
2012-10-19 11:56:59 +02:00
|
|
|
hres = push_task(&task->header, navigate_proc, navigate_task_destr, window->task_magic);
|
2011-11-15 13:29:43 +01:00
|
|
|
}
|
|
|
|
|
2012-10-19 11:56:59 +02:00
|
|
|
return hres;
|
2011-11-15 13:29:43 +01:00
|
|
|
}
|
|
|
|
|
2014-12-16 16:13:05 +01:00
|
|
|
HRESULT navigate_new_window(HTMLOuterWindow *window, IUri *uri, const WCHAR *name, request_data_t *request_data, IHTMLWindow2 **ret)
|
2012-01-09 17:56:54 +01:00
|
|
|
{
|
2017-06-21 17:05:31 +02:00
|
|
|
INewWindowManager *new_window_mgr;
|
|
|
|
BSTR display_uri, context_url;
|
2012-01-09 17:56:54 +01:00
|
|
|
IWebBrowser2 *web_browser;
|
|
|
|
IHTMLWindow2 *new_window;
|
|
|
|
IBindCtx *bind_ctx;
|
|
|
|
nsChannelBSC *bsc;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2019-03-14 14:14:15 +01:00
|
|
|
if(!window->browser)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if (window->browser->doc->client) {
|
|
|
|
hres = do_query_service((IUnknown*)window->browser->doc->client, &SID_SNewWindowManager,
|
2017-09-21 16:59:43 +02:00
|
|
|
&IID_INewWindowManager, (void**)&new_window_mgr);
|
|
|
|
if (FAILED(hres)) {
|
|
|
|
FIXME("No INewWindowManager\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2017-06-21 17:05:31 +02:00
|
|
|
hres = IUri_GetDisplayUri(window->uri_nofrag, &context_url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(uri, &display_uri);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SysFreeString(context_url);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, display_uri, name, context_url,
|
2019-03-14 14:14:15 +01:00
|
|
|
NULL, FALSE, window->browser->doc->has_popup ? 0 : NWMF_FIRST, 0);
|
|
|
|
window->browser->doc->has_popup = TRUE;
|
2017-06-21 17:05:31 +02:00
|
|
|
SysFreeString(display_uri);
|
|
|
|
SysFreeString(context_url);
|
|
|
|
INewWindowManager_Release(new_window_mgr);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
if(ret)
|
|
|
|
*ret = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-16 16:13:05 +01:00
|
|
|
if(request_data)
|
|
|
|
hres = create_channelbsc(NULL, request_data->headers,
|
|
|
|
request_data->post_data, request_data->post_data_len, FALSE,
|
|
|
|
&bsc);
|
|
|
|
else
|
|
|
|
hres = create_channelbsc(NULL, NULL, NULL, 0, FALSE, &bsc);
|
2012-01-09 17:56:54 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CreateAsyncBindCtx(0, &bsc->bsc.IBindStatusCallback_iface, NULL, &bind_ctx);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER,
|
|
|
|
&IID_IWebBrowser2, (void**)&web_browser);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
ITargetFramePriv2 *target_frame_priv;
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
hres = IWebBrowser2_QueryInterface(web_browser, &IID_ITargetFramePriv2, (void**)&target_frame_priv);
|
2012-01-09 17:56:54 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = ITargetFramePriv2_AggregatedNavigation2(target_frame_priv,
|
|
|
|
HLNF_DISABLEWINDOWRESTRICTIONS|HLNF_OPENINNEWWINDOW, bind_ctx, &bsc->bsc.IBindStatusCallback_iface,
|
2020-11-24 23:29:19 +01:00
|
|
|
name, uri, L"");
|
2012-01-09 17:56:54 +01:00
|
|
|
ITargetFramePriv2_Release(target_frame_priv);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = do_query_service((IUnknown*)web_browser, &SID_SHTMLWindow, &IID_IHTMLWindow2, (void**)&new_window);
|
|
|
|
}
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IWebBrowser2_Quit(web_browser);
|
|
|
|
IWebBrowser2_Release(web_browser);
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
WARN("Could not create InternetExplorer instance: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
|
|
|
IBindStatusCallback_Release(&bsc->bsc.IBindStatusCallback_iface);
|
|
|
|
IBindCtx_Release(bind_ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
IWebBrowser2_put_Visible(web_browser, VARIANT_TRUE);
|
|
|
|
IWebBrowser2_Release(web_browser);
|
|
|
|
|
2012-01-10 17:07:36 +01:00
|
|
|
if(ret)
|
|
|
|
*ret = new_window;
|
|
|
|
else
|
|
|
|
IHTMLWindow2_Release(new_window);
|
2012-01-09 17:56:54 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-05 15:23:25 +02:00
|
|
|
HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, nsChannel *nschannel, DWORD hlnf, BOOL *cancel)
|
2008-03-23 02:16:36 +01:00
|
|
|
{
|
2009-10-11 21:11:03 +02:00
|
|
|
IHlinkFrame *hlink_frame;
|
2010-03-03 14:53:49 +01:00
|
|
|
nsChannelBSC *callback;
|
2008-03-23 02:16:36 +01:00
|
|
|
IBindCtx *bindctx;
|
|
|
|
IMoniker *mon;
|
|
|
|
IHlink *hlink;
|
2009-10-11 21:11:03 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2010-03-03 14:54:44 +01:00
|
|
|
*cancel = FALSE;
|
|
|
|
|
2012-01-05 18:30:27 +01:00
|
|
|
hres = do_query_service((IUnknown*)doc->doc_obj->client, &IID_IHlinkFrame, &IID_IHlinkFrame,
|
2009-10-11 21:11:03 +02:00
|
|
|
(void**)&hlink_frame);
|
|
|
|
if(FAILED(hres))
|
2010-03-03 14:54:44 +01:00
|
|
|
return S_OK;
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2012-07-12 14:26:13 +02:00
|
|
|
hres = create_channelbsc(NULL, NULL, NULL, 0, FALSE, &callback);
|
2010-03-03 14:53:49 +01:00
|
|
|
if(FAILED(hres)) {
|
|
|
|
IHlinkFrame_Release(hlink_frame);
|
|
|
|
return hres;
|
|
|
|
}
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2011-04-05 15:23:25 +02:00
|
|
|
if(nschannel)
|
2013-09-26 17:34:49 +02:00
|
|
|
read_post_data_stream(nschannel->post_data_stream, nschannel->post_data_contains_headers,
|
|
|
|
&nschannel->request_headers, &callback->bsc.request_data);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
hres = CreateAsyncBindCtx(0, &callback->bsc.IBindStatusCallback_iface, NULL, &bindctx);
|
2009-10-11 21:11:03 +02:00
|
|
|
if(SUCCEEDED(hres))
|
2012-11-08 18:17:35 +01:00
|
|
|
hres = CoCreateInstance(&CLSID_StdHlink, NULL, CLSCTX_INPROC_SERVER,
|
2009-10-11 21:11:03 +02:00
|
|
|
&IID_IHlink, (LPVOID*)&hlink);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = CreateURLMoniker(NULL, url, &mon);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
2009-10-20 23:33:27 +02:00
|
|
|
IHlink_SetMonikerReference(hlink, HLINKSETF_TARGET, mon, NULL);
|
2008-03-23 02:16:36 +01:00
|
|
|
|
|
|
|
if(hlnf & HLNF_OPENINNEWWINDOW) {
|
2020-11-24 23:29:19 +01:00
|
|
|
IHlink_SetTargetFrameName(hlink, L"_blank"); /* FIXME */
|
2008-03-23 02:16:36 +01:00
|
|
|
}
|
|
|
|
|
2011-01-03 01:13:16 +01:00
|
|
|
hres = IHlinkFrame_Navigate(hlink_frame, hlnf, bindctx,
|
|
|
|
&callback->bsc.IBindStatusCallback_iface, hlink);
|
2008-03-23 02:16:36 +01:00
|
|
|
IMoniker_Release(mon);
|
2010-03-03 14:54:44 +01:00
|
|
|
*cancel = hres == S_OK;
|
|
|
|
hres = S_OK;
|
2008-03-23 02:16:36 +01:00
|
|
|
}
|
|
|
|
|
2009-10-11 21:11:03 +02:00
|
|
|
IHlinkFrame_Release(hlink_frame);
|
2008-03-23 02:16:36 +01:00
|
|
|
IBindCtx_Release(bindctx);
|
2011-01-03 01:13:16 +01:00
|
|
|
IBindStatusCallback_Release(&callback->bsc.IBindStatusCallback_iface);
|
2009-10-11 21:11:03 +02:00
|
|
|
return hres;
|
2008-03-23 02:16:36 +01:00
|
|
|
}
|
2009-10-11 21:11:35 +02:00
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
static HRESULT navigate_uri(HTMLOuterWindow *window, IUri *uri, const WCHAR *display_uri, const request_data_t *request_data,
|
|
|
|
DWORD flags)
|
2009-10-11 21:11:35 +02:00
|
|
|
{
|
2012-09-21 12:24:37 +02:00
|
|
|
nsWineURI *nsuri;
|
2009-10-11 21:11:35 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2013-04-04 16:15:33 +02:00
|
|
|
TRACE("%s\n", debugstr_w(display_uri));
|
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
if(!window->browser)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if(window->browser->doc->webbrowser) {
|
2013-09-27 15:22:30 +02:00
|
|
|
DWORD post_data_len = request_data ? request_data->post_data_len : 0;
|
|
|
|
void *post_data = post_data_len ? request_data->post_data : NULL;
|
|
|
|
const WCHAR *headers = request_data ? request_data->headers : NULL;
|
|
|
|
|
2012-11-12 12:58:41 +01:00
|
|
|
if(!(flags & BINDING_REFRESH)) {
|
2015-02-11 13:06:04 +01:00
|
|
|
BSTR frame_name = NULL;
|
2012-11-12 12:58:41 +01:00
|
|
|
BOOL cancel = FALSE;
|
2011-11-15 13:29:59 +01:00
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
if(!is_main_content_window(window)) {
|
2015-02-11 13:06:04 +01:00
|
|
|
hres = IHTMLWindow2_get_name(&window->base.IHTMLWindow2_iface, &frame_name);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
hres = IDocObjectService_FireBeforeNavigate2(window->browser->doc->doc_object_service, NULL, display_uri, 0x40,
|
2015-02-11 13:06:04 +01:00
|
|
|
frame_name, post_data, post_data_len ? post_data_len+1 : 0, headers, TRUE, &cancel);
|
|
|
|
SysFreeString(frame_name);
|
2012-11-12 12:58:41 +01:00
|
|
|
if(SUCCEEDED(hres) && cancel) {
|
|
|
|
TRACE("Navigation canceled\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-11-15 13:29:59 +01:00
|
|
|
}
|
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
if(is_main_content_window(window))
|
2015-02-11 13:06:04 +01:00
|
|
|
return super_navigate(window, uri, flags, headers, post_data, post_data_len);
|
2011-11-15 13:29:59 +01:00
|
|
|
}
|
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
if(is_main_content_window(window)) {
|
2010-03-03 14:54:44 +01:00
|
|
|
BOOL cancel;
|
|
|
|
|
2012-09-21 12:24:37 +02:00
|
|
|
hres = hlink_frame_navigate(&window->base.inner_window->doc->basedoc, display_uri, NULL, 0, &cancel);
|
2010-03-03 14:54:44 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(cancel) {
|
|
|
|
TRACE("Navigation handled by hlink frame\n");
|
2009-11-30 18:01:31 +01:00
|
|
|
return S_OK;
|
2010-03-03 14:54:44 +01:00
|
|
|
}
|
2009-11-30 18:01:31 +01:00
|
|
|
}
|
2009-10-11 21:11:35 +02:00
|
|
|
|
2019-03-08 13:48:11 +01:00
|
|
|
hres = create_doc_uri(uri, &nsuri);
|
2012-09-21 12:24:37 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2015-02-02 13:43:49 +01:00
|
|
|
hres = load_nsuri(window, nsuri, request_data ? request_data->post_stream : NULL, NULL, LOAD_FLAGS_NONE);
|
2012-09-21 12:24:37 +02:00
|
|
|
nsISupports_Release((nsISupports*)nsuri);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2012-11-08 18:17:55 +01:00
|
|
|
HRESULT load_uri(HTMLOuterWindow *window, IUri *uri, DWORD flags)
|
|
|
|
{
|
|
|
|
BSTR display_uri;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(uri, &display_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
hres = navigate_uri(window, uri, display_uri, NULL, flags);
|
2012-11-08 18:17:55 +01:00
|
|
|
SysFreeString(display_uri);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
static HRESULT translate_uri(HTMLOuterWindow *window, IUri *orig_uri, BSTR *ret_display_uri, IUri **ret_uri)
|
2012-09-21 12:24:37 +02:00
|
|
|
{
|
2013-09-27 15:22:30 +02:00
|
|
|
IUri *uri = NULL;
|
2012-09-21 12:24:37 +02:00
|
|
|
BSTR display_uri;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
hres = IUri_GetDisplayUri(orig_uri, &display_uri);
|
2010-01-04 00:38:57 +01:00
|
|
|
if(FAILED(hres))
|
2009-11-30 18:01:31 +01:00
|
|
|
return hres;
|
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
if(window->browser->doc->hostui) {
|
2012-09-21 12:24:37 +02:00
|
|
|
OLECHAR *translated_url = NULL;
|
|
|
|
|
2019-03-14 14:14:26 +01:00
|
|
|
hres = IDocHostUIHandler_TranslateUrl(window->browser->doc->hostui, 0, display_uri,
|
2012-09-21 12:24:37 +02:00
|
|
|
&translated_url);
|
2015-02-25 12:59:20 +01:00
|
|
|
if(hres == S_OK && translated_url) {
|
2012-09-21 12:24:37 +02:00
|
|
|
TRACE("%08x %s -> %s\n", hres, debugstr_w(display_uri), debugstr_w(translated_url));
|
|
|
|
SysFreeString(display_uri);
|
2013-03-26 11:37:47 +01:00
|
|
|
hres = create_uri(translated_url, 0, &uri);
|
2012-09-21 12:24:37 +02:00
|
|
|
CoTaskMemFree(translated_url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IUri_GetDisplayUri(uri, &display_uri);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IUri_Release(uri);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
if(!uri) {
|
|
|
|
IUri_AddRef(orig_uri);
|
|
|
|
uri = orig_uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret_display_uri = display_uri;
|
|
|
|
*ret_uri = uri;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-16 16:13:05 +01:00
|
|
|
HRESULT submit_form(HTMLOuterWindow *window, const WCHAR *target, IUri *submit_uri, nsIInputStream *post_stream)
|
2013-09-27 15:22:30 +02:00
|
|
|
{
|
|
|
|
request_data_t request_data = {NULL};
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = read_post_data_stream(post_stream, TRUE, NULL, &request_data);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2014-12-16 16:13:05 +01:00
|
|
|
if(window) {
|
|
|
|
IUri *uri;
|
|
|
|
BSTR display_uri;
|
|
|
|
|
|
|
|
window->readystate_locked++;
|
|
|
|
|
|
|
|
hres = translate_uri(window, submit_uri, &display_uri, &uri);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = navigate_uri(window, uri, display_uri, &request_data, BINDING_NAVIGATED|BINDING_SUBMIT);
|
|
|
|
IUri_Release(uri);
|
|
|
|
SysFreeString(display_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
window->readystate_locked--;
|
|
|
|
}else
|
|
|
|
hres = navigate_new_window(window, submit_uri, target, &request_data, NULL);
|
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
release_request_data(&request_data);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT navigate_url(HTMLOuterWindow *window, const WCHAR *new_url, IUri *base_uri, DWORD flags)
|
|
|
|
{
|
|
|
|
IUri *uri, *nav_uri;
|
|
|
|
BSTR display_uri;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(new_url && base_uri)
|
|
|
|
hres = CoInternetCombineUrlEx(base_uri, new_url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO,
|
|
|
|
&nav_uri, 0);
|
|
|
|
else
|
|
|
|
hres = create_uri(new_url, 0, &nav_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = translate_uri(window, nav_uri, &display_uri, &uri);
|
|
|
|
IUri_Release(nav_uri);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2012-09-21 12:24:37 +02:00
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
hres = navigate_uri(window, uri, display_uri, NULL, flags);
|
2012-09-21 12:24:37 +02:00
|
|
|
IUri_Release(uri);
|
|
|
|
SysFreeString(display_uri);
|
2010-01-04 00:38:57 +01:00
|
|
|
return hres;
|
2009-10-11 21:11:35 +02:00
|
|
|
}
|