From 02b54914e53ed820d369ee105fc946efd454ea4f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 19 Oct 2006 23:14:00 +0200 Subject: [PATCH] shdocvw: Move common Navigate2 code to navigate_url. --- dlls/shdocvw/ie.c | 36 +++----------------------------- dlls/shdocvw/navigate.c | 43 ++++++++++++++++++++++++++++++++++++++- dlls/shdocvw/shdocvw.h | 2 +- dlls/shdocvw/webbrowser.c | 37 +++------------------------------ 4 files changed, 49 insertions(+), 69 deletions(-) diff --git a/dlls/shdocvw/ie.c b/dlls/shdocvw/ie.c index 2c2414b1c79..e4400ec5749 100644 --- a/dlls/shdocvw/ie.c +++ b/dlls/shdocvw/ie.c @@ -442,48 +442,18 @@ static HRESULT WINAPI InternetExplorer_Navigate2(IWebBrowser2 *iface, VARIANT *U VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers) { InternetExplorer *This = WEBBROWSER_THIS(iface); - PBYTE post_data = NULL; - ULONG post_data_len = 0; - LPWSTR headers = NULL; - HRESULT hres; TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers); - if((Flags && V_VT(Flags) != VT_EMPTY) - || (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY)) - FIXME("Unsupported arguments\n"); - if(!URL) return S_OK; - if(V_VT(URL) != VT_BSTR) + if(V_VT(URL) != VT_BSTR) { + FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL)); return E_INVALIDARG; - - if(PostData && V_VT(PostData) != VT_EMPTY) { - if(V_VT(PostData) != (VT_ARRAY | VT_UI1) - || V_ARRAY(PostData)->cDims != 1) { - WARN("Invalid PostData\n"); - return E_INVALIDARG; - } - - SafeArrayAccessData(V_ARRAY(PostData), (void**)&post_data); - post_data_len = V_ARRAY(PostData)->rgsabound[0].cElements; } - if(Headers && V_VT(Headers) != VT_EMPTY) { - if(V_VT(Headers) != VT_BSTR) - return E_INVALIDARG; - - headers = V_BSTR(Headers); - TRACE("Headers: %s\n", debugstr_w(headers)); - } - - hres = navigate_url(&This->doc_host, V_BSTR(URL), post_data, post_data_len, headers); - - if(post_data) - SafeArrayUnaccessData(V_ARRAY(PostData)); - - return hres; + return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers); } static HRESULT WINAPI InternetExplorer_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf) diff --git a/dlls/shdocvw/navigate.c b/dlls/shdocvw/navigate.c index 7ca73ac831b..b57df99a596 100644 --- a/dlls/shdocvw/navigate.c +++ b/dlls/shdocvw/navigate.c @@ -476,7 +476,7 @@ static HRESULT navigate(DocHost *This, IMoniker *mon, IBindCtx *bindctx, } -HRESULT navigate_url(DocHost *This, LPCWSTR url, PBYTE post_data, ULONG post_data_len, +static HRESULT bind_url_to_object(DocHost *This, LPCWSTR url, PBYTE post_data, ULONG post_data_len, LPWSTR headers) { IBindStatusCallback *callback; @@ -507,6 +507,47 @@ HRESULT navigate_url(DocHost *This, LPCWSTR url, PBYTE post_data, ULONG post_dat return hres; } +HRESULT navigate_url(DocHost *This, BSTR url, VARIANT *Flags, VARIANT *TargetFrameName, + VARIANT *PostData, VARIANT *Headers) +{ + PBYTE post_data = NULL; + ULONG post_data_len = 0; + LPWSTR headers = NULL; + HRESULT hres; + + TRACE("navigating to %s\n", debugstr_w(url)); + + if((Flags && V_VT(Flags) != VT_EMPTY) + || (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY)) + FIXME("Unsupported arguments\n"); + + if(PostData && V_VT(PostData) != VT_EMPTY && V_VT(PostData) != VT_ERROR) { + if(V_VT(PostData) != (VT_ARRAY | VT_UI1) + || V_ARRAY(PostData)->cDims != 1) { + WARN("Invalid PostData\n"); + return E_INVALIDARG; + } + + SafeArrayAccessData(V_ARRAY(PostData), (void**)&post_data); + post_data_len = V_ARRAY(PostData)->rgsabound[0].cElements; + } + + if(Headers && V_VT(Headers) != VT_EMPTY && V_VT(Headers) != VT_ERROR) { + if(V_VT(Headers) != VT_BSTR) + return E_INVALIDARG; + + headers = V_BSTR(Headers); + TRACE("Headers: %s\n", debugstr_w(headers)); + } + + hres = bind_url_to_object(This, url, post_data, post_data_len, headers); + + if(post_data) + SafeArrayUnaccessData(V_ARRAY(PostData)); + + return hres; +} + HRESULT navigate_hlink(DocHost *This, IMoniker *mon, IBindCtx *bindctx, IBindStatusCallback *callback) { diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h index a022eb2b67c..e8ca951916a 100644 --- a/dlls/shdocvw/shdocvw.h +++ b/dlls/shdocvw/shdocvw.h @@ -192,7 +192,7 @@ HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**); void create_doc_view_hwnd(DocHost*); void deactivate_document(DocHost*); void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*); -HRESULT navigate_url(DocHost*,LPCWSTR,PBYTE,ULONG,LPWSTR); +HRESULT navigate_url(DocHost*,BSTR,VARIANT*,VARIANT*,VARIANT*,VARIANT*); HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**); void InternetExplorer_WebBrowser_Init(InternetExplorer*); diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c index 20fb8bfd2ed..47483c12b62 100644 --- a/dlls/shdocvw/webbrowser.c +++ b/dlls/shdocvw/webbrowser.c @@ -660,52 +660,21 @@ static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VA VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers) { WebBrowser *This = WEBBROWSER_THIS(iface); - PBYTE post_data = NULL; - ULONG post_data_len = 0; - LPWSTR headers = NULL; - HRESULT hres; TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers); if(!This->client) return E_FAIL; - if((Flags && V_VT(Flags) != VT_EMPTY) - || (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY)) - FIXME("Unsupported arguments\n"); - - if(!URL) return S_OK; - if(V_VT(URL) != VT_BSTR) + if(V_VT(URL) != VT_BSTR) { + FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL)); return E_INVALIDARG; - - if(PostData && V_VT(PostData) != VT_EMPTY && V_VT(PostData) != VT_ERROR) { - if(V_VT(PostData) != (VT_ARRAY | VT_UI1) - || V_ARRAY(PostData)->cDims != 1) { - WARN("Invalid PostData\n"); - return E_INVALIDARG; - } - - SafeArrayAccessData(V_ARRAY(PostData), (void**)&post_data); - post_data_len = V_ARRAY(PostData)->rgsabound[0].cElements; } - if(Headers && V_VT(Headers) != VT_EMPTY && V_VT(Headers) != VT_ERROR) { - if(V_VT(Headers) != VT_BSTR) - return E_INVALIDARG; - - headers = V_BSTR(Headers); - TRACE("Headers: %s\n", debugstr_w(headers)); - } - - hres = navigate_url(&This->doc_host, V_BSTR(URL), post_data, post_data_len, headers); - - if(post_data) - SafeArrayUnaccessData(V_ARRAY(PostData)); - - return hres; + return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers); } static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)