229695 Icon in download dialog is based on extension, not MIME type

r=neil.parkwaycc.co.uk sr=bz
This commit is contained in:
cbiesinger%web.de 2004-01-03 17:44:17 +00:00
Родитель 6ca5589875
Коммит 4cf97a6ea9
1 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -246,19 +246,20 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc
else
infoFlags |= SHGFI_SMALLICON;
if ( (filePath.IsEmpty()) && (contentType.get() && *contentType.get()) ) // if we have a content type without a file extension...then use it!
// if we have a content type... then use it! but for existing files, we want
// to show their real icon.
if (!fileExists && !contentType.IsEmpty())
{
nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString fileExt;
rv = mimeService->GetPrimaryExtension(contentType.get(), nsnull, getter_Copies(fileExt));
if (NS_SUCCEEDED(rv))
{
// we need to insert a '.' before the extension...
mimeService->GetPrimaryExtension(contentType.get(), nsnull, getter_Copies(fileExt));
// If the mime service does not know about this mime type, we show
// the generic icon.
// In any case, we need to insert a '.' before the extension.
filePath = NS_LITERAL_CSTRING(".") + fileExt;
}
}
// (1) get an hIcon for the file
if (SHGetFileInfo(filePath.get(), FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags) && sfi.hIcon)