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

Side by Side Diff: third_party/WebKit/Source/core/frame/csp/CSPSource.h

Issue 2487983003: Part 2.3: Is policy list subsumed under subsuming policy? (Closed)
Patch Set: Adding a comment Created 4 years 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
OLDNEW
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 10 matching lines...) Expand all
21 public: 21 public:
22 enum WildcardDisposition { HasWildcard, NoWildcard }; 22 enum WildcardDisposition { HasWildcard, NoWildcard };
23 23
24 CSPSource(ContentSecurityPolicy*, 24 CSPSource(ContentSecurityPolicy*,
25 const String& scheme, 25 const String& scheme,
26 const String& host, 26 const String& host,
27 int port, 27 int port,
28 const String& path, 28 const String& path,
29 WildcardDisposition hostWildcard, 29 WildcardDisposition hostWildcard,
30 WildcardDisposition portWildcard); 30 WildcardDisposition portWildcard);
31 bool isSchemeOnly() const;
32 const String& getScheme() { return m_scheme; };
31 bool matches(const KURL&, 33 bool matches(const KURL&,
32 ResourceRequest::RedirectStatus = 34 ResourceRequest::RedirectStatus =
33 ResourceRequest::RedirectStatus::NoRedirect) const; 35 ResourceRequest::RedirectStatus::NoRedirect) const;
34 36
35 // 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
36 // algorithm at https://w3c.github.io/webappsec-csp/embedded/#subsume-policy 38 // algorithm at https://w3c.github.io/webappsec-csp/embedded/#subsume-policy
37 bool subsumes(CSPSource*); 39 bool subsumes(CSPSource*);
38 // Retrieve the most restrictive information from the two CSPSources if 40 // Retrieve the most restrictive information from the two CSPSources if
39 // isSimilar is true for the two. Otherwise, return nullptr. 41 // isSimilar is true for the two. Otherwise, return nullptr.
40 CSPSource* intersect(CSPSource*); 42 CSPSource* intersect(CSPSource*);
41 // 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
42 // algorithm at 44 // algorithm at
43 // https://w3c.github.io/webappsec-csp/embedded/#subsume-source-list 45 // https://w3c.github.io/webappsec-csp/embedded/#subsume-source-list
44 static bool firstSubsumesSecond(HeapVector<Member<CSPSource>>, 46 static bool firstSubsumesSecond(HeapVector<Member<CSPSource>>,
45 HeapVector<Member<CSPSource>>); 47 HeapVector<Member<CSPSource>>);
46 48
47 DECLARE_TRACE(); 49 DECLARE_TRACE();
48 50
49 private: 51 private:
50 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IsSimilar); 52 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IsSimilar);
51 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, GetIntersectCSPSources); 53 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, GetIntersectCSPSources);
54 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest,
55 GetIntersectCSPSourcesSchemes);
56 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, Intersect);
57 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IntersectSchemesOnly);
52 58
53 bool schemeMatches(const String&) const; 59 bool schemeMatches(const String&) const;
54 bool hostMatches(const String&) const; 60 bool hostMatches(const String&) const;
55 bool pathMatches(const String&) const; 61 bool pathMatches(const String&) const;
56 // Protocol is necessary to determine default port if it is zero. 62 // Protocol is necessary to determine default port if it is zero.
57 bool portMatches(int port, const String& protocol) const; 63 bool portMatches(int port, const String& protocol) const;
58 bool isSchemeOnly() const;
59 bool isSimilar(CSPSource* other); 64 bool isSimilar(CSPSource* other);
60 65
61 Member<ContentSecurityPolicy> m_policy; 66 Member<ContentSecurityPolicy> m_policy;
62 String m_scheme; 67 String m_scheme;
63 String m_host; 68 String m_host;
64 int m_port; 69 int m_port;
65 String m_path; 70 String m_path;
66 71
67 WildcardDisposition m_hostWildcard; 72 WildcardDisposition m_hostWildcard;
68 WildcardDisposition m_portWildcard; 73 WildcardDisposition m_portWildcard;
69 }; 74 };
70 75
71 } // namespace blink 76 } // namespace blink
72 77
73 #endif 78 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698