Changeset 57513 in webkit


Ignore:
Timestamp:
Apr 13, 2010 6:45:26 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-13 Stephan Aßmus <superstippi@gmx.de>

Reviewed by David Levin.

Use the Haiku MIME type data base as a fall back for unknown file extensions.
https://bugs.webkit.org/show_bug.cgi?id=34686

Covered by existing tests.

  • platform/haiku/MIMETypeRegistryHaiku.cpp: (WebCore::):
    • fixed coding style issues

(WebCore::MIMETypeRegistry::getMIMETypeForExtension):

  • fall back to the system MIME database for unknown types.
  • return empty String as last resort, this is used elsewhere as indicator for unknown types.
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57512 r57513  
     12010-04-13  Stephan Aßmus  <superstippi@gmx.de>
     2
     3        Reviewed by David Levin.
     4
     5        Use the Haiku MIME type data base as a fall back for unknown file extensions.
     6        https://bugs.webkit.org/show_bug.cgi?id=34686
     7
     8        Covered by existing tests.
     9
     10        * platform/haiku/MIMETypeRegistryHaiku.cpp:
     11        (WebCore::):
     12            - fixed coding style issues
     13        (WebCore::MIMETypeRegistry::getMIMETypeForExtension):
     14            - fall back to the system MIME database for unknown types.
     15            - return empty String as last resort, this is used
     16              elsewhere as indicator for unknown types.
     17
    1182010-04-13  Stephan Aßmus  <superstippi@gmx.de>
    219
  • trunk/WebCore/platform/haiku/MIMETypeRegistryHaiku.cpp

    r56661 r57513  
    33 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
    44 * Copyright (C) 2007 Trolltech ASA
     5 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
    56 *
    67 * Redistribution and use in source and binary forms, with or without
     
    3031
    3132#include "PlatformString.h"
    32 
     33#include <MimeType.h>
     34#include <wtf/text/CString.h>
    3335
    3436namespace WebCore {
     
    3840};
    3941
    40 static const ExtensionMap extensionMap [] = {
     42static const ExtensionMap extensionMap[] = {
    4143    { "bmp", "image/bmp" },
    4244    { "gif", "image/gif" },
    4345    { "html", "text/html" },
    44     { "ico", "image/x-icon" },   
     46    { "ico", "image/x-icon" },
    4547    { "jpeg", "image/jpeg" },
    4648    { "jpg", "image/jpeg" },
     
    5961};
    6062
    61 // FIXME: Use the Haiku MIME registry
    62 String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
     63String MIMETypeRegistry::getMIMETypeForExtension(const String& ext)
    6364{
    6465    String str = ext.lower();
    65     const ExtensionMap *extMap = extensionMap;
     66
     67    // Try WebCore built-in types.
     68    const ExtensionMap* extMap = extensionMap;
    6669    while (extMap->extension) {
    6770        if (str == extMap->extension)
     
    6972        ++extMap;
    7073    }
    71     // unknown, let's just assume plain text
    72     return "text/plain";
     74
     75    // Try system mime database.
     76    String fakeFileName("filename.");
     77    fakeFileName.append(str);
     78
     79    BMimeType type;
     80    if (BMimeType::GuessMimeType(fakeFileName.utf8().data(), &type) == B_OK)
     81        return type.Type();
     82
     83    // unknown
     84    return String();
    7385}
    7486
     
    7789    return false;
    7890}
     91
    7992} // namespace WebCore
    8093
Note: See TracChangeset for help on using the changeset viewer.