Index: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
index fc1a846d6d6379fd01d8e89ad50fd1f2a924087c..8264c2fbb12df4a0ef35cd51151e22ba3aa5f902 100644 |
--- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
+++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
@@ -2246,4 +2246,52 @@ void WebLocalFrameImpl::usageCountChromeLoadTimes(const WebString& metric) |
UseCounter::count(frame(), feature); |
} |
+void WebLocalFrameImpl::reportContentSecurityPolicyViolation( |
+ const WebString& directiveText, |
+ const WebString& effectiveDirective, |
+ const WebString& consoleMessage, |
+ const WebURL& blockedURL, |
+ const WebVector<WebString>& reportEndpoints, |
+ const WebString& header, |
+ WebContentSecurityPolicyViolationType violationType, |
+ bool followedRedirect) |
+{ |
+ ContentSecurityPolicy* policy = m_frame->securityContext()->contentSecurityPolicy(); |
+ |
+ Vector<String> coreReportEndpoints; |
+ coreReportEndpoints.reserveInitialCapacity(reportEndpoints.size()); |
+ for (const WebString& reportEndpoint : reportEndpoints) { |
+ // |reportEndpoints| comes from another renderer process - restrict it |
+ // to endpoints actually covered by our Content Security Policy. |
+ if (policy->coversReportEndpoint(reportEndpoint)) |
+ coreReportEndpoints.append(reportEndpoint); |
+ } |
+ |
+ auto redirectStatus = followedRedirect |
+ ? ResourceRequest::RedirectStatus::FollowedRedirect |
+ : ResourceRequest::RedirectStatus::NoRedirect; |
+ |
+ // This method has no |contextLine| parameter, because source information |
+ // should not be disclosed cross-site and therefore caller of this method |
+ // (by design) does not have access to the line number associated with this |
+ // Content Security Policy violation. |
+ int contextLine = 0; |
+ |
+ policy->logToConsole(ConsoleMessage::create( |
+ SecurityMessageSource, |
+ ErrorMessageLevel, |
+ consoleMessage)); |
+ policy->reportViolation( |
+ directiveText, |
+ effectiveDirective, |
+ consoleMessage, |
+ blockedURL, |
+ coreReportEndpoints, |
+ header, |
+ static_cast<ContentSecurityPolicy::ViolationType>(violationType), |
+ nullptr, // contextFrame |
+ redirectStatus, |
+ contextLine); |
+} |
+ |
} // namespace blink |