Commit 2e6353d4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use nsIDocShell to load a page in set_moniker.

parent d60ebb30
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
typedef struct HTMLDOMNode HTMLDOMNode; typedef struct HTMLDOMNode HTMLDOMNode;
typedef struct ConnectionPoint ConnectionPoint; typedef struct ConnectionPoint ConnectionPoint;
typedef struct BSCallback BSCallback; typedef struct BSCallback BSCallback;
typedef struct nsChannelBSC nsChannelBSC;
typedef struct event_target_t event_target_t; typedef struct event_target_t event_target_t;
/* NOTE: make sure to keep in sync with dispex.c */ /* NOTE: make sure to keep in sync with dispex.c */
...@@ -425,7 +424,6 @@ struct NSContainer { ...@@ -425,7 +424,6 @@ struct NSContainer {
HWND hwnd; HWND hwnd;
nsChannelBSC *bscallback; /* hack */
HWND reset_focus; /* hack */ HWND reset_focus; /* hack */
}; };
...@@ -687,6 +685,7 @@ HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsIWineURI**); ...@@ -687,6 +685,7 @@ HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsIWineURI**);
HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD); HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*); HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*); HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
HRESULT load_nsuri(HTMLWindow*,nsIWineURI*,DWORD);
void call_property_onchanged(ConnectionPoint*,DISPID); void call_property_onchanged(ConnectionPoint*,DISPID);
HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*); HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
......
...@@ -1253,14 +1253,39 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url, ...@@ -1253,14 +1253,39 @@ HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url,
return hres; return hres;
} }
HRESULT load_nsuri(HTMLWindow *window, nsIWineURI *uri, DWORD flags)
{
nsIWebNavigation *web_navigation;
nsIDocShell *doc_shell;
nsresult nsres;
nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
nsIWebNavigation_Release(web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDocShell: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, flags, FALSE);
nsIDocShell_Release(doc_shell);
if(NS_FAILED(nsres)) {
WARN("LoadURI failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url) HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base_url)
{ {
WCHAR url[INTERNET_MAX_URL_LENGTH]; WCHAR url[INTERNET_MAX_URL_LENGTH];
nsIWebNavigation *web_navigation;
nsIDocShell *doc_shell;
nsIWineURI *uri; nsIWineURI *uri;
nsresult nsres;
HRESULT hres; HRESULT hres;
if(!new_url) { if(!new_url) {
...@@ -1294,31 +1319,11 @@ HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base ...@@ -1294,31 +1319,11 @@ HRESULT navigate_url(HTMLWindow *window, const WCHAR *new_url, const WCHAR *base
TRACE("hlink_frame_navigate failed: %08x\n", hres); TRACE("hlink_frame_navigate failed: %08x\n", hres);
} }
nsres = get_nsinterface((nsISupports*)window->nswindow, &IID_nsIWebNavigation, (void**)&web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
return E_FAIL;
}
nsres = nsIWebNavigation_QueryInterface(web_navigation, &IID_nsIDocShell, (void**)&doc_shell);
nsIWebNavigation_Release(web_navigation);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDocShell: %08x\n", nsres);
return E_FAIL;
}
hres = create_doc_uri(window, url, &uri); hres = create_doc_uri(window, url, &uri);
if(FAILED(hres)) { if(FAILED(hres))
nsIDocShell_Release(doc_shell);
return hres; return hres;
}
nsres = nsIDocShell_LoadURI(doc_shell, (nsIURI*)uri, NULL, 0, FALSE); hres = load_nsuri(window, uri, LOAD_FLAGS_NONE);
nsIDocShell_Release(doc_shell); nsIWineURI_Release(uri);
if(NS_FAILED(nsres)) { return hres;
WARN("LoadURI failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
} }
...@@ -1172,29 +1172,8 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener ...@@ -1172,29 +1172,8 @@ static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener
nsIWineURI_SetNSContainer(wine_uri, This); nsIWineURI_SetNSContainer(wine_uri, This);
nsIWineURI_SetIsDocumentURI(wine_uri, TRUE); nsIWineURI_SetIsDocumentURI(wine_uri, TRUE);
if(This->bscallback) {
IMoniker *mon = get_channelbsc_mon(This->bscallback);
if(mon) {
LPWSTR wine_url;
HRESULT hres;
hres = IMoniker_GetDisplayName(mon, NULL, 0, &wine_url);
if(SUCCEEDED(hres)) {
nsIWineURI_SetWineURL(wine_uri, wine_url);
CoTaskMemFree(wine_url);
}else {
WARN("GetDisplayName failed: %08x\n", hres);
}
IMoniker_Release(mon);
}
*_retval = FALSE;
}else if(This->doc) {
*_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri); *_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri);
} }
}
nsIWineURI_Release(wine_uri); nsIWineURI_Release(wine_uri);
......
...@@ -1706,7 +1706,8 @@ interface nsIBaseWindow : nsISupports ...@@ -1706,7 +1706,8 @@ interface nsIBaseWindow : nsISupports
nsresult SetTitle(const PRUnichar *aTitle); nsresult SetTitle(const PRUnichar *aTitle);
} }
cpp_quote("#define LOAD_FLAGS_NONE 0") cpp_quote("#define LOAD_FLAGS_NONE 0x00000")
cpp_quote("#define LOAD_INITIAL_DOCUMENT_URI 0x80000")
[ [
object, object,
...@@ -2835,11 +2836,14 @@ interface nsIWineURI : nsIURL ...@@ -2835,11 +2836,14 @@ interface nsIWineURI : nsIURL
{ {
typedef struct NSContainer NSContainer; typedef struct NSContainer NSContainer;
typedef struct HTMLWindow HTMLWindow; typedef struct HTMLWindow HTMLWindow;
typedef struct nsChannelBSC nsChannelBSC;
nsresult GetNSContainer(NSContainer **aNSContainer); nsresult GetNSContainer(NSContainer **aNSContainer);
nsresult SetNSContainer(NSContainer *aNSContainer); nsresult SetNSContainer(NSContainer *aNSContainer);
nsresult GetWindow(HTMLWindow **aHTMLWindow); nsresult GetWindow(HTMLWindow **aHTMLWindow);
nsresult SetWindow(HTMLWindow *aHTMLWindow); nsresult SetWindow(HTMLWindow *aHTMLWindow);
nsresult GetChannelBSC(nsChannelBSC **aChannelBSC);
nsresult SetChannelBSC(nsChannelBSC *aChannelBSC);
nsresult GetIsDocumentURI(PRBool *aIsDocumentURI); nsresult GetIsDocumentURI(PRBool *aIsDocumentURI);
nsresult SetIsDocumentURI(PRBool aIsDocumentURI); nsresult SetIsDocumentURI(PRBool aIsDocumentURI);
nsresult GetWineURL(LPCWSTR *aURL); nsresult GetWineURL(LPCWSTR *aURL);
......
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define LOAD_INITIAL_DOCUMENT_URI 0x80000
#define NS_IOSERVICE_CLASSNAME "nsIOService" #define NS_IOSERVICE_CLASSNAME "nsIOService"
#define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1" #define NS_IOSERVICE_CONTRACTID "@mozilla.org/network/io-service;1"
...@@ -60,6 +58,7 @@ typedef struct { ...@@ -60,6 +58,7 @@ typedef struct {
nsIURL *nsurl; nsIURL *nsurl;
NSContainer *container; NSContainer *container;
windowref_t *window_ref; windowref_t *window_ref;
nsChannelBSC *channel_bsc;
LPWSTR wine_url; LPWSTR wine_url;
PRBool is_doc_uri; PRBool is_doc_uri;
BOOL use_wine_url; BOOL use_wine_url;
...@@ -774,15 +773,17 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen ...@@ -774,15 +773,17 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
if(is_doc_uri && (This->load_flags & LOAD_INITIAL_DOCUMENT_URI) && window == window->doc_obj->basedoc.window) { if(is_doc_uri && window == window->doc_obj->basedoc.window) {
if(window->doc_obj->nscontainer->bscallback) { nsChannelBSC *channel_bsc;
NSContainer *nscontainer = window->doc_obj->nscontainer;
channelbsc_set_channel(nscontainer->bscallback, This, aListener, aContext); nsIWineURI_GetChannelBSC(This->uri, &channel_bsc);
if(channel_bsc) {
channelbsc_set_channel(channel_bsc, This, aListener, aContext);
IUnknown_Release((IUnknown*)channel_bsc);
if(nscontainer->doc->mime) { if(window->doc_obj->mime) {
heap_free(This->content_type); heap_free(This->content_type);
This->content_type = heap_strdupWtoA(nscontainer->doc->mime); This->content_type = heap_strdupWtoA(window->doc_obj->mime);
} }
open = FALSE; open = FALSE;
...@@ -798,7 +799,6 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen ...@@ -798,7 +799,6 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen
if(open) if(open)
nsres = async_open(This, window, is_doc_uri, aListener, aContext); nsres = async_open(This, window, is_doc_uri, aListener, aContext);
if(window)
IHTMLWindow2_Release(HTMLWINDOW2(window)); IHTMLWindow2_Release(HTMLWINDOW2(window));
return nsres; return nsres;
} }
...@@ -2057,6 +2057,32 @@ static nsresult NSAPI nsURI_SetWindow(nsIWineURI *iface, HTMLWindow *aHTMLWindow ...@@ -2057,6 +2057,32 @@ static nsresult NSAPI nsURI_SetWindow(nsIWineURI *iface, HTMLWindow *aHTMLWindow
return NS_OK; return NS_OK;
} }
static nsresult NSAPI nsURI_GetChannelBSC(nsIWineURI *iface, nsChannelBSC **aChannelBSC)
{
nsURI *This = NSURI_THIS(iface);
TRACE("(%p)->(%p)\n", This, aChannelBSC);
if(This->channel_bsc)
IUnknown_AddRef((IUnknown*)This->channel_bsc);
*aChannelBSC = This->channel_bsc;
return NS_OK;
}
static nsresult NSAPI nsURI_SetChannelBSC(nsIWineURI *iface, nsChannelBSC *aChannelBSC)
{
nsURI *This = NSURI_THIS(iface);
TRACE("(%p)->(%p)\n", This, aChannelBSC);
if(This->channel_bsc)
IUnknown_Release((IUnknown*)This->channel_bsc);
if(aChannelBSC)
IUnknown_AddRef((IUnknown*)aChannelBSC);
This->channel_bsc = aChannelBSC;
return NS_OK;
}
static nsresult NSAPI nsURI_GetIsDocumentURI(nsIWineURI *iface, PRBool *aIsDocumentURI) static nsresult NSAPI nsURI_GetIsDocumentURI(nsIWineURI *iface, PRBool *aIsDocumentURI)
{ {
nsURI *This = NSURI_THIS(iface); nsURI *This = NSURI_THIS(iface);
...@@ -2175,6 +2201,8 @@ static const nsIWineURIVtbl nsWineURIVtbl = { ...@@ -2175,6 +2201,8 @@ static const nsIWineURIVtbl nsWineURIVtbl = {
nsURI_SetNSContainer, nsURI_SetNSContainer,
nsURI_GetWindow, nsURI_GetWindow,
nsURI_SetWindow, nsURI_SetWindow,
nsURI_GetChannelBSC,
nsURI_SetChannelBSC,
nsURI_GetIsDocumentURI, nsURI_GetIsDocumentURI,
nsURI_SetIsDocumentURI, nsURI_SetIsDocumentURI,
nsURI_GetWineURL, nsURI_GetWineURL,
......
...@@ -172,8 +172,8 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO ...@@ -172,8 +172,8 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
LPOLESTR url = NULL; LPOLESTR url = NULL;
docobj_task_t *task; docobj_task_t *task;
download_proc_task_t *download_task; download_proc_task_t *download_task;
nsIWineURI *nsuri;
HRESULT hres; HRESULT hres;
nsresult nsres;
if(pibc) { if(pibc) {
IUnknown *unk = NULL; IUnknown *unk = NULL;
...@@ -254,8 +254,22 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO ...@@ -254,8 +254,22 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
} }
} }
hres = create_doc_uri(This->window, url, &nsuri);
CoTaskMemFree(url);
if(FAILED(hres))
return hres;
bscallback = create_channelbsc(mon); bscallback = create_channelbsc(mon);
nsIWineURI_SetChannelBSC(nsuri, bscallback);
hres = load_nsuri(This->window, nsuri, LOAD_INITIAL_DOCUMENT_URI);
nsIWineURI_SetChannelBSC(nsuri, NULL);
if(SUCCEEDED(hres))
set_window_bscallback(This->window, bscallback);
IUnknown_Release((IUnknown*)bscallback);
if(FAILED(hres))
return hres;
if(This->doc_obj->frame) { if(This->doc_obj->frame) {
task = heap_alloc(sizeof(docobj_task_t)); task = heap_alloc(sizeof(docobj_task_t));
task->doc = This->doc_obj; task->doc = This->doc_obj;
...@@ -267,23 +281,6 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO ...@@ -267,23 +281,6 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
download_task->set_download = set_download; download_task->set_download = set_download;
push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic); push_task(&download_task->header, set_downloading_proc, This->doc_obj->basedoc.task_magic);
if(This->doc_obj->nscontainer) {
This->doc_obj->nscontainer->bscallback = bscallback;
nsres = nsIWebNavigation_LoadURI(This->doc_obj->nscontainer->navigation, url,
LOAD_FLAGS_NONE, NULL, NULL, NULL);
This->doc_obj->nscontainer->bscallback = NULL;
if(NS_FAILED(nsres)) {
WARN("LoadURI failed: %08x\n", nsres);
IUnknown_Release((IUnknown*)bscallback);
CoTaskMemFree(url);
return E_FAIL;
}
}
set_window_bscallback(This->window, bscallback);
IUnknown_Release((IUnknown*)bscallback);
CoTaskMemFree(url);
return S_OK; return S_OK;
} }
......
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