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

Side by Side Diff: content/common/content_security_policy/csp_policy.h

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Temporary re-add the parser + transmit parsed CSP over IPC. Created 3 years, 11 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 unified diff | Download patch
OLDNEW
(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_BROWSER_COMMON_CONTENT_SECURITY_POLICY_POLICY_H
6 #define CONTENT_BROWSER_COMMON_CONTENT_SECURITY_POLICY_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_end_points);
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_end_points;
34
35 static CSPPolicy Parse(CSPContext* context,
36 const ContentSecurityPolicyHeader& header);
37
38 bool Allow(CSPContext* context,
39 CSPDirective::Name directive,
40 const GURL& url,
41 bool is_redirect = false) const;
42
43 std::string ToString() const;
44
45 private:
46 bool AllowDirective(CSPContext* context,
47 CSPDirective::Name directive_name,
48 const CSPDirective& directive,
49 const GURL& url,
50 bool is_redirect) const;
51 void ReportViolation(CSPContext* context,
52 const CSPDirective::Name effective_directive,
53 const CSPDirective& directive,
54 const GURL& url) const;
55 };
56
57 } // namespace content
58 #endif // CONTENT_BROWSER_COMMON_CONTENT_SECURITY_POLICY_POLICY_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698