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

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

Issue 2383403002: Reflow comments in core/loader (Closed)
Patch Set: yhirano comments 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 if (loadType == FrameLoadTypeReload) 270 if (loadType == FrameLoadTypeReload)
271 return CachePolicyRevalidate; 271 return CachePolicyRevalidate;
272 272
273 if (m_documentLoader && 273 if (m_documentLoader &&
274 m_documentLoader->request().getCachePolicy() == 274 m_documentLoader->request().getCachePolicy() ==
275 WebCachePolicy::ReturnCacheDataElseLoad) 275 WebCachePolicy::ReturnCacheDataElseLoad)
276 return CachePolicyHistoryBuffer; 276 return CachePolicyHistoryBuffer;
277 277
278 // Returns CachePolicyVerify for other cases, mainly FrameLoadTypeStandard 278 // Returns CachePolicyVerify for other cases, mainly FrameLoadTypeStandard and
279 // and FrameLoadTypeReloadMainResource. See public/web/WebFrameLoadType.h 279 // FrameLoadTypeReloadMainResource. See public/web/WebFrameLoadType.h to know
280 // to know how these load types work. 280 // how these load types work.
281 return CachePolicyVerify; 281 return CachePolicyVerify;
282 } 282 }
283 283
284 static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy( 284 static WebCachePolicy memoryCachePolicyToResourceRequestCachePolicy(
285 const CachePolicy policy) { 285 const CachePolicy policy) {
286 if (policy == CachePolicyVerify) 286 if (policy == CachePolicyVerify)
287 return WebCachePolicy::UseProtocolCachePolicy; 287 return WebCachePolicy::UseProtocolCachePolicy;
288 if (policy == CachePolicyRevalidate) 288 if (policy == CachePolicyRevalidate)
289 return WebCachePolicy::ValidatingCacheData; 289 return WebCachePolicy::ValidatingCacheData;
290 if (policy == CachePolicyReload) 290 if (policy == CachePolicyReload)
(...skipping 21 matching lines...) Expand all
312 if (!f->isLocalFrame()) 312 if (!f->isLocalFrame())
313 continue; 313 continue;
314 FrameLoadType parentFrameLoadType = toLocalFrame(f)->loader().loadType(); 314 FrameLoadType parentFrameLoadType = toLocalFrame(f)->loader().loadType();
315 if (parentFrameLoadType == FrameLoadTypeBackForward) 315 if (parentFrameLoadType == FrameLoadTypeBackForward)
316 return WebCachePolicy::ReturnCacheDataElseLoad; 316 return WebCachePolicy::ReturnCacheDataElseLoad;
317 if (parentFrameLoadType == FrameLoadTypeReloadBypassingCache) 317 if (parentFrameLoadType == FrameLoadTypeReloadBypassingCache)
318 return WebCachePolicy::BypassingCache; 318 return WebCachePolicy::BypassingCache;
319 if (parentFrameLoadType == FrameLoadTypeReload) 319 if (parentFrameLoadType == FrameLoadTypeReload)
320 return WebCachePolicy::ValidatingCacheData; 320 return WebCachePolicy::ValidatingCacheData;
321 } 321 }
322 // Returns UseProtocolCachePolicy for other cases, parent frames not 322 // Returns UseProtocolCachePolicy for other cases, parent frames not having
323 // having special kinds of FrameLoadType as they are checked inside 323 // special kinds of FrameLoadType as they are checked inside the for loop
324 // the for loop above, or |frameLoadType| being FrameLoadTypeStandard. 324 // above, or |frameLoadType| being FrameLoadTypeStandard. See
325 // See public/web/WebFrameLoadType.h to know how these load types work. 325 // public/web/WebFrameLoadType.h to know how these load types work.
326 return WebCachePolicy::UseProtocolCachePolicy; 326 return WebCachePolicy::UseProtocolCachePolicy;
327 } 327 }
328 328
329 // For users on slow connections, we want to avoid blocking the parser in 329 // For users on slow connections, we want to avoid blocking the parser in
330 // the main frame on script loads inserted via document.write, since it can 330 // the main frame on script loads inserted via document.write, since it can
331 // add significant delays before page content is displayed on the screen. 331 // add significant delays before page content is displayed on the screen.
332 if (type == Resource::Script && isMainFrame() && m_document && 332 if (type == Resource::Script && isMainFrame() && m_document &&
333 shouldDisallowFetchForMainFrameScript(request, defer, *m_document)) 333 shouldDisallowFetchForMainFrameScript(request, defer, *m_document))
334 return WebCachePolicy::ReturnCacheDataDontLoad; 334 return WebCachePolicy::ReturnCacheDataDontLoad;
335 335
336 if (request.isConditional()) 336 if (request.isConditional())
337 return WebCachePolicy::ValidatingCacheData; 337 return WebCachePolicy::ValidatingCacheData;
338 338
339 if (m_documentLoader && m_document && !m_document->loadEventFinished()) { 339 if (m_documentLoader && m_document && !m_document->loadEventFinished()) {
340 // For POST requests, we mutate the main resource's cache policy to avoid fo rm resubmission. 340 // For POST requests, we mutate the main resource's cache policy to avoid
341 // This policy should not be inherited by subresources. 341 // form resubmission. This policy should not be inherited by subresources.
342 WebCachePolicy mainResourceCachePolicy = 342 WebCachePolicy mainResourceCachePolicy =
343 m_documentLoader->request().getCachePolicy(); 343 m_documentLoader->request().getCachePolicy();
344 if (m_documentLoader->request().httpMethod() == "POST") { 344 if (m_documentLoader->request().httpMethod() == "POST") {
345 if (mainResourceCachePolicy == WebCachePolicy::ReturnCacheDataDontLoad) 345 if (mainResourceCachePolicy == WebCachePolicy::ReturnCacheDataDontLoad)
346 return WebCachePolicy::ReturnCacheDataElseLoad; 346 return WebCachePolicy::ReturnCacheDataElseLoad;
347 return WebCachePolicy::UseProtocolCachePolicy; 347 return WebCachePolicy::UseProtocolCachePolicy;
348 } 348 }
349 return memoryCachePolicyToResourceRequestCachePolicy(getCachePolicy()); 349 return memoryCachePolicyToResourceRequestCachePolicy(getCachePolicy());
350 } 350 }
351 return WebCachePolicy::UseProtocolCachePolicy; 351 return WebCachePolicy::UseProtocolCachePolicy;
352 } 352 }
353 353
354 // The |m_documentLoader| is null in the FrameFetchContext of an imported docume nt. 354 // The |m_documentLoader| is null in the FrameFetchContext of an imported
355 // FIXME(http://crbug.com/274173): This means Inspector, which uses DocumentLoad er 355 // document.
356 // as a grouping entity, cannot see imported documents. 356 // FIXME(http://crbug.com/274173): This means Inspector, which uses
357 // DocumentLoader as a grouping entity, cannot see imported documents.
357 inline DocumentLoader* FrameFetchContext::masterDocumentLoader() const { 358 inline DocumentLoader* FrameFetchContext::masterDocumentLoader() const {
358 return m_documentLoader ? m_documentLoader.get() 359 return m_documentLoader ? m_documentLoader.get()
359 : frame()->loader().documentLoader(); 360 : frame()->loader().documentLoader();
360 } 361 }
361 362
362 void FrameFetchContext::dispatchDidChangeResourcePriority( 363 void FrameFetchContext::dispatchDidChangeResourcePriority(
363 unsigned long identifier, 364 unsigned long identifier,
364 ResourceLoadPriority loadPriority, 365 ResourceLoadPriority loadPriority,
365 int intraPriorityValue) { 366 int intraPriorityValue) {
366 TRACE_EVENT_INSTANT1( 367 TRACE_EVENT_INSTANT1(
367 "devtools.timeline", "ResourceChangePriority", TRACE_EVENT_SCOPE_THREAD, 368 "devtools.timeline", "ResourceChangePriority", TRACE_EVENT_SCOPE_THREAD,
368 "data", 369 "data",
369 InspectorChangeResourcePriorityEvent::data(identifier, loadPriority)); 370 InspectorChangeResourcePriorityEvent::data(identifier, loadPriority));
370 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier, 371 InspectorInstrumentation::didChangeResourcePriority(frame(), identifier,
371 loadPriority); 372 loadPriority);
372 } 373 }
373 374
374 void FrameFetchContext::prepareRequest(ResourceRequest& request) { 375 void FrameFetchContext::prepareRequest(ResourceRequest& request) {
375 frame()->loader().applyUserAgent(request); 376 frame()->loader().applyUserAgent(request);
376 frame()->loader().client()->dispatchWillSendRequest(request); 377 frame()->loader().client()->dispatchWillSendRequest(request);
377 } 378 }
378 379
379 void FrameFetchContext::dispatchWillSendRequest( 380 void FrameFetchContext::dispatchWillSendRequest(
380 unsigned long identifier, 381 unsigned long identifier,
381 ResourceRequest& request, 382 ResourceRequest& request,
382 const ResourceResponse& redirectResponse, 383 const ResourceResponse& redirectResponse,
383 const FetchInitiatorInfo& initiatorInfo) { 384 const FetchInitiatorInfo& initiatorInfo) {
384 // For initial requests, prepareRequest() is called in 385 // For initial requests, prepareRequest() is called in
385 // willStartLoadingResource(), before revalidation policy is determined. 386 // willStartLoadingResource(), before revalidation policy is determined. That
386 // That call doesn't exist for redirects, so call preareRequest() here. 387 // call doesn't exist for redirects, so call preareRequest() here.
387 if (!redirectResponse.isNull()) 388 if (!redirectResponse.isNull())
388 prepareRequest(request); 389 prepareRequest(request);
389 else 390 else
390 frame()->loader().progress().willStartLoading(identifier, 391 frame()->loader().progress().willStartLoading(identifier,
391 request.priority()); 392 request.priority());
392 TRACE_EVENT_INSTANT1( 393 TRACE_EVENT_INSTANT1(
393 "devtools.timeline", "ResourceSendRequest", TRACE_EVENT_SCOPE_THREAD, 394 "devtools.timeline", "ResourceSendRequest", TRACE_EVENT_SCOPE_THREAD,
394 "data", InspectorSendRequestEvent::data(identifier, frame(), request)); 395 "data", InspectorSendRequestEvent::data(identifier, frame(), request));
395 InspectorInstrumentation::willSendRequest(frame(), identifier, 396 InspectorInstrumentation::willSendRequest(frame(), identifier,
396 masterDocumentLoader(), request, 397 masterDocumentLoader(), request,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 450 }
450 451
451 void FrameFetchContext::dispatchDidFail(unsigned long identifier, 452 void FrameFetchContext::dispatchDidFail(unsigned long identifier,
452 const ResourceError& error, 453 const ResourceError& error,
453 bool isInternalRequest) { 454 bool isInternalRequest) {
454 frame()->loader().progress().completeProgress(identifier); 455 frame()->loader().progress().completeProgress(identifier);
455 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", 456 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish",
456 TRACE_EVENT_SCOPE_THREAD, "data", 457 TRACE_EVENT_SCOPE_THREAD, "data",
457 InspectorResourceFinishEvent::data(identifier, 0, true)); 458 InspectorResourceFinishEvent::data(identifier, 0, true));
458 InspectorInstrumentation::didFailLoading(frame(), identifier, error); 459 InspectorInstrumentation::didFailLoading(frame(), identifier, error);
459 // Notification to FrameConsole should come AFTER InspectorInstrumentation cal l, DevTools front-end relies on this. 460 // Notification to FrameConsole should come AFTER InspectorInstrumentation
461 // call, DevTools front-end relies on this.
460 if (!isInternalRequest) 462 if (!isInternalRequest)
461 frame()->console().didFailLoading(identifier, error); 463 frame()->console().didFailLoading(identifier, error);
462 if (frame()->frameScheduler()) 464 if (frame()->frameScheduler())
463 frame()->frameScheduler()->didStopLoading(identifier); 465 frame()->frameScheduler()->didStopLoading(identifier);
464 } 466 }
465 467
466 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( 468 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(
467 unsigned long identifier, 469 unsigned long identifier,
468 Resource* resource, 470 Resource* resource,
469 WebURLRequest::FrameType frameType, 471 WebURLRequest::FrameType frameType,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 case Resource::XSLStyleSheet: 654 case Resource::XSLStyleSheet:
653 DCHECK(RuntimeEnabledFeatures::xsltEnabled()); 655 DCHECK(RuntimeEnabledFeatures::xsltEnabled());
654 case Resource::SVGDocument: 656 case Resource::SVGDocument:
655 if (!securityOrigin->canRequest(url)) { 657 if (!securityOrigin->canRequest(url)) {
656 printAccessDeniedMessage(url); 658 printAccessDeniedMessage(url);
657 return ResourceRequestBlockedReasonOrigin; 659 return ResourceRequestBlockedReasonOrigin;
658 } 660 }
659 break; 661 break;
660 } 662 }
661 663
662 // FIXME: Convert this to check the isolated world's Content Security Policy o nce webkit.org/b/104520 is solved. 664 // FIXME: Convert this to check the isolated world's Content Security Policy
665 // once webkit.org/b/104520 is solved.
663 bool shouldBypassMainWorldCSP = 666 bool shouldBypassMainWorldCSP =
664 frame()->script().shouldBypassMainWorldCSP() || 667 frame()->script().shouldBypassMainWorldCSP() ||
665 options.contentSecurityPolicyOption == DoNotCheckContentSecurityPolicy; 668 options.contentSecurityPolicyOption == DoNotCheckContentSecurityPolicy;
666 669
667 // Don't send CSP messages for preloads, we might never actually display those items. 670 // Don't send CSP messages for preloads, we might never actually display those
671 // items.
668 ContentSecurityPolicy::ReportingStatus cspReporting = 672 ContentSecurityPolicy::ReportingStatus cspReporting =
669 forPreload ? ContentSecurityPolicy::SuppressReport 673 forPreload ? ContentSecurityPolicy::SuppressReport
670 : ContentSecurityPolicy::SendReport; 674 : ContentSecurityPolicy::SendReport;
671 675
672 if (m_document) { 676 if (m_document) {
673 DCHECK(m_document->contentSecurityPolicy()); 677 DCHECK(m_document->contentSecurityPolicy());
674 if (!shouldBypassMainWorldCSP && 678 if (!shouldBypassMainWorldCSP &&
675 !m_document->contentSecurityPolicy()->allowRequest( 679 !m_document->contentSecurityPolicy()->allowRequest(
676 resourceRequest.requestContext(), url, 680 resourceRequest.requestContext(), url,
677 options.contentSecurityPolicyNonce, options.integrityMetadata, 681 options.contentSecurityPolicyNonce, options.integrityMetadata,
678 redirectStatus, cspReporting)) 682 redirectStatus, cspReporting))
679 return ResourceRequestBlockedReasonCSP; 683 return ResourceRequestBlockedReasonCSP;
680 } 684 }
681 685
682 if (type == Resource::Script || type == Resource::ImportResource) { 686 if (type == Resource::Script || type == Resource::ImportResource) {
683 DCHECK(frame()); 687 DCHECK(frame());
684 if (!frame()->loader().client()->allowScriptFromSource( 688 if (!frame()->loader().client()->allowScriptFromSource(
685 !frame()->settings() || frame()->settings()->scriptEnabled(), 689 !frame()->settings() || frame()->settings()->scriptEnabled(),
686 url)) { 690 url)) {
687 frame()->loader().client()->didNotAllowScript(); 691 frame()->loader().client()->didNotAllowScript();
688 // TODO(estark): Use a different ResourceRequestBlockedReason 692 // TODO(estark): Use a different ResourceRequestBlockedReason here, since
689 // here, since this check has nothing to do with 693 // this check has nothing to do with CSP. https://crbug.com/600795
690 // CSP. https://crbug.com/600795
691 return ResourceRequestBlockedReasonCSP; 694 return ResourceRequestBlockedReasonCSP;
692 } 695 }
693 } else if (type == Resource::Media || type == Resource::TextTrack) { 696 } else if (type == Resource::Media || type == Resource::TextTrack) {
694 DCHECK(frame()); 697 DCHECK(frame());
695 if (!frame()->loader().client()->allowMedia(url)) 698 if (!frame()->loader().client()->allowMedia(url))
696 return ResourceRequestBlockedReasonOther; 699 return ResourceRequestBlockedReasonOther;
697 } 700 }
698 701
699 // SVG Images have unique security rules that prevent all subresource requests 702 // SVG Images have unique security rules that prevent all subresource requests
700 // except for data urls. 703 // except for data urls.
701 if (type != Resource::MainResource && 704 if (type != Resource::MainResource &&
702 frame()->chromeClient().isSVGImageChromeClient() && !url.protocolIsData()) 705 frame()->chromeClient().isSVGImageChromeClient() && !url.protocolIsData())
703 return ResourceRequestBlockedReasonOrigin; 706 return ResourceRequestBlockedReasonOrigin;
704 707
705 // Measure the number of legacy URL schemes ('ftp://') and the number of embed ded-credential 708 // Measure the number of legacy URL schemes ('ftp://') and the number of
706 // ('http://user:password@...') resources embedded as subresources. in the hop es that we can 709 // embedded-credential ('http://user:password@...') resources embedded as
707 // block them at some point in the future. 710 // subresources. in the hopes that we can block them at some point in the
711 // future.
708 if (resourceRequest.frameType() != WebURLRequest::FrameTypeTopLevel) { 712 if (resourceRequest.frameType() != WebURLRequest::FrameTypeTopLevel) {
709 DCHECK(frame()->document()); 713 DCHECK(frame()->document());
710 if (SchemeRegistry::shouldTreatURLSchemeAsLegacy(url.protocol()) && 714 if (SchemeRegistry::shouldTreatURLSchemeAsLegacy(url.protocol()) &&
711 !SchemeRegistry::shouldTreatURLSchemeAsLegacy( 715 !SchemeRegistry::shouldTreatURLSchemeAsLegacy(
712 frame()->document()->getSecurityOrigin()->protocol())) 716 frame()->document()->getSecurityOrigin()->protocol()))
713 UseCounter::count(frame()->document(), 717 UseCounter::count(frame()->document(),
714 UseCounter::LegacyProtocolEmbeddedAsSubresource); 718 UseCounter::LegacyProtocolEmbeddedAsSubresource);
715 if (!url.user().isEmpty() || !url.pass().isEmpty()) 719 if (!url.user().isEmpty() || !url.pass().isEmpty())
716 UseCounter::count( 720 UseCounter::count(
717 frame()->document(), 721 frame()->document(),
718 UseCounter::RequestedSubresourceWithEmbeddedCredentials); 722 UseCounter::RequestedSubresourceWithEmbeddedCredentials);
719 } 723 }
720 724
721 // Check for mixed content. We do this second-to-last so that when folks block 725 // Check for mixed content. We do this second-to-last so that when folks block
722 // mixed content with a CSP policy, they don't get a warning. They'll still 726 // mixed content with a CSP policy, they don't get a warning. They'll still
723 // get a warning in the console about CSP blocking the load. 727 // get a warning in the console about CSP blocking the load.
724 MixedContentChecker::ReportingStatus mixedContentReporting = 728 MixedContentChecker::ReportingStatus mixedContentReporting =
725 forPreload ? MixedContentChecker::SuppressReport 729 forPreload ? MixedContentChecker::SuppressReport
726 : MixedContentChecker::SendReport; 730 : MixedContentChecker::SendReport;
727 if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url, 731 if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url,
728 mixedContentReporting)) 732 mixedContentReporting))
729 return ResourceRequestBlockedReasonMixedContent; 733 return ResourceRequestBlockedReasonMixedContent;
730 734
731 // Let the client have the final say into whether or not the load should proce ed. 735 // Let the client have the final say into whether or not the load should
736 // proceed.
732 DocumentLoader* documentLoader = masterDocumentLoader(); 737 DocumentLoader* documentLoader = masterDocumentLoader();
733 if (documentLoader && documentLoader->subresourceFilter() && 738 if (documentLoader && documentLoader->subresourceFilter() &&
734 type != Resource::MainResource && type != Resource::ImportResource && 739 type != Resource::MainResource && type != Resource::ImportResource &&
735 !documentLoader->subresourceFilter()->allowLoad( 740 !documentLoader->subresourceFilter()->allowLoad(
736 url, resourceRequest.requestContext())) 741 url, resourceRequest.requestContext()))
737 return ResourceRequestBlockedReasonSubresourceFilter; 742 return ResourceRequestBlockedReasonSubresourceFilter;
738 743
739 return ResourceRequestBlockedReasonNone; 744 return ResourceRequestBlockedReasonNone;
740 } 745 }
741 746
742 bool FrameFetchContext::isControlledByServiceWorker() const { 747 bool FrameFetchContext::isControlledByServiceWorker() const {
743 DCHECK(m_documentLoader || frame()->loader().documentLoader()); 748 DCHECK(m_documentLoader || frame()->loader().documentLoader());
744 749
745 // Service workers are bypassed by suborigins (see 750 // Service workers are bypassed by suborigins (see
746 // https://w3c.github.io/webappsec-suborigins/). Since service worker 751 // https://w3c.github.io/webappsec-suborigins/). Since service worker
747 // controllers are assigned based on physical origin, without knowledge of 752 // controllers are assigned based on physical origin, without knowledge of
748 // whether the context is in a suborigin, it is necessary to explicitly 753 // whether the context is in a suborigin, it is necessary to explicitly bypass
749 // bypass service workers on a per-request basis. Additionally, it is 754 // service workers on a per-request basis. Additionally, it is necessary to
750 // necessary to explicitly return |false| here so that it is clear that the 755 // explicitly return |false| here so that it is clear that the SW will be
751 // SW will be bypassed. In particular, this is important for 756 // bypassed. In particular, this is important for
752 // ResourceFetcher::getCacheIdentifier(), which will return the SW's cache 757 // ResourceFetcher::getCacheIdentifier(), which will return the SW's cache if
753 // if the context's isControlledByServiceWorker() returns |true|, and thus 758 // the context's isControlledByServiceWorker() returns |true|, and thus will
754 // will returned cached resources from the service worker. That would have 759 // returned cached resources from the service worker. That would have the
755 // the effect of not bypassing the SW. 760 // effect of not bypassing the SW.
756 if (getSecurityOrigin() && getSecurityOrigin()->hasSuborigin()) 761 if (getSecurityOrigin() && getSecurityOrigin()->hasSuborigin())
757 return false; 762 return false;
758 763
759 if (m_documentLoader) 764 if (m_documentLoader)
760 return frame()->loader().client()->isControlledByServiceWorker( 765 return frame()->loader().client()->isControlledByServiceWorker(
761 *m_documentLoader); 766 *m_documentLoader);
762 // m_documentLoader is null while loading resources from an HTML import. 767 // m_documentLoader is null while loading resources from an HTML import. In
763 // In such cases whether the request is controlled by ServiceWorker or not 768 // such cases whether the request is controlled by ServiceWorker or not is
764 // is determined by the document loader of the frame. 769 // determined by the document loader of the frame.
765 return frame()->loader().client()->isControlledByServiceWorker( 770 return frame()->loader().client()->isControlledByServiceWorker(
766 *frame()->loader().documentLoader()); 771 *frame()->loader().documentLoader());
767 } 772 }
768 773
769 int64_t FrameFetchContext::serviceWorkerID() const { 774 int64_t FrameFetchContext::serviceWorkerID() const {
770 DCHECK(m_documentLoader || frame()->loader().documentLoader()); 775 DCHECK(m_documentLoader || frame()->loader().documentLoader());
771 if (m_documentLoader) 776 if (m_documentLoader)
772 return frame()->loader().client()->serviceWorkerID(*m_documentLoader); 777 return frame()->loader().client()->serviceWorkerID(*m_documentLoader);
773 // m_documentLoader is null while loading resources from an HTML import. 778 // m_documentLoader is null while loading resources from an HTML import.
774 // In such cases a service worker ID could be retrieved from the document 779 // In such cases a service worker ID could be retrieved from the document
(...skipping 15 matching lines...) Expand all
790 } 795 }
791 796
792 bool FrameFetchContext::pageDismissalEventBeingDispatched() const { 797 bool FrameFetchContext::pageDismissalEventBeingDispatched() const {
793 return m_document && 798 return m_document &&
794 m_document->pageDismissalEventBeingDispatched() != 799 m_document->pageDismissalEventBeingDispatched() !=
795 Document::NoDismissal; 800 Document::NoDismissal;
796 } 801 }
797 802
798 bool FrameFetchContext::updateTimingInfoForIFrameNavigation( 803 bool FrameFetchContext::updateTimingInfoForIFrameNavigation(
799 ResourceTimingInfo* info) { 804 ResourceTimingInfo* info) {
800 // <iframe>s should report the initial navigation requested by the parent docu ment, but not subsequent navigations. 805 // <iframe>s should report the initial navigation requested by the parent
806 // document, but not subsequent navigations.
801 // FIXME: Resource timing is broken when the parent is a remote frame. 807 // FIXME: Resource timing is broken when the parent is a remote frame.
802 if (!frame()->deprecatedLocalOwner() || 808 if (!frame()->deprecatedLocalOwner() ||
803 frame()->deprecatedLocalOwner()->loadedNonEmptyDocument()) 809 frame()->deprecatedLocalOwner()->loadedNonEmptyDocument())
804 return false; 810 return false;
805 frame()->deprecatedLocalOwner()->didLoadNonEmptyDocument(); 811 frame()->deprecatedLocalOwner()->didLoadNonEmptyDocument();
806 // Do not report iframe navigation that restored from history, since its 812 // Do not report iframe navigation that restored from history, since its
807 // location may have been changed after initial navigation. 813 // location may have been changed after initial navigation.
808 if (frame()->loader().loadType() == FrameLoadTypeInitialHistoryLoad) 814 if (frame()->loader().loadType() == FrameLoadTypeInitialHistoryLoad)
809 return false; 815 return false;
810 info->setInitiatorType(frame()->deprecatedLocalOwner()->localName()); 816 info->setInitiatorType(frame()->deprecatedLocalOwner()->localName());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 void FrameFetchContext::populateRequestData(ResourceRequest& request) { 885 void FrameFetchContext::populateRequestData(ResourceRequest& request) {
880 if (!m_document) 886 if (!m_document)
881 return; 887 return;
882 888
883 if (request.firstPartyForCookies().isNull()) { 889 if (request.firstPartyForCookies().isNull()) {
884 request.setFirstPartyForCookies( 890 request.setFirstPartyForCookies(
885 m_document ? m_document->firstPartyForCookies() 891 m_document ? m_document->firstPartyForCookies()
886 : SecurityOrigin::urlWithUniqueSecurityOrigin()); 892 : SecurityOrigin::urlWithUniqueSecurityOrigin());
887 } 893 }
888 894
889 // Subresource requests inherit their requestor origin from |m_document| direc tly. 895 // Subresource requests inherit their requestor origin from |m_document|
890 // Top-level and nested frame types are taken care of in 'FrameLoadRequest()'. 896 // directly. Top-level and nested frame types are taken care of in
891 // Auxiliary frame types in 'createWindow()' and 'FrameLoader::load'. 897 // 'FrameLoadRequest()'. Auxiliary frame types in 'createWindow()' and
892 // 898 // 'FrameLoader::load'.
893 // TODO(mkwst): It would be cleaner to adjust blink::ResourceRequest to 899 // TODO(mkwst): It would be cleaner to adjust blink::ResourceRequest to
894 // initialize itself with a `nullptr` initiator so that this can be a simple 900 // initialize itself with a `nullptr` initiator so that this can be a simple
895 // `isNull()` check. https://crbug.com/625969 901 // `isNull()` check. https://crbug.com/625969
896 if (request.frameType() == WebURLRequest::FrameTypeNone && 902 if (request.frameType() == WebURLRequest::FrameTypeNone &&
897 request.requestorOrigin()->isUnique()) { 903 request.requestorOrigin()->isUnique()) {
898 request.setRequestorOrigin(m_document->isSandboxed(SandboxOrigin) 904 request.setRequestorOrigin(m_document->isSandboxed(SandboxOrigin)
899 ? SecurityOrigin::create(m_document->url()) 905 ? SecurityOrigin::create(m_document->url())
900 : m_document->getSecurityOrigin()); 906 : m_document->getSecurityOrigin());
901 } 907 }
902 } 908 }
903 909
904 MHTMLArchive* FrameFetchContext::archive() const { 910 MHTMLArchive* FrameFetchContext::archive() const {
905 DCHECK(!isMainFrame()); 911 DCHECK(!isMainFrame());
906 // TODO(nasko): How should this work with OOPIF? 912 // TODO(nasko): How should this work with OOPIF?
907 // The MHTMLArchive is parsed as a whole, but can be constructed from 913 // The MHTMLArchive is parsed as a whole, but can be constructed from frames
908 // frames in mutliple processes. In that case, which process should parse 914 // in mutliple processes. In that case, which process should parse it and how
909 // it and how should the output be spread back across multiple processes? 915 // should the output be spread back across multiple processes?
910 if (!frame()->tree().parent()->isLocalFrame()) 916 if (!frame()->tree().parent()->isLocalFrame())
911 return nullptr; 917 return nullptr;
912 return toLocalFrame(frame()->tree().parent()) 918 return toLocalFrame(frame()->tree().parent())
913 ->loader() 919 ->loader()
914 .documentLoader() 920 .documentLoader()
915 ->fetcher() 921 ->fetcher()
916 ->archive(); 922 ->archive();
917 } 923 }
918 924
919 void FrameFetchContext::countClientHintsDPR() { 925 void FrameFetchContext::countClientHintsDPR() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 MixedContentChecker::checkMixedPrivatePublic(frame(), 961 MixedContentChecker::checkMixedPrivatePublic(frame(),
956 response.remoteIPAddress()); 962 response.remoteIPAddress());
957 if (m_documentLoader && 963 if (m_documentLoader &&
958 m_documentLoader == frame()->loader().provisionalDocumentLoader()) { 964 m_documentLoader == frame()->loader().provisionalDocumentLoader()) {
959 ResourceFetcher* fetcher = nullptr; 965 ResourceFetcher* fetcher = nullptr;
960 if (frame()->document()) 966 if (frame()->document())
961 fetcher = frame()->document()->fetcher(); 967 fetcher = frame()->document()->fetcher();
962 m_documentLoader->clientHintsPreferences() 968 m_documentLoader->clientHintsPreferences()
963 .updateFromAcceptClientHintsHeader( 969 .updateFromAcceptClientHintsHeader(
964 response.httpHeaderField(HTTPNames::Accept_CH), fetcher); 970 response.httpHeaderField(HTTPNames::Accept_CH), fetcher);
965 // When response is received with a provisional docloader, the resource have n't committed yet, and we cannot load resources, only preconnect. 971 // When response is received with a provisional docloader, the resource
972 // haven't committed yet, and we cannot load resources, only preconnect.
966 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; 973 resourceLoadingPolicy = LinkLoader::DoNotLoadResources;
967 } 974 }
968 LinkLoader::loadLinksFromHeader( 975 LinkLoader::loadLinksFromHeader(
969 response.httpHeaderField(HTTPNames::Link), response.url(), 976 response.httpHeaderField(HTTPNames::Link), response.url(),
970 frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy, 977 frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy,
971 LinkLoader::LoadAll, nullptr); 978 LinkLoader::LoadAll, nullptr);
972 979
973 if (response.hasMajorCertificateErrors()) 980 if (response.hasMajorCertificateErrors())
974 MixedContentChecker::handleCertificateError(frame(), response, frameType, 981 MixedContentChecker::handleCertificateError(frame(), response, frameType,
975 requestContext); 982 requestContext);
(...skipping 12 matching lines...) Expand all
988 response); 995 response);
989 } 996 }
990 997
991 DEFINE_TRACE(FrameFetchContext) { 998 DEFINE_TRACE(FrameFetchContext) {
992 visitor->trace(m_document); 999 visitor->trace(m_document);
993 visitor->trace(m_documentLoader); 1000 visitor->trace(m_documentLoader);
994 FetchContext::trace(visitor); 1001 FetchContext::trace(visitor);
995 } 1002 }
996 1003
997 } // namespace blink 1004 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698