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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2415373002: Loading: bulk style errors fix in core/loader (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 request.url(), 227 request.url(),
228 request.httpReferrer()) 228 request.httpReferrer())
229 .referrer, 229 .referrer,
230 request.httpReferrer()); 230 request.httpReferrer());
231 outgoingOrigin = SecurityOrigin::createFromString(request.httpReferrer()); 231 outgoingOrigin = SecurityOrigin::createFromString(request.httpReferrer());
232 } 232 }
233 233
234 request.addHTTPOriginIfNeeded(outgoingOrigin.get()); 234 request.addHTTPOriginIfNeeded(outgoingOrigin.get());
235 } 235 }
236 236
237 if (m_document) 237 if (m_document) {
238 request.setExternalRequestStateFromRequestorAddressSpace( 238 request.setExternalRequestStateFromRequestorAddressSpace(
239 m_document->addressSpace()); 239 m_document->addressSpace());
240 }
240 241
241 // The remaining modifications are only necessary for HTTP and HTTPS. 242 // The remaining modifications are only necessary for HTTP and HTTPS.
242 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) 243 if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily())
243 return; 244 return;
244 245
245 if (frame()->loader().loadType() == FrameLoadTypeReload) 246 if (frame()->loader().loadType() == FrameLoadTypeReload)
246 request.clearHTTPHeaderField("Save-Data"); 247 request.clearHTTPHeaderField("Save-Data");
247 248
248 if (frame()->settings() && frame()->settings()->dataSaverEnabled()) 249 if (frame()->settings() && frame()->settings()->dataSaverEnabled())
249 request.setHTTPHeaderField("Save-Data", "on"); 250 request.setHTTPHeaderField("Save-Data", "on");
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 382 }
382 383
383 void FrameFetchContext::dispatchWillSendRequest( 384 void FrameFetchContext::dispatchWillSendRequest(
384 unsigned long identifier, 385 unsigned long identifier,
385 ResourceRequest& request, 386 ResourceRequest& request,
386 const ResourceResponse& redirectResponse, 387 const ResourceResponse& redirectResponse,
387 const FetchInitiatorInfo& initiatorInfo) { 388 const FetchInitiatorInfo& initiatorInfo) {
388 // For initial requests, prepareRequest() is called in 389 // For initial requests, prepareRequest() is called in
389 // willStartLoadingResource(), before revalidation policy is determined. That 390 // willStartLoadingResource(), before revalidation policy is determined. That
390 // call doesn't exist for redirects, so call preareRequest() here. 391 // call doesn't exist for redirects, so call preareRequest() here.
391 if (!redirectResponse.isNull()) 392 if (!redirectResponse.isNull()) {
392 prepareRequest(request); 393 prepareRequest(request);
393 else 394 } else {
394 frame()->loader().progress().willStartLoading(identifier, 395 frame()->loader().progress().willStartLoading(identifier,
395 request.priority()); 396 request.priority());
397 }
396 TRACE_EVENT_INSTANT1( 398 TRACE_EVENT_INSTANT1(
397 "devtools.timeline", "ResourceSendRequest", TRACE_EVENT_SCOPE_THREAD, 399 "devtools.timeline", "ResourceSendRequest", TRACE_EVENT_SCOPE_THREAD,
398 "data", InspectorSendRequestEvent::data(identifier, frame(), request)); 400 "data", InspectorSendRequestEvent::data(identifier, frame(), request));
399 InspectorInstrumentation::willSendRequest(frame(), identifier, 401 InspectorInstrumentation::willSendRequest(frame(), identifier,
400 masterDocumentLoader(), request, 402 masterDocumentLoader(), request,
401 redirectResponse, initiatorInfo); 403 redirectResponse, initiatorInfo);
402 if (frame()->frameScheduler()) 404 if (frame()->frameScheduler())
403 frame()->frameScheduler()->didStartLoading(identifier); 405 frame()->frameScheduler()->didStartLoading(identifier);
404 } 406 }
405 407
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 Resource* resource, 475 Resource* resource,
474 WebURLRequest::FrameType frameType, 476 WebURLRequest::FrameType frameType,
475 WebURLRequest::RequestContext requestContext) { 477 WebURLRequest::RequestContext requestContext) {
476 ResourceRequest request(resource->url()); 478 ResourceRequest request(resource->url());
477 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache( 479 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(
478 request, resource->response()); 480 request, resource->response());
479 dispatchWillSendRequest(identifier, request, ResourceResponse(), 481 dispatchWillSendRequest(identifier, request, ResourceResponse(),
480 resource->options().initiatorInfo); 482 resource->options().initiatorInfo);
481 483
482 InspectorInstrumentation::markResourceAsCached(frame(), identifier); 484 InspectorInstrumentation::markResourceAsCached(frame(), identifier);
483 if (!resource->response().isNull()) 485 if (!resource->response().isNull()) {
484 dispatchDidReceiveResponseInternal(identifier, resource->response(), 486 dispatchDidReceiveResponseInternal(identifier, resource->response(),
485 frameType, requestContext, resource, 487 frameType, requestContext, resource,
486 LinkLoader::DoNotLoadResources); 488 LinkLoader::DoNotLoadResources);
489 }
487 490
488 if (resource->encodedSize() > 0) 491 if (resource->encodedSize() > 0)
489 dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0); 492 dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0);
490 493
491 dispatchDidFinishLoading(identifier, 0, 0); 494 dispatchDidFinishLoading(identifier, 0, 0);
492 } 495 }
493 496
494 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { 497 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const {
495 if (!m_documentLoader) 498 if (!m_documentLoader)
496 return true; 499 return true;
(...skipping 17 matching lines...) Expand all
514 ResourceRequest& request, 517 ResourceRequest& request,
515 Resource::Type type) { 518 Resource::Type type) {
516 TRACE_EVENT_ASYNC_BEGIN1( 519 TRACE_EVENT_ASYNC_BEGIN1(
517 "blink.net", "Resource", identifier, "data", 520 "blink.net", "Resource", identifier, "data",
518 loadResourceTraceData(identifier, request.url(), request.priority())); 521 loadResourceTraceData(identifier, request.url(), request.priority()));
519 prepareRequest(request); 522 prepareRequest(request);
520 523
521 if (!m_documentLoader || m_documentLoader->fetcher()->archive() || 524 if (!m_documentLoader || m_documentLoader->fetcher()->archive() ||
522 !request.url().isValid()) 525 !request.url().isValid())
523 return; 526 return;
524 if (type == Resource::MainResource) 527 if (type == Resource::MainResource) {
525 m_documentLoader->applicationCacheHost()->willStartLoadingMainResource( 528 m_documentLoader->applicationCacheHost()->willStartLoadingMainResource(
526 request); 529 request);
527 else 530 } else {
528 m_documentLoader->applicationCacheHost()->willStartLoadingResource(request); 531 m_documentLoader->applicationCacheHost()->willStartLoadingResource(request);
532 }
529 } 533 }
530 534
531 void FrameFetchContext::didLoadResource(Resource* resource) { 535 void FrameFetchContext::didLoadResource(Resource* resource) {
532 if (resource->isLoadEventBlockingResourceType()) 536 if (resource->isLoadEventBlockingResourceType())
533 frame()->loader().checkCompleted(); 537 frame()->loader().checkCompleted();
534 if (m_document) 538 if (m_document)
535 FirstMeaningfulPaintDetector::from(*m_document).checkNetworkStable(); 539 FirstMeaningfulPaintDetector::from(*m_document).checkNetworkStable();
536 } 540 }
537 541
538 void FrameFetchContext::addResourceTiming(const ResourceTimingInfo& info) { 542 void FrameFetchContext::addResourceTiming(const ResourceTimingInfo& info) {
539 Document* initiatorDocument = m_document && info.isMainResource() 543 Document* initiatorDocument = m_document && info.isMainResource()
540 ? m_document->parentDocument() 544 ? m_document->parentDocument()
541 : m_document.get(); 545 : m_document.get();
542 if (!initiatorDocument || !initiatorDocument->domWindow()) 546 if (!initiatorDocument || !initiatorDocument->domWindow())
543 return; 547 return;
544 DOMWindowPerformance::performance(*initiatorDocument->domWindow()) 548 DOMWindowPerformance::performance(*initiatorDocument->domWindow())
545 ->addResourceTiming(info); 549 ->addResourceTiming(info);
546 } 550 }
547 551
548 bool FrameFetchContext::allowImage(bool imagesEnabled, const KURL& url) const { 552 bool FrameFetchContext::allowImage(bool imagesEnabled, const KURL& url) const {
549 return frame()->loader().client()->allowImage(imagesEnabled, url); 553 return frame()->loader().client()->allowImage(imagesEnabled, url);
550 } 554 }
551 555
552 void FrameFetchContext::printAccessDeniedMessage(const KURL& url) const { 556 void FrameFetchContext::printAccessDeniedMessage(const KURL& url) const {
553 if (url.isNull()) 557 if (url.isNull())
554 return; 558 return;
555 559
556 String message; 560 String message;
557 if (!m_document || m_document->url().isNull()) 561 if (!m_document || m_document->url().isNull()) {
558 message = "Unsafe attempt to load URL " + url.elidedString() + '.'; 562 message = "Unsafe attempt to load URL " + url.elidedString() + '.';
559 else if (url.isLocalFile() || m_document->url().isLocalFile()) 563 } else if (url.isLocalFile() || m_document->url().isLocalFile()) {
560 message = "Unsafe attempt to load URL " + url.elidedString() + 564 message = "Unsafe attempt to load URL " + url.elidedString() +
561 " from frame with URL " + m_document->url().elidedString() + 565 " from frame with URL " + m_document->url().elidedString() +
562 ". 'file:' URLs are treated as unique security origins.\n"; 566 ". 'file:' URLs are treated as unique security origins.\n";
563 else 567 } else {
564 message = "Unsafe attempt to load URL " + url.elidedString() + 568 message = "Unsafe attempt to load URL " + url.elidedString() +
565 " from frame with URL " + m_document->url().elidedString() + 569 " from frame with URL " + m_document->url().elidedString() +
566 ". Domains, protocols and ports must match.\n"; 570 ". Domains, protocols and ports must match.\n";
571 }
567 572
568 frame()->document()->addConsoleMessage(ConsoleMessage::create( 573 frame()->document()->addConsoleMessage(ConsoleMessage::create(
569 SecurityMessageSource, ErrorMessageLevel, message)); 574 SecurityMessageSource, ErrorMessageLevel, message));
570 } 575 }
571 576
572 bool FrameFetchContext::canRequest( 577 bool FrameFetchContext::canRequest(
573 Resource::Type type, 578 Resource::Type type,
574 const ResourceRequest& resourceRequest, 579 const ResourceRequest& resourceRequest,
575 const KURL& url, 580 const KURL& url,
576 const ResourceLoaderOptions& options, 581 const ResourceLoaderOptions& options,
577 bool forPreload, 582 bool forPreload,
578 FetchRequest::OriginRestriction originRestriction) const { 583 FetchRequest::OriginRestriction originRestriction) const {
579 ResourceRequestBlockedReason reason = 584 ResourceRequestBlockedReason reason =
580 canRequestInternal(type, resourceRequest, url, options, forPreload, 585 canRequestInternal(type, resourceRequest, url, options, forPreload,
581 originRestriction, resourceRequest.redirectStatus()); 586 originRestriction, resourceRequest.redirectStatus());
582 if (reason != ResourceRequestBlockedReasonNone) { 587 if (reason != ResourceRequestBlockedReasonNone) {
583 if (!forPreload) 588 if (!forPreload) {
584 InspectorInstrumentation::didBlockRequest(frame(), resourceRequest, 589 InspectorInstrumentation::didBlockRequest(frame(), resourceRequest,
585 masterDocumentLoader(), 590 masterDocumentLoader(),
586 options.initiatorInfo, reason); 591 options.initiatorInfo, reason);
592 }
587 return false; 593 return false;
588 } 594 }
589 return true; 595 return true;
590 } 596 }
591 597
592 bool FrameFetchContext::allowResponse( 598 bool FrameFetchContext::allowResponse(
593 Resource::Type type, 599 Resource::Type type,
594 const ResourceRequest& resourceRequest, 600 const ResourceRequest& resourceRequest,
595 const KURL& url, 601 const KURL& url,
596 const ResourceLoaderOptions& options) const { 602 const ResourceLoaderOptions& options) const {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return ResourceRequestBlockedReasonOrigin; 715 return ResourceRequestBlockedReasonOrigin;
710 716
711 // Measure the number of legacy URL schemes ('ftp://') and the number of 717 // Measure the number of legacy URL schemes ('ftp://') and the number of
712 // embedded-credential ('http://user:password@...') resources embedded as 718 // embedded-credential ('http://user:password@...') resources embedded as
713 // subresources. in the hopes that we can block them at some point in the 719 // subresources. in the hopes that we can block them at some point in the
714 // future. 720 // future.
715 if (resourceRequest.frameType() != WebURLRequest::FrameTypeTopLevel) { 721 if (resourceRequest.frameType() != WebURLRequest::FrameTypeTopLevel) {
716 DCHECK(frame()->document()); 722 DCHECK(frame()->document());
717 if (SchemeRegistry::shouldTreatURLSchemeAsLegacy(url.protocol()) && 723 if (SchemeRegistry::shouldTreatURLSchemeAsLegacy(url.protocol()) &&
718 !SchemeRegistry::shouldTreatURLSchemeAsLegacy( 724 !SchemeRegistry::shouldTreatURLSchemeAsLegacy(
719 frame()->document()->getSecurityOrigin()->protocol())) 725 frame()->document()->getSecurityOrigin()->protocol())) {
720 UseCounter::count(frame()->document(), 726 UseCounter::count(frame()->document(),
721 UseCounter::LegacyProtocolEmbeddedAsSubresource); 727 UseCounter::LegacyProtocolEmbeddedAsSubresource);
722 if (!url.user().isEmpty() || !url.pass().isEmpty()) 728 }
729 if (!url.user().isEmpty() || !url.pass().isEmpty()) {
723 UseCounter::count( 730 UseCounter::count(
724 frame()->document(), 731 frame()->document(),
725 UseCounter::RequestedSubresourceWithEmbeddedCredentials); 732 UseCounter::RequestedSubresourceWithEmbeddedCredentials);
733 }
726 } 734 }
727 735
728 // Check for mixed content. We do this second-to-last so that when folks block 736 // Check for mixed content. We do this second-to-last so that when folks block
729 // mixed content with a CSP policy, they don't get a warning. They'll still 737 // mixed content with a CSP policy, they don't get a warning. They'll still
730 // get a warning in the console about CSP blocking the load. 738 // get a warning in the console about CSP blocking the load.
731 MixedContentChecker::ReportingStatus mixedContentReporting = 739 MixedContentChecker::ReportingStatus mixedContentReporting =
732 forPreload ? MixedContentChecker::SuppressReport 740 forPreload ? MixedContentChecker::SuppressReport
733 : MixedContentChecker::SendReport; 741 : MixedContentChecker::SendReport;
734 if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url, 742 if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url,
735 mixedContentReporting)) 743 mixedContentReporting))
(...skipping 21 matching lines...) Expand all
757 // service workers on a per-request basis. Additionally, it is necessary to 765 // service workers on a per-request basis. Additionally, it is necessary to
758 // explicitly return |false| here so that it is clear that the SW will be 766 // explicitly return |false| here so that it is clear that the SW will be
759 // bypassed. In particular, this is important for 767 // bypassed. In particular, this is important for
760 // ResourceFetcher::getCacheIdentifier(), which will return the SW's cache if 768 // ResourceFetcher::getCacheIdentifier(), which will return the SW's cache if
761 // the context's isControlledByServiceWorker() returns |true|, and thus will 769 // the context's isControlledByServiceWorker() returns |true|, and thus will
762 // returned cached resources from the service worker. That would have the 770 // returned cached resources from the service worker. That would have the
763 // effect of not bypassing the SW. 771 // effect of not bypassing the SW.
764 if (getSecurityOrigin() && getSecurityOrigin()->hasSuborigin()) 772 if (getSecurityOrigin() && getSecurityOrigin()->hasSuborigin())
765 return false; 773 return false;
766 774
767 if (m_documentLoader) 775 if (m_documentLoader) {
768 return frame()->loader().client()->isControlledByServiceWorker( 776 return frame()->loader().client()->isControlledByServiceWorker(
769 *m_documentLoader); 777 *m_documentLoader);
778 }
770 // m_documentLoader is null while loading resources from an HTML import. In 779 // m_documentLoader is null while loading resources from an HTML import. In
771 // such cases whether the request is controlled by ServiceWorker or not is 780 // such cases whether the request is controlled by ServiceWorker or not is
772 // determined by the document loader of the frame. 781 // determined by the document loader of the frame.
773 return frame()->loader().client()->isControlledByServiceWorker( 782 return frame()->loader().client()->isControlledByServiceWorker(
774 *frame()->loader().documentLoader()); 783 *frame()->loader().documentLoader());
775 } 784 }
776 785
777 int64_t FrameFetchContext::serviceWorkerID() const { 786 int64_t FrameFetchContext::serviceWorkerID() const {
778 DCHECK(m_documentLoader || frame()->loader().documentLoader()); 787 DCHECK(m_documentLoader || frame()->loader().documentLoader());
779 if (m_documentLoader) 788 if (m_documentLoader)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 830 }
822 831
823 void FrameFetchContext::sendImagePing(const KURL& url) { 832 void FrameFetchContext::sendImagePing(const KURL& url) {
824 PingLoader::loadImage(frame(), url); 833 PingLoader::loadImage(frame(), url);
825 } 834 }
826 835
827 void FrameFetchContext::addConsoleMessage(const String& message, 836 void FrameFetchContext::addConsoleMessage(const String& message,
828 LogMessageType messageType) const { 837 LogMessageType messageType) const {
829 MessageLevel level = messageType == LogWarningMessage ? WarningMessageLevel 838 MessageLevel level = messageType == LogWarningMessage ? WarningMessageLevel
830 : ErrorMessageLevel; 839 : ErrorMessageLevel;
831 if (frame()->document()) 840 if (frame()->document()) {
832 frame()->document()->addConsoleMessage( 841 frame()->document()->addConsoleMessage(
833 ConsoleMessage::create(JSMessageSource, level, message)); 842 ConsoleMessage::create(JSMessageSource, level, message));
843 }
834 } 844 }
835 845
836 SecurityOrigin* FrameFetchContext::getSecurityOrigin() const { 846 SecurityOrigin* FrameFetchContext::getSecurityOrigin() const {
837 return m_document ? m_document->getSecurityOrigin() : nullptr; 847 return m_document ? m_document->getSecurityOrigin() : nullptr;
838 } 848 }
839 849
840 void FrameFetchContext::modifyRequestForCSP(ResourceRequest& resourceRequest) { 850 void FrameFetchContext::modifyRequestForCSP(ResourceRequest& resourceRequest) {
841 // Record the latest requiredCSP value that will be used when sending this 851 // Record the latest requiredCSP value that will be used when sending this
842 // request. 852 // request.
843 frame()->loader().recordLatestRequiredCSP(); 853 frame()->loader().recordLatestRequiredCSP();
844 frame()->loader().modifyRequestForCSP(resourceRequest, m_document); 854 frame()->loader().modifyRequestForCSP(resourceRequest, m_document);
845 } 855 }
846 856
847 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) { 857 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) {
848 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document) 858 if (!RuntimeEnabledFeatures::clientHintsEnabled() || !m_document)
849 return; 859 return;
850 860
851 bool shouldSendDPR = m_document->clientHintsPreferences().shouldSendDPR() || 861 bool shouldSendDPR = m_document->clientHintsPreferences().shouldSendDPR() ||
852 fetchRequest.clientHintsPreferences().shouldSendDPR(); 862 fetchRequest.clientHintsPreferences().shouldSendDPR();
853 bool shouldSendResourceWidth = 863 bool shouldSendResourceWidth =
854 m_document->clientHintsPreferences().shouldSendResourceWidth() || 864 m_document->clientHintsPreferences().shouldSendResourceWidth() ||
855 fetchRequest.clientHintsPreferences().shouldSendResourceWidth(); 865 fetchRequest.clientHintsPreferences().shouldSendResourceWidth();
856 bool shouldSendViewportWidth = 866 bool shouldSendViewportWidth =
857 m_document->clientHintsPreferences().shouldSendViewportWidth() || 867 m_document->clientHintsPreferences().shouldSendViewportWidth() ||
858 fetchRequest.clientHintsPreferences().shouldSendViewportWidth(); 868 fetchRequest.clientHintsPreferences().shouldSendViewportWidth();
859 869
860 if (shouldSendDPR) 870 if (shouldSendDPR) {
861 fetchRequest.mutableResourceRequest().addHTTPHeaderField( 871 fetchRequest.mutableResourceRequest().addHTTPHeaderField(
862 "DPR", AtomicString(String::number(m_document->devicePixelRatio()))); 872 "DPR", AtomicString(String::number(m_document->devicePixelRatio())));
873 }
863 874
864 if (shouldSendResourceWidth) { 875 if (shouldSendResourceWidth) {
865 FetchRequest::ResourceWidth resourceWidth = fetchRequest.getResourceWidth(); 876 FetchRequest::ResourceWidth resourceWidth = fetchRequest.getResourceWidth();
866 if (resourceWidth.isSet) { 877 if (resourceWidth.isSet) {
867 float physicalWidth = 878 float physicalWidth =
868 resourceWidth.width * m_document->devicePixelRatio(); 879 resourceWidth.width * m_document->devicePixelRatio();
869 fetchRequest.mutableResourceRequest().addHTTPHeaderField( 880 fetchRequest.mutableResourceRequest().addHTTPHeaderField(
870 "Width", AtomicString(String::number(ceil(physicalWidth)))); 881 "Width", AtomicString(String::number(ceil(physicalWidth))));
871 } 882 }
872 } 883 }
873 884
874 if (shouldSendViewportWidth && frame()->view()) 885 if (shouldSendViewportWidth && frame()->view()) {
875 fetchRequest.mutableResourceRequest().addHTTPHeaderField( 886 fetchRequest.mutableResourceRequest().addHTTPHeaderField(
876 "Viewport-Width", 887 "Viewport-Width",
877 AtomicString(String::number(frame()->view()->viewportWidth()))); 888 AtomicString(String::number(frame()->view()->viewportWidth())));
889 }
878 } 890 }
879 891
880 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, 892 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type,
881 FetchRequest& fetchRequest) { 893 FetchRequest& fetchRequest) {
882 if (!m_document) 894 if (!m_document)
883 return; 895 return;
884 896
885 const ContentSecurityPolicy* csp = m_document->contentSecurityPolicy(); 897 const ContentSecurityPolicy* csp = m_document->contentSecurityPolicy();
886 if (csp->shouldSendCSPHeader(type)) 898 if (csp->shouldSendCSPHeader(type))
887 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active"); 899 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active");
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 response.httpHeaderField(HTTPNames::Accept_CH), fetcher); 987 response.httpHeaderField(HTTPNames::Accept_CH), fetcher);
976 // When response is received with a provisional docloader, the resource 988 // When response is received with a provisional docloader, the resource
977 // haven't committed yet, and we cannot load resources, only preconnect. 989 // haven't committed yet, and we cannot load resources, only preconnect.
978 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; 990 resourceLoadingPolicy = LinkLoader::DoNotLoadResources;
979 } 991 }
980 LinkLoader::loadLinksFromHeader( 992 LinkLoader::loadLinksFromHeader(
981 response.httpHeaderField(HTTPNames::Link), response.url(), 993 response.httpHeaderField(HTTPNames::Link), response.url(),
982 frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy, 994 frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy,
983 LinkLoader::LoadAll, nullptr); 995 LinkLoader::LoadAll, nullptr);
984 996
985 if (response.hasMajorCertificateErrors()) 997 if (response.hasMajorCertificateErrors()) {
986 MixedContentChecker::handleCertificateError(frame(), response, frameType, 998 MixedContentChecker::handleCertificateError(frame(), response, frameType,
987 requestContext); 999 requestContext);
1000 }
988 1001
989 frame()->loader().progress().incrementProgress(identifier, response); 1002 frame()->loader().progress().incrementProgress(identifier, response);
990 frame()->loader().client()->dispatchDidReceiveResponse(response); 1003 frame()->loader().client()->dispatchDidReceiveResponse(response);
991 TRACE_EVENT_INSTANT1( 1004 TRACE_EVENT_INSTANT1(
992 "devtools.timeline", "ResourceReceiveResponse", TRACE_EVENT_SCOPE_THREAD, 1005 "devtools.timeline", "ResourceReceiveResponse", TRACE_EVENT_SCOPE_THREAD,
993 "data", 1006 "data",
994 InspectorReceiveResponseEvent::data(identifier, frame(), response)); 1007 InspectorReceiveResponseEvent::data(identifier, frame(), response));
995 DocumentLoader* documentLoader = masterDocumentLoader(); 1008 DocumentLoader* documentLoader = masterDocumentLoader();
996 InspectorInstrumentation::didReceiveResourceResponse( 1009 InspectorInstrumentation::didReceiveResourceResponse(
997 frame(), identifier, documentLoader, response, resource); 1010 frame(), identifier, documentLoader, response, resource);
998 // It is essential that inspector gets resource response BEFORE console. 1011 // It is essential that inspector gets resource response BEFORE console.
999 frame()->console().reportResourceResponseReceived(documentLoader, identifier, 1012 frame()->console().reportResourceResponseReceived(documentLoader, identifier,
1000 response); 1013 response);
1001 } 1014 }
1002 1015
1003 DEFINE_TRACE(FrameFetchContext) { 1016 DEFINE_TRACE(FrameFetchContext) {
1004 visitor->trace(m_document); 1017 visitor->trace(m_document);
1005 visitor->trace(m_documentLoader); 1018 visitor->trace(m_documentLoader);
1006 FetchContext::trace(visitor); 1019 FetchContext::trace(visitor);
1007 } 1020 }
1008 1021
1009 } // namespace blink 1022 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698