| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 document.loader()->didObserveLoadingBehavior( | 181 document.loader()->didObserveLoadingBehavior( |
| 182 WebLoadingBehaviorFlag::WebLoadingBehaviorDocumentWriteBlock); | 182 WebLoadingBehaviorFlag::WebLoadingBehaviorDocumentWriteBlock); |
| 183 | 183 |
| 184 const bool is2G = | 184 const bool is2G = |
| 185 networkStateNotifier().connectionType() == WebConnectionTypeCellular2G; | 185 networkStateNotifier().connectionType() == WebConnectionTypeCellular2G; |
| 186 WebEffectiveConnectionType effectiveConnection = | 186 WebEffectiveConnectionType effectiveConnection = |
| 187 document.frame()->loader().client()->getEffectiveConnectionType(); | 187 document.frame()->loader().client()->getEffectiveConnectionType(); |
| 188 const bool is2GOrLike2G = | 188 const bool is2GOrLike2G = |
| 189 is2G || isConnectionEffectively2G(effectiveConnection); | 189 is2G || isConnectionEffectively2G(effectiveConnection); |
| 190 | 190 |
| 191 return document.settings()->disallowFetchForDocWrittenScriptsInMainFrame() || | 191 return document.settings() |
| 192 ->getDisallowFetchForDocWrittenScriptsInMainFrame() || |
| 192 (document.settings() | 193 (document.settings() |
| 193 ->disallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections()
&& | 194 ->getDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections
() && |
| 194 is2G) || | 195 is2G) || |
| 195 (document.settings() | 196 (document.settings() |
| 196 ->disallowFetchForDocWrittenScriptsInMainFrameIfEffectively2G() && | 197 ->getDisallowFetchForDocWrittenScriptsInMainFrameIfEffectively2G()
&& |
| 197 is2GOrLike2G); | 198 is2GOrLike2G); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace | 201 } // namespace |
| 201 | 202 |
| 202 FrameFetchContext::FrameFetchContext(DocumentLoader* loader, Document* document) | 203 FrameFetchContext::FrameFetchContext(DocumentLoader* loader, Document* document) |
| 203 : m_document(document), m_documentLoader(loader) { | 204 : m_document(document), m_documentLoader(loader) { |
| 204 DCHECK(frame()); | 205 DCHECK(frame()); |
| 205 } | 206 } |
| 206 | 207 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 m_document->addressSpace()); | 253 m_document->addressSpace()); |
| 253 } | 254 } |
| 254 | 255 |
| 255 // The remaining modifications are only necessary for HTTP and HTTPS. | 256 // The remaining modifications are only necessary for HTTP and HTTPS. |
| 256 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) | 257 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) |
| 257 return; | 258 return; |
| 258 | 259 |
| 259 if (frame()->loader().loadType() == FrameLoadTypeReload) | 260 if (frame()->loader().loadType() == FrameLoadTypeReload) |
| 260 request.clearHTTPHeaderField("Save-Data"); | 261 request.clearHTTPHeaderField("Save-Data"); |
| 261 | 262 |
| 262 if (frame()->settings() && frame()->settings()->dataSaverEnabled()) | 263 if (frame()->settings() && frame()->settings()->getDataSaverEnabled()) |
| 263 request.setHTTPHeaderField("Save-Data", "on"); | 264 request.setHTTPHeaderField("Save-Data", "on"); |
| 264 } | 265 } |
| 265 | 266 |
| 266 CachePolicy FrameFetchContext::getCachePolicy() const { | 267 CachePolicy FrameFetchContext::getCachePolicy() const { |
| 267 if (m_document && m_document->loadEventFinished()) | 268 if (m_document && m_document->loadEventFinished()) |
| 268 return CachePolicyVerify; | 269 return CachePolicyVerify; |
| 269 | 270 |
| 270 FrameLoadType loadType = frame()->loader().loadType(); | 271 FrameLoadType loadType = frame()->loader().loadType(); |
| 271 if (loadType == FrameLoadTypeReloadBypassingCache) | 272 if (loadType == FrameLoadTypeReloadBypassingCache) |
| 272 return CachePolicyReload; | 273 return CachePolicyReload; |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 !m_document->contentSecurityPolicy()->allowRequest( | 725 !m_document->contentSecurityPolicy()->allowRequest( |
| 725 resourceRequest.requestContext(), url, | 726 resourceRequest.requestContext(), url, |
| 726 options.contentSecurityPolicyNonce, options.integrityMetadata, | 727 options.contentSecurityPolicyNonce, options.integrityMetadata, |
| 727 options.parserDisposition, redirectStatus, cspReporting)) | 728 options.parserDisposition, redirectStatus, cspReporting)) |
| 728 return ResourceRequestBlockedReason::CSP; | 729 return ResourceRequestBlockedReason::CSP; |
| 729 } | 730 } |
| 730 | 731 |
| 731 if (type == Resource::Script || type == Resource::ImportResource) { | 732 if (type == Resource::Script || type == Resource::ImportResource) { |
| 732 DCHECK(frame()); | 733 DCHECK(frame()); |
| 733 if (!frame()->loader().client()->allowScriptFromSource( | 734 if (!frame()->loader().client()->allowScriptFromSource( |
| 734 !frame()->settings() || frame()->settings()->scriptEnabled(), | 735 !frame()->settings() || frame()->settings()->getScriptEnabled(), |
| 735 url)) { | 736 url)) { |
| 736 frame()->loader().client()->didNotAllowScript(); | 737 frame()->loader().client()->didNotAllowScript(); |
| 737 // TODO(estark): Use a different ResourceRequestBlockedReason here, since | 738 // TODO(estark): Use a different ResourceRequestBlockedReason here, since |
| 738 // this check has nothing to do with CSP. https://crbug.com/600795 | 739 // this check has nothing to do with CSP. https://crbug.com/600795 |
| 739 return ResourceRequestBlockedReason::CSP; | 740 return ResourceRequestBlockedReason::CSP; |
| 740 } | 741 } |
| 741 } else if (type == Resource::Media || type == Resource::TextTrack) { | 742 } else if (type == Resource::Media || type == Resource::TextTrack) { |
| 742 DCHECK(frame()); | 743 DCHECK(frame()); |
| 743 if (!frame()->loader().client()->allowMedia(url)) | 744 if (!frame()->loader().client()->allowMedia(url)) |
| 744 return ResourceRequestBlockedReason::Other; | 745 return ResourceRequestBlockedReason::Other; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 ->archive(); | 980 ->archive(); |
| 980 } | 981 } |
| 981 | 982 |
| 982 ResourceLoadPriority FrameFetchContext::modifyPriorityForExperiments( | 983 ResourceLoadPriority FrameFetchContext::modifyPriorityForExperiments( |
| 983 ResourceLoadPriority priority) { | 984 ResourceLoadPriority priority) { |
| 984 // If Settings is null, we can't verify any experiments are in force. | 985 // If Settings is null, we can't verify any experiments are in force. |
| 985 if (!frame()->settings()) | 986 if (!frame()->settings()) |
| 986 return priority; | 987 return priority; |
| 987 | 988 |
| 988 // If enabled, drop the priority of all resources in a subframe. | 989 // If enabled, drop the priority of all resources in a subframe. |
| 989 if (frame()->settings()->lowPriorityIframes() && !frame()->isMainFrame()) | 990 if (frame()->settings()->getLowPriorityIframes() && !frame()->isMainFrame()) |
| 990 return ResourceLoadPriorityVeryLow; | 991 return ResourceLoadPriorityVeryLow; |
| 991 | 992 |
| 992 return priority; | 993 return priority; |
| 993 } | 994 } |
| 994 | 995 |
| 995 WebTaskRunner* FrameFetchContext::loadingTaskRunner() const { | 996 WebTaskRunner* FrameFetchContext::loadingTaskRunner() const { |
| 996 return frame()->frameScheduler()->loadingTaskRunner(); | 997 return frame()->frameScheduler()->loadingTaskRunner(); |
| 997 } | 998 } |
| 998 | 999 |
| 999 void FrameFetchContext::dispatchDidReceiveResponseInternal( | 1000 void FrameFetchContext::dispatchDidReceiveResponseInternal( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 response); | 1040 response); |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 DEFINE_TRACE(FrameFetchContext) { | 1043 DEFINE_TRACE(FrameFetchContext) { |
| 1043 visitor->trace(m_document); | 1044 visitor->trace(m_document); |
| 1044 visitor->trace(m_documentLoader); | 1045 visitor->trace(m_documentLoader); |
| 1045 FetchContext::trace(visitor); | 1046 FetchContext::trace(visitor); |
| 1046 } | 1047 } |
| 1047 | 1048 |
| 1048 } // namespace blink | 1049 } // namespace blink |
| OLD | NEW |