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

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

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Rebase from master. 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 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_COMMON_CONTENT_SECURITY_POLICY_CONTENT_SECURITY_POLICY_H_
6 #define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CONTENT_SECURITY_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 //
22 // A ContentSecurityPolicy is a collection of CSPDirectives which will be
23 // enforced upon requests.
24 struct CONTENT_EXPORT ContentSecurityPolicy {
25 ContentSecurityPolicy();
26 ContentSecurityPolicy(blink::WebContentSecurityPolicyType disposition,
27 blink::WebContentSecurityPolicySource source,
28 const std::vector<CSPDirective>& directives,
29 const std::vector<std::string>& report_endpoints);
30 ContentSecurityPolicy(const ContentSecurityPolicy&);
31 ~ContentSecurityPolicy();
32
33 blink::WebContentSecurityPolicyType disposition;
34 blink::WebContentSecurityPolicySource source;
35 std::vector<CSPDirective> directives;
36 std::vector<std::string> report_endpoints;
37
38 std::string ToString() const;
39
40 // Return true when the |policy| allows a request to the |url| in relation to
41 // the |directive |for a given |context|.
42 // Note: Any policy violation are reported to the |context|.
43 static bool Allow(const ContentSecurityPolicy& policy,
44 CSPDirective::Name directive,
45 const GURL& url,
46 CSPContext* context,
47 bool is_redirect = false);
48 };
49
50 } // namespace content
51 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CONTENT_SECURITY_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698