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

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

Issue 1849223002: Blocking synchronous and third party doc.written scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 f040553594f41cd97ae0e4d1ae27be96348e4b53..1c959a95eba230fd6a69988527f5b1223f6fde9a 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -56,6 +56,7 @@
#include "core/loader/PingLoader.h"
#include "core/loader/ProgressTracker.h"
#include "core/loader/appcache/ApplicationCacheHost.h"
+#include "core/page/NetworkStateNotifier.h"
jkarlin 2016/04/01 15:23:36 This isn't used yet.
#include "core/page/Page.h"
#include "core/svg/graphics/SVGImageChromeClient.h"
#include "core/timing/DOMWindowPerformance.h"
@@ -173,7 +174,7 @@ static ResourceRequestCachePolicy memoryCachePolicyToResourceRequestCachePolicy(
return UseProtocolCachePolicy;
}
-ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const ResourceRequest& request, Resource::Type type) const
+ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const ResourceRequest& request, Resource::Type type, FetchRequest::DeferOption defer) const
{
ASSERT(frame());
if (type == Resource::MainResource) {
@@ -208,10 +209,14 @@ ResourceRequestCachePolicy FrameFetchContext::resourceRequestCachePolicy(const R
// future, we'll extend this logic to only block if estimated network RTT
// is above some threshold.
if (type == Resource::Script && isMainFrame()) {
- const bool isInDocumentWrite = m_document && m_document->isInDocumentWrite();
const bool disallowFetchForDocWriteScripts = frame()->settings() && frame()->settings()->disallowFetchForDocWrittenScriptsInMainFrame();
- if (isInDocumentWrite && disallowFetchForDocWriteScripts)
- return ReturnCacheDataDontLoad;
+ const bool isInDocumentWrite = m_document && m_document->isInDocumentWrite();
jkarlin 2016/04/01 15:23:36 Please also restrict to 2G connection type in this
shivanisha 2016/04/01 16:15:13 Ok. Will update
+ if (isInDocumentWrite && disallowFetchForDocWriteScripts) {
+ const bool isSync = (defer == FetchRequest::NoDefer);
jkarlin 2016/04/01 15:23:36 no need for parens
shivanisha 2016/04/01 16:15:13 will remove parens
+ const bool isThirdParty = (request.url().host() != m_document->getSecurityOrigin()->domain());
jkarlin 2016/04/01 15:23:36 no need for parens
shivanisha 2016/04/01 16:15:13 will remove parens
+ if (isSync && isThirdParty)
+ return ReturnCacheDataDontLoad;
+ }
}
if (request.isConditional())

Powered by Google App Engine
This is Rietveld 408576698