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 #include "third_party/WebKit/public/platform/WebContentSecurityPolicyStruct.h" | |
7 | 6 |
8 namespace content { | 7 namespace content { |
9 | 8 |
10 CSPSource BuildCSPSource( | 9 CSPSource BuildCSPSource( |
11 const blink::WebContentSecurityPolicySourceExpression& source) { | 10 const blink::WebContentSecurityPolicySourceExpression& source) { |
12 return CSPSource( | 11 return CSPSource( |
13 source.scheme.utf8(), // scheme | 12 source.scheme.utf8(), // scheme |
14 source.host.utf8(), // host | 13 source.host.utf8(), // host |
15 source.isHostWildcard == blink::WebWildcardDispositionHasWildcard, | 14 source.isHostWildcard == blink::WebWildcardDispositionHasWildcard, |
16 source.port == 0 ? url::PORT_UNSPECIFIED : source.port, // port | 15 source.port == 0 ? url::PORT_UNSPECIFIED : source.port, // port |
(...skipping 30 matching lines...) Expand all Loading... |
47 for (const blink::WebString& endpoint : policy.reportEndpoints) | 46 for (const blink::WebString& endpoint : policy.reportEndpoints) |
48 report_endpoints.push_back(endpoint.utf8()); | 47 report_endpoints.push_back(endpoint.utf8()); |
49 | 48 |
50 return ContentSecurityPolicy(policy.disposition, // disposition | 49 return ContentSecurityPolicy(policy.disposition, // disposition |
51 policy.source, // source | 50 policy.source, // source |
52 directives, // directives | 51 directives, // directives |
53 report_endpoints, // report_endpoints | 52 report_endpoints, // report_endpoints |
54 policy.header.utf8()); // header | 53 policy.header.utf8()); // header |
55 } | 54 } |
56 | 55 |
| 56 blink::WebContentSecurityPolicyViolation BuildWebContentSecurityPolicyViolation( |
| 57 const content::CSPViolationParams& violation_params) { |
| 58 blink::WebContentSecurityPolicyViolation violation; |
| 59 violation.directive = blink::WebString::fromASCII(violation_params.directive); |
| 60 violation.effectiveDirective = |
| 61 blink::WebString::fromASCII(violation_params.effective_directive); |
| 62 violation.consoleMessage = |
| 63 blink::WebString::fromASCII(violation_params.console_message); |
| 64 violation.blockedUrl = violation_params.blocked_url; |
| 65 violation.reportEndpoints = blink::WebVector<blink::WebString>( |
| 66 violation_params.report_endpoints.size()); |
| 67 for (size_t i = 0; i < violation_params.report_endpoints.size(); ++i) { |
| 68 violation.reportEndpoints[i] = |
| 69 blink::WebString::fromASCII(violation_params.report_endpoints[i]); |
| 70 } |
| 71 violation.header = blink::WebString::fromASCII(violation_params.header); |
| 72 violation.disposition = violation_params.disposition; |
| 73 violation.afterRedirect = violation_params.after_redirect; |
| 74 return violation; |
| 75 } |
| 76 |
57 } // namespace content | 77 } // namespace content |
OLD | NEW |