Commit 4e3bd6e6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

shdocvw: Delay creating URL moniker to bind_to_object call.

parent 1a7bf2e0
......@@ -20,7 +20,6 @@
#define NONAMELESSSTRUCT
#include "wine/debug.h"
#include "wine/unicode.h"
#include "shdocvw.h"
#include "mshtml.h"
......@@ -388,8 +387,8 @@ static const IHttpNegotiateVtbl HttpNegotiateVtbl = {
HttpNegotiate_OnResponse
};
static IBindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE post_data,
ULONG post_data_len, LPWSTR headers)
static BindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYTE post_data,
ULONG post_data_len, LPCWSTR headers)
{
BindStatusCallback *ret = heap_alloc(sizeof(BindStatusCallback));
......@@ -416,7 +415,7 @@ static IBindStatusCallback *create_callback(DocHost *doc_host, LPCWSTR url, PBYT
memcpy(ret->headers, headers, size);
}
return BINDSC(ret);
return ret;
}
static void on_before_navigate2(DocHost *This, LPCWSTR url, const BYTE *post_data,
......@@ -567,12 +566,24 @@ static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCt
static const WCHAR httpsW[] = {'h','t','t','p','s',0};
static const WCHAR ftpW[]= {'f','t','p',0};
if(mon) {
IMoniker_AddRef(mon);
}else {
hres = CreateURLMoniker(NULL, url, &mon);
if(FAILED(hres)) {
WARN("CreateURLMoniker failed: %08x\n", hres);
return hres;
}
}
CoTaskMemFree(This->url);
hres = IMoniker_GetDisplayName(mon, 0, NULL, &This->url);
if(FAILED(hres))
FIXME("GetDisplayName failed: %08x\n", hres);
IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM,
(IUnknown*)CLIENTSITE(This));
if(This->frame)
IOleInPlaceFrame_EnableModeless(This->frame, FALSE);
hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
&schema_len, 0);
if(SUCCEEDED(hres) &&
......@@ -586,49 +597,42 @@ static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCt
hres = S_OK;
if(unk)
IUnknown_Release(unk);
}else if(try_application_url(This->url)) {
}else if(try_application_url(url)) {
hres = S_OK;
}else {
FIXME("BindToObject failed: %08x\n", hres);
}
}
if(This->frame)
IOleInPlaceFrame_EnableModeless(This->frame, TRUE);
IMoniker_Release(mon);
return S_OK;
}
static HRESULT navigate_mon(DocHost *This, IMoniker *mon, PBYTE post_data, ULONG post_data_len,
LPWSTR headers)
static HRESULT navigate_bsc(DocHost *This, BindStatusCallback *bsc, IMoniker *mon)
{
IBindStatusCallback *callback;
IBindCtx *bindctx;
VARIANT_BOOL cancel = VARIANT_FALSE;
LPWSTR url;
HRESULT hres;
IMoniker_GetDisplayName(mon, NULL, NULL, &url);
TRACE("navigating to %s\n", debugstr_w(url));
on_before_navigate2(This, url, post_data, post_data_len, headers, &cancel);
on_before_navigate2(This, bsc->url, bsc->post_data, bsc->post_data_len, bsc->headers, &cancel);
if(cancel) {
FIXME("Navigation canceled\n");
CoTaskMemFree(url);
return S_OK;
}
if(This->document)
deactivate_document(This);
CoTaskMemFree(This->url);
This->url = url;
callback = create_callback(This, url, post_data, post_data_len, (LPWSTR)headers);
CreateAsyncBindCtx(0, callback, 0, &bindctx);
CreateAsyncBindCtx(0, BINDSC(bsc), 0, &bindctx);
if(This->frame)
IOleInPlaceFrame_EnableModeless(This->frame, FALSE);
hres = bind_to_object(This, mon, bsc->url, bindctx, BINDSC(bsc));
hres = bind_to_object(This, mon, This->url, bindctx, callback);
if(This->frame)
IOleInPlaceFrame_EnableModeless(This->frame, TRUE);
IBindStatusCallback_Release(callback);
IBindCtx_Release(bindctx);
return hres;
......@@ -637,20 +641,13 @@ static HRESULT navigate_mon(DocHost *This, IMoniker *mon, PBYTE post_data, ULONG
HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags,
const VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
{
IMoniker *mon;
BindStatusCallback *bsc;
PBYTE post_data = NULL;
ULONG post_data_len = 0;
LPWSTR headers = NULL;
HRESULT hres;
TRACE("navigating to %s\n", debugstr_w(url));
hres = CreateURLMoniker(NULL, url, &mon);
if(FAILED(hres)) {
WARN("CreateURLMoniker failed: %08x\n", hres);
return hres;
}
if((Flags && V_VT(Flags) != VT_EMPTY)
|| (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY))
FIXME("Unsupported args (Flags %p:%d; TargetFrameName %p:%d)\n",
......@@ -677,22 +674,25 @@ HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags,
if(!This->hwnd)
create_doc_view_hwnd(This);
hres = navigate_mon(This, mon, post_data, post_data_len, headers);
IMoniker_Release(mon);
bsc = create_callback(This, url, post_data, post_data_len, headers);
if(post_data)
SafeArrayUnaccessData(V_ARRAY(PostData));
return hres;
navigate_bsc(This, bsc, NULL);
IBindStatusCallback_Release(BINDSC(bsc));
return S_OK;
}
static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
IBindStatusCallback *callback)
{
IHttpNegotiate *http_negotiate;
BindStatusCallback *bsc;
PBYTE post_data = NULL;
ULONG post_data_len = 0;
LPWSTR headers = NULL;
LPWSTR headers = NULL, url;
BINDINFO bindinfo;
DWORD bindf = 0;
HRESULT hres;
......@@ -718,8 +718,16 @@ static HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx,
post_data = bindinfo.stgmedData.u.hGlobal;
}
hres = navigate_mon(This, mon, post_data, post_data_len, headers);
hres = IMoniker_GetDisplayName(mon, 0, NULL, &url);
if(FAILED(hres))
FIXME("GetDisplayName failed: %08x\n", hres);
bsc = create_callback(This, url, post_data, post_data_len, headers);
CoTaskMemFree(url);
hres = navigate_bsc(This, bsc, mon);
IBindStatusCallback_Release(BINDSC(bsc));
CoTaskMemFree(headers);
ReleaseBindInfo(&bindinfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment