OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/content_security_policy/csp_context.h" | 5 #include "content/common/content_security_policy/csp_context.h" |
6 | 6 |
7 namespace content { | 7 namespace content { |
8 | 8 |
9 CSPContext::CSPContext() : has_self_(false) {} | 9 CSPContext::CSPContext() : has_self_(false) {} |
10 | 10 |
11 CSPContext::~CSPContext() {} | 11 CSPContext::~CSPContext() {} |
12 | 12 |
13 bool CSPContext::Allow(const std::vector<ContentSecurityPolicy>& policies, | 13 bool CSPContext::Allow(const std::vector<ContentSecurityPolicy>& policies, |
14 CSPDirective::Name directive_name, | 14 CSPDirective::Name directive_name, |
15 const GURL& url, | 15 const GURL& url, |
16 bool is_redirect) { | 16 bool is_redirect) { |
17 if (SchemeShouldBypassCSP(url.scheme_piece())) | 17 if (SchemeShouldBypassCSP(url.scheme_piece())) |
18 return true; | 18 return true; |
19 | 19 |
20 for (const auto& policy : policies) { | 20 for (const auto& policy : policies) { |
21 if (!ContentSecurityPolicy::Allow(policy, directive_name, url, this, | 21 if (!ContentSecurityPolicy::Allow(policy, directive_name, url, this, |
22 is_redirect)) | 22 is_redirect)) |
23 return false; | 23 return false; |
24 } | 24 } |
25 return true; | 25 return true; |
26 } | 26 } |
27 | 27 |
28 void CSPContext::SetSelf(const url::Origin origin) { | 28 void CSPContext::SetSelf(const url::Origin origin) { |
29 if (origin.unique()) { | 29 if (origin.opaque()) { |
30 // TODO(arthursonzogni): Decide what to do with unique origins. | 30 // TODO(arthursonzogni): Decide what to do with opaque origins. |
31 has_self_ = false; | 31 has_self_ = false; |
32 return; | 32 return; |
33 } | 33 } |
34 | 34 |
35 if (origin.scheme() == url::kFileScheme) { | 35 if (origin.scheme() == url::kFileScheme) { |
36 has_self_ = true; | 36 has_self_ = true; |
37 self_scheme_ = url::kFileScheme; | 37 self_scheme_ = url::kFileScheme; |
38 self_source_ = CSPSource(url::kFileScheme, "", false, url::PORT_UNSPECIFIED, | 38 self_source_ = CSPSource(url::kFileScheme, "", false, url::PORT_UNSPECIFIED, |
39 false, ""); | 39 false, ""); |
40 return; | 40 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const std::string& effective_directive, | 79 const std::string& effective_directive, |
80 const std::string& message, | 80 const std::string& message, |
81 const GURL& blocked_url, | 81 const GURL& blocked_url, |
82 const std::vector<std::string>& report_end_points, | 82 const std::vector<std::string>& report_end_points, |
83 const std::string& header, | 83 const std::string& header, |
84 blink::WebContentSecurityPolicyType disposition) { | 84 blink::WebContentSecurityPolicyType disposition) { |
85 return; | 85 return; |
86 } | 86 } |
87 | 87 |
88 } // namespace content | 88 } // namespace content |
OLD | NEW |