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 d0989dd9057974c38833dcffd82afd7bf77dfbfe..45a1cc41e7ccb624de8db56501ca002e3cf1c338 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" |
| @@ -19,52 +20,72 @@ std::string ToASCIIOrEmpty(const WebString& string) { |
| return IsStringASCII(string) ? UTF16ToASCII(string) : std::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[] = { |
|
darin (slow to review)
2012/04/03 23:01:14
seems unfortunate to replicate code between here a
ddorwin
2012/04/04 20:59:19
Since we already include mime_util.h, we can expos
|
| + // 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", |
| + "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( |
| +TestShellWebMimeRegistryImpl::supportsMediaMIMEType( |
| const WebString& mime_type, |
| const WebString& codecs) { |
| - // Not supporting the container is a flat-out no. |
| - if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type))) |
| + if (IsBlacklistedMediaMimeType(ToASCIIOrEmpty(mime_type))) |
| 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), &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 !codecs.empty(); |
| + return false; |
| } |