Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: content/renderer/content_security_policy_util.cc

Issue 2655463006: PlzNavigate: Enforce 'frame-src' CSP on the browser. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/content_security_policy_util.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « content/renderer/content_security_policy_util.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698