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

Side by Side Diff: webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc

Issue 4705007: Don't restrict supported media types in test_shell when running interactively (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h" 5 #include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "net/base/mime_util.h" 8 #include "net/base/mime_util.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 9 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
10 10
11 using WebKit::WebString; 11 using WebKit::WebString;
12 using WebKit::WebMimeRegistry; 12 using WebKit::WebMimeRegistry;
13 13
14 namespace { 14 namespace {
15 15
16 // Convert a WebString to ASCII, falling back on an empty string in the case 16 // Convert a WebString to ASCII, falling back on an empty string in the case
17 // of a non-ASCII string. 17 // of a non-ASCII string.
18 std::string ToASCIIOrEmpty(const WebString& string) { 18 std::string ToASCIIOrEmpty(const WebString& string) {
19 if (!IsStringASCII(string)) 19 if (!IsStringASCII(string))
20 return std::string(); 20 return std::string();
21 return UTF16ToASCII(string); 21 return UTF16ToASCII(string);
22 } 22 }
23 23
24 } // namespace 24 } // namespace
25 25
26 TestShellWebMimeRegistryImpl::TestShellWebMimeRegistryImpl() { 26 TestShellWebMimeRegistryImpl::TestShellWebMimeRegistryImpl(
27 media_map_.insert("video/ogg"); 27 bool layout_test_mode) {
28 media_map_.insert("audio/ogg"); 28 if (layout_test_mode) {
29 media_map_.insert("application/ogg"); 29 // Restrict the set of supported media types when in layout test mode.
30 media_map_.insert("video/ogg");
31 media_map_.insert("audio/ogg");
32 media_map_.insert("application/ogg");
30 33
31 codecs_map_.insert("theora"); 34 codecs_map_.insert("theora");
32 codecs_map_.insert("vorbis"); 35 codecs_map_.insert("vorbis");
36 }
33 } 37 }
34 38
35 WebMimeRegistry::SupportsType 39 WebMimeRegistry::SupportsType
36 TestShellWebMimeRegistryImpl::supportsMediaMIMEType( 40 TestShellWebMimeRegistryImpl::supportsMediaMIMEType(
37 const WebString& mime_type, const WebString& codecs) { 41 const WebString& mime_type, const WebString& codecs) {
42 if (media_map_.empty()) {
43 // Don't restrict the supported media types.
44 return webkit_glue::SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
45 mime_type, codecs);
46 }
47
38 // Not supporting the container is a flat-out no. 48 // Not supporting the container is a flat-out no.
39 if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) 49 if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str()))
40 return IsNotSupported; 50 return IsNotSupported;
41 51
42 // If we don't recognize the codec, it's possible we support it. 52 // If we don't recognize the codec, it's possible we support it.
43 std::vector<std::string> parsed_codecs; 53 std::vector<std::string> parsed_codecs;
44 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true); 54 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true);
45 if (!AreSupportedMediaCodecs(parsed_codecs)) 55 if (!AreSupportedMediaCodecs(parsed_codecs))
46 return MayBeSupported; 56 return MayBeSupported;
47 57
48 // Otherwise we have a perfect match. 58 // Otherwise we have a perfect match.
49 return IsSupported; 59 return IsSupported;
50 } 60 }
51 61
52 bool TestShellWebMimeRegistryImpl::IsSupportedMediaMimeType( 62 bool TestShellWebMimeRegistryImpl::IsSupportedMediaMimeType(
53 const std::string& mime_type) { 63 const std::string& mime_type) {
54 return media_map_.find(mime_type) != media_map_.end(); 64 return media_map_.find(mime_type) != media_map_.end();
55 } 65 }
56 66
57 bool TestShellWebMimeRegistryImpl::AreSupportedMediaCodecs( 67 bool TestShellWebMimeRegistryImpl::AreSupportedMediaCodecs(
58 const std::vector<std::string>& codecs) { 68 const std::vector<std::string>& codecs) {
59 for (size_t i = 0; i < codecs.size(); ++i) { 69 for (size_t i = 0; i < codecs.size(); ++i) {
60 if (codecs_map_.find(codecs[i]) == codecs_map_.end()) { 70 if (codecs_map_.find(codecs[i]) == codecs_map_.end()) {
61 return false; 71 return false;
62 } 72 }
63 } 73 }
64 return true; 74 return true;
65 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698