MIMETypeRegistryQt.cpp [plain text]
#include "config.h"
#include "MIMETypeRegistry.h"
#include "NotImplemented.h"
#if QT_VERSION < 0x040400
#include "qwebobjectplugin_p.h"
#endif
namespace WebCore {
struct ExtensionMap {
const char* extension;
const char* mimeType;
};
static const ExtensionMap extensionMap [] = {
{ "bmp", "image/bmp" },
{ "gif", "image/gif" },
{ "html", "text/html" },
{ "htm", "text/html" },
{ "ico", "image/x-icon" },
{ "jpeg", "image/jpeg" },
{ "jpg", "image/jpeg" },
{ "js", "application/x-javascript" },
{ "mng", "video/x-mng" },
{ "pbm", "image/x-portable-bitmap" },
{ "pgm", "image/x-portable-graymap" },
{ "pdf", "application/pdf" },
{ "png", "image/png" },
{ "ppm", "image/x-portable-pixmap" },
{ "rss", "application/rss+xml" },
{ "svg", "image/svg+xml" },
{ "text", "text/plain" },
{ "tif", "image/tiff" },
{ "tiff", "image/tiff" },
{ "txt", "text/plain" },
{ "xbm", "image/x-xbitmap" },
{ "xml", "text/xml" },
{ "xpm", "image/x-xpm" },
{ "xsl", "text/xsl" },
{ "xhtml", "application/xhtml+xml" },
{ 0, 0 }
};
String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
{
String s = ext.lower();
const ExtensionMap *e = extensionMap;
while (e->extension) {
if (s == e->extension)
return e->mimeType;
++e;
}
#if QT_VERSION < 0x040400
QString type = QWebFactoryLoader::self()->mimeTypeForExtension(ext);
if (!type.isEmpty())
return type;
#endif
return "application/octet-stream";
}
}