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

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

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Add the TODO and bug ids that was forgotten. 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_CSP_CONTEXT_H_
6 #define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_CONTEXT_H_
7
8 #include <vector>
9
10 #include "content/common/content_export.h"
11 #include "content/common/content_security_policy/content_security_policy.h"
12 #include "content/common/content_security_policy_header.h"
13 #include "url/gurl.h"
14 #include "url/origin.h"
15
16 namespace content {
17
18 // A CSPContext represents the system on which the Content-Security-Policy are
19 // enforced. One must define via its virtual methods how to report violations,
20 // how to log messages on the console and what is the set of scheme that bypass
21 // the CSP.
22 // Its main implementation is in content/browser/frame_host/csp_context_impl.h
23 class CONTENT_EXPORT CSPContext {
24 public:
25 CSPContext();
26 virtual ~CSPContext();
27
28 bool Allow(const std::vector<ContentSecurityPolicy>& policies,
29 CSPDirective::Name directive_name,
30 const GURL& url,
31 bool is_redirect = false);
32
33 void SetSelf(const url::Origin origin);
34 bool AllowSelf(const GURL& url);
35 bool ProtocolMatchesSelf(const GURL& url);
36
37 virtual void LogToConsole(const std::string& message);
38 virtual void ReportViolation(
39 const std::string& directive_text,
40 const std::string& effective_directive,
41 const std::string& message,
42 const GURL& blocked_url,
43 const std::vector<std::string>& report_end_points,
44 const std::string& header,
45 blink::WebContentSecurityPolicyType disposition);
46
47 bool SelfSchemeShouldBypassCSP();
48
49 private:
50 virtual bool SchemeShouldBypassCSP(const base::StringPiece& scheme);
51
52 bool has_self_ = false;
53 std::string self_scheme_;
54 CSPSource self_source_;
55
56 DISALLOW_COPY_AND_ASSIGN(CSPContext);
57 };
58
59 } // namespace content
60 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698