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

Unified Diff: content/common/content_security_policy/csp_policy.h

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Rename SchemeShouldBypass => SchemeShouldBypassCSP. Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698