Title: [121727] trunk/Source/WebCore
Revision
121727
Author
[email protected]
Date
2012-07-02 20:43:19 -0700 (Mon, 02 Jul 2012)

Log Message

[BlackBerry] Refactor : move the implementation of getMIMETypeForExtension and getPreferredExtensionForMIMEType into BlackBerry platform
https://bugs.webkit.org/show_bug.cgi?id=90360

Patch by Chris Guan <[email protected]> on 2012-07-02
Reviewed by Antonio Gomes.

We should have one implementation for getMIMETypeForExtension
and getPreferredExtensionForMIMEType for both webkit and platform,
so I move this implementation to BlackBerry platform.

No new test cases , because no behavior changed.

* platform/blackberry/MIMETypeRegistryBlackBerry.cpp:
(WebCore::MIMETypeRegistry::getMIMETypeForExtension):
(WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121726 => 121727)


--- trunk/Source/WebCore/ChangeLog	2012-07-03 03:40:34 UTC (rev 121726)
+++ trunk/Source/WebCore/ChangeLog	2012-07-03 03:43:19 UTC (rev 121727)
@@ -1,3 +1,20 @@
+2012-07-02  Chris Guan  <[email protected]>
+
+        [BlackBerry] Refactor : move the implementation of getMIMETypeForExtension and getPreferredExtensionForMIMEType into BlackBerry platform
+        https://bugs.webkit.org/show_bug.cgi?id=90360
+
+        Reviewed by Antonio Gomes.
+
+        We should have one implementation for getMIMETypeForExtension
+        and getPreferredExtensionForMIMEType for both webkit and platform,
+        so I move this implementation to BlackBerry platform.
+        
+        No new test cases , because no behavior changed.
+
+        * platform/blackberry/MIMETypeRegistryBlackBerry.cpp:
+        (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
+        (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
+
 2012-07-02  Emil A Eklund  <[email protected]>
 
         Position replaced elements on pixel bounds

Modified: trunk/Source/WebCore/platform/blackberry/MIMETypeRegistryBlackBerry.cpp (121726 => 121727)


--- trunk/Source/WebCore/platform/blackberry/MIMETypeRegistryBlackBerry.cpp	2012-07-03 03:40:34 UTC (rev 121726)
+++ trunk/Source/WebCore/platform/blackberry/MIMETypeRegistryBlackBerry.cpp	2012-07-03 03:43:19 UTC (rev 121727)
@@ -30,107 +30,19 @@
 #include "MIMETypeRegistry.h"
 
 #include "NotImplemented.h"
+#include <BlackBerryPlatformCommonFunctions.h>
+#include <wtf/text/CString.h>
 
 namespace WebCore {
 
-struct ExtensionMap {
-    const char* extension;
-    const char* mimeType;
-};
-
-static const ExtensionMap extensionMap[] = {
-    { "bmp", "image/bmp" },
-    { "css", "text/css" },
-    { "gif", "image/gif" },
-    { "html", "text/html" },
-    { "htm", "text/html" },
-    { "ico", "image/x-icon" },
-    { "jpg", "image/jpeg" },
-    { "jpeg", "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" },
-    { "svgz", "image/svg+xml" },
-    { "txt", "text/plain" },
-    { "text", "text/plain" },
-    { "tiff", "image/tiff" },
-    { "tif", "image/tiff" },
-    { "xbm", "image/x-xbitmap" },
-    { "xml", "text/xml" },
-    { "xpm", "image/x-xpm" },
-    { "xsl", "text/xsl" },
-    { "xhtml", "application/xhtml+xml" },
-    { "m4a", "audio/m4a" },
-    { "midi", "audio/midi" },
-    { "mid", "audio/mid" },
-    { "mp3", "audio/mp3" },
-    { "wma", "audio/x-ms-wma" },
-    { "3gp", "video/3gpp" },
-    { "3gpp", "video/3gpp" },
-    { "3gpp2", "video/3gpp2" },
-    { "3g2", "video/3gpp2" },
-    { "3gp2", "video/3gpp2" },
-    { "mp4", "video/mp4" },
-    { "m4v", "video/m4v" },
-    { "avi", "video/x-msvideo" },
-    { "mov", "video/quicktime" },
-    { "divx", "video/divx" },
-    { "mpeg", "video/mpeg" },
-    { "sbv", "video/sbv" },
-    { "asf", "video/x-ms-asf" },
-    { "wm", "video/x-ms-wm" },
-    { "wmv", "video/x-ms-wmv" },
-    { "wmx", "video/x-ms-wmx" },
-    { "wav", "audio/x-wav" },
-    { "amr", "audio/amr" },
-    { "aac", "audio/aac" },
-    { "x-gsm", "audio/x-gsm" },
-    { "swf", "application/x-shockwave-flash" },
-    { "m3u8", "application/vnd.apple.mpegurl" },
-    { "m3url", "audio/mpegurl" },
-    { "m3u", "audio/mpegurl" },
-    { "flac", "audio/x-flac" },
-    { "ogg", "audio/ogg" },
-    { "oga", "audio/ogg" },
-    // FIXME: wince also maps ttf and otf to text/plain. Should we do that too?
-    { 0, 0 }
-};
-
 String MIMETypeRegistry::getMIMETypeForExtension(const String& extension)
 {
-    String lowerExtension = extension.lower();
-
-    const ExtensionMap* entry = extensionMap;
-    while (entry->extension) {
-        if (lowerExtension == entry->extension)
-            return entry->mimeType;
-        ++entry;
-    }
-
-    return String();
+    return String(BlackBerry::Platform::getMIMETypeForExtension(extension.lower().utf8().data()).c_str());
 }
 
 String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
 {
-    if (type.isEmpty())
-        return String();
-
-    String lowerType = type.lower();
-
-    const ExtensionMap* entry = extensionMap;
-    while (entry->mimeType) {
-        if (lowerType == entry->mimeType)
-            return entry->extension;
-        ++entry;
-    }
-
-    return String();
+    return String(BlackBerry::Platform::getPreferredExtensionForMIMEType(type.lower().utf8().data()).c_str());
 }
 
 bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to