Index: content/common/content_security_policy/csp_policy.h |
diff --git a/content/common/content_security_policy/csp_policy.h b/content/common/content_security_policy/csp_policy.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..09891acb8dfcba09058394dba150b18db97b1ed5 |
--- /dev/null |
+++ b/content/common/content_security_policy/csp_policy.h |
@@ -0,0 +1,56 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_POLICY_H_ |
+#define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_POLICY_H_ |
+ |
+#include <memory> |
+#include <vector> |
+ |
+#include "content/common/content_export.h" |
+#include "content/common/content_security_policy/csp_directive.h" |
+#include "content/common/content_security_policy_header.h" |
+#include "url/gurl.h" |
+ |
+namespace content { |
+ |
+class CSPContext; |
+ |
+// https://www.w3.org/TR/CSP3/#framework-policy |
+struct CONTENT_EXPORT CSPPolicy { |
+ CSPPolicy(); |
+ CSPPolicy(blink::WebContentSecurityPolicyType disposition, |
+ blink::WebContentSecurityPolicySource source, |
+ const std::vector<CSPDirective>& directives, |
+ const std::vector<std::string>& report_endpoints); |
+ CSPPolicy(const CSPPolicy&); |
+ ~CSPPolicy(); |
+ |
+ blink::WebContentSecurityPolicyType disposition; |
+ blink::WebContentSecurityPolicySource source; |
+ std::vector<CSPDirective> directives; |
+ std::vector<std::string> report_endpoints; |
+ |
+ bool Allow(CSPContext* context, |
+ CSPDirective::Name directive, |
+ const GURL& url, |
+ bool is_redirect = false) const; |
+ |
+ std::string ToString() const; |
+ |
+ private: |
+ bool AllowDirective(CSPContext* context, |
+ CSPDirective::Name directive_name, |
+ const CSPDirective& directive, |
+ const GURL& url, |
+ bool is_redirect) const; |
+ |
+ void ReportViolation(CSPContext* context, |
+ const CSPDirective::Name effective_directive, |
+ const CSPDirective& directive, |
+ const GURL& url) const; |
+}; |
+ |
+} // namespace content |
+#endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_POLICY_H_ |