| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CSPSource_h | 5 #ifndef CSPSource_h |
| 6 #define CSPSource_h | 6 #define CSPSource_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/frame/csp/ContentSecurityPolicy.h" | 9 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 WildcardDisposition hostWildcard, | 29 WildcardDisposition hostWildcard, |
| 30 WildcardDisposition portWildcard); | 30 WildcardDisposition portWildcard); |
| 31 bool isSchemeOnly() const; | 31 bool isSchemeOnly() const; |
| 32 const String& getScheme() { return m_scheme; }; | 32 const String& getScheme() { return m_scheme; }; |
| 33 bool matches(const KURL&, | 33 bool matches(const KURL&, |
| 34 ResourceRequest::RedirectStatus = | 34 ResourceRequest::RedirectStatus = |
| 35 ResourceRequest::RedirectStatus::NoRedirect) const; | 35 ResourceRequest::RedirectStatus::NoRedirect) const; |
| 36 | 36 |
| 37 // Returns true if this CSPSource subsumes the other, as defined by the | 37 // Returns true if this CSPSource subsumes the other, as defined by the |
| 38 // algorithm at https://w3c.github.io/webappsec-csp/embedded/#subsume-policy | 38 // algorithm at https://w3c.github.io/webappsec-csp/embedded/#subsume-policy |
| 39 bool subsumes(CSPSource*); | 39 bool subsumes(CSPSource*) const; |
| 40 // Retrieve the most restrictive information from the two CSPSources if | 40 // Retrieve the most restrictive information from the two CSPSources if |
| 41 // isSimilar is true for the two. Otherwise, return nullptr. | 41 // isSimilar is true for the two. Otherwise, return nullptr. |
| 42 CSPSource* intersect(CSPSource*); | 42 CSPSource* intersect(CSPSource*) const; |
| 43 // Returns true if the first list subsumes the second, as defined by the | 43 // Returns true if the first list subsumes the second, as defined by the |
| 44 // algorithm at | 44 // algorithm at |
| 45 // https://w3c.github.io/webappsec-csp/embedded/#subsume-source-list | 45 // https://w3c.github.io/webappsec-csp/embedded/#subsume-source-list |
| 46 static bool firstSubsumesSecond(HeapVector<Member<CSPSource>>, | 46 static bool firstSubsumesSecond(const HeapVector<Member<CSPSource>>&, |
| 47 HeapVector<Member<CSPSource>>); | 47 const HeapVector<Member<CSPSource>>&); |
| 48 | 48 |
| 49 DECLARE_TRACE(); | 49 DECLARE_TRACE(); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IsSimilar); | 52 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IsSimilar); |
| 53 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, Intersect); | 53 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, Intersect); |
| 54 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IntersectSchemesOnly); | 54 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IntersectSchemesOnly); |
| 55 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, GetIntersectCSPSources); | 55 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, GetIntersectCSPSources); |
| 56 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, | 56 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, |
| 57 GetIntersectCSPSourcesSchemes); | 57 GetIntersectCSPSourcesSchemes); |
| 58 FRIEND_TEST_ALL_PREFIXES(CSPDirectiveListTest, GetSourceVector); | 58 FRIEND_TEST_ALL_PREFIXES(CSPDirectiveListTest, GetSourceVector); |
| 59 FRIEND_TEST_ALL_PREFIXES(CSPDirectiveListTest, OperativeDirectiveGivenType); | 59 FRIEND_TEST_ALL_PREFIXES(CSPDirectiveListTest, OperativeDirectiveGivenType); |
| 60 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, SubsumesWithSelf); | 60 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, SubsumesWithSelf); |
| 61 | 61 |
| 62 bool schemeMatches(const String&) const; | 62 bool schemeMatches(const String&) const; |
| 63 bool hostMatches(const String&) const; | 63 bool hostMatches(const String&) const; |
| 64 bool pathMatches(const String&) const; | 64 bool pathMatches(const String&) const; |
| 65 // Protocol is necessary to determine default port if it is zero. | 65 // Protocol is necessary to determine default port if it is zero. |
| 66 bool portMatches(int port, const String& protocol) const; | 66 bool portMatches(int port, const String& protocol) const; |
| 67 bool isSimilar(CSPSource* other); | 67 bool isSimilar(CSPSource* other) const; |
| 68 | 68 |
| 69 Member<ContentSecurityPolicy> m_policy; | 69 Member<ContentSecurityPolicy> m_policy; |
| 70 String m_scheme; | 70 String m_scheme; |
| 71 String m_host; | 71 String m_host; |
| 72 int m_port; | 72 int m_port; |
| 73 String m_path; | 73 String m_path; |
| 74 | 74 |
| 75 WildcardDisposition m_hostWildcard; | 75 WildcardDisposition m_hostWildcard; |
| 76 WildcardDisposition m_portWildcard; | 76 WildcardDisposition m_portWildcard; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace blink | 79 } // namespace blink |
| 80 | 80 |
| 81 #endif | 81 #endif |
| OLD | NEW |