1/* 2 * Copyright (C) 2006 Zack Rusin <zack@kde.org> 3 * Copyright (C) 2006 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 5 * Copyright (C) 2008 Torch Mobile Inc. http://www.torchmobile.com/ 6 * Copyright (C) 2009-2010 ProFUSION embedded systems 7 * Copyright (C) 2009-2010 Samsung Electronics 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include "config.h" 32#include "MIMETypeRegistry.h" 33 34#include "NotImplemented.h" 35#include <wtf/Assertions.h> 36#include <wtf/MainThread.h> 37 38namespace WebCore { 39 40struct ExtensionMap { 41 const char* extension; 42 const char* mimeType; 43}; 44 45static const ExtensionMap extensionMap[] = { 46 { "bmp", "image/bmp" }, 47 { "css", "text/css" }, 48 { "gif", "image/gif" }, 49 { "html", "text/html" }, 50 { "htm", "text/html" }, 51 { "ico", "image/x-icon" }, 52 { "jpeg", "image/jpeg" }, 53 { "jpg", "image/jpeg" }, 54 { "js", "application/x-javascript" }, 55 { "mht", "application/x-mimearchive" }, 56 { "mhtml", "application/x-mimearchive" }, 57 { "mng", "video/x-mng" }, 58 { "pbm", "image/x-portable-bitmap" }, 59 { "pgm", "image/x-portable-graymap" }, 60 { "pdf", "application/pdf" }, 61 { "png", "image/png" }, 62 { "ppm", "image/x-portable-pixmap" }, 63 { "rss", "application/rss+xml" }, 64 { "svg", "image/svg+xml" }, 65 { "text", "text/plain" }, 66 { "tif", "image/tiff" }, 67 { "tiff", "image/tiff" }, 68 { "txt", "text/plain" }, 69 { "xbm", "image/x-xbitmap" }, 70 { "xml", "text/xml" }, 71 { "xpm", "image/x-xpm" }, 72 { "xsl", "text/xsl" }, 73 { "xhtml", "application/xhtml+xml" }, 74 { "wml", "text/vnd.wap.wml" }, 75 { "wmlc", "application/vnd.wap.wmlc" }, 76 { 0, 0 } 77}; 78 79String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) 80{ 81 ASSERT(isMainThread()); 82 83 String s = ext.lower(); 84 const ExtensionMap *e = extensionMap; 85 while (e->extension) { 86 if (s == e->extension) 87 return e->mimeType; 88 ++e; 89 } 90 91 return String(); 92} 93 94bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&) 95{ 96 return false; 97} 98 99} 100