Index: content/renderer/renderer_webkitplatformsupport_impl.cc |
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc |
index 3565af5d230f0d866833d90e24917a505c8074be..095b685159fef0e65bcfb0c3061bee299bbc36b4 100644 |
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc |
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc |
@@ -40,6 +40,8 @@ |
#include "ipc/ipc_sync_message_filter.h" |
#include "media/audio/audio_output_device.h" |
#include "media/base/audio_hardware_config.h" |
+#include "media/filters/stream_parser_factory.h" |
+#include "net/base/mime_util.h" |
#include "net/base/net_util.h" |
#include "third_party/WebKit/public/web/WebFrame.h" |
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
@@ -58,6 +60,7 @@ |
#include "webkit/glue/webfileutilities_impl.h" |
#include "webkit/glue/webkit_glue.h" |
#include "webkit/renderer/media/audio_decoder.h" |
+#include "webkit/renderer/media/crypto/key_systems.h" |
#if defined(OS_WIN) |
#include "content/common/child_process_messages.h" |
@@ -94,6 +97,7 @@ using WebKit::WebIDBFactory; |
using WebKit::Platform; |
using WebKit::WebMediaStreamCenter; |
using WebKit::WebMediaStreamCenterClient; |
+using WebKit::WebMimeRegistry; |
using WebKit::WebRTCPeerConnectionHandler; |
using WebKit::WebRTCPeerConnectionHandlerClient; |
using WebKit::WebStorageNamespace; |
@@ -112,6 +116,15 @@ base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
class RendererWebKitPlatformSupportImpl::MimeRegistry |
: public webkit_glue::SimpleWebMimeRegistryImpl { |
public: |
+ // TODO(ddorwin): Remove after http://webk.it/82983 lands. |
jamesr
2013/06/21 01:24:14
could you check and see if this TODO is still rele
scherkus (not reviewing)
2013/06/21 02:44:06
Done.
|
+ virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
+ const WebKit::WebString&, const WebKit::WebString&); |
+ virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
+ const WebKit::WebString&, |
jamesr
2013/06/21 01:24:14
this is chromium style, so all parameters need chr
scherkus (not reviewing)
2013/06/21 02:44:06
Done.
|
+ const WebKit::WebString&, |
+ const WebKit::WebString&); |
+ virtual bool supportsMediaSourceMIMEType(const WebKit::WebString&, |
+ const WebKit::WebString&); |
virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); |
virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); |
virtual WebKit::WebString preferredExtensionForMIMEType( |
@@ -223,10 +236,6 @@ WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { |
} |
WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { |
- WebKit::WebMimeRegistry* mime_registry = |
- GetContentClient()->renderer()->OverrideWebMimeRegistry(); |
- if (mime_registry) |
- return mime_registry; |
return mime_registry_.get(); |
} |
@@ -380,6 +389,80 @@ WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { |
//------------------------------------------------------------------------------ |
+WebMimeRegistry::SupportsType |
+RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( |
+ const WebString& mime_type, |
+ const WebString& codecs) { |
+ return supportsMediaMIMEType(mime_type, codecs, WebString()); |
+} |
+ |
+WebMimeRegistry::SupportsType |
+RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaMIMEType( |
+ const WebString& mime_type, |
+ const WebString& codecs, |
+ const WebString& key_system) { |
+ const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
+ // Not supporting the container is a flat-out no. |
+ if (!net::IsSupportedMediaMimeType(mime_type_ascii)) |
+ return IsNotSupported; |
+ |
+ if (!key_system.isEmpty()) { |
+ // Check whether the key system is supported with the mime_type and codecs. |
+ |
+ // Not supporting the key system is a flat-out no. |
+ if (!webkit_media::IsSupportedKeySystem(key_system)) |
+ return IsNotSupported; |
+ |
+ std::vector<std::string> strict_codecs; |
+ bool strip_suffix = !net::IsStrictMediaMimeType(mime_type_ascii); |
+ net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, strip_suffix); |
+ |
+ if (!webkit_media::IsSupportedKeySystemWithMediaMimeType( |
+ mime_type_ascii, strict_codecs, ToASCIIOrEmpty(key_system))) |
+ return IsNotSupported; |
+ |
+ // Continue processing the mime_type and codecs. |
+ } |
+ |
+ // Check list of strict codecs to see if it is supported. |
+ if (net::IsStrictMediaMimeType(mime_type_ascii)) { |
+ // We support the container, but no codecs were specified. |
+ if (codecs.isNull()) |
+ return MayBeSupported; |
+ |
+ // Check if the codecs are a perfect match. |
+ std::vector<std::string> strict_codecs; |
+ net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); |
+ if (!net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)) |
+ return IsNotSupported; |
+ |
+ // Good to go! |
+ return IsSupported; |
+ } |
+ |
+ // If we don't recognize the codec, it's possible we support it. |
+ std::vector<std::string> parsed_codecs; |
+ net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); |
+ if (!net::AreSupportedMediaCodecs(parsed_codecs)) |
+ return MayBeSupported; |
+ |
+ // Otherwise we have a perfect match. |
+ return IsSupported; |
+} |
+ |
+bool |
+RendererWebKitPlatformSupportImpl::MimeRegistry::supportsMediaSourceMIMEType( |
+ const WebKit::WebString& mime_type, |
+ const WebString& codecs) { |
+ const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); |
+ std::vector<std::string> parsed_codec_ids; |
+ net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); |
+ if (mime_type_ascii.empty() || parsed_codec_ids.size() == 0) |
+ return false; |
+ return media::StreamParserFactory::IsTypeSupported( |
+ mime_type_ascii, parsed_codec_ids); |
+} |
+ |
WebString |
RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( |
const WebString& file_extension) { |