Commit a22282cc authored by scherkus@chromium.org's avatar scherkus@chromium.org

Shuffle media-related WebMimeRegistry code from webkit/ to content/.

TestShellWebMimeRegistryImpl has been replaced in lieu of content_shell calling net::RemoveProprietaryMediaTypesAndCodecsForTests().

BUG=251306

Review URL: https://chromiumcodereview.appspot.com/17447011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208045 0039d316-1c4b-4281-b951-d872f2087c98
parent d1049d07
...@@ -63,10 +63,6 @@ WebKit::WebClipboard* ContentRendererClient::OverrideWebClipboard() { ...@@ -63,10 +63,6 @@ WebKit::WebClipboard* ContentRendererClient::OverrideWebClipboard() {
return NULL; return NULL;
} }
WebKit::WebMimeRegistry* ContentRendererClient::OverrideWebMimeRegistry() {
return NULL;
}
WebKit::WebHyphenator* ContentRendererClient::OverrideWebHyphenator() { WebKit::WebHyphenator* ContentRendererClient::OverrideWebHyphenator() {
return NULL; return NULL;
} }
......
...@@ -32,7 +32,6 @@ class WebHyphenator; ...@@ -32,7 +32,6 @@ class WebHyphenator;
class WebMediaPlayerClient; class WebMediaPlayerClient;
class WebMediaStreamCenter; class WebMediaStreamCenter;
class WebMediaStreamCenterClient; class WebMediaStreamCenterClient;
class WebMimeRegistry;
class WebPlugin; class WebPlugin;
class WebPluginContainer; class WebPluginContainer;
class WebPrescientNetworking; class WebPrescientNetworking;
...@@ -149,10 +148,6 @@ class CONTENT_EXPORT ContentRendererClient { ...@@ -149,10 +148,6 @@ class CONTENT_EXPORT ContentRendererClient {
// returns NULL the content layer will handle clipboard interactions. // returns NULL the content layer will handle clipboard interactions.
virtual WebKit::WebClipboard* OverrideWebClipboard(); virtual WebKit::WebClipboard* OverrideWebClipboard();
// Allows the embedder to override the WebKit::WebMimeRegistry used. If it
// returns NULL the content layer will provide its own mime registry.
virtual WebKit::WebMimeRegistry* OverrideWebMimeRegistry();
// Allows the embedder to override the WebKit::WebHyphenator used. If it // Allows the embedder to override the WebKit::WebHyphenator used. If it
// returns NULL the content layer will handle hyphenation. // returns NULL the content layer will handle hyphenation.
virtual WebKit::WebHyphenator* OverrideWebHyphenator(); virtual WebKit::WebHyphenator* OverrideWebHyphenator();
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#include "ipc/ipc_sync_message_filter.h" #include "ipc/ipc_sync_message_filter.h"
#include "media/audio/audio_output_device.h" #include "media/audio/audio_output_device.h"
#include "media/base/audio_hardware_config.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 "net/base/net_util.h"
#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
...@@ -59,6 +61,7 @@ ...@@ -59,6 +61,7 @@
#include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webfileutilities_impl.h"
#include "webkit/glue/webkit_glue.h" #include "webkit/glue/webkit_glue.h"
#include "webkit/renderer/media/audio_decoder.h" #include "webkit/renderer/media/audio_decoder.h"
#include "webkit/renderer/media/crypto/key_systems.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "content/common/child_process_messages.h" #include "content/common/child_process_messages.h"
...@@ -100,6 +103,7 @@ using WebKit::WebMIDIAccessor; ...@@ -100,6 +103,7 @@ using WebKit::WebMIDIAccessor;
using WebKit::Platform; using WebKit::Platform;
using WebKit::WebMediaStreamCenter; using WebKit::WebMediaStreamCenter;
using WebKit::WebMediaStreamCenterClient; using WebKit::WebMediaStreamCenterClient;
using WebKit::WebMimeRegistry;
using WebKit::WebRTCPeerConnectionHandler; using WebKit::WebRTCPeerConnectionHandler;
using WebKit::WebRTCPeerConnectionHandlerClient; using WebKit::WebRTCPeerConnectionHandlerClient;
using WebKit::WebStorageNamespace; using WebKit::WebStorageNamespace;
...@@ -118,10 +122,22 @@ base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = ...@@ -118,10 +122,22 @@ base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
class RendererWebKitPlatformSupportImpl::MimeRegistry class RendererWebKitPlatformSupportImpl::MimeRegistry
: public webkit_glue::SimpleWebMimeRegistryImpl { : public webkit_glue::SimpleWebMimeRegistryImpl {
public: public:
virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&); // TODO(ddorwin): Remove after http://webk.it/82983 lands.
virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&); 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( virtual WebKit::WebString preferredExtensionForMIMEType(
const WebKit::WebString&); const WebKit::WebString& mime_type);
}; };
class RendererWebKitPlatformSupportImpl::FileUtilities class RendererWebKitPlatformSupportImpl::FileUtilities
...@@ -229,10 +245,6 @@ WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { ...@@ -229,10 +245,6 @@ WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() {
} }
WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() {
WebKit::WebMimeRegistry* mime_registry =
GetContentClient()->renderer()->OverrideWebMimeRegistry();
if (mime_registry)
return mime_registry;
return mime_registry_.get(); return mime_registry_.get();
} }
...@@ -386,6 +398,80 @@ WebFileSystem* RendererWebKitPlatformSupportImpl::fileSystem() { ...@@ -386,6 +398,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 WebString
RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension( RendererWebKitPlatformSupportImpl::MimeRegistry::mimeTypeForExtension(
const WebString& file_extension) { const WebString& file_extension) {
......
...@@ -141,6 +141,13 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { ...@@ -141,6 +141,13 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitch(switches::kEnableSoftwareCompositingGLAdapter); command_line.AppendSwitch(switches::kEnableSoftwareCompositingGLAdapter);
net::CookieMonster::EnableFileScheme(); net::CookieMonster::EnableFileScheme();
// Unless/until WebM files are added to the media layout tests, we need to
// avoid removing MP4/H264/AAC so that layout tests can run on Android.
#if !defined(OS_ANDROID)
net::RemoveProprietaryMediaTypesAndCodecsForTests();
#endif
if (!WebKitTestPlatformInitialize()) { if (!WebKitTestPlatformInitialize()) {
if (exit_code) if (exit_code)
*exit_code = 1; *exit_code = 1;
......
...@@ -23,14 +23,12 @@ ...@@ -23,14 +23,12 @@
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "webkit/mocks/mock_webhyphenator.h" #include "webkit/mocks/mock_webhyphenator.h"
#include "webkit/support/mock_webclipboard_impl.h" #include "webkit/support/mock_webclipboard_impl.h"
#include "webkit/support/test_shell_webmimeregistry_impl.h"
using WebKit::WebClipboard; using WebKit::WebClipboard;
using WebKit::WebFrame; using WebKit::WebFrame;
using WebKit::WebHyphenator; using WebKit::WebHyphenator;
using WebKit::WebMediaStreamCenter; using WebKit::WebMediaStreamCenter;
using WebKit::WebMediaStreamCenterClient; using WebKit::WebMediaStreamCenterClient;
using WebKit::WebMimeRegistry;
using WebKit::WebPlugin; using WebKit::WebPlugin;
using WebKit::WebPluginParams; using WebKit::WebPluginParams;
using WebKit::WebRTCPeerConnectionHandler; using WebKit::WebRTCPeerConnectionHandler;
...@@ -150,14 +148,6 @@ WebClipboard* ShellContentRendererClient::OverrideWebClipboard() { ...@@ -150,14 +148,6 @@ WebClipboard* ShellContentRendererClient::OverrideWebClipboard() {
return clipboard_.get(); return clipboard_.get();
} }
WebMimeRegistry* ShellContentRendererClient::OverrideWebMimeRegistry() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
return NULL;
if (!mime_registry_)
mime_registry_.reset(new TestShellWebMimeRegistryImpl);
return mime_registry_.get();
}
WebHyphenator* ShellContentRendererClient::OverrideWebHyphenator() { WebHyphenator* ShellContentRendererClient::OverrideWebHyphenator() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
return NULL; return NULL;
......
...@@ -25,7 +25,6 @@ class MockWebHyphenator; ...@@ -25,7 +25,6 @@ class MockWebHyphenator;
} }
class MockWebClipboardImpl; class MockWebClipboardImpl;
class TestShellWebMimeRegistryImpl;
namespace content { namespace content {
...@@ -54,7 +53,6 @@ class ShellContentRendererClient : public ContentRendererClient { ...@@ -54,7 +53,6 @@ class ShellContentRendererClient : public ContentRendererClient {
OverrideCreateWebRTCPeerConnectionHandler( OverrideCreateWebRTCPeerConnectionHandler(
WebKit::WebRTCPeerConnectionHandlerClient* client) OVERRIDE; WebKit::WebRTCPeerConnectionHandlerClient* client) OVERRIDE;
virtual WebKit::WebClipboard* OverrideWebClipboard() OVERRIDE; virtual WebKit::WebClipboard* OverrideWebClipboard() OVERRIDE;
virtual WebKit::WebMimeRegistry* OverrideWebMimeRegistry() OVERRIDE;
virtual WebKit::WebHyphenator* OverrideWebHyphenator() OVERRIDE; virtual WebKit::WebHyphenator* OverrideWebHyphenator() OVERRIDE;
virtual WebKit::WebThemeEngine* OverrideThemeEngine() OVERRIDE; virtual WebKit::WebThemeEngine* OverrideThemeEngine() OVERRIDE;
virtual bool AllowBrowserPlugin( virtual bool AllowBrowserPlugin(
...@@ -66,7 +64,6 @@ class ShellContentRendererClient : public ContentRendererClient { ...@@ -66,7 +64,6 @@ class ShellContentRendererClient : public ContentRendererClient {
scoped_ptr<ShellRenderProcessObserver> shell_observer_; scoped_ptr<ShellRenderProcessObserver> shell_observer_;
scoped_ptr<MockWebClipboardImpl> clipboard_; scoped_ptr<MockWebClipboardImpl> clipboard_;
scoped_ptr<TestShellWebMimeRegistryImpl> mime_registry_;
scoped_ptr<webkit_glue::MockWebHyphenator> hyphenator_; scoped_ptr<webkit_glue::MockWebHyphenator> hyphenator_;
}; };
......
...@@ -77,6 +77,8 @@ class MimeUtil : public PlatformMimeUtil { ...@@ -77,6 +77,8 @@ class MimeUtil : public PlatformMimeUtil {
const std::string& mime_type, const std::string& mime_type,
const std::vector<std::string>& codecs) const; const std::vector<std::string>& codecs) const;
void RemoveProprietaryMediaTypesAndCodecsForTests();
private: private:
friend struct base::DefaultLazyInstanceTraits<MimeUtil>; friend struct base::DefaultLazyInstanceTraits<MimeUtil>;
...@@ -264,7 +266,7 @@ static const char* const common_media_types[] = { ...@@ -264,7 +266,7 @@ static const char* const common_media_types[] = {
// Ogg. // Ogg.
"audio/ogg", "audio/ogg",
"application/ogg", "application/ogg",
#if defined(ENABLE_MEDIA_CODEC_THEORA) #if !defined(OS_ANDROID) // Android doesn't support Ogg Theora.
"video/ogg", "video/ogg",
#endif #endif
...@@ -300,7 +302,7 @@ static const char* const proprietary_media_types[] = { ...@@ -300,7 +302,7 @@ static const char* const proprietary_media_types[] = {
// The codecs for WAV are integers as defined in Appendix A of RFC2361: // The codecs for WAV are integers as defined in Appendix A of RFC2361:
// http://tools.ietf.org/html/rfc2361 // http://tools.ietf.org/html/rfc2361
static const char* const common_media_codecs[] = { static const char* const common_media_codecs[] = {
#if defined(ENABLE_MEDIA_CODEC_THEORA) #if !defined(OS_ANDROID) // Android doesn't support Ogg Theora.
"theora", "theora",
#endif #endif
"vorbis", "vorbis",
...@@ -675,6 +677,15 @@ bool MimeUtil::IsSupportedStrictMediaMimeType( ...@@ -675,6 +677,15 @@ bool MimeUtil::IsSupportedStrictMediaMimeType(
AreSupportedCodecs(it->second, codecs); AreSupportedCodecs(it->second, codecs);
} }
void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() {
for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) {
non_image_map_.erase(proprietary_media_types[i]);
media_map_.erase(proprietary_media_types[i]);
}
for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i)
codecs_map_.erase(proprietary_media_codecs[i]);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Wrappers for the singleton // Wrappers for the singleton
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -934,28 +945,8 @@ void GetExtensionsForMimeType( ...@@ -934,28 +945,8 @@ void GetExtensionsForMimeType(
HashSetToVector(&unique_extensions, extensions); HashSetToVector(&unique_extensions, extensions);
} }
void GetMediaTypesBlacklistedForTests(std::vector<std::string>* types) { void RemoveProprietaryMediaTypesAndCodecsForTests() {
types->clear(); g_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests();
// Unless/until WebM files are added to the media layout tests, we need to avoid
// blacklisting mp4 and H.264 when Theora is not supported (and proprietary
// codecs are) so that the media tests can still run.
#if defined(ENABLE_MEDIA_CODEC_THEORA) || !defined(USE_PROPRIETARY_CODECS)
for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
types->push_back(proprietary_media_types[i]);
#endif
}
void GetMediaCodecsBlacklistedForTests(std::vector<std::string>* codecs) {
codecs->clear();
// Unless/until WebM files are added to the media layout tests, we need to avoid
// blacklisting mp4 and H.264 when Theora is not supported (and proprietary
// codecs are) so that the media tests can still run.
#if defined(ENABLE_MEDIA_CODEC_THEORA) || !defined(USE_PROPRIETARY_CODECS)
for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i)
codecs->push_back(proprietary_media_codecs[i]);
#endif
} }
const std::string GetIANAMediaType(const std::string& mime_type) { const std::string GetIANAMediaType(const std::string& mime_type) {
......
...@@ -94,14 +94,11 @@ NET_EXPORT void GetExtensionsForMimeType( ...@@ -94,14 +94,11 @@ NET_EXPORT void GetExtensionsForMimeType(
const std::string& mime_type, const std::string& mime_type,
std::vector<base::FilePath::StringType>* extensions); std::vector<base::FilePath::StringType>* extensions);
// Test only methods that return lists of proprietary media types and codecs // Test only method that removes proprietary media types and codecs from the
// that are not supported by all variations of Chromium. // list of supported MIME types and codecs. These types and codecs must be
// These types and codecs must be blacklisted to ensure consistent layout test // removed to ensure consistent layout test results across all Chromium
// results across all Chromium variations. // variations.
NET_EXPORT void GetMediaTypesBlacklistedForTests( NET_EXPORT void RemoveProprietaryMediaTypesAndCodecsForTests();
std::vector<std::string>* types);
NET_EXPORT void GetMediaCodecsBlacklistedForTests(
std::vector<std::string>* codecs);
// Returns the IANA media type contained in |mime_type|, or an empty // Returns the IANA media type contained in |mime_type|, or an empty
// string if |mime_type| does not specifify a known media type. // string if |mime_type| does not specifify a known media type.
......
...@@ -1414,11 +1414,6 @@ ...@@ -1414,11 +1414,6 @@
'include_dirs': [ 'include_dirs': [
'../third_party/openssl', '../third_party/openssl',
], ],
}, { # else OS != "android"
'defines': [
# These are the features Android doesn't support.
'ENABLE_MEDIA_CODEC_THEORA',
],
}, },
], ],
], ],
......
include_rules = [ include_rules = [
"+gpu", "+gpu",
"+media/filters",
"+skia/ext", "+skia/ext",
"+skia/include", "+skia/include",
"+ui", "+ui",
......
...@@ -7,27 +7,20 @@ ...@@ -7,27 +7,20 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "media/filters/stream_parser_factory.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebString.h"
#include "webkit/base/file_path_string_conversions.h" #include "webkit/base/file_path_string_conversions.h"
#include "webkit/renderer/media/crypto/key_systems.h"
using WebKit::WebString; using WebKit::WebString;
using WebKit::WebMimeRegistry; using WebKit::WebMimeRegistry;
namespace { namespace webkit_glue {
// Convert a WebString to ASCII, falling back on an empty string in the case //static
// of a non-ASCII string. std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) {
std::string ToASCIIOrEmpty(const WebString& string) {
return IsStringASCII(string) ? UTF16ToASCII(string) : std::string(); return IsStringASCII(string) ? UTF16ToASCII(string) : std::string();
} }
} // namespace
namespace webkit_glue {
WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType(
const WebString& mime_type) { const WebString& mime_type) {
return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ?
...@@ -51,72 +44,23 @@ WebMimeRegistry::SupportsType ...@@ -51,72 +44,23 @@ WebMimeRegistry::SupportsType
// see TestShellWebMimeRegistryImpl. // see TestShellWebMimeRegistryImpl.
WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
const WebString& mime_type, const WebString& codecs) { const WebString& mime_type, const WebString& codecs) {
return supportsMediaMIMEType(mime_type, codecs, WebString()); // Media features are only supported at the content/ layer.
return IsNotSupported;
} }
WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
const WebString& mime_type, const WebString& mime_type,
const WebString& codecs, const WebString& codecs,
const WebString& key_system) { const WebString& key_system) {
const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); // Media features are only supported at the content/ layer.
// Not supporting the container is a flat-out no. return IsNotSupported;
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 SimpleWebMimeRegistryImpl::supportsMediaSourceMIMEType( bool SimpleWebMimeRegistryImpl::supportsMediaSourceMIMEType(
const WebKit::WebString& mime_type, const WebString& mime_type,
const WebString& codecs) { const WebString& codecs) {
const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); // Media features are only supported at the content/ layer.
std::vector<std::string> parsed_codec_ids; return IsNotSupported;
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);
} }
WebMimeRegistry::SupportsType WebMimeRegistry::SupportsType
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef WEBMIMEREGISTRY_IMPL_H_ #ifndef WEBKIT_GLUE_SIMPLE_WEBMIMEREGISTRY_IMPL_H_
#define WEBMIMEREGISTRY_IMPL_H_ #define WEBKIT_GLUE_SIMPLE_WEBMIMEREGISTRY_IMPL_H_
#include <string>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "third_party/WebKit/public/platform/WebMimeRegistry.h" #include "third_party/WebKit/public/platform/WebMimeRegistry.h"
...@@ -17,6 +19,10 @@ class WEBKIT_GLUE_EXPORT SimpleWebMimeRegistryImpl : ...@@ -17,6 +19,10 @@ class WEBKIT_GLUE_EXPORT SimpleWebMimeRegistryImpl :
SimpleWebMimeRegistryImpl() {} SimpleWebMimeRegistryImpl() {}
virtual ~SimpleWebMimeRegistryImpl() {} virtual ~SimpleWebMimeRegistryImpl() {}
// Convert a WebString to ASCII, falling back on an empty string in the case
// of a non-ASCII string.
static std::string ToASCIIOrEmpty(const WebKit::WebString& string);
// WebMimeRegistry methods: // WebMimeRegistry methods:
virtual WebKit::WebMimeRegistry::SupportsType supportsMIMEType( virtual WebKit::WebMimeRegistry::SupportsType supportsMIMEType(
const WebKit::WebString&); const WebKit::WebString&);
...@@ -45,4 +51,4 @@ class WEBKIT_GLUE_EXPORT SimpleWebMimeRegistryImpl : ...@@ -45,4 +51,4 @@ class WEBKIT_GLUE_EXPORT SimpleWebMimeRegistryImpl :
} // namespace webkit_glue } // namespace webkit_glue
#endif // WEBMIMEREGISTRY_IMPL_H_ #endif // WEBKIT_GLUE_SIMPLE_WEBMIMEREGISTRY_IMPL_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/support/test_shell_webmimeregistry_impl.h"
#include "base/basictypes.h"
#include "base/strings/string_util.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/public/platform/WebString.h"
using WebKit::WebString;
using WebKit::WebMimeRegistry;
namespace {
// Convert a WebString to ASCII, falling back on an empty string in the case
// of a non-ASCII string.
std::string ToASCIIOrEmpty(const WebString& string) {
return IsStringASCII(string) ? UTF16ToASCII(string) : std::string();
}
} // namespace
TestShellWebMimeRegistryImpl::TestShellWebMimeRegistryImpl() {
net::GetMediaTypesBlacklistedForTests(&blacklisted_media_types_);
net::GetMediaCodecsBlacklistedForTests(&blacklisted_media_codecs_);
}
TestShellWebMimeRegistryImpl::~TestShellWebMimeRegistryImpl() {}
// Returns IsNotSupported if mime_type or any of the codecs are not supported.
// Otherwse, defers to the real registry.
WebMimeRegistry::SupportsType
TestShellWebMimeRegistryImpl::supportsMediaMIMEType(
const WebString& mime_type,
const WebString& codecs,
const WebKit::WebString& key_system) {
if (IsBlacklistedMediaMimeType(ToASCIIOrEmpty(mime_type)))
return IsNotSupported;
std::vector<std::string> parsed_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
if (HasBlacklistedMediaCodecs(parsed_codecs))
return IsNotSupported;
return SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
mime_type, codecs, key_system);
}
bool TestShellWebMimeRegistryImpl::IsBlacklistedMediaMimeType(
const std::string& mime_type) {
for (size_t i = 0; i < blacklisted_media_types_.size(); ++i) {
if (blacklisted_media_types_[i] == mime_type)
return true;
}
return false;
}
bool TestShellWebMimeRegistryImpl::HasBlacklistedMediaCodecs(
const std::vector<std::string>& codecs) {
for (size_t i = 0; i < codecs.size(); ++i) {
for (size_t j = 0; j < blacklisted_media_codecs_.size(); ++j) {
if (blacklisted_media_codecs_[j] == codecs[i])
return true;
}
}
return false;
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_SUPPORT_TEST_SHELL_WEBMIMEREGISTRY_IMPL_H_
#define WEBKIT_SUPPORT_TEST_SHELL_WEBMIMEREGISTRY_IMPL_H_
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
#include "webkit/glue/simple_webmimeregistry_impl.h"
class TestShellWebMimeRegistryImpl
: public webkit_glue::SimpleWebMimeRegistryImpl {
public:
TestShellWebMimeRegistryImpl();
virtual ~TestShellWebMimeRegistryImpl();
// Override to force that we only support types and codecs that are supported
// by all variations of Chromium.
//
// Media layout tests use canPlayType() to determine the test input files.
// Different flavours of Chromium support different codecs, which has an
// impact on how canPlayType() behaves. Since Chromium's baselines and
// expectations are generated against the common set of types, we need to
// prevent canPlayType() from indicating it supports other types when running
// layout tests.
virtual WebKit::WebMimeRegistry::SupportsType supportsMediaMIMEType(
const WebKit::WebString&,
const WebKit::WebString&,
const WebKit::WebString&) OVERRIDE;
private:
bool IsBlacklistedMediaMimeType(const std::string& mime_type);
bool HasBlacklistedMediaCodecs(const std::vector<std::string>& codecs);
std::vector<std::string> blacklisted_media_types_;
std::vector<std::string> blacklisted_media_codecs_;
DISALLOW_COPY_AND_ASSIGN(TestShellWebMimeRegistryImpl);
};
#endif // WEBKIT_SUPPORT_TEST_SHELL_WEBMIMEREGISTRY_IMPL_H_
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "third_party/WebKit/public/platform/WebUnitTestSupport.h" #include "third_party/WebKit/public/platform/WebUnitTestSupport.h"
#include "webkit/child/webkitplatformsupport_child_impl.h" #include "webkit/child/webkitplatformsupport_child_impl.h"
#include "webkit/glue/simple_webmimeregistry_impl.h"
#include "webkit/glue/webfileutilities_impl.h" #include "webkit/glue/webfileutilities_impl.h"
#include "webkit/mocks/mock_webhyphenator.h" #include "webkit/mocks/mock_webhyphenator.h"
#include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h" #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"
...@@ -19,7 +20,6 @@ ...@@ -19,7 +20,6 @@
#include "webkit/support/simple_dom_storage_system.h" #include "webkit/support/simple_dom_storage_system.h"
#include "webkit/support/simple_file_system.h" #include "webkit/support/simple_file_system.h"
#include "webkit/support/simple_webcookiejar_impl.h" #include "webkit/support/simple_webcookiejar_impl.h"
#include "webkit/support/test_shell_webmimeregistry_impl.h"
#include "webkit/support/weburl_loader_mock_factory.h" #include "webkit/support/weburl_loader_mock_factory.h"
class TestShellWebBlobRegistryImpl; class TestShellWebBlobRegistryImpl;
...@@ -163,7 +163,7 @@ class TestWebKitPlatformSupport : ...@@ -163,7 +163,7 @@ class TestWebKitPlatformSupport :
TestViewType type); TestViewType type);
private: private:
TestShellWebMimeRegistryImpl mime_registry_; webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
MockWebClipboardImpl mock_clipboard_; MockWebClipboardImpl mock_clipboard_;
webkit_glue::WebFileUtilitiesImpl file_utilities_; webkit_glue::WebFileUtilitiesImpl file_utilities_;
base::ScopedTempDir appcache_dir_; base::ScopedTempDir appcache_dir_;
......
...@@ -151,8 +151,6 @@ ...@@ -151,8 +151,6 @@
'<(DEPTH)/webkit/support/test_shell_request_context.h', '<(DEPTH)/webkit/support/test_shell_request_context.h',
'<(DEPTH)/webkit/support/test_shell_webblobregistry_impl.cc', '<(DEPTH)/webkit/support/test_shell_webblobregistry_impl.cc',
'<(DEPTH)/webkit/support/test_shell_webblobregistry_impl.h', '<(DEPTH)/webkit/support/test_shell_webblobregistry_impl.h',
'<(DEPTH)/webkit/support/test_shell_webmimeregistry_impl.cc',
'<(DEPTH)/webkit/support/test_shell_webmimeregistry_impl.h',
'<(DEPTH)/webkit/mocks/mock_webhyphenator.cc', '<(DEPTH)/webkit/mocks/mock_webhyphenator.cc',
'<(DEPTH)/webkit/mocks/mock_webhyphenator.h', '<(DEPTH)/webkit/mocks/mock_webhyphenator.h',
'simple_database_system.cc', 'simple_database_system.cc',
......
include_rules = [ include_rules = [
"+content/common", "+content/common",
"+media",
"+skia/ext", "+skia/ext",
] ]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment