From c6e1678052c8ac6346f0751ff2cd4f11b4fa337e Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Fri, 22 Sep 2000 06:31:29 +0000 Subject: [PATCH] Fix for 44692, allowing default plugin guess about mime type by extension, a=mscott git-svn-id: svn://10.0.0.236/trunk@79858 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/nsPluginHostImpl.cpp | 27 +++++++++++++++++++ .../plugin/nglsrc/nsPluginHostImpl.cpp | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index a64a21b7884..1101e5faafe 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -90,6 +90,9 @@ #include "nsPluginDocLoaderFactory.h" #include "nsIDocumentLoaderFactory.h" +#include "nsIMIMEService.h" +#include "nsCExternalHandlerService.h" + #ifdef XP_UNIX #include // for GDK_DISPLAY() #endif @@ -2443,6 +2446,30 @@ nsresult nsPluginHostImpl::SetUpDefaultPluginInstance(const char *aMimeType, nsI if(peer == nsnull) return NS_ERROR_OUT_OF_MEMORY; + // if we don't have a mimetype, check by file extension + nsXPIDLCString mt; + if(mimetype == nsnull) + { + nsresult res = NS_OK; + nsCOMPtr url = do_QueryInterface(aURL); + if(url) + { + nsXPIDLCString extension; + url->GetFileExtension(getter_Copies(extension)); + + if(extension) + { + nsCOMPtr ms (do_GetService(NS_MIMESERVICE_CONTRACTID, &res)); + if(NS_SUCCEEDED(res) && ms) + { + res = ms->GetTypeFromExtension(extension, getter_Copies(mt)); + if(NS_SUCCEEDED(res)) + mimetype = mt; + } + } + } + } + // set up the peer for the instance peer->Initialize(aOwner, mimetype); diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index a64a21b7884..1101e5faafe 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -90,6 +90,9 @@ #include "nsPluginDocLoaderFactory.h" #include "nsIDocumentLoaderFactory.h" +#include "nsIMIMEService.h" +#include "nsCExternalHandlerService.h" + #ifdef XP_UNIX #include // for GDK_DISPLAY() #endif @@ -2443,6 +2446,30 @@ nsresult nsPluginHostImpl::SetUpDefaultPluginInstance(const char *aMimeType, nsI if(peer == nsnull) return NS_ERROR_OUT_OF_MEMORY; + // if we don't have a mimetype, check by file extension + nsXPIDLCString mt; + if(mimetype == nsnull) + { + nsresult res = NS_OK; + nsCOMPtr url = do_QueryInterface(aURL); + if(url) + { + nsXPIDLCString extension; + url->GetFileExtension(getter_Copies(extension)); + + if(extension) + { + nsCOMPtr ms (do_GetService(NS_MIMESERVICE_CONTRACTID, &res)); + if(NS_SUCCEEDED(res) && ms) + { + res = ms->GetTypeFromExtension(extension, getter_Copies(mt)); + if(NS_SUCCEEDED(res)) + mimetype = mt; + } + } + } + } + // set up the peer for the instance peer->Initialize(aOwner, mimetype);