Commit f947670c authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Switch to UTTypeCopyAllTagsWithClass.

This allows us to remove the use of a private API.

Bug: 1027401
Change-Id: I1cd0e236fdb4ded2093a4120a0af326b57d9efd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1929848
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Matt Mueller <mattm@chromium.org>
Reviewed-by: default avatarSidney San Martín <sdy@chromium.org>
Reviewed-by: default avatarMatt Mueller <mattm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718877}
parent 190c0e45
...@@ -18,16 +18,6 @@ ...@@ -18,16 +18,6 @@
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
#endif // defined(OS_IOS) #endif // defined(OS_IOS)
#if !defined(OS_IOS)
// SPI declaration; see the commentary in GetPlatformExtensionsForMimeType.
// iOS must not use any private API, per Apple guideline.
@interface NSURLFileTypeMappings : NSObject
+ (NSURLFileTypeMappings*)sharedMappings;
- (NSArray*)extensionsForMIMEType:(NSString*)mimeType;
@end
#endif // !defined(OS_IOS)
namespace net { namespace net {
bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
...@@ -40,7 +30,7 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( ...@@ -40,7 +30,7 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
if (!ext_ref) if (!ext_ref)
return false; return false;
base::ScopedCFTypeRef<CFStringRef> uti(UTTypeCreatePreferredIdentifierForTag( base::ScopedCFTypeRef<CFStringRef> uti(UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, ext_ref, NULL)); kUTTagClassFilenameExtension, ext_ref, nullptr));
if (!uti) if (!uti)
return false; return false;
base::ScopedCFTypeRef<CFStringRef> mime_ref( base::ScopedCFTypeRef<CFStringRef> mime_ref(
...@@ -60,7 +50,7 @@ bool PlatformMimeUtil::GetPlatformPreferredExtensionForMimeType( ...@@ -60,7 +50,7 @@ bool PlatformMimeUtil::GetPlatformPreferredExtensionForMimeType(
if (!mime_ref) if (!mime_ref)
return false; return false;
base::ScopedCFTypeRef<CFStringRef> uti(UTTypeCreatePreferredIdentifierForTag( base::ScopedCFTypeRef<CFStringRef> uti(UTTypeCreatePreferredIdentifierForTag(
kUTTagClassMIMEType, mime_ref, NULL)); kUTTagClassMIMEType, mime_ref, nullptr));
if (!uti) if (!uti)
return false; return false;
base::ScopedCFTypeRef<CFStringRef> ext_ref( base::ScopedCFTypeRef<CFStringRef> ext_ref(
...@@ -75,22 +65,21 @@ bool PlatformMimeUtil::GetPlatformPreferredExtensionForMimeType( ...@@ -75,22 +65,21 @@ bool PlatformMimeUtil::GetPlatformPreferredExtensionForMimeType(
void PlatformMimeUtil::GetPlatformExtensionsForMimeType( void PlatformMimeUtil::GetPlatformExtensionsForMimeType(
const std::string& mime_type, const std::string& mime_type,
std::unordered_set<base::FilePath::StringType>* extensions) const { std::unordered_set<base::FilePath::StringType>* extensions) const {
#if defined(OS_IOS) base::ScopedCFTypeRef<CFArrayRef> exts_ref;
NSArray* extensions_list = nil;
#else base::ScopedCFTypeRef<CFStringRef> mime_ref(
// There is no API for this that uses UTIs. The WebKitSystemInterface call base::SysUTF8ToCFStringRef(mime_type));
// WKGetExtensionsForMIMEType() is a thin wrapper around if (mime_ref) {
// [[NSURLFileTypeMappings sharedMappings] extensionsForMIMEType:], which is base::ScopedCFTypeRef<CFStringRef> uti(
// used by Firefox as well. UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mime_ref,
// nullptr));
// See: if (uti) {
// http://mxr.mozilla.org/mozilla-central/search?string=extensionsForMIMEType exts_ref.reset(
// http://www.openradar.me/11384153 UTTypeCopyAllTagsWithClass(uti, kUTTagClassFilenameExtension));
// rdar://11384153 }
NSArray* extensions_list = }
[[NSURLFileTypeMappings sharedMappings]
extensionsForMIMEType:base::SysUTF8ToNSString(mime_type)]; NSArray* extensions_list = base::mac::CFToNSCast(exts_ref);
#endif // defined(OS_IOS)
if (extensions_list) { if (extensions_list) {
for (NSString* extension in extensions_list) for (NSString* extension in extensions_list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment