Fix for 44692, allowing default plugin guess about mime type by extension, a=mscott

This commit is contained in:
av%netscape.com 2000-09-22 06:31:29 +00:00
parent 69980043ac
commit 2f358f1418
2 changed files with 54 additions and 0 deletions

View File

@ -90,6 +90,9 @@
#include "nsPluginDocLoaderFactory.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#ifdef XP_UNIX
#include <gdk/gdkx.h> // 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<nsIURL> url = do_QueryInterface(aURL);
if(url)
{
nsXPIDLCString extension;
url->GetFileExtension(getter_Copies(extension));
if(extension)
{
nsCOMPtr<nsIMIMEService> 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);

View File

@ -90,6 +90,9 @@
#include "nsPluginDocLoaderFactory.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#ifdef XP_UNIX
#include <gdk/gdkx.h> // 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<nsIURL> url = do_QueryInterface(aURL);
if(url)
{
nsXPIDLCString extension;
url->GetFileExtension(getter_Copies(extension));
if(extension)
{
nsCOMPtr<nsIMIMEService> 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);