| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "net/base/mime_util.h" | 9 #include "net/base/mime_util.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 net::GetMediaCodecsBlacklistedForTests(&blacklisted_media_codecs_); | 28 net::GetMediaCodecsBlacklistedForTests(&blacklisted_media_codecs_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TestShellWebMimeRegistryImpl::~TestShellWebMimeRegistryImpl() {} | 31 TestShellWebMimeRegistryImpl::~TestShellWebMimeRegistryImpl() {} |
| 32 | 32 |
| 33 // Returns IsNotSupported if mime_type or any of the codecs are not supported. | 33 // Returns IsNotSupported if mime_type or any of the codecs are not supported. |
| 34 // Otherwse, defers to the real registry. | 34 // Otherwse, defers to the real registry. |
| 35 WebMimeRegistry::SupportsType | 35 WebMimeRegistry::SupportsType |
| 36 TestShellWebMimeRegistryImpl::supportsMediaMIMEType( | 36 TestShellWebMimeRegistryImpl::supportsMediaMIMEType( |
| 37 const WebString& mime_type, | 37 const WebString& mime_type, |
| 38 const WebString& codecs) { | 38 const WebString& codecs, |
| 39 const WebKit::WebString& key_system) { |
| 39 if (IsBlacklistedMediaMimeType(ToASCIIOrEmpty(mime_type))) | 40 if (IsBlacklistedMediaMimeType(ToASCIIOrEmpty(mime_type))) |
| 40 return IsNotSupported; | 41 return IsNotSupported; |
| 41 | 42 |
| 42 std::vector<std::string> parsed_codecs; | 43 std::vector<std::string> parsed_codecs; |
| 43 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); | 44 net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); |
| 44 if (HasBlacklistedMediaCodecs(parsed_codecs)) | 45 if (HasBlacklistedMediaCodecs(parsed_codecs)) |
| 45 return IsNotSupported; | 46 return IsNotSupported; |
| 46 | 47 |
| 47 return SimpleWebMimeRegistryImpl::supportsMediaMIMEType(mime_type, codecs); | 48 return SimpleWebMimeRegistryImpl::supportsMediaMIMEType( |
| 49 mime_type, codecs, key_system); |
| 48 } | 50 } |
| 49 | 51 |
| 50 bool TestShellWebMimeRegistryImpl::IsBlacklistedMediaMimeType( | 52 bool TestShellWebMimeRegistryImpl::IsBlacklistedMediaMimeType( |
| 51 const std::string& mime_type) { | 53 const std::string& mime_type) { |
| 52 for (size_t i = 0; i < blacklisted_media_types_.size(); ++i) { | 54 for (size_t i = 0; i < blacklisted_media_types_.size(); ++i) { |
| 53 if (blacklisted_media_types_[i] == mime_type) | 55 if (blacklisted_media_types_[i] == mime_type) |
| 54 return true; | 56 return true; |
| 55 } | 57 } |
| 56 return false; | 58 return false; |
| 57 } | 59 } |
| 58 | 60 |
| 59 bool TestShellWebMimeRegistryImpl::HasBlacklistedMediaCodecs( | 61 bool TestShellWebMimeRegistryImpl::HasBlacklistedMediaCodecs( |
| 60 const std::vector<std::string>& codecs) { | 62 const std::vector<std::string>& codecs) { |
| 61 for (size_t i = 0; i < codecs.size(); ++i) { | 63 for (size_t i = 0; i < codecs.size(); ++i) { |
| 62 for (size_t j = 0; j < blacklisted_media_codecs_.size(); ++j) { | 64 for (size_t j = 0; j < blacklisted_media_codecs_.size(); ++j) { |
| 63 if (blacklisted_media_codecs_[j] == codecs[i]) | 65 if (blacklisted_media_codecs_[j] == codecs[i]) |
| 64 return true; | 66 return true; |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 return false; | 69 return false; |
| 68 } | 70 } |
| OLD | NEW |