mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
If we don't have a file ext in the moz-icon url, fall back to using the content type if it
was specified. r/sr=sspitzer
This commit is contained in:
parent
079d7bea96
commit
712ed0f759
@ -33,6 +33,8 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
|
||||
// we need windows.h to read out registry information...
|
||||
#include <windows.h>
|
||||
@ -278,6 +280,25 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
|
||||
else
|
||||
infoFlags |= SHGFI_SMALLICON;
|
||||
|
||||
if ( (!filePath.get()) && (contentType.get() && *contentType.get()) ) // if we have a content type without a file extension...then use it!
|
||||
{
|
||||
nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIMIMEInfo> mimeObject;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mimeService->GetFromMIMEType(contentType.get(), getter_AddRefs(mimeObject));
|
||||
if (mimeObject)
|
||||
{
|
||||
nsXPIDLCString fileExt;
|
||||
mimeObject->FirstExtension(getter_Copies(fileExt));
|
||||
// we need to insert a '.' b4 the extension...
|
||||
nsCAutoString formattedFileExt;
|
||||
formattedFileExt = ".";
|
||||
formattedFileExt.Append(fileExt.get());
|
||||
*((char **)getter_Copies(filePath)) = formattedFileExt.ToNewCString(); // yuck...shove it into our xpidl string...
|
||||
}
|
||||
}
|
||||
|
||||
// (1) get an hIcon for the file
|
||||
LONG result= SHGetFileInfo(filePath.get(), FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags);
|
||||
if (result > 0 && sfi.hIcon)
|
||||
|
Loading…
Reference in New Issue
Block a user