Changeset 257687 in webkit
- Timestamp:
- Feb 29, 2020 7:32:16 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r257685 r257687 1 2020-02-29 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-02-29 Zalan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebCore/platform/network/mac/UTIUtilities.h
r250256 r257687 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(); 39 WEBCORE_EXPORT const Vector<String>& mimeTypes(); 37 40 } 38 39 #endif // UTIUtilities_h -
trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm
r251134 r257687 41 41 #endif 42 42 43 #define EMPTY_MIME_TYPE_STRING "emptyMimeType"_s 44 43 45 namespace WebCore { 44 46 … … 114 116 } 115 117 118 static Optional<HashMap<String, String>>& mapUTIFromMIMEType() 119 { 120 static NeverDestroyed<Optional<HashMap<String, String>>> map; 121 return map; 122 } 123 116 124 struct UTIFromMIMETypeCachePolicy : TinyLRUCachePolicy<String, String> { 117 125 public: 118 static String createValueForKey(const String& key)126 static String createValueForKey(const String& mimeType) 119 127 { 128 String key = mimeType; 129 if (mapUTIFromMIMEType().hasValue()) { 130 if (key.isEmpty()) 131 key = EMPTY_MIME_TYPE_STRING; 132 const auto& it = mapUTIFromMIMEType()->find(key); 133 if (it != mapUTIFromMIMEType()->end()) 134 return it->value; 135 WTFLogAlways("UTI for MIME type %s not found.", key.utf8().data()); 136 ASSERT_NOT_REACHED(); 137 } 120 138 auto type = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, key.createCFString().get(), 0)); 121 139 if (type) … … 125 143 }; 126 144 145 static TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>& cacheUTIFromMimeType() 146 { 147 static NeverDestroyed<TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>> cache; 148 return cache; 149 } 150 127 151 String UTIFromMIMEType(const String& mimeType) 128 152 { 129 153 ASSERT(isMainThread()); 130 static NeverDestroyed<TinyLRUCache<String, String, 16, UTIFromMIMETypeCachePolicy>> cache; 131 return cache.get().get(mimeType); 154 return cacheUTIFromMimeType().get(mimeType); 132 155 } 133 156 … … 137 160 } 138 161 139 } 162 const Vector<String>& mimeTypes() 163 { 164 static NeverDestroyed<Vector<String>> mimeTypes = std::initializer_list<String> { 165 "application/ogg"_s, 166 "audio/ogg"_s, 167 "video/ogg"_s, 168 "application/annodex"_s, 169 "audio/annodex"_s, 170 "video/annodex"_s, 171 "audio/speex"_s, 172 "video/webm"_s, 173 "audio/webm"_s, 174 "audio/mpeg"_s, 175 "video/mpeg"_s, 176 "application/vnd.apple.mpegurl"_s, 177 "application/mpegurl"_s, 178 "application/x-mpegurl"_s, 179 "audio/mpegurl"_s, 180 "audio/x-mpegurl"_s, 181 "audio/mpegurl"_s, 182 "video/x-m4v"_s, 183 "audio/x-m4a"_s, 184 "audio/x-m4b"_s, 185 "audio/x-m4p"_s, 186 "audio/mp4"_s, 187 "audio/mp3"_s, 188 "audio/x-mp3"_s, 189 "audio/x-mpeg"_s, 190 "video/x-mpeg2"_s, 191 "video/mpeg2"_s, 192 "video/m2ts"_s, 193 "video/x-m2ts"_s, 194 "audio/3gpp"_s, 195 "audio/3gpp2"_s, 196 "application/x-mpeg"_s, 197 "audio/aac"_s, 198 "audio/x-aac"_s, 199 "audio/x-caf"_s, 200 "audio/x-gsm"_s, 201 "audio/x-wav"_s, 202 "audio/vnd.wave"_s, 203 }; 204 return mimeTypes; 205 }; 206 207 const HashMap<String, String>& createUTIFromMIMETypeMap() 208 { 209 static NeverDestroyed<HashMap<String, String>> map = [] { 210 HashMap<String, String> cache; 211 for (auto mimeType : mimeTypes()) 212 cache.add(mimeType, UTIFromMIMEType(mimeType)); 213 cache.add(EMPTY_MIME_TYPE_STRING, UTIFromMIMEType(emptyString())); 214 return cache; 215 }(); 216 return map; 217 } 218 219 void setUTIFromMIMETypeMap(HashMap<String, String>&& map) 220 { 221 mapUTIFromMIMEType() = WTFMove(map); 222 } 223 224 } -
trunk/Source/WebCore/testing/Internals.cpp
r257655 r257687 5475 5475 return emptyString(); 5476 5476 } 5477 5478 String Internals::getUTIFromMIMEType(const String& mimeType) 5479 { 5480 return emptyString(); 5481 } 5477 5482 #endif 5478 5483 -
trunk/Source/WebCore/testing/Internals.h
r257354 r257687 939 939 String mediaMIMETypeForExtension(const String& extension); 940 940 941 String getUTIFromMIMEType(const String& mimeType); 942 941 943 bool supportsPictureInPicture(); 942 944 -
trunk/Source/WebCore/testing/Internals.idl
r256756 r257687 847 847 848 848 DOMString mediaMIMETypeForExtension(DOMString extension); 849 849 850 DOMString getUTIFromMIMEType(DOMString mimeType); 851 850 852 boolean supportsPictureInPicture(); 851 853 }; -
trunk/Source/WebCore/testing/Internals.mm
r257592 r257687 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
r257686 r257687 1 2020-02-29 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-02-29 Jer Noble <jer.noble@apple.com> 2 21 -
trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp
r257611 r257687 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
r257611 r257687 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
r257611 r257687 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
r257611 r257687 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
r257679 r257687 1 2020-02-29 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-02-28 Fujii Hironori <Hironori.Fujii@sony.com> 2 13 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r257614 r257687 884 884 C15CBB3F23FB177A00300CC7 /* PreferenceChanges.mm in Sources */ = {isa = PBXBuildFile; fileRef = C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */; }; 885 885 C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */ = {isa = PBXBuildFile; fileRef = C1692DC923D10DAE006E88F7 /* Battery.mm */; }; 886 C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */ = {isa = PBXBuildFile; fileRef = C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */; }; 886 887 C20F88A72295B96700D610FA /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C20F88A62295B96700D610FA /* CoreText.framework */; }; 887 888 C22FA32B228F8708009D7988 /* TextWidth.mm in Sources */ = {isa = PBXBuildFile; fileRef = C22FA32A228F8708009D7988 /* TextWidth.mm */; }; … … 2449 2450 C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreferenceChanges.mm; sourceTree = "<group>"; }; 2450 2451 C1692DC923D10DAE006E88F7 /* Battery.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Battery.mm; sourceTree = "<group>"; }; 2452 C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UTIFromMIMEType.mm; sourceTree = "<group>"; }; 2451 2453 C1D8EE212028E8E3008EB141 /* WebProcessTerminate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessTerminate.mm; sourceTree = "<group>"; }; 2452 2454 C20F88A62295B96700D610FA /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; … … 2901 2903 E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */, 2902 2904 C15CBB3E23FB177A00300CC7 /* PreferenceChanges.mm */, 2905 C194E31C2409DF43002939ED /* UTIFromMIMEType.mm */, 2903 2906 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */, 2904 2907 ); … … 5097 5100 7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */, 5098 5101 2EB242B821D4140B0055C1C0 /* UseSelectionAsFindString.mm in Sources */, 5102 C194E31D2409DF43002939ED /* UTIFromMIMEType.mm in Sources */, 5099 5103 7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */, 5100 5104 7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.