| 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::IsAllowedByCsp(CSPDirective::Name directive_name, | 13 bool CSPContext::IsAllowedByCsp(CSPDirective::Name directive_name, |
| 14 const GURL& url, | 14 const GURL& url, |
| 15 bool is_redirect, | 15 bool is_redirect, |
| 16 const SourceLocation& source_location) { | 16 const SourceLocation& source_location) { |
| 17 if (SchemeShouldBypassCSP(url.scheme_piece())) | 17 if (SchemeShouldBypassCSP(url.scheme_piece())) |
| 18 return true; | 18 return true; |
| 19 | 19 |
| 20 bool allow = true; |
| 20 for (const auto& policy : policies_) { | 21 for (const auto& policy : policies_) { |
| 21 if (!ContentSecurityPolicy::Allow(policy, directive_name, url, is_redirect, | 22 allow &= ContentSecurityPolicy::Allow(policy, directive_name, url, |
| 22 this, source_location)) | 23 is_redirect, this, source_location); |
| 23 return false; | |
| 24 } | 24 } |
| 25 return true; | 25 return allow; |
| 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.unique()) { |
| 30 // TODO(arthursonzogni): Decide what to do with unique origins. | 30 // TODO(arthursonzogni): Decide what to do with unique 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) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 disposition(disposition), | 106 disposition(disposition), |
| 107 after_redirect(after_redirect), | 107 after_redirect(after_redirect), |
| 108 source_location(source_location) {} | 108 source_location(source_location) {} |
| 109 | 109 |
| 110 CSPViolationParams::CSPViolationParams(const CSPViolationParams& other) = | 110 CSPViolationParams::CSPViolationParams(const CSPViolationParams& other) = |
| 111 default; | 111 default; |
| 112 | 112 |
| 113 CSPViolationParams::~CSPViolationParams() {} | 113 CSPViolationParams::~CSPViolationParams() {} |
| 114 | 114 |
| 115 } // namespace content | 115 } // namespace content |
| OLD | NEW |