1 /* 2 * Copyright (C) 2006 Zack Rusin <zack (at) kde.org> 3 * Copyright (C) 2006 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 <wtf/Assertions.h> 35 #include <wtf/MainThread.h> 36 37 namespace WebCore { 38 39 struct ExtensionMap { 40 const char* extension; 41 const char* mimeType; 42 }; 43 44 static const ExtensionMap extensionMap[] = { 45 { "bmp", "image/bmp" }, 46 { "css", "text/css" }, 47 { "gif", "image/gif" }, 48 { "html", "text/html" }, 49 { "htm", "text/html" }, 50 { "ico", "image/x-icon" }, 51 { "jpeg", "image/jpeg" }, 52 { "jpg", "image/jpeg" }, 53 { "js", "application/x-javascript" }, 54 { "mng", "video/x-mng" }, 55 { "pbm", "image/x-portable-bitmap" }, 56 { "pgm", "image/x-portable-graymap" }, 57 { "pdf", "application/pdf" }, 58 { "png", "image/png" }, 59 { "ppm", "image/x-portable-pixmap" }, 60 { "rss", "application/rss+xml" }, 61 { "svg", "image/svg+xml" }, 62 { "text", "text/plain" }, 63 { "tif", "image/tiff" }, 64 { "tiff", "image/tiff" }, 65 { "txt", "text/plain" }, 66 { "xbm", "image/x-xbitmap" }, 67 { "xml", "text/xml" }, 68 { "xpm", "image/x-xpm" }, 69 { "xsl", "text/xsl" }, 70 { "xhtml", "application/xhtml+xml" }, 71 { "wml", "text/vnd.wap.wml" }, 72 { "wmlc", "application/vnd.wap.wmlc" }, 73 { 0, 0 } 74 }; 75 76 String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) 77 { 78 ASSERT(isMainThread()); 79 80 String s = ext.lower(); 81 const ExtensionMap *e = extensionMap; 82 while (e->extension) { 83 if (s == e->extension) 84 return e->mimeType; 85 ++e; 86 } 87 88 return String(); 89 } 90 91 bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&) 92 { 93 return false; 94 } 95 96 } 97