Changeset 244201 in webkit
- Timestamp:
- Apr 11, 2019 4:13:44 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244200 r244201 1 2019-04-11 Dean Jackson <dino@apple.com> 2 3 Extract UTI mapping and allow for additions 4 https://bugs.webkit.org/show_bug.cgi?id=196822 5 <rdar://problem/49822339> 6 7 Reviewed by Tim Horton. 8 9 Add an ADDITIONAL_SYSTEM_PREVIEW_TYPES macro to the list 10 of accepted MIME types. And add a new helper to map 11 MIME types to UTI types when the system was unable to 12 find an existing type. 13 14 * platform/MIMETypeRegistry.cpp: 15 (WebCore::MIMETypeRegistry::systemPreviewMIMETypes): 16 * platform/network/mac/UTIUtilities.mm: 17 (WebCore::UTIFromUnknownMIMEType): 18 (WebCore::UTIFromMIMETypeCachePolicy::createValueForKey): 19 1 20 2019-04-09 Ryosuke Niwa <rniwa@webkit.org> 2 21 -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r243682 r244201 56 56 #if USE(QUICK_LOOK) 57 57 #include "PreviewConverter.h" 58 #endif 59 60 #if USE(APPLE_INTERNAL_SDK) 61 #include <WebKitAdditions/AdditionalSystemPreviewTypes.h> 62 #else 63 #define ADDITIONAL_SYSTEM_PREVIEW_TYPES 58 64 #endif 59 65 … … 672 678 // Unofficial, but supported because we documented them. 673 679 "model/usd", 674 "model/vnd.pixar.usd" 680 "model/vnd.pixar.usd", 681 ADDITIONAL_SYSTEM_PREVIEW_TYPES 675 682 }; 676 683 return systemPreviewMIMETypes; -
trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm
r237266 r244201 32 32 #if PLATFORM(IOS_FAMILY) 33 33 #import <MobileCoreServices/MobileCoreServices.h> 34 #endif 35 36 #if USE(APPLE_INTERNAL_SDK) 37 #import <WebKitAdditions/AdditionalUTIMappings.h> 38 #else 39 #define ADDITIONAL_UTI_MAPPINGS 34 40 #endif 35 41 … … 79 85 } 80 86 87 static String UTIFromUnknownMIMEType(const String& mimeType) 88 { 89 static const auto map = makeNeverDestroyed([] { 90 struct TypeExtensionPair { 91 ASCIILiteral type; 92 ASCIILiteral uti; 93 }; 94 95 static const TypeExtensionPair pairs[] = { 96 { "model/vnd.usdz+zip"_s, "com.pixar.universal-scene-description-mobile"_s }, 97 { "model/usd"_s, "com.pixar.universal-scene-description-mobile"_s }, 98 { "model/vnd.pixar.usd"_s, "com.pixar.universal-scene-description-mobile"_s }, 99 ADDITIONAL_UTI_MAPPINGS 100 }; 101 102 HashMap<String, String, ASCIICaseInsensitiveHash> map; 103 for (auto& pair : pairs) 104 map.add(pair.type, pair.uti); 105 return map; 106 }()); 107 108 auto mapEntry = map.get().find(mimeType); 109 if (mapEntry == map.get().end()) 110 return emptyString(); 111 112 return mapEntry->value; 113 } 114 81 115 struct UTIFromMIMETypeCachePolicy : TinyLRUCachePolicy<String, String> { 82 116 public: 83 117 static String createValueForKey(const String& key) 84 118 { 85 return String(adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, key.createCFString().get(), 0)).get()); 119 auto type = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, key.createCFString().get(), 0)); 120 if (type) 121 return String(type.get()); 122 return UTIFromUnknownMIMEType(key); 86 123 } 87 124 }; -
trunk/Source/WebKit/ChangeLog
r244198 r244201 1 2019-04-11 Dean Jackson <dino@apple.com> 2 3 Extract UTI mapping and allow for additions 4 https://bugs.webkit.org/show_bug.cgi?id=196822 5 <rdar://problem/49822339> 6 7 Reviewed by Tim Horton. 8 9 Use the new helper to map MIME type to UTI. 10 11 * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: 12 (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): 13 * UIProcess/ios/WKSystemPreviewView.mm: 14 (getUTIForSystemPreviewMIMEType): 15 16 1 17 2019-04-11 Said Abou-Hallawa <sabouhallawa@apple.com> 2 18 -
trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
r241730 r244201 35 35 #import <UIKit/UIViewController.h> 36 36 #import <WebCore/MIMETypeRegistry.h> 37 #import <WebCore/UTIUtilities.h> 37 38 #import <pal/ios/QuickLookSoftLink.h> 38 39 #import <pal/spi/ios/QuickLookSPI.h> … … 82 83 // FIXME: We are launching the preview controller before getting a response from the resource, which 83 84 // means we don't actually know the real MIME type yet. 84 // FIXME: At the moment we only have one supported UTI, but if we start supporting more types, 85 // then we'll need a table. 86 static NSString *contentType = (__bridge NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("usdz"), nil); 85 NSString *contentType = WebCore::UTIFromMIMEType("model/vnd.usdz+zip"_s); 87 86 88 87 _item = adoptNS([PAL::allocQLItemInstance() initWithPreviewItemProvider:_itemProvider.get() contentType:contentType previewTitle:@"Preview" fileSize:@(0)]); -
trunk/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm
r243595 r244201 37 37 #import <WebCore/LocalizedStrings.h> 38 38 #import <WebCore/MIMETypeRegistry.h> 39 #import <WebCore/UTIUtilities.h> 39 40 #import <pal/ios/QuickLookSoftLink.h> 40 41 #import <pal/spi/cg/CoreGraphicsSPI.h> … … 46 47 SOFT_LINK_CLASS(AssetViewer, ASVThumbnailView); 47 48 48 // FIXME: At the moment we only have one supported UTI, but49 // if we start supporting more types, then we'll need a table.50 49 static NSString *getUTIForSystemPreviewMIMEType(const String& mimeType) 51 50 { 52 static NSString *uti = (__bridge NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, CFSTR("usdz"), nil);53 54 51 if (!WebCore::MIMETypeRegistry::isSystemPreviewMIMEType(mimeType)) 55 52 return nil; 56 53 57 return uti;54 return WebCore::UTIFromMIMEType(mimeType); 58 55 } 59 56
Note: See TracChangeset
for help on using the changeset viewer.