Changeset 135507 in webkit
- Timestamp:
- Nov 22, 2012 5:23:28 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r135503 r135507 1 2012-11-22 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 [Qt] Lookup mimetypes using QMimeDatabase 4 https://bugs.webkit.org/show_bug.cgi?id=102667 5 6 Reviewed by Simon Hausmann. 7 8 The Qt backend of MIMETypeRegistry now looks up using QMimeDatabase. 9 10 * loader/archive/ArchiveFactory.cpp: 11 (WebCore::archiveMIMETypes): 12 Also map the preferred freedesktop mimetype for MIME archives to MIME archive constructor. 13 * platform/MIMETypeRegistry.cpp: 14 (WebCore::MIMETypeRegistry::getNormalizedMIMEType): 15 * platform/qt/MIMETypeRegistryQt.cpp: 16 (WebCore::MIMETypeRegistry::getMIMETypeForExtension): 17 (WebCore::MIMETypeRegistry::getMIMETypeForPath): 18 (WebCore::MIMETypeRegistry::getNormalizedMIMEType): 19 1 20 2012-11-22 Cosmin Truta <ctruta@rim.com> 2 21 -
trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp
r130612 r135507 71 71 #if PLATFORM(GTK) 72 72 mimeTypes.set("message/rfc822", archiveFactoryCreate<MHTMLArchive>); 73 #elif PLATFORM(QT) 74 mimeTypes.set("application/x-mimearchive", archiveFactoryCreate<MHTMLArchive>); 73 75 #endif 74 76 #endif -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r131826 r135507 492 492 } 493 493 494 #if !PLATFORM(QT) 494 495 String MIMETypeRegistry::getMIMETypeForPath(const String& path) 495 496 { … … 501 502 return result; 502 503 } 503 return "application/octet-stream"; 504 } 504 return defaultMIMEType(); 505 } 506 #endif 505 507 506 508 bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType) … … 638 640 return defaultMIMEType; 639 641 } 642 643 #if !PLATFORM(QT) && !PLATFORM(BLACKBERRY) 644 String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeType) 645 { 646 return mimeType; 647 } 648 #endif 640 649 641 650 #if PLATFORM(BLACKBERRY) … … 697 706 return *mimeTypeMap; 698 707 } 699 #endif700 708 701 709 String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeType) 702 710 { 703 #if PLATFORM(BLACKBERRY)704 711 MIMETypeAssociationMap::const_iterator it = mimeTypeAssociationMap().find(mimeType); 705 712 706 713 if (it != mimeTypeAssociationMap().end()) 707 714 return it->value; 708 #endif 715 709 716 return mimeType; 710 717 } 711 718 #endif 712 719 713 720 } // namespace WebCore -
trunk/Source/WebCore/platform/qt/MIMETypeRegistryQt.cpp
r134214 r135507 30 30 #include "MIMETypeRegistry.h" 31 31 32 #include <QMimeDatabase> 32 33 #include <wtf/Assertions.h> 33 34 #include <wtf/MainThread.h> … … 35 36 namespace WebCore { 36 37 37 struct ExtensionMap {38 const char* extension;39 const char* mimeType;40 };41 42 static const ExtensionMap extensionMap[] = {43 { "bmp", "image/bmp" },44 { "css", "text/css" },45 { "gif", "image/gif" },46 { "html", "text/html" },47 { "htm", "text/html" },48 { "ico", "image/x-icon" },49 { "jpeg", "image/jpeg" },50 { "jpg", "image/jpeg" },51 { "js", "application/x-javascript" },52 { "mng", "video/x-mng" },53 { "mp4", "video/mp4" },54 { "m4v", "video/mp4" },55 { "m4a", "audio/x-m4a" },56 { "mht", "multipart/related" },57 { "mhtml", "multipart/related" },58 { "mp3", "audio/mp3" },59 { "ogv", "video/ogg" },60 { "oga", "audio/ogg" },61 { "ogm", "audio/ogg" },62 { "ogg", "audio/ogg" },63 { "webm", "video/webm" },64 { "webm", "audio/webm" },65 { "wav", "audio/wav" },66 { "mov", "video/quicktime" },67 { "pbm", "image/x-portable-bitmap" },68 { "pgm", "image/x-portable-graymap" },69 { "pdf", "application/pdf" },70 { "png", "image/png" },71 { "ppm", "image/x-portable-pixmap" },72 { "rss", "application/rss+xml" },73 { "svg", "image/svg+xml" },74 { "text", "text/plain" },75 { "tif", "image/tiff" },76 { "tiff", "image/tiff" },77 { "txt", "text/plain" },78 { "xbm", "image/x-xbitmap" },79 { "xml", "text/xml" },80 { "xpm", "image/x-xpm" },81 { "xsl", "text/xsl" },82 { "xhtml", "application/xhtml+xml" },83 { "wml", "text/vnd.wap.wml" },84 { "wmlc", "application/vnd.wap.wmlc" },85 { 0, 0 }86 };87 88 38 String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) 89 39 { 90 ASSERT(isMainThread()); 40 // QMimeDatabase lacks the ability to query by extension alone, so we create a fake filename to lookup. 41 const QString filename = QStringLiteral("filename.") + QString(ext.lower()); 91 42 92 String s = ext.lower(); 93 94 const ExtensionMap *e = extensionMap; 95 while (e->extension) { 96 if (s == e->extension) 97 return e->mimeType; 98 ++e; 99 } 43 QMimeType mimeType = QMimeDatabase().mimeTypeForFile(filename, QMimeDatabase::MatchExtension); 44 if (mimeType.isValid() && !mimeType.isDefault()) 45 return mimeType.name(); 100 46 101 47 return String(); 48 } 49 50 String MIMETypeRegistry::getMIMETypeForPath(const String& path) 51 { 52 QMimeType type = QMimeDatabase().mimeTypeForFile(path, QMimeDatabase::MatchExtension); 53 if (type.isValid()) 54 return type.name(); 55 56 return defaultMIMEType(); 57 } 58 59 String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeTypeName) 60 { 61 // This looks up the mime type object by preferred name or alias, and returns the preferred name. 62 QMimeType mimeType = QMimeDatabase().mimeTypeForName(mimeTypeName); 63 if (mimeType.isValid() && !mimeType.isDefault()) 64 return mimeType.name(); 65 66 return mimeTypeName; 102 67 } 103 68
Note: See TracChangeset
for help on using the changeset viewer.