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