Commit 80f02b82 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use URL moniker to load http documents.

parent 8cee331b
......@@ -33,9 +33,6 @@
#include "nsiface.h"
#define GENERATE_MSHTML_NS_FAILURE(code) \
((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
#define NS_OK ((nsresult)0x00000000L)
#define NS_ERROR_FAILURE ((nsresult)0x80004005L)
#define NS_NOINTERFACE ((nsresult)0x80004002L)
......@@ -44,8 +41,6 @@
#define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
#define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
#define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
#define NS_FAILED(res) ((res) & 0x80000000)
#define NS_SUCCEEDED(res) (!NS_FAILED(res))
......
......@@ -608,37 +608,6 @@ static nsresult NSAPI nsChannel_Open(nsIHttpChannel *iface, nsIInputStream **_re
return NS_ERROR_NOT_IMPLEMENTED;
}
static BOOL do_load_from_moniker_hack(nsChannel *This)
{
nsACString scheme_str;
nsresult nsres;
BOOL ret = TRUE;
/*
* We should always load the page from IMoniker, but Wine is not yet
* ready for this. This function is a heuristic, that decides which
* way of loading is better (Gecko implementation or IMoniker). The
* aim is to always return TRUE.
*/
/* Load from moniker if there is no Gecko channel available */
if(!This->channel)
return TRUE;
nsACString_Init(&scheme_str, NULL);
nsres = nsIWineURI_GetScheme(This->uri, &scheme_str);
if(NS_SUCCEEDED(nsres)) {
const char *scheme;
nsACString_GetData(&scheme_str, &scheme);
ret = !strcmp(scheme, "wine") || !strcmp(scheme, "about");
}
nsACString_Finish(&scheme_str);
return ret;
}
static HRESULT create_mon_for_nschannel(nsChannel *channel, IMoniker **mon)
{
nsIWineURI *wine_uri;
......@@ -732,8 +701,7 @@ static nsresult async_open_doc_uri(nsChannel *This, NSContainer *container,
This->content_type = heap_strdupWtoA(container->doc->mime);
}
if(do_load_from_moniker_hack(This))
return WINE_NS_LOAD_FROM_MONIKER;
return NS_OK;
}else {
BOOL cont = before_async_open(This, container);
......@@ -764,23 +732,9 @@ static nsresult async_open(nsChannel *This, NSContainer *container, nsIStreamLis
{
nsChannelBSC *bscallback;
IMoniker *mon = NULL;
nsresult nsres;
task_t *task;
HRESULT hres;
if(This->channel) {
nsres = nsIChannel_AsyncOpen(This->channel, listener, context);
if(mon)
IMoniker_Release(mon);
if(NS_FAILED(nsres) && (This->load_flags & LOAD_INITIAL_DOCUMENT_URI))
return WINE_NS_LOAD_FROM_MONIKER;
return nsres;
}
TRACE("channel == NULL\n");
hres = create_mon_for_nschannel(This, &mon);
if(FAILED(hres))
return NS_ERROR_UNEXPECTED;
......
......@@ -314,17 +314,11 @@ static HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, BO
if(post_data_stream)
nsIInputStream_Release(post_data_stream);
if(NS_SUCCEEDED(nsres)) {
/* FIXME: don't return here (URL Moniker needs to be good enough) */
if(NS_FAILED(nsres)) {
WARN("LoadURI failed: %08x\n", nsres);
IUnknown_Release((IUnknown*)bscallback);
CoTaskMemFree(url);
if(bind_complete)
*bind_complete = TRUE;
return S_OK;
}else if(nsres != WINE_NS_LOAD_FROM_MONIKER) {
WARN("LoadURI failed: %08x\n", nsres);
return E_FAIL;
}
}
......
......@@ -513,46 +513,6 @@ static BOOL try_application_url(LPCWSTR url)
return ShellExecuteExW(&exec_info);
}
static HRESULT http_load_hack(DocHost *This, IMoniker *mon, IBindStatusCallback *callback, IBindCtx *bindctx)
{
IPersistMoniker *persist;
IUnknown *doc;
HRESULT hres;
/*
* FIXME:
* We should use URLMoniker's BindToObject instead creating HTMLDocument here.
* This should be fixed when mshtml.dll and urlmon.dll will be good enough.
*/
hres = CoCreateInstance(&CLSID_HTMLDocument, NULL,
CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IUnknown, (void**)&doc);
if(FAILED(hres)) {
ERR("Could not create HTMLDocument: %08x\n", hres);
return hres;
}
hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist);
if(FAILED(hres)) {
IUnknown_Release(doc);
return hres;
}
hres = IPersistMoniker_Load(persist, FALSE, mon, bindctx, 0);
IPersistMoniker_Release(persist);
if(SUCCEEDED(hres))
hres = IBindStatusCallback_OnObjectAvailable(callback, &IID_IUnknown, doc);
else
WARN("Load failed: %08x\n", hres);
IUnknown_Release(doc);
return IBindStatusCallback_OnStopBinding(callback, hres, NULL);
}
static HRESULT create_moniker(LPCWSTR url, IMoniker **mon)
{
WCHAR new_url[INTERNET_MAX_URL_LENGTH];
......@@ -585,14 +545,9 @@ static HRESULT create_moniker(LPCWSTR url, IMoniker **mon)
static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx,
IBindStatusCallback *callback)
{
WCHAR schema[30];
DWORD schema_len;
IUnknown *unk = NULL;
HRESULT hres;
static const WCHAR httpW[] = {'h','t','t','p',0};
static const WCHAR httpsW[] = {'h','t','t','p','s',0};
static const WCHAR ftpW[]= {'f','t','p',0};
if(mon) {
IMoniker_AddRef(mon);
}else {
......@@ -609,24 +564,15 @@ static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCt
IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM,
(IUnknown*)CLIENTSITE(This));
hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
&schema_len, 0);
if(SUCCEEDED(hres) &&
(!strcmpW(schema, httpW) || !strcmpW(schema, httpsW) || !strcmpW(schema, ftpW))) {
hres = http_load_hack(This, mon, callback, bindctx);
hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk);
if(SUCCEEDED(hres)) {
hres = S_OK;
if(unk)
IUnknown_Release(unk);
}else if(try_application_url(url)) {
hres = S_OK;
}else {
IUnknown *unk = NULL;
hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk);
if(SUCCEEDED(hres)) {
hres = S_OK;
if(unk)
IUnknown_Release(unk);
}else if(try_application_url(url)) {
hres = S_OK;
}else {
FIXME("BindToObject failed: %08x\n", hres);
}
FIXME("BindToObject failed: %08x\n", hres);
}
IMoniker_Release(mon);
......
......@@ -2551,16 +2551,12 @@ static void test_BindToObject(int protocol, BOOL emul)
CHECK_CALLED(Obj_OnStopBinding);
}
if(test_protocol != HTTP_TEST || test_protocol == HTTPS_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL || !(bindf & BINDF_ASYNCHRONOUS)) {
ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
}else {
todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
if(bindf & BINDF_ASYNCHRONOUS)
IBindCtx_Release(bctx);
else
todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
IBindCtx_Release(bctx);
}
if(emul)
......
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