| 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 93725dc7081a5f72a128d1e95155e97cef7e3f11..17fc24d3db3ad742528fd44ce22159bcb56d7bf5 100644
|
| --- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
|
| +++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
|
| @@ -89,6 +89,22 @@ void emitWarningForDocWriteScripts(const String& url, Document& document)
|
| WTFLogAlways("%s", message.utf8().data());
|
| }
|
|
|
| +bool isConnectionEffectively2G(WebEffectiveConnectionType effectiveType)
|
| +{
|
| + switch (effectiveType) {
|
| + case WebEffectiveConnectionType::TypeSlow2G:
|
| + case WebEffectiveConnectionType::Type2G:
|
| + return true;
|
| + case WebEffectiveConnectionType::Type3G:
|
| + case WebEffectiveConnectionType::Type4G:
|
| + case WebEffectiveConnectionType::TypeUnknown:
|
| + case WebEffectiveConnectionType::TypeOffline:
|
| + return false;
|
| + }
|
| + NOTREACHED();
|
| + return false;
|
| +}
|
| +
|
| bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, FetchRequest::DeferOption defer, Document& document)
|
| {
|
| // Only scripts inserted via document.write are candidates for having their
|
| @@ -146,10 +162,11 @@ bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch
|
| // the flag will be conveyed to the browser process only once.
|
| document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoadingBehaviorDocumentWriteBlock);
|
|
|
| - const bool isSlowConnection = networkStateNotifier().connectionType() == WebConnectionTypeCellular2G;
|
| - const bool disallowFetch = document.settings()->disallowFetchForDocWrittenScriptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections() && isSlowConnection);
|
| + const bool is2G = networkStateNotifier().connectionType() == WebConnectionTypeCellular2G;
|
| + WebEffectiveConnectionType effectiveConnection = document.frame()->loader().client()->getEffectiveConnectionType();
|
| + const bool is2GOrLike2G = is2G || isConnectionEffectively2G(effectiveConnection);
|
|
|
| - return disallowFetch;
|
| + return document.settings()->disallowFetchForDocWrittenScriptsInMainFrame() || (document.settings()->disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections() && is2G) || (RuntimeEnabledFeatures::blockDocWriteIfEffectively2GEnabled() && is2GOrLike2G);
|
| }
|
|
|
| } // namespace
|
|
|