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

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: Separating scheme to scheme normalization 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*);
43 void addToMap(HashMap<String, CSPSource*>&);
amalika 2016/11/19 18:34:32 Would it be better if I change it to be a lambda f
Mike West 2016/11/23 09:19:18 I think you can just stuff it into `SourceListDire
amalika 2016/11/24 14:50:32 perfect! addressed.
41 44
42 DECLARE_TRACE(); 45 DECLARE_TRACE();
43 46
44 private: 47 private:
45 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IsSimilar); 48 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IsSimilar);
46 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, GetIntersectCSPSources); 49 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest, GetIntersectCSPSources);
50 FRIEND_TEST_ALL_PREFIXES(SourceListDirectiveTest,
51 GetIntersectCSPSourcesSchemes);
52 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, Intersect);
53 FRIEND_TEST_ALL_PREFIXES(CSPSourceTest, IntersectSchemesOnly);
47 54
48 bool schemeMatches(const String&) const; 55 bool schemeMatches(const String&) const;
49 bool hostMatches(const String&) const; 56 bool hostMatches(const String&) const;
50 bool pathMatches(const String&) const; 57 bool pathMatches(const String&) const;
51 // Protocol is necessary to determine default port if it is zero. 58 // Protocol is necessary to determine default port if it is zero.
52 bool portMatches(int port, const String& protocol) const; 59 bool portMatches(int port, const String& protocol) const;
53 bool isSchemeOnly() const;
54 bool isSimilar(CSPSource* other); 60 bool isSimilar(CSPSource* other);
55 61
56 Member<ContentSecurityPolicy> m_policy; 62 Member<ContentSecurityPolicy> m_policy;
57 String m_scheme; 63 String m_scheme;
58 String m_host; 64 String m_host;
59 int m_port; 65 int m_port;
60 String m_path; 66 String m_path;
61 67
62 WildcardDisposition m_hostWildcard; 68 WildcardDisposition m_hostWildcard;
63 WildcardDisposition m_portWildcard; 69 WildcardDisposition m_portWildcard;
64 }; 70 };
65 71
66 } // namespace blink 72 } // namespace blink
67 73
68 #endif 74 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698