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" |
6 | 7 |
7 namespace content { | 8 namespace content { |
8 | 9 |
9 CSPSource BuildCSPSource( | 10 CSPSource BuildCSPSource( |
10 const blink::WebContentSecurityPolicySourceExpression& source) { | 11 const blink::WebContentSecurityPolicySourceExpression& source) { |
11 return CSPSource( | 12 return CSPSource( |
12 source.scheme.utf8(), // scheme | 13 source.scheme.utf8(), // scheme |
13 source.host.utf8(), // host | 14 source.host.utf8(), // host |
14 source.isHostWildcard == blink::WebWildcardDispositionHasWildcard, | 15 source.isHostWildcard == blink::WebWildcardDispositionHasWildcard, |
15 source.port == 0 ? url::PORT_UNSPECIFIED : source.port, // port | 16 source.port == 0 ? url::PORT_UNSPECIFIED : source.port, // port |
(...skipping 30 matching lines...) Expand all Loading... |
46 for (const blink::WebString& endpoint : policy.reportEndpoints) | 47 for (const blink::WebString& endpoint : policy.reportEndpoints) |
47 report_endpoints.push_back(endpoint.utf8()); | 48 report_endpoints.push_back(endpoint.utf8()); |
48 | 49 |
49 return ContentSecurityPolicy(policy.disposition, // disposition | 50 return ContentSecurityPolicy(policy.disposition, // disposition |
50 policy.source, // source | 51 policy.source, // source |
51 directives, // directives | 52 directives, // directives |
52 report_endpoints, // report_endpoints | 53 report_endpoints, // report_endpoints |
53 policy.header.utf8()); // header | 54 policy.header.utf8()); // header |
54 } | 55 } |
55 | 56 |
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 | |
77 } // namespace content | 57 } // namespace content |
OLD | NEW |