Chromium Code Reviews| Index: webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc |
| diff --git a/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc b/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc |
| index a411c21e6dbc84bc4ef1320c5a7b38c37227e765..43973f3756e5e01c02875cd31c1f36688f73e4f1 100644 |
| --- a/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc |
| +++ b/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc |
| @@ -4,6 +4,7 @@ |
| #include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h" |
| +#include "base/basictypes.h" |
| #include "base/string_util.h" |
| #include "net/base/mime_util.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| @@ -21,52 +22,72 @@ std::string ToASCIIOrEmpty(const WebString& string) { |
| return UTF16ToASCII(string); |
| } |
| +// Contains the types in mime_util.cc:supported_media_types that are |
| +// conditionally compiled based on defined(GOOGLE_CHROME_BUILD) or |
| +// defined(USE_PROPRIETARY_CODECS). These must be blacklisted to ensure |
| +// consistent layout test results across all Chromium variations. |
| +static const char* const blacklisted_media_types[] = { |
| + // MPEG-4. |
| + "video/mp4", |
| + "video/x-m4v", |
| + "audio/mp4", |
| + "audio/x-m4a", |
| + |
| + // MP3. |
| + "audio/mp3", |
| + "audio/x-mp3", |
| + "audio/mpeg", |
| +}; |
| + |
| +// Contains the types in mime_util.cc:supported_media_codecs that are |
| +// conditionally compiled based on defined(GOOGLE_CHROME_BUILD) or |
| +// defined(USE_PROPRIETARY_CODECS). These must be blacklisted to ensure |
| +// consistent layout test results across all Chromium variations. |
| +static const char* const blacklisted_media_codecs[] = { |
| + "avc1", |
|
scherkus (not reviewing)
2012/04/02 19:54:30
should be 2 space indent
|
| + "mp4a", |
| +}; |
| + |
| } // namespace |
| TestShellWebMimeRegistryImpl::TestShellWebMimeRegistryImpl() { |
| - // Claim we support Ogg+Theora/Vorbis. |
| - media_map_.insert("video/ogg"); |
| - media_map_.insert("audio/ogg"); |
| - media_map_.insert("application/ogg"); |
| - codecs_map_.insert("theora"); |
| - codecs_map_.insert("vorbis"); |
| - |
| - // Claim we support WAV. |
| - media_map_.insert("audio/wav"); |
| - media_map_.insert("audio/x-wav"); |
| - codecs_map_.insert("1"); // PCM for WAV. |
| + for (size_t i = 0; i < arraysize(blacklisted_media_types); ++i) |
| + blacklisted_media_map_.insert(blacklisted_media_types[i]); |
| + |
| + for (size_t i = 0; i < arraysize(blacklisted_media_codecs); ++i) |
| + blacklisted_codecs_map_.insert(blacklisted_media_codecs[i]); |
| } |
| 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) { |
| - // Not supporting the container is a flat-out no. |
| - if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) |
| + if (IsBlacklistedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) |
| return IsNotSupported; |
| - // If we don't recognize the codec, it's possible we support it. |
| std::vector<std::string> parsed_codecs; |
| net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true); |
| - if (!AreSupportedMediaCodecs(parsed_codecs)) |
| - return MayBeSupported; |
| + if (HasBlacklistedMediaCodecs(parsed_codecs)) |
| + return IsNotSupported; |
| - // Otherwise we have a perfect match. |
| - return IsSupported; |
| + return SimpleWebMimeRegistryImpl::supportsMediaMIMEType(mime_type, codecs); |
| } |
| -bool TestShellWebMimeRegistryImpl::IsSupportedMediaMimeType( |
| +bool TestShellWebMimeRegistryImpl::IsBlacklistedMediaMimeType( |
| const std::string& mime_type) { |
| - return media_map_.find(mime_type) != media_map_.end(); |
| + return blacklisted_media_map_.find(mime_type) != blacklisted_media_map_.end(); |
| } |
| -bool TestShellWebMimeRegistryImpl::AreSupportedMediaCodecs( |
| +bool TestShellWebMimeRegistryImpl::HasBlacklistedMediaCodecs( |
| const std::vector<std::string>& codecs) { |
| for (size_t i = 0; i < codecs.size(); ++i) { |
| - if (codecs_map_.find(codecs[i]) == codecs_map_.end()) { |
| - return false; |
| + if (blacklisted_codecs_map_.find(codecs[i]) != |
| + blacklisted_codecs_map_.end()) { |
| + return true; |
| } |
| } |
| - return true; |
| + return false; |
| } |