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

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

Issue 2761153003: PlzNavigate & CSP. Use the SourceLocation in violation reports. (Closed)
Patch Set: Nit. 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
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 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 FrameLoader& frameloader = frame()->loader(); 2092 FrameLoader& frameloader = frame()->loader();
2093 DCHECK(frameloader.provisionalDocumentLoader()); 2093 DCHECK(frameloader.provisionalDocumentLoader());
2094 frameloader.loadFailed(frameloader.provisionalDocumentLoader(), error); 2094 frameloader.loadFailed(frameloader.provisionalDocumentLoader(), error);
2095 return true; 2095 return true;
2096 } 2096 }
2097 2097
2098 // Called when a navigation is blocked because a Content Security Policy (CSP) 2098 // Called when a navigation is blocked because a Content Security Policy (CSP)
2099 // is infringed. 2099 // is infringed.
2100 void WebLocalFrameImpl::reportContentSecurityPolicyViolation( 2100 void WebLocalFrameImpl::reportContentSecurityPolicyViolation(
2101 const blink::WebContentSecurityPolicyViolation& violation) { 2101 const blink::WebContentSecurityPolicyViolation& violation) {
2102 addMessageToConsole(blink::WebConsoleMessage(
2103 WebConsoleMessage::LevelError, violation.consoleMessage,
2104 violation.sourceLocation.url, violation.sourceLocation.lineNumber,
2105 violation.sourceLocation.columnNumber));
2106
2102 DCHECK(frame() && frame()->document()); 2107 DCHECK(frame() && frame()->document());
2103 Document* document = frame()->document(); 2108 Document* document = frame()->document();
2104 Vector<String> reportEndpoints; 2109 Vector<String> reportEndpoints;
2105 for (const WebString& endPoint : violation.reportEndpoints) 2110 for (const WebString& endPoint : violation.reportEndpoints)
2106 reportEndpoints.push_back(endPoint); 2111 reportEndpoints.push_back(endPoint);
2107 document->contentSecurityPolicy()->reportViolation( 2112 document->contentSecurityPolicy()->reportViolation(
2108 violation.directive, /* directiveText */ 2113 violation.directive, /* directiveText */
2109 ContentSecurityPolicy::getDirectiveType( 2114 ContentSecurityPolicy::getDirectiveType(
2110 violation.effectiveDirective), /* effectiveType */ 2115 violation.effectiveDirective), /* effectiveType */
2111 violation.consoleMessage, /* consoleMessage */ 2116 violation.consoleMessage, /* consoleMessage */
2112 violation.blockedUrl, /* blockedUrl */ 2117 violation.blockedUrl, /* blockedUrl */
2113 reportEndpoints, /* reportEndpoints */ 2118 reportEndpoints, /* reportEndpoints */
2114 violation.header, /* header */ 2119 violation.header, /* header */
2115 static_cast<ContentSecurityPolicyHeaderType>(violation.disposition), 2120 static_cast<ContentSecurityPolicyHeaderType>(violation.disposition),
2116 ContentSecurityPolicy::ViolationType::URLViolation, /* ViolationType */ 2121 ContentSecurityPolicy::ViolationType::URLViolation, /* ViolationType */
2117 nullptr, /* LocalFrame */ 2122 nullptr, /* LocalFrame */
2118 violation.afterRedirect ? RedirectStatus::FollowedRedirect 2123 violation.afterRedirect ? RedirectStatus::FollowedRedirect
2119 : RedirectStatus::NoRedirect, 2124 : RedirectStatus::NoRedirect,
2120 // TODO(arthursonzogni, clamy) Provide the context line number here. 2125 violation.sourceLocation.lineNumber, /* contextLine */
2121 // See http://crbug.com/690946 2126 nullptr); /* Element */
2122 0, /* contextLine */
2123 nullptr); /* Element */
2124 } 2127 }
2125 2128
2126 bool WebLocalFrameImpl::isLoading() const { 2129 bool WebLocalFrameImpl::isLoading() const {
2127 if (!frame() || !frame()->document()) 2130 if (!frame() || !frame()->document())
2128 return false; 2131 return false;
2129 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() || 2132 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument() ||
2130 frame()->loader().hasProvisionalNavigation() || 2133 frame()->loader().hasProvisionalNavigation() ||
2131 !frame()->document()->loadEventFinished(); 2134 !frame()->document()->loadEventFinished();
2132 } 2135 }
2133 2136
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 createMarkup(startPosition, endPosition, AnnotateForInterchange, 2519 createMarkup(startPosition, endPosition, AnnotateForInterchange,
2517 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2520 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2518 } else { 2521 } else {
2519 clipHtml = 2522 clipHtml =
2520 createMarkup(endPosition, startPosition, AnnotateForInterchange, 2523 createMarkup(endPosition, startPosition, AnnotateForInterchange,
2521 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 2524 ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs);
2522 } 2525 }
2523 } 2526 }
2524 2527
2525 } // namespace blink 2528 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698