Changeset 257828 in webkit
- Timestamp:
- Mar 3, 2020 9:13:01 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r257820 r257828 1 2020-03-03 Per Arne Vollan <pvollan@apple.com> 2 3 [Cocoa] Mapping from MIME type to UTI type should be done in the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=208415 5 6 Reviewed by Brent Fulgham. 7 8 This is currently done in the WebContent process, but since this is using a system service which will be closed, 9 this mapping should be moved to the UI process. The UI process will create this mapping for a set of mime types, 10 and send it to the WebContent process. 11 12 API test: WebKit.UTIFromMIMEType 13 14 * platform/network/mac/UTIUtilities.h: 15 * platform/network/mac/UTIUtilities.mm: 16 (WebCore::mapUTIFromMIMEType): 17 (WebCore::UTIFromMIMETypeCachePolicy::createValueForKey): 18 (WebCore::cacheUTIFromMimeType): 19 (WebCore::UTIFromMIMEType): 20 (WebCore::mimeTypes): 21 (WebCore::createUTIFromMIMETypeMap): 22 (WebCore::setUTIFromMIMETypeMap): 23 * testing/Internals.cpp: 24 (WebCore::Internals::getUTIFromMIMEType): 25 * testing/Internals.mm: 26 (WebCore::Internals::getUTIFromMIMEType): 27 * testing/Internals.h: 28 * testing/Internals.idl: 29 1 30 2020-03-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 31 -
trunk/Source/WebCore/platform/network/mac/UTIUtilities.h
r257777 r257828 24 24 */ 25 25 26 #ifndef UTIUtilities_h 27 #define UTIUtilities_h 26 #pragma once 28 27 29 #import <wtf/Forward.h> 30 #import <wtf/RetainPtr.h> 28 #include <wtf/text/WTFString.h> 31 29 32 30 namespace WebCore { 31 33 32 WEBCORE_EXPORT String MIMETypeFromUTI(const String&); 34 33 String MIMETypeFromUTITree(const String&); 35 34 WEBCORE_EXPORT String UTIFromMIMEType(const String&); 36 35 bool isDeclaredUTI(const String&); 36 37 WEBCORE_EXPORT void setUTIFromMIMETypeMap(HashMap<String, String>&&); 38 WEBCORE_EXPORT const HashMap<String, String>& createUTIFromMIMETypeMap(); 37 39 } 38 39 #endif // UTIUtilities_h -
trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm
r257777 r257828 26 26 #import "config.h" 27 27 #import "UTIUtilities.h" 28 29 #import "MIMETypeRegistry.h" 28 30 #import <wtf/MainThread.h> 29 31 #import <wtf/TinyLRUCache.h> … … 40 42 #define ADDITIONAL_UTI_MAPPINGS 41 43 #endif 44 45 #define EMPTY_MIME_TYPE_STRING "emptyMimeType"_s 42 46 43 47 namespace WebCore { … … 114 118 } 115 119 120 static Optional<HashMap<String, String>>& mapUTIFromMIMEType() 121 { 122 static NeverDestroyed<Optional<HashMap<String, String>>> map; 123 return map; 124 } 125 116 126 struct UTIFromMIMETypeCachePolicy : TinyLRUCachePolicy<String, String> { 117 127 public: 118 static String createValueForKey(const String& key)128 static String createValueForKey(const String& mimeType) 119 129 { 130 String key = mimeType; 131 if (mapUTIFromMIMEType().hasValue()) { 132 if (key.isEmpty()) 133 key = EMPTY_MIME_TYPE_STRING; 134 const auto& it = mapUTIFromMIMEType()->find(key); 135 if (it != mapUTIFromMIMEType()->end()) 136 return it->value; 137 WTFLogAlways("UTI for MIME type %s not found.", key.utf8().data()); 138 return UTIFromUnknownMIMEType(key); 139 } 120 140 auto type = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, key.createCFString().get(), 0)); 121 141 if (type) … … 125 145 }; 126 146 147 static TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>& cacheUTIFromMimeType() 148 { 149 static NeverDestroyed<TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>> cache; 150 return cache; 151 } 152 127 153 String UTIFromMIMEType(const String& mimeType) 128 154 { 129 155 ASSERT(isMainThread()); 130 static NeverDestroyed<TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>> cache; 131 return cache.get().get(mimeType); 156 return cacheUTIFromMimeType().get(mimeType); 132 157 } 133 158 … … 137 162 } 138 163 164 static const Vector<String>& additionalMIMETypes() 165 { 166 static NeverDestroyed<Vector<String>> mimeTypes = std::initializer_list<String> { 167 "application/zip"_s, 168 }; 169 return mimeTypes; 139 170 } 171 172 const HashMap<String, String>& createUTIFromMIMETypeMap() 173 { 174 static NeverDestroyed<HashMap<String, String>> map = [] { 175 HashMap<String, String> cache; 176 for (auto mimeType : MIMETypeRegistry::supportedImageMIMETypes()) 177 cache.add(mimeType, UTIFromMIMEType(mimeType)); 178 for (auto mimeType : MIMETypeRegistry::supportedNonImageMIMETypes()) 179 cache.add(mimeType, UTIFromMIMEType(mimeType)); 180 for (auto mimeType : MIMETypeRegistry::unsupportedTextMIMETypes()) 181 cache.add(mimeType, UTIFromMIMEType(mimeType)); 182 for (auto mimeType : MIMETypeRegistry::supportedMediaMIMETypes()) 183 cache.add(mimeType, UTIFromMIMEType(mimeType)); 184 for (auto mimeType : MIMETypeRegistry::pdfMIMETypes()) 185 cache.add(mimeType, UTIFromMIMEType(mimeType)); 186 for (auto mimeType : additionalMIMETypes()) 187 cache.add(mimeType, UTIFromMIMEType(mimeType)); 188 cache.add(EMPTY_MIME_TYPE_STRING, UTIFromMIMEType(emptyString())); 189 return cache; 190 }(); 191 return map; 192 } 193 194 void setUTIFromMIMETypeMap(HashMap<String, String>&& map) 195 { 196 mapUTIFromMIMEType() = WTFMove(map); 197 } 198 199 } -
trunk/Source/WebCore/testing/Internals.cpp
r257811 r257828 5484 5484 return emptyString(); 5485 5485 } 5486 5487 String Internals::getUTIFromMIMEType(const String& mimeType) 5488 { 5489 return emptyString(); 5490 } 5486 5491 #endif 5487 5492 -
trunk/Source/WebCore/testing/Internals.h
r257811 r257828 940 940 String mediaMIMETypeForExtension(const String& extension); 941 941 942 String getUTIFromMIMEType(const String& mimeType); 943 942 944 bool supportsPictureInPicture(); 943 945 -
trunk/Source/WebCore/testing/Internals.idl
r257811 r257828 849 849 850 850 DOMString mediaMIMETypeForExtension(DOMString extension); 851 851 852 DOMString getUTIFromMIMEType(DOMString mimeType); 853 852 854 boolean supportsPictureInPicture(); 853 855 }; -
trunk/Source/WebCore/testing/Internals.mm
r257777 r257828 35 35 #import "MediaPlayerPrivate.h" 36 36 #import "Range.h" 37 #import "UTIUtilities.h" 37 38 #import <AVFoundation/AVPlayer.h> 38 39 #import <wtf/cocoa/NSURLExtras.h> … … 101 102 } 102 103 104 String Internals::getUTIFromMIMEType(const String& mimeType) 105 { 106 return UTIFromMIMEType(mimeType); 103 107 } 108 109 } -
trunk/Source/WebKit/ChangeLog
r257819 r257828 1 2020-03-03 Per Arne Vollan <pvollan@apple.com> 2 3 [Cocoa] Mapping from MIME type to UTI type should be done in the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=208415 5 6 Reviewed by Brent Fulgham. 7 8 Send the mapping between MIME types and UTI types to the WebContent process as part of the Web 9 process creation parameters. 10 11 * Shared/WebProcessCreationParameters.cpp: 12 (WebKit::WebProcessCreationParameters::encode const): 13 (WebKit::WebProcessCreationParameters::decode): 14 * Shared/WebProcessCreationParameters.h: 15 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 16 (WebKit::WebProcessPool::platformInitializeWebProcess): 17 * WebProcess/cocoa/WebProcessCocoa.mm: 18 (WebKit::WebProcess::platformInitializeWebProcess): 19 1 20 2020-03-03 James Savage <james.savage@apple.com> 2 21 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp
r257777 r257828 172 172 encoder << systemHasBattery; 173 173 encoder << mimeTypesMap; 174 encoder << mapUTIFromMIMEType; 174 175 #endif 175 176 … … 461 462 return false; 462 463 parameters.mimeTypesMap = WTFMove(*mimeTypesMap); 464 465 Optional<HashMap<String, String>> mapUTIFromMIMEType; 466 decoder >> mapUTIFromMIMEType; 467 if (!mapUTIFromMIMEType) 468 return false; 469 parameters.mapUTIFromMIMEType = WTFMove(*mapUTIFromMIMEType); 463 470 #endif 464 471 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.h
r257777 r257828 214 214 bool systemHasBattery { false }; 215 215 Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>> mimeTypesMap; 216 HashMap<String, String> mapUTIFromMIMEType; 216 217 #endif 217 218 -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r257777 r257828 57 57 #import <WebCore/RuntimeApplicationChecks.h> 58 58 #import <WebCore/SharedBuffer.h> 59 #import <WebCore/UTIUtilities.h> 59 60 #import <objc/runtime.h> 60 61 #import <pal/spi/cf/CFNetworkSPI.h> … … 407 408 } 408 409 parameters.systemHasBattery = systemHasBattery(); 410 parameters.mimeTypesMap = commonMimeTypesMap(); 411 parameters.mapUTIFromMIMEType = createUTIFromMIMETypeMap(); 409 412 #endif 410 413 … … 415 418 parameters.contentFilterExtensionHandle = WTFMove(handle); 416 419 } 417 parameters.mimeTypesMap = commonMimeTypesMap();418 420 #endif 419 421 -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r257777 r257828 68 68 #import <WebCore/RuntimeApplicationChecks.h> 69 69 #import <WebCore/SWContextManager.h> 70 #import <WebCore/UTIUtilities.h> 70 71 #import <algorithm> 71 72 #import <dispatch/dispatch.h> … … 275 276 if (parameters.mimeTypesMap) 276 277 overriddenMimeTypesMap() = WTFMove(parameters.mimeTypesMap); 278 279 setUTIFromMIMETypeMap(WTFMove(parameters.mapUTIFromMIMEType)); 277 280 #endif 278 281 -
trunk/Tools/ChangeLog
r257818 r257828 1 2020-03-03 Per Arne Vollan <pvollan@apple.com> 2 3 [Cocoa] Mapping from MIME type to UTI type should be done in the UI process 4 https://bugs.webkit.org/show_bug.cgi?id=208415 5 6 Reviewed by Brent Fulgham. 7 8 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 9 * TestWebKitAPI/Tests/WebKit/UTIFromMIMEType.mm: Added. 10 (TEST): 11 1 12 2020-03-03 Alex Christensen <achristensen@webkit.org> 2 13 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r257780 r257828 887 887 C15CBB3F23FB177A00300CC7 /* PreferenceChanges.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */; }; 888 888 C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; }; 889 C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */ = {isa = PBXBuildFile; fileRef = C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */; }; 889 890 C20F88A72295B96700D610FA /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20F88A62295B96700D610FA /* CoreText.framework */; }; 890 891 C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */ = {isa = PBXBuildFile; fileRef = C22FA32A228F8708009D7988 /* TextWidth.mm */; }; … … 2457 2458 C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferenceChanges.mm; sourceTree = "<group>"; }; 2458 2459 C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; }; 2460 C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UTIFromMIMEType.mm; sourceTree = "<group>"; }; 2459 2461 C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; }; 2460 2462 C20F88A62295B96700D610FA /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; … … 2909 2911 E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */, 2910 2912 C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */, 2913 C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */, 2911 2914 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */, 2912 2915 ); … … 5109 5112 7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */, 5110 5113 2EB242B821D4140B0055C1C0 /* UseSelectionAsFindString.mm in Sources */, 5114 C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */, 5111 5115 7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */, 5112 5116 7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.