зеркало из https://github.com/mozilla/gecko-dev.git
225807 r=bzbarsky sr=darin make more use of getPrimaryExtension
This commit is contained in:
Родитель
a65ac517d9
Коммит
7a40e9e1fe
|
@ -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.
|
||||
|
|
|
@ -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<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIMIMEInfo> mimeObject;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mimeService->GetFromTypeAndExtension(contentType.get(), nsnull, getter_AddRefs(mimeObject));
|
||||
if (mimeObject)
|
||||
{
|
||||
nsXPIDLCString fileExt;
|
||||
mimeObject->GetPrimaryExtension(getter_Copies(fileExt));
|
||||
// we need to insert a '.' b4 the extension...
|
||||
rv = mimeService->GetPrimaryExtension(contentType.get(), nsnull, getter_Copies(fileExt));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// we need to insert a '.' before the extension...
|
||||
filePath = NS_LITERAL_CSTRING(".") + fileExt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIMIMEInfo> mimeObject;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mimeService->GetFromTypeAndExtension(contentType.get(), nsnull, getter_AddRefs(mimeObject));
|
||||
if (mimeObject)
|
||||
{
|
||||
nsXPIDLCString fileExt;
|
||||
mimeObject->GetPrimaryExtension(getter_Copies(fileExt));
|
||||
// we need to insert a '.' b4 the extension...
|
||||
rv = mimeService->GetPrimaryExtension(contentType.get(), nsnull, getter_Copies(fileExt));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// we need to insert a '.' before the extension...
|
||||
filePath = NS_LITERAL_CSTRING(".") + fileExt;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче