This source file includes following definitions.
- getMIMETypeForExtension
- getWellKnownMIMETypeForExtension
- getMIMETypeForPath
- isSupportedImageMIMEType
- isSupportedImageResourceMIMEType
- isSupportedImageMIMETypeForEncoding
- isSupportedJavaScriptMIMEType
- isSupportedNonImageMIMEType
- isSupportedMediaSourceMIMEType
- isSupportedEncryptedMediaMIMEType
- isJavaAppletMIMEType
#include "config.h"
#include "platform/MIMETypeRegistry.h"
#include "platform/plugins/PluginData.h"
#include "public/platform/Platform.h"
#include "public/platform/WebMimeRegistry.h"
#include "wtf/text/CString.h"
namespace WebCore {
String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
{
return blink::Platform::current()->mimeRegistry()->mimeTypeForExtension(ext);
}
String MIMETypeRegistry::getWellKnownMIMETypeForExtension(const String &ext)
{
return blink::Platform::current()->mimeRegistry()->wellKnownMimeTypeForExtension(ext);
}
String MIMETypeRegistry::getMIMETypeForPath(const String& path)
{
int pos = path.reverseFind('.');
if (pos < 0)
return "application/octet-stream";
String extension = path.substring(pos + 1);
String mimeType = getMIMETypeForExtension(extension);
if (mimeType.isEmpty()) {
mimeType = getPluginMimeTypeFromExtension(extension);
}
if (mimeType.isEmpty())
return "application/octet-stream";
return mimeType;
}
bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType)
{
return blink::Platform::current()->mimeRegistry()->supportsImageMIMEType(mimeType.lower())
!= blink::WebMimeRegistry::IsNotSupported;
}
bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType)
{
return isSupportedImageMIMEType(mimeType);
}
bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType)
{
if (equalIgnoringCase(mimeType, "image/jpeg") || equalIgnoringCase(mimeType, "image/png"))
return true;
if (equalIgnoringCase(mimeType, "image/webp"))
return true;
return false;
}
bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType)
{
return blink::Platform::current()->mimeRegistry()->supportsJavaScriptMIMEType(mimeType.lower())
!= blink::WebMimeRegistry::IsNotSupported;
}
bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType)
{
return blink::Platform::current()->mimeRegistry()->supportsNonImageMIMEType(mimeType.lower())
!= blink::WebMimeRegistry::IsNotSupported;
}
bool MIMETypeRegistry::isSupportedMediaSourceMIMEType(const String& mimeType, const String& codecs)
{
return !mimeType.isEmpty()
&& blink::Platform::current()->mimeRegistry()->supportsMediaSourceMIMEType(mimeType.lower(), codecs);
}
bool MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(const String& keySystem, const String& mimeType, const String& codecs)
{
return blink::Platform::current()->mimeRegistry()->supportsEncryptedMediaMIMEType(keySystem, mimeType.lower(), codecs);
}
bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType)
{
return mimeType.startsWith("application/x-java-applet", false)
|| mimeType.startsWith("application/x-java-bean", false)
|| mimeType.startsWith("application/x-java-vm", false);
}
}