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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 17447011: Shuffle media-related WebMimeRegistry code from webkit/ to content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forgot some diffs Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/renderer/content_renderer_client.cc ('k') | content/shell/app/shell_main_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_webkitplatformsupport_impl.cc
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 5e74dc4557e40d43fae9fa619c4c936dce33152e..9737a486861b5794a35b2e1233a58c47ee2e84b7 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -41,6 +41,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,10 +116,22 @@ base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
class RendererWebKitPlatformSupportImpl::MimeRegistry
: public webkit_glue::SimpleWebMimeRegistryImpl {
public:
- virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&);
- virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&);
+ // TODO(ddorwin): Remove after http://webk.it/82983 lands.
+ virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType(
+ const WebKit::WebString& mime_type,
+ const WebKit::WebString& codecs);
+ virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType(
+ const WebKit::WebString& mime_type,
+ const WebKit::WebString& codecs,
+ const WebKit::WebString& key_system);
+ virtual bool supportsMediaSourceMIMEType(const WebKit::WebString& mime_type,
+ const WebKit::WebString& codecs);
+ virtual WebKit::WebString mimeTypeForExtension(
+ const WebKit::WebString& file_extension);
+ virtual WebKit::WebString mimeTypeFromFile(
+ const WebKit::WebString& file_path);
virtual WebKit::WebString preferredExtensionForMIMEType(
- const WebKit::WebString&);
+ const WebKit::WebString& mime_type);
};
class RendererWebKitPlatformSupportImpl::FileUtilities
@@ -223,10 +239,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 +392,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) {
« no previous file with comments | « content/public/renderer/content_renderer_client.cc ('k') | content/shell/app/shell_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698