| 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/renderer/content_security_policy_util.h" | 5 #include "content/renderer/content_security_policy_util.h" |
| 6 | 6 |
| 7 namespace content { | 7 namespace content { |
| 8 | 8 |
| 9 CSPSource BuildCSPSource( | 9 CSPSource BuildCSPSource( |
| 10 const blink::WebContentSecurityPolicySourceExpression& source) { | 10 const blink::WebContentSecurityPolicySourceExpression& source) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 ContentSecurityPolicy BuildContentSecurityPolicy( | 39 ContentSecurityPolicy BuildContentSecurityPolicy( |
| 40 const blink::WebContentSecurityPolicy& policy) { | 40 const blink::WebContentSecurityPolicy& policy) { |
| 41 std::vector<CSPDirective> directives; | 41 std::vector<CSPDirective> directives; |
| 42 for (const auto& directive : policy.directives) | 42 for (const auto& directive : policy.directives) |
| 43 directives.push_back(BuildCSPDirective(directive)); | 43 directives.push_back(BuildCSPDirective(directive)); |
| 44 | 44 |
| 45 std::vector<std::string> report_endpoints; | 45 std::vector<std::string> report_endpoints; |
| 46 for (const blink::WebString& endpoint : policy.reportEndpoints) | 46 for (const blink::WebString& endpoint : policy.reportEndpoints) |
| 47 report_endpoints.push_back(endpoint.utf8()); | 47 report_endpoints.push_back(endpoint.utf8()); |
| 48 | 48 |
| 49 return ContentSecurityPolicy(policy.disposition, // disposition | 49 return ContentSecurityPolicy( |
| 50 policy.source, // source | 50 ContentSecurityPolicyHeader(policy.header.utf8(), policy.disposition, |
| 51 directives, // directives | 51 policy.source), |
| 52 report_endpoints, // report_endpoints | 52 directives, report_endpoints); |
| 53 policy.header.utf8()); // header | |
| 54 } | 53 } |
| 55 | 54 |
| 56 blink::WebContentSecurityPolicyViolation BuildWebContentSecurityPolicyViolation( | 55 blink::WebContentSecurityPolicyViolation BuildWebContentSecurityPolicyViolation( |
| 57 const content::CSPViolationParams& violation_params) { | 56 const content::CSPViolationParams& violation_params) { |
| 58 blink::WebContentSecurityPolicyViolation violation; | 57 blink::WebContentSecurityPolicyViolation violation; |
| 59 violation.directive = blink::WebString::fromASCII(violation_params.directive); | 58 violation.directive = blink::WebString::fromASCII(violation_params.directive); |
| 60 violation.effectiveDirective = | 59 violation.effectiveDirective = |
| 61 blink::WebString::fromASCII(violation_params.effective_directive); | 60 blink::WebString::fromASCII(violation_params.effective_directive); |
| 62 violation.consoleMessage = | 61 violation.consoleMessage = |
| 63 blink::WebString::fromASCII(violation_params.console_message); | 62 blink::WebString::fromASCII(violation_params.console_message); |
| 64 violation.blockedUrl = violation_params.blocked_url; | 63 violation.blockedUrl = violation_params.blocked_url; |
| 65 violation.reportEndpoints = blink::WebVector<blink::WebString>( | 64 violation.reportEndpoints = blink::WebVector<blink::WebString>( |
| 66 violation_params.report_endpoints.size()); | 65 violation_params.report_endpoints.size()); |
| 67 for (size_t i = 0; i < violation_params.report_endpoints.size(); ++i) { | 66 for (size_t i = 0; i < violation_params.report_endpoints.size(); ++i) { |
| 68 violation.reportEndpoints[i] = | 67 violation.reportEndpoints[i] = |
| 69 blink::WebString::fromASCII(violation_params.report_endpoints[i]); | 68 blink::WebString::fromASCII(violation_params.report_endpoints[i]); |
| 70 } | 69 } |
| 71 violation.header = blink::WebString::fromASCII(violation_params.header); | 70 violation.header = blink::WebString::fromASCII(violation_params.header); |
| 72 violation.disposition = violation_params.disposition; | 71 violation.disposition = violation_params.disposition; |
| 73 violation.afterRedirect = violation_params.after_redirect; | 72 violation.afterRedirect = violation_params.after_redirect; |
| 74 return violation; | 73 return violation; |
| 75 } | 74 } |
| 76 | 75 |
| 77 } // namespace content | 76 } // namespace content |
| OLD | NEW |