Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: net/base/platform_mime_util_mac.mm

Issue 1884453002: Revert of Convert //net and //chromecast to std::unordered_* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/platform_mime_util_linux.cc ('k') | net/base/platform_mime_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/platform_mime_util.h" 5 #include "net/base/platform_mime_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 UTTypeCopyPreferredTagWithClass(uti, kUTTagClassFilenameExtension)); 66 UTTypeCopyPreferredTagWithClass(uti, kUTTagClassFilenameExtension));
67 if (!ext_ref) 67 if (!ext_ref)
68 return false; 68 return false;
69 69
70 *ext = base::SysCFStringRefToUTF8(ext_ref); 70 *ext = base::SysCFStringRefToUTF8(ext_ref);
71 return true; 71 return true;
72 } 72 }
73 73
74 void PlatformMimeUtil::GetPlatformExtensionsForMimeType( 74 void PlatformMimeUtil::GetPlatformExtensionsForMimeType(
75 const std::string& mime_type, 75 const std::string& mime_type,
76 std::unordered_set<base::FilePath::StringType>* extensions) const { 76 base::hash_set<base::FilePath::StringType>* extensions) const {
77 #if defined(OS_IOS) 77 #if defined(OS_IOS)
78 NSArray* extensions_list = nil; 78 NSArray* extensions_list = nil;
79 #else 79 #else
80 // There is no API for this that uses UTIs. The WebKitSystemInterface call 80 // There is no API for this that uses UTIs. The WebKitSystemInterface call
81 // WKGetExtensionsForMIMEType() is a thin wrapper around 81 // WKGetExtensionsForMIMEType() is a thin wrapper around
82 // [[NSURLFileTypeMappings sharedMappings] extensionsForMIMEType:], which is 82 // [[NSURLFileTypeMappings sharedMappings] extensionsForMIMEType:], which is
83 // used by Firefox as well. 83 // used by Firefox as well.
84 // 84 //
85 // See: 85 // See:
86 // http://mxr.mozilla.org/mozilla-central/search?string=extensionsForMIMEType 86 // http://mxr.mozilla.org/mozilla-central/search?string=extensionsForMIMEType
87 // http://www.openradar.me/11384153 87 // http://www.openradar.me/11384153
88 // rdar://11384153 88 // rdar://11384153
89 NSArray* extensions_list = 89 NSArray* extensions_list =
90 [[NSURLFileTypeMappings sharedMappings] 90 [[NSURLFileTypeMappings sharedMappings]
91 extensionsForMIMEType:base::SysUTF8ToNSString(mime_type)]; 91 extensionsForMIMEType:base::SysUTF8ToNSString(mime_type)];
92 #endif // defined(OS_IOS) 92 #endif // defined(OS_IOS)
93 93
94 if (extensions_list) { 94 if (extensions_list) {
95 for (NSString* extension in extensions_list) 95 for (NSString* extension in extensions_list)
96 extensions->insert(base::SysNSStringToUTF8(extension)); 96 extensions->insert(base::SysNSStringToUTF8(extension));
97 } else { 97 } else {
98 // Huh? Give up. 98 // Huh? Give up.
99 base::FilePath::StringType ext; 99 base::FilePath::StringType ext;
100 if (GetPreferredExtensionForMimeType(mime_type, &ext)) 100 if (GetPreferredExtensionForMimeType(mime_type, &ext))
101 extensions->insert(ext); 101 extensions->insert(ext);
102 } 102 }
103 } 103 }
104 104
105 } // namespace net 105 } // namespace net
OLDNEW
« no previous file with comments | « net/base/platform_mime_util_linux.cc ('k') | net/base/platform_mime_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698