OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_POLICY_H_ |
| 6 #define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_POLICY_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "content/common/content_export.h" |
| 12 #include "content/common/content_security_policy/csp_directive.h" |
| 13 #include "content/common/content_security_policy_header.h" |
| 14 #include "url/gurl.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class CSPContext; |
| 19 |
| 20 // https://www.w3.org/TR/CSP3/#framework-policy |
| 21 struct CONTENT_EXPORT CSPPolicy { |
| 22 CSPPolicy(); |
| 23 CSPPolicy(blink::WebContentSecurityPolicyType disposition, |
| 24 blink::WebContentSecurityPolicySource source, |
| 25 const std::vector<CSPDirective>& directives, |
| 26 const std::vector<std::string>& report_endpoints); |
| 27 CSPPolicy(const CSPPolicy&); |
| 28 ~CSPPolicy(); |
| 29 |
| 30 blink::WebContentSecurityPolicyType disposition; |
| 31 blink::WebContentSecurityPolicySource source; |
| 32 std::vector<CSPDirective> directives; |
| 33 std::vector<std::string> report_endpoints; |
| 34 |
| 35 bool Allow(CSPContext* context, |
| 36 CSPDirective::Name directive, |
| 37 const GURL& url, |
| 38 bool is_redirect = false) const; |
| 39 |
| 40 std::string ToString() const; |
| 41 |
| 42 private: |
| 43 bool AllowDirective(CSPContext* context, |
| 44 CSPDirective::Name directive_name, |
| 45 const CSPDirective& directive, |
| 46 const GURL& url, |
| 47 bool is_redirect) const; |
| 48 |
| 49 void ReportViolation(CSPContext* context, |
| 50 const CSPDirective::Name effective_directive, |
| 51 const CSPDirective& directive, |
| 52 const GURL& url) const; |
| 53 }; |
| 54 |
| 55 } // namespace content |
| 56 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_POLICY_H_ |
OLD | NEW |