| Index: third_party/WebKit/Source/core/frame/csp/MediaListDirective.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/csp/MediaListDirective.cpp b/third_party/WebKit/Source/core/frame/csp/MediaListDirective.cpp
|
| index c067b3ce3c9ee6c6dcda9668f741be9e57aa87db..b031f79ec1219ee8779a0a5c98d1060f0645460a 100644
|
| --- a/third_party/WebKit/Source/core/frame/csp/MediaListDirective.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/csp/MediaListDirective.cpp
|
| @@ -81,4 +81,37 @@ void MediaListDirective::parse(const UChar* begin, const UChar* end) {
|
| }
|
| }
|
|
|
| +bool MediaListDirective::subsumes(
|
| + const std::vector<MediaListDirective*>& other) {
|
| + if (!other.size())
|
| + return false;
|
| +
|
| + // Find the effective set of plugins allowed by `other`.
|
| + HashSet<String> normalizedB = other[0]->m_pluginTypes;
|
| + for (size_t i = 1; i < other.size(); i++)
|
| + normalizedB = other[i]->getIntersect(normalizedB);
|
| +
|
| + // Empty list of plugins is equivalent to no plugins being allowed.
|
| + if (!m_pluginTypes.size())
|
| + return !normalizedB.size();
|
| +
|
| + // Check that each element of `normalizedB` is allowed by `m_pluginTypes`.
|
| + for (auto it = normalizedB.begin(); it != normalizedB.end(); ++it) {
|
| + if (!allows(*it))
|
| + return false;
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +HashSet<String> MediaListDirective::getIntersect(const HashSet<String>& other) {
|
| + HashSet<String> normalized;
|
| + for (const auto& type : m_pluginTypes) {
|
| + if (other.contains(type))
|
| + normalized.add(type);
|
| + }
|
| +
|
| + return normalized;
|
| +}
|
| +
|
| } // namespace blink
|
|
|