OLD | NEW |
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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 WebMimeRegistry::SupportsType | 35 WebMimeRegistry::SupportsType |
36 TestShellWebMimeRegistryImpl::supportsMediaMIMEType( | 36 TestShellWebMimeRegistryImpl::supportsMediaMIMEType( |
37 const WebString& mime_type, const WebString& codecs) { | 37 const WebString& mime_type, const WebString& codecs) { |
38 // Not supporting the container is a flat-out no. | 38 // Not supporting the container is a flat-out no. |
39 if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) | 39 if (!IsSupportedMediaMimeType(ToASCIIOrEmpty(mime_type).c_str())) |
40 return IsNotSupported; | 40 return IsNotSupported; |
41 | 41 |
42 // If we don't recognize the codec, it's possible we support it. | 42 // If we don't recognize the codec, it's possible we support it. |
43 std::vector<std::string> parsed_codecs; | 43 std::vector<std::string> parsed_codecs; |
44 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs); | 44 net::ParseCodecString(ToASCIIOrEmpty(codecs).c_str(), &parsed_codecs, true); |
45 if (!AreSupportedMediaCodecs(parsed_codecs)) | 45 if (!AreSupportedMediaCodecs(parsed_codecs)) |
46 return MayBeSupported; | 46 return MayBeSupported; |
47 | 47 |
48 // Otherwise we have a perfect match. | 48 // Otherwise we have a perfect match. |
49 return IsSupported; | 49 return IsSupported; |
50 } | 50 } |
51 | 51 |
52 bool TestShellWebMimeRegistryImpl::IsSupportedMediaMimeType( | 52 bool TestShellWebMimeRegistryImpl::IsSupportedMediaMimeType( |
53 const std::string& mime_type) { | 53 const std::string& mime_type) { |
54 return media_map_.find(mime_type) != media_map_.end(); | 54 return media_map_.find(mime_type) != media_map_.end(); |
55 } | 55 } |
56 | 56 |
57 bool TestShellWebMimeRegistryImpl::AreSupportedMediaCodecs( | 57 bool TestShellWebMimeRegistryImpl::AreSupportedMediaCodecs( |
58 const std::vector<std::string>& codecs) { | 58 const std::vector<std::string>& codecs) { |
59 for (size_t i = 0; i < codecs.size(); ++i) { | 59 for (size_t i = 0; i < codecs.size(); ++i) { |
60 if (codecs_map_.find(codecs[i]) == codecs_map_.end()) { | 60 if (codecs_map_.find(codecs[i]) == codecs_map_.end()) { |
61 return false; | 61 return false; |
62 } | 62 } |
63 } | 63 } |
64 return true; | 64 return true; |
65 } | 65 } |
OLD | NEW |