OLD | NEW |
(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/csp_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 class CONTENT_EXPORT CSPContext { |
| 19 public: |
| 20 CSPContext(); |
| 21 virtual ~CSPContext(); |
| 22 |
| 23 bool Allow(const std::vector<CSPPolicy>& policies, |
| 24 CSPDirective::Name directive_name, |
| 25 const GURL& url, |
| 26 bool is_redirect = false); |
| 27 |
| 28 void SetSelf(const url::Origin origin); |
| 29 bool AllowSelf(const GURL& url); |
| 30 bool ProtocolMatchesSelf(const GURL& url); |
| 31 |
| 32 virtual void LogToConsole(const std::string& message); |
| 33 virtual void ReportViolation( |
| 34 const std::string& directive_text, |
| 35 const std::string& effective_directive, |
| 36 const std::string& message, |
| 37 const GURL& blocked_url, |
| 38 const std::vector<std::string>& report_end_points, |
| 39 const std::string& header, |
| 40 blink::WebContentSecurityPolicyType disposition); |
| 41 |
| 42 bool SelfSchemeShouldBypassCSP(); |
| 43 |
| 44 private: |
| 45 virtual bool SchemeShouldBypassCSP(const base::StringPiece& scheme); |
| 46 |
| 47 bool has_self_ = false; |
| 48 std::string self_scheme_; |
| 49 CSPSource self_source_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(CSPContext); |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_CONTEXT_H_ |
OLD | NEW |