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

Side by Side Diff: content/child/simple_webmimeregistry_impl.cc

Issue 401523002: Move media related mimetype functionality out of net/ and into media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add content/common/mime_util.h for realz Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/simple_webmimeregistry_impl.h" 5 #include "content/child/simple_webmimeregistry_impl.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/common/mime_util.h"
12 #include "media/base/mime_util.h"
11 #include "net/base/mime_util.h" 13 #include "net/base/mime_util.h"
12 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
13 15
14 using blink::WebString; 16 using blink::WebString;
15 using blink::WebMimeRegistry; 17 using blink::WebMimeRegistry;
16 18
17 namespace content { 19 namespace content {
18 20
19 //static 21 //static
20 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { 22 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) {
21 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) 23 return base::IsStringASCII(string) ? base::UTF16ToASCII(string)
22 : std::string(); 24 : std::string();
23 } 25 }
24 26
25 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( 27 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType(
26 const WebString& mime_type) { 28 const WebString& mime_type) {
27 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? 29 return content::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ?
28 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 30 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
29 } 31 }
30 32
31 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( 33 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType(
32 const WebString& mime_type) { 34 const WebString& mime_type) {
33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ? 35 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ?
34 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 36 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
35 } 37 }
36 38
37 WebMimeRegistry::SupportsType 39 WebMimeRegistry::SupportsType
(...skipping 24 matching lines...) Expand all
62 const blink::WebString& key_system, 64 const blink::WebString& key_system,
63 const blink::WebString& mime_type, 65 const blink::WebString& mime_type,
64 const blink::WebString& codecs) { 66 const blink::WebString& codecs) {
65 // Media features are only supported at the content/renderer layer. 67 // Media features are only supported at the content/renderer layer.
66 return false; 68 return false;
67 } 69 }
68 70
69 WebMimeRegistry::SupportsType 71 WebMimeRegistry::SupportsType
70 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( 72 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
71 const WebString& mime_type) { 73 const WebString& mime_type) {
72 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? 74 return (net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ||
75 media::IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type))) ?
73 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; 76 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
74 } 77 }
75 78
76 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension( 79 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(
77 const WebString& file_extension) { 80 const WebString& file_extension) {
78 std::string mime_type; 81 std::string mime_type;
79 net::GetMimeTypeFromExtension( 82 net::GetMimeTypeFromExtension(
80 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type); 83 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type);
81 return WebString::fromUTF8(mime_type); 84 return WebString::fromUTF8(mime_type);
82 } 85 }
83 86
84 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension( 87 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension(
85 const WebString& file_extension) { 88 const WebString& file_extension) {
86 std::string mime_type; 89 std::string mime_type;
87 net::GetWellKnownMimeTypeFromExtension( 90 net::GetWellKnownMimeTypeFromExtension(
88 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type); 91 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type);
89 return WebString::fromUTF8(mime_type); 92 return WebString::fromUTF8(mime_type);
90 } 93 }
91 94
92 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( 95 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile(
93 const WebString& file_path) { 96 const WebString& file_path) {
94 std::string mime_type; 97 std::string mime_type;
95 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), 98 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path),
96 &mime_type); 99 &mime_type);
97 return WebString::fromUTF8(mime_type); 100 return WebString::fromUTF8(mime_type);
98 } 101 }
99 102
100 } // namespace content 103 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698