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

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2761153003: PlzNavigate & CSP. Use the SourceLocation in violation reports. (Closed)
Patch Set: Transmit the source_location instead of the line number. Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 FrameLoader& frameloader = frame()->loader(); 2079 FrameLoader& frameloader = frame()->loader();
2080 DCHECK(frameloader.provisionalDocumentLoader()); 2080 DCHECK(frameloader.provisionalDocumentLoader());
2081 frameloader.loadFailed(frameloader.provisionalDocumentLoader(), error); 2081 frameloader.loadFailed(frameloader.provisionalDocumentLoader(), error);
2082 return true; 2082 return true;
2083 } 2083 }
2084 2084
2085 // Called when a navigation is blocked because a Content Security Policy (CSP) 2085 // Called when a navigation is blocked because a Content Security Policy (CSP)
2086 // is infringed. 2086 // is infringed.
2087 void WebLocalFrameImpl::reportContentSecurityPolicyViolation( 2087 void WebLocalFrameImpl::reportContentSecurityPolicyViolation(
2088 const blink::WebContentSecurityPolicyViolation& violation) { 2088 const blink::WebContentSecurityPolicyViolation& violation) {
2089 addMessageToConsole(blink::WebConsoleMessage(
2090 WebConsoleMessage::LevelError, violation.consoleMessage,
2091 violation.sourceLocation.url, violation.sourceLocation.lineNumber,
2092 violation.sourceLocation.columnNumber));
2093
2094 std::unique_ptr<SourceLocation> sourceLocation = SourceLocation::create(
2095 violation.sourceLocation.url, violation.sourceLocation.lineNumber,
2096 violation.sourceLocation.columnNumber, nullptr);
2097
2089 DCHECK(frame() && frame()->document()); 2098 DCHECK(frame() && frame()->document());
2090 Document* document = frame()->document(); 2099 Document* document = frame()->document();
2091 Vector<String> reportEndpoints; 2100 Vector<String> reportEndpoints;
2092 for (const WebString& endPoint : violation.reportEndpoints) 2101 for (const WebString& endPoint : violation.reportEndpoints)
2093 reportEndpoints.push_back(endPoint); 2102 reportEndpoints.push_back(endPoint);
2094 document->contentSecurityPolicy()->reportViolation( 2103 document->contentSecurityPolicy()->reportViolation(
2095 violation.directive, /* directiveText */ 2104 violation.directive, /* directiveText */
2096 ContentSecurityPolicy::getDirectiveType( 2105 ContentSecurityPolicy::getDirectiveType(
2097 violation.effectiveDirective), /* effectiveType */ 2106 violation.effectiveDirective), /* effectiveType */
2098 violation.consoleMessage, /* consoleMessage */ 2107 violation.consoleMessage, /* consoleMessage */
2099 violation.blockedUrl, /* blockedUrl */ 2108 violation.blockedUrl, /* blockedUrl */
2100 reportEndpoints, /* reportEndpoints */ 2109 reportEndpoints, /* reportEndpoints */
2101 violation.header, /* header */ 2110 violation.header, /* header */
2102 static_cast<ContentSecurityPolicyHeaderType>(violation.disposition), 2111 static_cast<ContentSecurityPolicyHeaderType>(violation.disposition),
2103 ContentSecurityPolicy::ViolationType::URLViolation, /* ViolationType */ 2112 ContentSecurityPolicy::ViolationType::URLViolation, /* ViolationType */
2104 nullptr, /* LocalFrame */ 2113 std::move(sourceLocation), nullptr, /* LocalFrame */
2105 violation.afterRedirect ? RedirectStatus::FollowedRedirect 2114 violation.afterRedirect ? RedirectStatus::FollowedRedirect
2106 : RedirectStatus::NoRedirect, 2115 : RedirectStatus::NoRedirect,
2107 // TODO(arthursonzogni, clamy) Provide the context line number here.
2108 // See http://crbug.com/690946
2109 0, /* contextLine */
2110 nullptr); /* Element */ 2116 nullptr); /* Element */
2111 } 2117 }
2112 2118
2113 bool WebLocalFrameImpl::isLoading() const { 2119 bool WebLocalFrameImpl::isLoading() const {
2114 if (!frame() || !frame()->document()) 2120 if (!frame() || !frame()->document())
2115 return false; 2121 return false;
2116 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() || 2122 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() ||
2117 frame()->loader().hasProvisionalNavigation() || 2123 frame()->loader().hasProvisionalNavigation() ||
2118 !frame()->document()->loadEventFinished(); 2124 !frame()->document()->loadEventFinished();
2119 } 2125 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 createMarkup(startPosition, endPosition, AnnotateForInterchange, 2509 createMarkup(startPosition, endPosition, AnnotateForInterchange,
2504 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2510 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2505 } else { 2511 } else {
2506 clipHtml = 2512 clipHtml =
2507 createMarkup(endPosition, startPosition, AnnotateForInterchange, 2513 createMarkup(endPosition, startPosition, AnnotateForInterchange,
2508 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2514 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2509 } 2515 }
2510 } 2516 }
2511 2517
2512 } // namespace blink 2518 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698