| 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" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); | 94 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
| 95 if (mime_type_ascii.empty()) | 95 if (mime_type_ascii.empty()) |
| 96 return false; | 96 return false; |
| 97 | 97 |
| 98 std::vector<std::string> parsed_codec_ids; | 98 std::vector<std::string> parsed_codec_ids; |
| 99 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); | 99 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); |
| 100 return media::StreamParserFactory::IsTypeSupported(mime_type_ascii, | 100 return media::StreamParserFactory::IsTypeSupported(mime_type_ascii, |
| 101 parsed_codec_ids); | 101 parsed_codec_ids); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool WebMimeRegistryImpl::supportsEncryptedMediaMIMEType( | |
| 105 const blink::WebString& key_system, | |
| 106 const blink::WebString& mime_type, | |
| 107 const blink::WebString& codecs) { | |
| 108 // Only supports ASCII parameters. | |
| 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)); | |
| 126 } | |
| 127 | |
| 128 blink::WebMimeRegistry::SupportsType | 104 blink::WebMimeRegistry::SupportsType |
| 129 WebMimeRegistryImpl::supportsNonImageMIMEType( | 105 WebMimeRegistryImpl::supportsNonImageMIMEType( |
| 130 const blink::WebString& mime_type) { | 106 const blink::WebString& mime_type) { |
| 131 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? | 107 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? |
| 132 blink::WebMimeRegistry::IsSupported : | 108 blink::WebMimeRegistry::IsSupported : |
| 133 blink::WebMimeRegistry::IsNotSupported; | 109 blink::WebMimeRegistry::IsNotSupported; |
| 134 } | 110 } |
| 135 | 111 |
| 136 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension( | 112 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension( |
| 137 const blink::WebString& file_extension) { | 113 const blink::WebString& file_extension) { |
| 138 NOTIMPLEMENTED(); | 114 NOTIMPLEMENTED(); |
| 139 return blink::WebString(); | 115 return blink::WebString(); |
| 140 } | 116 } |
| 141 | 117 |
| 142 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension( | 118 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension( |
| 143 const blink::WebString& file_extension) { | 119 const blink::WebString& file_extension) { |
| 144 NOTIMPLEMENTED(); | 120 NOTIMPLEMENTED(); |
| 145 return blink::WebString(); | 121 return blink::WebString(); |
| 146 } | 122 } |
| 147 | 123 |
| 148 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( | 124 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( |
| 149 const blink::WebString& file_path) { | 125 const blink::WebString& file_path) { |
| 150 NOTIMPLEMENTED(); | 126 NOTIMPLEMENTED(); |
| 151 return blink::WebString(); | 127 return blink::WebString(); |
| 152 } | 128 } |
| 153 | 129 |
| 154 } // namespace html_viewer | 130 } // namespace html_viewer |
| OLD | NEW |