| OLD | NEW |
| 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 "webkit/glue/simple_webmimeregistry_impl.h" | 5 #include "webkit/glue/simple_webmimeregistry_impl.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "media/filters/stream_parser_factory.h" |
| 10 #include "net/base/mime_util.h" | 11 #include "net/base/mime_util.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 12 #include "webkit/base/file_path_string_conversions.h" | 13 #include "webkit/base/file_path_string_conversions.h" |
| 13 #include "webkit/media/crypto/key_systems.h" | 14 #include "webkit/media/crypto/key_systems.h" |
| 14 | 15 |
| 15 using WebKit::WebString; | 16 using WebKit::WebString; |
| 16 using WebKit::WebMimeRegistry; | 17 using WebKit::WebMimeRegistry; |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // If we don't recognize the codec, it's possible we support it. | 100 // If we don't recognize the codec, it's possible we support it. |
| 100 std::vector<std::string> parsed_codecs; | 101 std::vector<std::string> parsed_codecs; |
| 101 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); | 102 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); |
| 102 if (!net::AreSupportedMediaCodecs(parsed_codecs)) | 103 if (!net::AreSupportedMediaCodecs(parsed_codecs)) |
| 103 return MayBeSupported; | 104 return MayBeSupported; |
| 104 | 105 |
| 105 // Otherwise we have a perfect match. | 106 // Otherwise we have a perfect match. |
| 106 return IsSupported; | 107 return IsSupported; |
| 107 } | 108 } |
| 108 | 109 |
| 110 bool SimpleWebMimeRegistryImpl::supportsMediaSourceMIMEType( |
| 111 const WebKit::WebString& mime_type, |
| 112 const WebString& codecs) { |
| 113 const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
| 114 std::vector<std::string> parsed_codec_ids; |
| 115 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); |
| 116 if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0) |
| 117 return false; |
| 118 return media::StreamParserFactory::IsTypeSupported( |
| 119 mime_type_ascii, parsed_codec_ids); |
| 120 } |
| 121 |
| 109 WebMimeRegistry::SupportsType | 122 WebMimeRegistry::SupportsType |
| 110 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( | 123 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType( |
| 111 const WebString& mime_type) { | 124 const WebString& mime_type) { |
| 112 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? | 125 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? |
| 113 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 126 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
| 114 } | 127 } |
| 115 | 128 |
| 116 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension( | 129 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension( |
| 117 const WebString& file_extension) { | 130 const WebString& file_extension) { |
| 118 std::string mime_type; | 131 std::string mime_type; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 139 | 152 |
| 140 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( | 153 WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType( |
| 141 const WebString& mime_type) { | 154 const WebString& mime_type) { |
| 142 base::FilePath::StringType file_extension; | 155 base::FilePath::StringType file_extension; |
| 143 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), | 156 net::GetPreferredExtensionForMimeType(ToASCIIOrEmpty(mime_type), |
| 144 &file_extension); | 157 &file_extension); |
| 145 return webkit_base::FilePathStringToWebString(file_extension); | 158 return webkit_base::FilePathStringToWebString(file_extension); |
| 146 } | 159 } |
| 147 | 160 |
| 148 } // namespace webkit_glue | 161 } // namespace webkit_glue |
| OLD | NEW |