Changeset 121727 in webkit


Ignore:
Timestamp:
Jul 2, 2012 8:43:19 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <chris.guan@torchmobile.com.cn> 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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121722 r121727  
     12012-07-02  Chris Guan  <chris.guan@torchmobile.com.cn>
     2
     3        [BlackBerry] Refactor : move the implementation of getMIMETypeForExtension and getPreferredExtensionForMIMEType into BlackBerry platform
     4        https://bugs.webkit.org/show_bug.cgi?id=90360
     5
     6        Reviewed by Antonio Gomes.
     7
     8        We should have one implementation for getMIMETypeForExtension
     9        and getPreferredExtensionForMIMEType for both webkit and platform,
     10        so I move this implementation to BlackBerry platform.
     11       
     12        No new test cases , because no behavior changed.
     13
     14        * platform/blackberry/MIMETypeRegistryBlackBerry.cpp:
     15        (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
     16        (WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType):
     17
    1182012-07-02  Emil A Eklund  <eae@chromium.org>
    219
  • trunk/Source/WebCore/platform/blackberry/MIMETypeRegistryBlackBerry.cpp

    r112092 r121727  
    3131
    3232#include "NotImplemented.h"
     33#include <BlackBerryPlatformCommonFunctions.h>
     34#include <wtf/text/CString.h>
    3335
    3436namespace WebCore {
    3537
    36 struct ExtensionMap {
    37     const char* extension;
    38     const char* mimeType;
    39 };
    40 
    41 static const ExtensionMap extensionMap[] = {
    42     { "bmp", "image/bmp" },
    43     { "css", "text/css" },
    44     { "gif", "image/gif" },
    45     { "html", "text/html" },
    46     { "htm", "text/html" },
    47     { "ico", "image/x-icon" },
    48     { "jpg", "image/jpeg" },
    49     { "jpeg", "image/jpeg" },
    50     { "js", "application/x-javascript" },
    51     { "mng", "video/x-mng" },
    52     { "pbm", "image/x-portable-bitmap" },
    53     { "pgm", "image/x-portable-graymap" },
    54     { "pdf", "application/pdf" },
    55     { "png", "image/png" },
    56     { "ppm", "image/x-portable-pixmap" },
    57     { "rss", "application/rss+xml" },
    58     { "svg", "image/svg+xml" },
    59     { "svgz", "image/svg+xml" },
    60     { "txt", "text/plain" },
    61     { "text", "text/plain" },
    62     { "tiff", "image/tiff" },
    63     { "tif", "image/tiff" },
    64     { "xbm", "image/x-xbitmap" },
    65     { "xml", "text/xml" },
    66     { "xpm", "image/x-xpm" },
    67     { "xsl", "text/xsl" },
    68     { "xhtml", "application/xhtml+xml" },
    69     { "m4a", "audio/m4a" },
    70     { "midi", "audio/midi" },
    71     { "mid", "audio/mid" },
    72     { "mp3", "audio/mp3" },
    73     { "wma", "audio/x-ms-wma" },
    74     { "3gp", "video/3gpp" },
    75     { "3gpp", "video/3gpp" },
    76     { "3gpp2", "video/3gpp2" },
    77     { "3g2", "video/3gpp2" },
    78     { "3gp2", "video/3gpp2" },
    79     { "mp4", "video/mp4" },
    80     { "m4v", "video/m4v" },
    81     { "avi", "video/x-msvideo" },
    82     { "mov", "video/quicktime" },
    83     { "divx", "video/divx" },
    84     { "mpeg", "video/mpeg" },
    85     { "sbv", "video/sbv" },
    86     { "asf", "video/x-ms-asf" },
    87     { "wm", "video/x-ms-wm" },
    88     { "wmv", "video/x-ms-wmv" },
    89     { "wmx", "video/x-ms-wmx" },
    90     { "wav", "audio/x-wav" },
    91     { "amr", "audio/amr" },
    92     { "aac", "audio/aac" },
    93     { "x-gsm", "audio/x-gsm" },
    94     { "swf", "application/x-shockwave-flash" },
    95     { "m3u8", "application/vnd.apple.mpegurl" },
    96     { "m3url", "audio/mpegurl" },
    97     { "m3u", "audio/mpegurl" },
    98     { "flac", "audio/x-flac" },
    99     { "ogg", "audio/ogg" },
    100     { "oga", "audio/ogg" },
    101     // FIXME: wince also maps ttf and otf to text/plain. Should we do that too?
    102     { 0, 0 }
    103 };
    104 
    10538String MIMETypeRegistry::getMIMETypeForExtension(const String& extension)
    10639{
    107     String lowerExtension = extension.lower();
    108 
    109     const ExtensionMap* entry = extensionMap;
    110     while (entry->extension) {
    111         if (lowerExtension == entry->extension)
    112             return entry->mimeType;
    113         ++entry;
    114     }
    115 
    116     return String();
     40    return String(BlackBerry::Platform::getMIMETypeForExtension(extension.lower().utf8().data()).c_str());
    11741}
    11842
    11943String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
    12044{
    121     if (type.isEmpty())
    122         return String();
    123 
    124     String lowerType = type.lower();
    125 
    126     const ExtensionMap* entry = extensionMap;
    127     while (entry->mimeType) {
    128         if (lowerType == entry->mimeType)
    129             return entry->extension;
    130         ++entry;
    131     }
    132 
    133     return String();
     45    return String(BlackBerry::Platform::getPreferredExtensionForMIMEType(type.lower().utf8().data()).c_str());
    13446}
    13547
Note: See TracChangeset for help on using the changeset viewer.