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

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2389753002: doc.write blocking intervention warning header (Closed)
Patch Set: Rebased till refs/heads/master@{#422406} Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
index 7fccf4bb176bb95e82ed23de68978db6595626f3..9fbdae7cff358fcab7f2f66bd4f841c713969196 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -107,9 +107,11 @@ bool isConnectionEffectively2G(WebEffectiveConnectionType effectiveType) {
return false;
}
-bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request,
- FetchRequest::DeferOption defer,
- Document& document) {
+bool shouldDisallowFetchForMainFrameScript(
+ const ResourceRequest& request,
+ FetchRequest::DeferOption defer,
+ Document& document,
+ std::pair<AtomicString, AtomicString>& customHeader) {
// Only scripts inserted via document.write are candidates for having their
// fetch disallowed.
if (!document.isInDocumentWrite())
@@ -151,6 +153,10 @@ bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request,
return false;
emitWarningForDocWriteScripts(request.url().getString(), document);
+ customHeader.first = "Intervention";
+ customHeader.second =
+ "<https://www.chromestatus.com/feature/5718547946799104>; "
+ "level=\"warning\"";
// Do not block scripts if it is a page reload. This is to enable pages to
// recover if blocking of a script is leading to a page break and the user
@@ -297,7 +303,8 @@ static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy(
WebCachePolicy FrameFetchContext::resourceRequestCachePolicy(
const ResourceRequest& request,
Resource::Type type,
- FetchRequest::DeferOption defer) const {
+ FetchRequest::DeferOption defer,
+ std::pair<AtomicString, AtomicString>& customHeader) const {
DCHECK(frame());
if (type == Resource::MainResource) {
FrameLoadType frameLoadType = frame()->loader().loadType();
@@ -330,7 +337,8 @@ WebCachePolicy FrameFetchContext::resourceRequestCachePolicy(
// the main frame on script loads inserted via document.write, since it can
// add significant delays before page content is displayed on the screen.
if (type == Resource::Script && isMainFrame() && m_document &&
- shouldDisallowFetchForMainFrameScript(request, defer, *m_document))
+ shouldDisallowFetchForMainFrameScript(request, defer, *m_document,
+ customHeader))
return WebCachePolicy::ReturnCacheDataDontLoad;
if (request.isConditional())

Powered by Google App Engine
This is Rietveld 408576698