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

Side by Side Diff: webkit/support/test_shell_webmimeregistry_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/support/test_shell_webmimeregistry_impl.h"
6
7 #include "base/basictypes.h"
8 #include "base/strings/string_util.h"
9 #include "net/base/mime_util.h"
10 #include "third_party/WebKit/public/platform/WebString.h"
11
12 using WebKit::WebString;
13 using WebKit::WebMimeRegistry;
14
15 namespace {
16
17 // Convert a WebString to ASCII, falling back on an empty string in the case
18 // of a non-ASCII string.
19 std::string ToASCIIOrEmpty(const WebString& string) {
20 return IsStringASCII(string) ? UTF16ToASCII(string) : std::string();
21 }
22
23 } // namespace
24
25 TestShellWebMimeRegistryImpl::TestShellWebMimeRegistryImpl() {
26 net::GetMediaTypesBlacklistedForTests(&blacklisted_media_types_);
27
28 net::GetMediaCodecsBlacklistedForTests(&blacklisted_media_codecs_);
29 }
30
31 TestShellWebMimeRegistryImpl::~TestShellWebMimeRegistryImpl() {}
32
33 // Returns IsNotSupported if mime_type or any of the codecs are not supported.
34 // Otherwse, defers to the real registry.
35 WebMimeRegistry::SupportsType
36 TestShellWebMimeRegistryImpl::supportsMediaMIMEType(
37 const WebString& mime_type,
38 const WebString& codecs,
39 const WebKit::WebString& key_system) {
40 if (IsBlacklistedMediaMimeType(ToASCIIOrEmpty(mime_type)))
41 return IsNotSupported;
42
43 std::vector<std::string> parsed_codecs;
44 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
45 if (HasBlacklistedMediaCodecs(parsed_codecs))
46 return IsNotSupported;
47
48 return SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
49 mime_type, codecs, key_system);
50 }
51
52 bool TestShellWebMimeRegistryImpl::IsBlacklistedMediaMimeType(
53 const std::string& mime_type) {
54 for (size_t i = 0; i < blacklisted_media_types_.size(); ++i) {
55 if (blacklisted_media_types_[i] == mime_type)
56 return true;
57 }
58 return false;
59 }
60
61 bool TestShellWebMimeRegistryImpl::HasBlacklistedMediaCodecs(
62 const std::vector<std::string>& codecs) {
63 for (size_t i = 0; i < codecs.size(); ++i) {
64 for (size_t j = 0; j < blacklisted_media_codecs_.size(); ++j) {
65 if (blacklisted_media_codecs_[j] == codecs[i])
66 return true;
67 }
68 }
69 return false;
70 }
OLDNEW
« no previous file with comments | « webkit/support/test_shell_webmimeregistry_impl.h ('k') | webkit/support/test_webkit_platform_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698