| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (m_documentLoader->request().httpMethod() == "POST") { | 269 if (m_documentLoader->request().httpMethod() == "POST") { |
| 270 if (mainResourceCachePolicy == WebCachePolicy::ReturnCacheDataDontLo
ad) | 270 if (mainResourceCachePolicy == WebCachePolicy::ReturnCacheDataDontLo
ad) |
| 271 return WebCachePolicy::ReturnCacheDataElseLoad; | 271 return WebCachePolicy::ReturnCacheDataElseLoad; |
| 272 return WebCachePolicy::UseProtocolCachePolicy; | 272 return WebCachePolicy::UseProtocolCachePolicy; |
| 273 } | 273 } |
| 274 return memoryCachePolicyToResourceRequestCachePolicy(getCachePolicy()); | 274 return memoryCachePolicyToResourceRequestCachePolicy(getCachePolicy()); |
| 275 } | 275 } |
| 276 return WebCachePolicy::UseProtocolCachePolicy; | 276 return WebCachePolicy::UseProtocolCachePolicy; |
| 277 } | 277 } |
| 278 | 278 |
| 279 // FIXME(http://crbug.com/274173): | 279 // The |m_documentLoader| is null in the FrameFetchContext of an imported docume
nt. |
| 280 // |loader| can be null if the resource is loaded from imported document. | 280 // FIXME(http://crbug.com/274173): This means Inspector, which uses DocumentLoad
er |
| 281 // This means inspector, which uses DocumentLoader as an grouping entity, | 281 // as a grouping entity, cannot see imported documents. |
| 282 // cannot see imported documents. | 282 inline DocumentLoader* FrameFetchContext::masterDocumentLoader() const |
| 283 inline DocumentLoader* FrameFetchContext::ensureLoaderForNotifications() const | |
| 284 { | 283 { |
| 285 return m_documentLoader ? m_documentLoader.get() : frame()->loader().documen
tLoader(); | 284 return m_documentLoader ? m_documentLoader.get() : frame()->loader().documen
tLoader(); |
| 286 } | 285 } |
| 287 | 286 |
| 288 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) | 287 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi
er, ResourceLoadPriority loadPriority, int intraPriorityValue) |
| 289 { | 288 { |
| 290 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); | 289 frame()->loader().client()->dispatchDidChangeResourcePriority(identifier, lo
adPriority, intraPriorityValue); |
| 291 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceChangePriority", TRACE_EV
ENT_SCOPE_THREAD, "data", InspectorChangeResourcePriorityEvent::data(identifier,
loadPriority)); | 290 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceChangePriority", TRACE_EV
ENT_SCOPE_THREAD, "data", InspectorChangeResourcePriorityEvent::data(identifier,
loadPriority)); |
| 292 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, loa
dPriority); | 291 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, loa
dPriority); |
| 293 } | 292 } |
| 294 | 293 |
| 295 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) | 294 void FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, Resour
ceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiat
orInfo& initiatorInfo) |
| 296 { | 295 { |
| 297 frame()->loader().applyUserAgent(request); | 296 frame()->loader().applyUserAgent(request); |
| 298 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); | 297 frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identi
fier, request, redirectResponse); |
| 299 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ
est)); | 298 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT
_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ
est)); |
| 300 InspectorInstrumentation::willSendRequest(frame(), identifier, ensureLoaderF
orNotifications(), request, redirectResponse, initiatorInfo); | 299 InspectorInstrumentation::willSendRequest(frame(), identifier, masterDocumen
tLoader(), request, redirectResponse, initiatorInfo); |
| 301 } | 300 } |
| 302 | 301 |
| 303 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con
st ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest
::RequestContext requestContext, Resource* resource) | 302 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con
st ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest
::RequestContext requestContext, Resource* resource) |
| 304 { | 303 { |
| 305 LinkLoader::CanLoadResources resourceLoadingPolicy = LinkLoader::LoadResourc
esAndPreconnect; | 304 LinkLoader::CanLoadResources resourceLoadingPolicy = LinkLoader::LoadResourc
esAndPreconnect; |
| 306 MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddre
ss()); | 305 MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddre
ss()); |
| 307 if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { | 306 if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { |
| 308 ResourceFetcher* fetcher = nullptr; | 307 ResourceFetcher* fetcher = nullptr; |
| 309 if (frame()->document()) | 308 if (frame()->document()) |
| 310 fetcher = frame()->document()->fetcher(); | 309 fetcher = frame()->document()->fetcher(); |
| 311 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe
ader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); | 310 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe
ader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); |
| 312 // When response is received with a provisional docloader, the resource
haven't committed yet, and we cannot load resources, only preconnect. | 311 // When response is received with a provisional docloader, the resource
haven't committed yet, and we cannot load resources, only preconnect. |
| 313 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; | 312 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; |
| 314 } | 313 } |
| 315 LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), r
esponse.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoading
Policy, nullptr); | 314 LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), r
esponse.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoading
Policy, nullptr); |
| 316 | 315 |
| 317 if (response.hasMajorCertificateErrors()) | 316 if (response.hasMajorCertificateErrors()) |
| 318 MixedContentChecker::handleCertificateError(frame(), response, frameType
, requestContext); | 317 MixedContentChecker::handleCertificateError(frame(), response, frameType
, requestContext); |
| 319 | 318 |
| 320 frame()->loader().progress().incrementProgress(identifier, response); | 319 frame()->loader().progress().incrementProgress(identifier, response); |
| 321 frame()->loader().client()->dispatchDidReceiveResponse(m_documentLoader, ide
ntifier, response); | 320 frame()->loader().client()->dispatchDidReceiveResponse(m_documentLoader, ide
ntifier, response); |
| 322 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_E
VENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame
(), response)); | 321 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_E
VENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame
(), response)); |
| 323 DocumentLoader* documentLoader = ensureLoaderForNotifications(); | 322 DocumentLoader* documentLoader = masterDocumentLoader(); |
| 324 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do
cumentLoader, response, resource); | 323 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do
cumentLoader, response, resource); |
| 325 // It is essential that inspector gets resource response BEFORE console. | 324 // It is essential that inspector gets resource response BEFORE console. |
| 326 frame()->console().reportResourceResponseReceived(documentLoader, identifier
, response); | 325 frame()->console().reportResourceResponseReceived(documentLoader, identifier
, response); |
| 327 } | 326 } |
| 328 | 327 |
| 329 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, const c
har* data, int dataLength, int encodedDataLength) | 328 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, const c
har* data, int dataLength, int encodedDataLength) |
| 330 { | 329 { |
| 331 frame()->loader().progress().incrementProgress(identifier, dataLength); | 330 frame()->loader().progress().incrementProgress(identifier, dataLength); |
| 332 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN
T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc
odedDataLength)); | 331 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN
T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc
odedDataLength)); |
| 333 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng
th, encodedDataLength); | 332 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng
th, encodedDataLength); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 message = "Unsafe attempt to load URL " + url.elidedString() + " from fr
ame with URL " + m_document->url().elidedString() + ". Domains, protocols and po
rts must match.\n"; | 441 message = "Unsafe attempt to load URL " + url.elidedString() + " from fr
ame with URL " + m_document->url().elidedString() + ". Domains, protocols and po
rts must match.\n"; |
| 443 | 442 |
| 444 frame()->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessag
eSource, ErrorMessageLevel, message)); | 443 frame()->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessag
eSource, ErrorMessageLevel, message)); |
| 445 } | 444 } |
| 446 | 445 |
| 447 bool FrameFetchContext::canRequest(Resource::Type type, const ResourceRequest& r
esourceRequest, const KURL& url, const ResourceLoaderOptions& options, bool forP
reload, FetchRequest::OriginRestriction originRestriction) const | 446 bool FrameFetchContext::canRequest(Resource::Type type, const ResourceRequest& r
esourceRequest, const KURL& url, const ResourceLoaderOptions& options, bool forP
reload, FetchRequest::OriginRestriction originRestriction) const |
| 448 { | 447 { |
| 449 ResourceRequestBlockedReason reason = canRequestInternal(type, resourceReque
st, url, options, forPreload, originRestriction, resourceRequest.redirectStatus(
)); | 448 ResourceRequestBlockedReason reason = canRequestInternal(type, resourceReque
st, url, options, forPreload, originRestriction, resourceRequest.redirectStatus(
)); |
| 450 if (reason != ResourceRequestBlockedReasonNone) { | 449 if (reason != ResourceRequestBlockedReasonNone) { |
| 451 if (!forPreload) | 450 if (!forPreload) |
| 452 InspectorInstrumentation::didBlockRequest(frame(), resourceRequest,
ensureLoaderForNotifications(), options.initiatorInfo, reason); | 451 InspectorInstrumentation::didBlockRequest(frame(), resourceRequest,
masterDocumentLoader(), options.initiatorInfo, reason); |
| 453 return false; | 452 return false; |
| 454 } | 453 } |
| 455 return true; | 454 return true; |
| 456 } | 455 } |
| 457 | 456 |
| 458 bool FrameFetchContext::allowResponse(Resource::Type type, const ResourceRequest
& resourceRequest, const KURL& url, const ResourceLoaderOptions& options) const | 457 bool FrameFetchContext::allowResponse(Resource::Type type, const ResourceRequest
& resourceRequest, const KURL& url, const ResourceLoaderOptions& options) const |
| 459 { | 458 { |
| 460 ResourceRequestBlockedReason reason = canRequestInternal(type, resourceReque
st, url, options, false, FetchRequest::UseDefaultOriginRestrictionForType, Redir
ectStatus::FollowedRedirect); | 459 ResourceRequestBlockedReason reason = canRequestInternal(type, resourceReque
st, url, options, false, FetchRequest::UseDefaultOriginRestrictionForType, Redir
ectStatus::FollowedRedirect); |
| 461 if (reason != ResourceRequestBlockedReasonNone) { | 460 if (reason != ResourceRequestBlockedReasonNone) { |
| 462 InspectorInstrumentation::didBlockRequest(frame(), resourceRequest, ensu
reLoaderForNotifications(), options.initiatorInfo, reason); | 461 InspectorInstrumentation::didBlockRequest(frame(), resourceRequest, mast
erDocumentLoader(), options.initiatorInfo, reason); |
| 463 return false; | 462 return false; |
| 464 } | 463 } |
| 465 return true; | 464 return true; |
| 466 } | 465 } |
| 467 | 466 |
| 468 ResourceRequestBlockedReason FrameFetchContext::canRequestInternal(Resource::Typ
e type, const ResourceRequest& resourceRequest, const KURL& url, const ResourceL
oaderOptions& options, bool forPreload, FetchRequest::OriginRestriction originRe
striction, ResourceRequest::RedirectStatus redirectStatus) const | 467 ResourceRequestBlockedReason FrameFetchContext::canRequestInternal(Resource::Typ
e type, const ResourceRequest& resourceRequest, const KURL& url, const ResourceL
oaderOptions& options, bool forPreload, FetchRequest::OriginRestriction originRe
striction, ResourceRequest::RedirectStatus redirectStatus) const |
| 469 { | 468 { |
| 470 if (InspectorInstrumentation::shouldBlockRequest(frame(), resourceRequest)) | 469 if (InspectorInstrumentation::shouldBlockRequest(frame(), resourceRequest)) |
| 471 return ResourceRequestBlockedReasonInspector; | 470 return ResourceRequestBlockedReasonInspector; |
| 472 | 471 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 } | 812 } |
| 814 | 813 |
| 815 DEFINE_TRACE(FrameFetchContext) | 814 DEFINE_TRACE(FrameFetchContext) |
| 816 { | 815 { |
| 817 visitor->trace(m_document); | 816 visitor->trace(m_document); |
| 818 visitor->trace(m_documentLoader); | 817 visitor->trace(m_documentLoader); |
| 819 FetchContext::trace(visitor); | 818 FetchContext::trace(visitor); |
| 820 } | 819 } |
| 821 | 820 |
| 822 } // namespace blink | 821 } // namespace blink |
| OLD | NEW |