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

Alexandre Julliard julliard at winehq.org
Thu Sep 19 17:21:07 CDT 2013


Module: wine
Branch: master
Commit: b17d139328895b88d43af753ce6560af5b1bbe74
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b17d139328895b88d43af753ce6560af5b1bbe74

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Sep 19 16:12:51 2013 +0200

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

---

 dlls/mshtml/mshtml_private.h |    1 +
 dlls/mshtml/navigate.c       |   29 ++++++++++++++++++++++++++++-
 dlls/mshtml/nsembed.c        |   19 +++++++++++++++++++
 dlls/mshtml/nsiface.idl      |   16 ++++++++++++++++
 4 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 8063ac5..f3c3b28 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -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;
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index 94c7717..444abbc 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -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;
 
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index 4e72464..bbac821 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -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);
 
diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl
index fcdf6f1..010aa51 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -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
 ]




More information about the wine-cvs mailing list