From 7a40e9e1fee454f9727135f56423d9ce77c1c2e5 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Fri, 19 Dec 2003 21:34:00 +0000 Subject: [PATCH] 225807 r=bzbarsky sr=darin make more use of getPrimaryExtension --- editor/ui/composer/content/ComposerCommands.js | 5 +---- modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp | 10 ++++------ modules/libpr0n/decoders/icon/win/nsIconChannel.cpp | 12 +++++------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/editor/ui/composer/content/ComposerCommands.js b/editor/ui/composer/content/ComposerCommands.js index 287ee4ff5c54..562a78d10116 100644 --- a/editor/ui/composer/content/ComposerCommands.js +++ b/editor/ui/composer/content/ComposerCommands.js @@ -766,10 +766,7 @@ function GetExtensionBasedOnMimeType(aMIMEType) mimeService = Components.classes["@mozilla.org/mime;1"].getService(); mimeService = mimeService.QueryInterface(Components.interfaces.nsIMIMEService); - var mimeInfo = mimeService.getFromTypeAndExtension(aMIMEType, null); - if (!mimeInfo) return ""; - - var fileExtension = mimeInfo.primaryExtension; + var fileExtension = mimeService.getPrimaryExtension(aMIMEType, null); // the MIME service likes to give back ".htm" for text/html files, // so do a special-case fix here. diff --git a/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp index acffc785aec7..353aeede32ab 100644 --- a/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp @@ -403,15 +403,13 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports if ( (filePath.IsEmpty()) && (contentType.get() && *contentType.get()) ) // if we have a content type without a file extension...then use it! { nsCOMPtr mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); - nsCOMPtr mimeObject; NS_ENSURE_SUCCESS(rv, rv); - mimeService->GetFromTypeAndExtension(contentType.get(), nsnull, getter_AddRefs(mimeObject)); - if (mimeObject) + nsXPIDLCString fileExt; + rv = mimeService->GetPrimaryExtension(contentType.get(), nsnull, getter_Copies(fileExt)); + if (NS_SUCCEEDED(rv)) { - nsXPIDLCString fileExt; - mimeObject->GetPrimaryExtension(getter_Copies(fileExt)); - // we need to insert a '.' b4 the extension... + // we need to insert a '.' before the extension... filePath = NS_LITERAL_CSTRING(".") + fileExt; } } diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp index 3b9dd1f47a1e..3cd789d1e8d6 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp @@ -249,15 +249,13 @@ nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBloc if ( (filePath.IsEmpty()) && (contentType.get() && *contentType.get()) ) // if we have a content type without a file extension...then use it! { nsCOMPtr mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); - nsCOMPtr mimeObject; NS_ENSURE_SUCCESS(rv, rv); - - mimeService->GetFromTypeAndExtension(contentType.get(), nsnull, getter_AddRefs(mimeObject)); - if (mimeObject) + + nsXPIDLCString fileExt; + rv = mimeService->GetPrimaryExtension(contentType.get(), nsnull, getter_Copies(fileExt)); + if (NS_SUCCEEDED(rv)) { - nsXPIDLCString fileExt; - mimeObject->GetPrimaryExtension(getter_Copies(fileExt)); - // we need to insert a '.' b4 the extension... + // we need to insert a '.' before the extension... filePath = NS_LITERAL_CSTRING(".") + fileExt; } }