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

Unified Diff: webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc

Issue 9969061: Changed TestShellWebMimeRegistryImpl to blacklist rather than whitelist containers and codecs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed merge Created 8 years, 9 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 | « webkit/tools/test_shell/test_shell_webmimeregistry_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « webkit/tools/test_shell/test_shell_webmimeregistry_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698