OLD | NEW |
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 "mojo/services/html_viewer/webmimeregistry_impl.h" | 5 #include "mojo/services/html_viewer/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 "media/base/key_systems.h" |
11 #include "media/filters/stream_parser_factory.h" | 12 #include "media/filters/stream_parser_factory.h" |
12 #include "net/base/mime_util.h" | 13 #include "net/base/mime_util.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
14 | 15 |
15 namespace html_viewer { | 16 namespace html_viewer { |
16 namespace { | 17 namespace { |
17 | 18 |
18 std::string ToASCIIOrEmpty(const blink::WebString& string) { | 19 std::string ToASCIIOrEmpty(const blink::WebString& string) { |
19 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) | 20 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) |
20 : std::string(); | 21 : std::string(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 std::vector<std::string> parsed_codec_ids; | 98 std::vector<std::string> parsed_codec_ids; |
98 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); | 99 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); |
99 return media::StreamParserFactory::IsTypeSupported(mime_type_ascii, | 100 return media::StreamParserFactory::IsTypeSupported(mime_type_ascii, |
100 parsed_codec_ids); | 101 parsed_codec_ids); |
101 } | 102 } |
102 | 103 |
103 bool WebMimeRegistryImpl::supportsEncryptedMediaMIMEType( | 104 bool WebMimeRegistryImpl::supportsEncryptedMediaMIMEType( |
104 const blink::WebString& key_system, | 105 const blink::WebString& key_system, |
105 const blink::WebString& mime_type, | 106 const blink::WebString& mime_type, |
106 const blink::WebString& codecs) { | 107 const blink::WebString& codecs) { |
107 NOTIMPLEMENTED(); | 108 // Only supports ASCII parameters. |
108 return false; | 109 if (!base::IsStringASCII(key_system) || !base::IsStringASCII(mime_type) || |
| 110 !base::IsStringASCII(codecs)) { |
| 111 return false; |
| 112 } |
| 113 |
| 114 if (key_system.isEmpty()) |
| 115 return false; |
| 116 |
| 117 const std::string mime_type_ascii = base::UTF16ToASCII(mime_type); |
| 118 |
| 119 std::vector<std::string> codec_vector; |
| 120 bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii); |
| 121 net::ParseCodecString(base::UTF16ToASCII(codecs), &codec_vector, |
| 122 strip_suffix); |
| 123 |
| 124 return media::IsSupportedKeySystemWithMediaMimeType( |
| 125 mime_type_ascii, codec_vector, base::UTF16ToASCII(key_system)); |
109 } | 126 } |
110 | 127 |
111 blink::WebMimeRegistry::SupportsType | 128 blink::WebMimeRegistry::SupportsType |
112 WebMimeRegistryImpl::supportsNonImageMIMEType( | 129 WebMimeRegistryImpl::supportsNonImageMIMEType( |
113 const blink::WebString& mime_type) { | 130 const blink::WebString& mime_type) { |
114 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? | 131 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? |
115 blink::WebMimeRegistry::IsSupported : | 132 blink::WebMimeRegistry::IsSupported : |
116 blink::WebMimeRegistry::IsNotSupported; | 133 blink::WebMimeRegistry::IsNotSupported; |
117 } | 134 } |
118 | 135 |
119 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension( | 136 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension( |
120 const blink::WebString& file_extension) { | 137 const blink::WebString& file_extension) { |
121 NOTIMPLEMENTED(); | 138 NOTIMPLEMENTED(); |
122 return blink::WebString(); | 139 return blink::WebString(); |
123 } | 140 } |
124 | 141 |
125 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension( | 142 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension( |
126 const blink::WebString& file_extension) { | 143 const blink::WebString& file_extension) { |
127 NOTIMPLEMENTED(); | 144 NOTIMPLEMENTED(); |
128 return blink::WebString(); | 145 return blink::WebString(); |
129 } | 146 } |
130 | 147 |
131 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( | 148 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( |
132 const blink::WebString& file_path) { | 149 const blink::WebString& file_path) { |
133 NOTIMPLEMENTED(); | 150 NOTIMPLEMENTED(); |
134 return blink::WebString(); | 151 return blink::WebString(); |
135 } | 152 } |
136 | 153 |
137 } // namespace html_viewer | 154 } // namespace html_viewer |
OLD | NEW |