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 CSPDirectiveList_h | 5 #ifndef CSPDirectiveList_h |
6 #define CSPDirectiveList_h | 6 #define CSPDirectiveList_h |
7 | 7 |
8 #include "core/frame/csp/ContentSecurityPolicy.h" | 8 #include "core/frame/csp/ContentSecurityPolicy.h" |
9 #include "core/frame/csp/MediaListDirective.h" | 9 #include "core/frame/csp/MediaListDirective.h" |
10 #include "core/frame/csp/SourceListDirective.h" | 10 #include "core/frame/csp/SourceListDirective.h" |
11 #include "platform/network/ContentSecurityPolicyParsers.h" | 11 #include "platform/network/ContentSecurityPolicyParsers.h" |
12 #include "platform/network/HTTPParsers.h" | 12 #include "platform/network/HTTPParsers.h" |
13 #include "platform/weborigin/KURL.h" | 13 #include "platform/weborigin/KURL.h" |
14 #include "platform/weborigin/ReferrerPolicy.h" | 14 #include "platform/weborigin/ReferrerPolicy.h" |
15 #include "wtf/OwnPtr.h" | 15 #include "wtf/OwnPtr.h" |
16 #include "wtf/Vector.h" | 16 #include "wtf/Vector.h" |
17 #include "wtf/text/WTFString.h" | 17 #include "wtf/text/WTFString.h" |
18 | 18 |
19 namespace WebCore { | 19 namespace WebCore { |
20 | 20 |
21 class ContentSecurityPolicy; | 21 class ContentSecurityPolicy; |
| 22 class ScriptCallStack; |
22 | 23 |
23 class CSPDirectiveList { | 24 class CSPDirectiveList { |
24 WTF_MAKE_FAST_ALLOCATED; | 25 WTF_MAKE_FAST_ALLOCATED; |
25 WTF_MAKE_NONCOPYABLE(CSPDirectiveList); | 26 WTF_MAKE_NONCOPYABLE(CSPDirectiveList); |
26 public: | 27 public: |
27 static PassOwnPtr<CSPDirectiveList> create(ContentSecurityPolicy*, const UCh
ar* begin, const UChar* end, ContentSecurityPolicyHeaderType, ContentSecurityPol
icyHeaderSource); | 28 static PassOwnPtr<CSPDirectiveList> create(ContentSecurityPolicy*, const UCh
ar* begin, const UChar* end, ContentSecurityPolicyHeaderType, ContentSecurityPol
icyHeaderSource); |
28 | 29 |
29 void parse(const UChar* begin, const UChar* end); | 30 void parse(const UChar* begin, const UChar* end); |
30 | 31 |
31 const String& header() const { return m_header; } | 32 const String& header() const { return m_header; } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void addDirective(const String& name, const String& value); | 75 void addDirective(const String& name, const String& value); |
75 void applySandboxPolicy(const String& name, const String& sandboxPolicy); | 76 void applySandboxPolicy(const String& name, const String& sandboxPolicy); |
76 | 77 |
77 template <class CSPDirectiveType> | 78 template <class CSPDirectiveType> |
78 void setCSPDirective(const String& name, const String& value, OwnPtr<CSPDire
ctiveType>&); | 79 void setCSPDirective(const String& name, const String& value, OwnPtr<CSPDire
ctiveType>&); |
79 | 80 |
80 SourceListDirective* operativeDirective(SourceListDirective*) const; | 81 SourceListDirective* operativeDirective(SourceListDirective*) const; |
81 SourceListDirective* operativeDirective(SourceListDirective*, SourceListDire
ctive* override) const; | 82 SourceListDirective* operativeDirective(SourceListDirective*, SourceListDire
ctive* override) const; |
82 void reportViolation(const String& directiveText, const String& effectiveDir
ective, const String& consoleMessage, const KURL& blockedURL) const; | 83 void reportViolation(const String& directiveText, const String& effectiveDir
ective, const String& consoleMessage, const KURL& blockedURL) const; |
83 void reportViolationWithLocation(const String& directiveText, const String&
effectiveDirective, const String& consoleMessage, const KURL& blockedURL, const
String& contextURL, const WTF::OrdinalNumber& contextLine) const; | 84 void reportViolationWithLocation(const String& directiveText, const String&
effectiveDirective, const String& consoleMessage, const KURL& blockedURL, const
String& contextURL, const WTF::OrdinalNumber& contextLine) const; |
84 void reportViolationWithState(const String& directiveText, const String& eff
ectiveDirective, const String& consoleMessage, const KURL& blockedURL, ScriptSta
te*) const; | 85 void reportViolationWithStack(const String& directiveText, const String& eff
ectiveDirective, const String& consoleMessage, const KURL& blockedURL, PassRefPt
r<ScriptCallStack>) const; |
85 | 86 |
86 bool checkEval(SourceListDirective*) const; | 87 bool checkEval(SourceListDirective*) const; |
87 bool checkInline(SourceListDirective*) const; | 88 bool checkInline(SourceListDirective*) const; |
88 bool checkNonce(SourceListDirective*, const String&) const; | 89 bool checkNonce(SourceListDirective*, const String&) const; |
89 bool checkHash(SourceListDirective*, const CSPHashValue&) const; | 90 bool checkHash(SourceListDirective*, const CSPHashValue&) const; |
90 bool checkSource(SourceListDirective*, const KURL&) const; | 91 bool checkSource(SourceListDirective*, const KURL&) const; |
91 bool checkMediaType(MediaListDirective*, const String& type, const String& t
ypeAttribute) const; | 92 bool checkMediaType(MediaListDirective*, const String& type, const String& t
ypeAttribute) const; |
92 bool checkAncestors(SourceListDirective*, LocalFrame*) const; | 93 bool checkAncestors(SourceListDirective*, LocalFrame*) const; |
93 | 94 |
94 void setEvalDisabledErrorMessage(const String& errorMessage) { m_evalDisable
dErrorMessage = errorMessage; } | 95 void setEvalDisabledErrorMessage(const String& errorMessage) { m_evalDisable
dErrorMessage = errorMessage; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 133 |
133 Vector<KURL> m_reportURIs; | 134 Vector<KURL> m_reportURIs; |
134 | 135 |
135 String m_evalDisabledErrorMessage; | 136 String m_evalDisabledErrorMessage; |
136 }; | 137 }; |
137 | 138 |
138 | 139 |
139 } // namespace | 140 } // namespace |
140 | 141 |
141 #endif | 142 #endif |
OLD | NEW |