Commit b17d1393 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Don't pass navigation to Gecko for MIME types that it doesn't support.

parent 4db1b008
......@@ -832,6 +832,7 @@ void get_editor_controller(NSContainer*) DECLSPEC_HIDDEN;
nsresult get_nsinterface(nsISupports*,REFIID,void**) DECLSPEC_HIDDEN;
nsIWritableVariant *create_nsvariant(void) DECLSPEC_HIDDEN;
nsresult create_nsfile(const PRUnichar*,nsIFile**) DECLSPEC_HIDDEN;
char *get_nscategory_entry(const char*,const char*) DECLSPEC_HIDDEN;
HRESULT create_pending_window(HTMLOuterWindow*,nsChannelBSC*) DECLSPEC_HIDDEN;
HRESULT start_binding(HTMLInnerWindow*,BSCallback*,IBindCtx*) DECLSPEC_HIDDEN;
......
......@@ -1161,6 +1161,9 @@ static HRESULT read_stream_data(nsChannelBSC *This, IStream *stream)
}
}
if(!This->nschannel)
return S_OK;
if(!This->nslistener) {
BYTE buf[1024];
......@@ -1544,7 +1547,7 @@ static HRESULT nsChannelBSC_stop_binding(BSCallback *bsc, HRESULT result)
if(result != E_ABORT) {
if(FAILED(result))
handle_navigation_error(This, result);
else if(This->is_doc_channel) {
else if(This->is_doc_channel && This->nschannel) {
result = async_stop_request(This);
if(SUCCEEDED(result))
return S_OK;
......@@ -1604,12 +1607,36 @@ static HRESULT handle_redirect(nsChannelBSC *This, const WCHAR *new_url)
return hres;
}
static BOOL is_supported_doc_mime(const WCHAR *mime)
{
char *nscat, *mimea;
BOOL ret;
mimea = heap_strdupWtoA(mime);
if(!mimea)
return FALSE;
nscat = get_nscategory_entry("Gecko-Content-Viewers", mimea);
ret = nscat != NULL && !strcmp(nscat, "@mozilla.org/content/document-loader-factory;1");
heap_free(mimea);
nsfree(nscat);
return ret;
}
static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCWSTR status_text)
{
nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
switch(status_code) {
case BINDSTATUS_MIMETYPEAVAILABLE:
if(This->is_doc_channel && !is_supported_doc_mime(status_text)) {
FIXME("External MIME: %s\n", debugstr_w(status_text));
This->nschannel = NULL;
}
if(!This->nschannel)
return S_OK;
......
......@@ -48,6 +48,7 @@ WINE_DECLARE_DEBUG_CHANNEL(gecko);
#define NS_EDITORCONTROLLER_CONTRACTID "@mozilla.org/editor/editorcontroller;1"
#define NS_PREFERENCES_CONTRACTID "@mozilla.org/preferences;1"
#define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1"
#define NS_CATEGORYMANAGER_CONTRACTID "@mozilla.org/categorymanager;1"
#define PR_UINT32_MAX 0xffffffff
......@@ -73,6 +74,7 @@ static HINSTANCE xul_handle = NULL;
static nsIServiceManager *pServMgr = NULL;
static nsIComponentManager *pCompMgr = NULL;
static nsICategoryManager *cat_mgr;
static nsIMemory *nsmem = NULL;
static nsIFile *profile_directory, *plugin_directory;
......@@ -725,6 +727,11 @@ static BOOL init_xpcom(const PRUnichar *gre_path)
if(NS_FAILED(nsres))
ERR("Could not get nsIMemory: %08x\n", nsres);
nsres = nsIServiceManager_GetServiceByContractID(pServMgr, NS_CATEGORYMANAGER_CONTRACTID,
&IID_nsICategoryManager, (void**)&cat_mgr);
if(NS_FAILED(nsres))
ERR("Could not get category manager service: %08x\n", nsres);
if(registrar) {
register_nsservice(registrar, pServMgr);
nsIComponentRegistrar_Release(registrar);
......@@ -901,6 +908,15 @@ nsIWritableVariant *create_nsvariant(void)
return ret;
}
char *get_nscategory_entry(const char *category, const char *entry)
{
char *ret = NULL;
nsresult nsres;
nsres = nsICategoryManager_GetCategoryEntry(cat_mgr, category, entry, &ret);
return NS_SUCCEEDED(nsres) ? ret : NULL;
}
nsresult get_nsinterface(nsISupports *iface, REFIID riid, void **ppv)
{
nsIInterfaceRequestor *iface_req;
......@@ -1093,6 +1109,9 @@ void close_gecko(void)
if(pServMgr)
nsIServiceManager_Release(pServMgr);
if(cat_mgr)
nsICategoryManager_Release(cat_mgr);
if(nsmem)
nsIMemory_Release(nsmem);
......
......@@ -3263,6 +3263,22 @@ interface nsICommandManager : nsISupports
[
object,
uuid(3275b2cd-af6d-429a-80d7-f0c5120342ac),
local
]
interface nsICategoryManager : nsISupports
{
nsresult GetCategoryEntry(const char *aCategory, const char *aEntry, char **_retval);
nsresult AddCategoryEntry(const char *aCategory, const char *aEntry, const char *aValue, bool aPersist,
bool aReplace, char **_retval);
nsresult DeleteCategoryEntry(const char *aCategory, const char *aEntry, bool aPersist);
nsresult DeleteCategory(const char *aCategory);
nsresult EnumerateCategory(const char *aCategory, nsISimpleEnumerator **_retval);
nsresult EnumerateCategories(nsISimpleEnumerator **_retval);
}
[
object,
uuid(47b82b60-a36f-4167-8072-6f421151ed50),
local
]
......
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