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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 document_loader_->GetFrame()->Loader().ProvisionalDocumentLoader()) { | 346 document_loader_->GetFrame()->Loader().ProvisionalDocumentLoader()) { |
347 FrameClientHintsPreferencesContext hints_context(GetFrame()); | 347 FrameClientHintsPreferencesContext hints_context(GetFrame()); |
348 document_loader_->GetClientHintsPreferences() | 348 document_loader_->GetClientHintsPreferences() |
349 .UpdateFromAcceptClientHintsHeader( | 349 .UpdateFromAcceptClientHintsHeader( |
350 response.HttpHeaderField(HTTPNames::Accept_CH), &hints_context); | 350 response.HttpHeaderField(HTTPNames::Accept_CH), &hints_context); |
351 // When response is received with a provisional docloader, the resource | 351 // When response is received with a provisional docloader, the resource |
352 // haven't committed yet, and we cannot load resources, only preconnect. | 352 // haven't committed yet, and we cannot load resources, only preconnect. |
353 resource_loading_policy = LinkLoader::kDoNotLoadResources; | 353 resource_loading_policy = LinkLoader::kDoNotLoadResources; |
354 } | 354 } |
355 LinkLoader::LoadLinksFromHeader( | 355 LinkLoader::LoadLinksFromHeader( |
356 response.HttpHeaderField(HTTPNames::Link), response.Url(), | 356 response.HttpHeaderField(HTTPNames::Link), response.Url(), *GetFrame(), |
357 GetFrame()->GetDocument(), NetworkHintsInterfaceImpl(), | 357 GetDocument(), NetworkHintsInterfaceImpl(), resource_loading_policy, |
358 resource_loading_policy, LinkLoader::kLoadAll, nullptr); | 358 LinkLoader::kLoadAll, nullptr); |
359 | 359 |
360 if (response.HasMajorCertificateErrors()) { | 360 if (response.HasMajorCertificateErrors()) { |
361 MixedContentChecker::HandleCertificateError(GetFrame(), response, | 361 MixedContentChecker::HandleCertificateError(GetFrame(), response, |
362 frame_type, request_context); | 362 frame_type, request_context); |
363 } | 363 } |
364 | 364 |
365 GetFrame()->Loader().Progress().IncrementProgress(identifier, response); | 365 GetFrame()->Loader().Progress().IncrementProgress(identifier, response); |
366 GetLocalFrameClient()->DispatchDidReceiveResponse(response); | 366 GetLocalFrameClient()->DispatchDidReceiveResponse(response); |
367 DocumentLoader* document_loader = MasterDocumentLoader(); | 367 DocumentLoader* document_loader = MasterDocumentLoader(); |
368 probe::didReceiveResourceResponse(GetFrame(), identifier, document_loader, | 368 probe::didReceiveResourceResponse(GetFrame(), identifier, document_loader, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 } | 563 } |
564 | 564 |
565 void FrameFetchContext::SendImagePing(const KURL& url) { | 565 void FrameFetchContext::SendImagePing(const KURL& url) { |
566 PingLoader::LoadImage(GetFrame(), url); | 566 PingLoader::LoadImage(GetFrame(), url); |
567 } | 567 } |
568 | 568 |
569 void FrameFetchContext::AddConsoleMessage(const String& message, | 569 void FrameFetchContext::AddConsoleMessage(const String& message, |
570 LogMessageType message_type) const { | 570 LogMessageType message_type) const { |
571 MessageLevel level = message_type == kLogWarningMessage ? kWarningMessageLevel | 571 MessageLevel level = message_type == kLogWarningMessage ? kWarningMessageLevel |
572 : kErrorMessageLevel; | 572 : kErrorMessageLevel; |
573 if (GetFrame()->GetDocument()) { | 573 ConsoleMessage* console_message = |
574 GetFrame()->GetDocument()->AddConsoleMessage( | 574 ConsoleMessage::Create(kJSMessageSource, level, message); |
575 ConsoleMessage::Create(kJSMessageSource, level, message)); | 575 // Route the console message through Document if it's attached, so |
576 } | 576 // that script line numbers can be included. Otherwise, route directly to the |
| 577 // FrameConsole, to ensure we never drop a message. |
| 578 if (GetDocument() && GetDocument()->GetFrame()) |
| 579 GetDocument()->AddConsoleMessage(console_message); |
| 580 else |
| 581 GetFrame()->Console().AddMessage(console_message); |
577 } | 582 } |
578 | 583 |
579 void FrameFetchContext::ModifyRequestForCSP(ResourceRequest& resource_request) { | 584 void FrameFetchContext::ModifyRequestForCSP(ResourceRequest& resource_request) { |
580 // Record the latest requiredCSP value that will be used when sending this | 585 // Record the latest requiredCSP value that will be used when sending this |
581 // request. | 586 // request. |
582 GetFrame()->Loader().RecordLatestRequiredCSP(); | 587 GetFrame()->Loader().RecordLatestRequiredCSP(); |
583 GetFrame()->Loader().ModifyRequestForCSP(resource_request, GetDocument()); | 588 GetFrame()->Loader().ModifyRequestForCSP(resource_request, GetDocument()); |
584 } | 589 } |
585 | 590 |
586 void FrameFetchContext::AddClientHintsIfNecessary( | 591 void FrameFetchContext::AddClientHintsIfNecessary( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 Settings* FrameFetchContext::GetSettings() const { | 715 Settings* FrameFetchContext::GetSettings() const { |
711 DCHECK(GetFrame()); | 716 DCHECK(GetFrame()); |
712 return GetFrame()->GetSettings(); | 717 return GetFrame()->GetSettings(); |
713 } | 718 } |
714 | 719 |
715 SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const { | 720 SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const { |
716 DocumentLoader* document_loader = MasterDocumentLoader(); | 721 DocumentLoader* document_loader = MasterDocumentLoader(); |
717 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; | 722 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; |
718 } | 723 } |
719 | 724 |
720 SecurityContext* FrameFetchContext::GetMainResourceSecurityContext() const { | 725 SecurityContext* FrameFetchContext::GetParentSecurityContext() const { |
721 DCHECK(GetFrame()->GetDocument()); | 726 if (Frame* parent = GetFrame()->Tree().Parent()) |
722 return GetFrame()->GetDocument(); | 727 return parent->GetSecurityContext(); |
| 728 return nullptr; |
723 } | 729 } |
724 | 730 |
725 bool FrameFetchContext::ShouldBlockRequestByInspector( | 731 bool FrameFetchContext::ShouldBlockRequestByInspector( |
726 const ResourceRequest& resource_request) const { | 732 const ResourceRequest& resource_request) const { |
727 bool should_block_request = false; | 733 bool should_block_request = false; |
728 probe::shouldBlockRequest(GetFrame(), resource_request, | 734 probe::shouldBlockRequest(GetFrame(), resource_request, |
729 &should_block_request); | 735 &should_block_request); |
730 return should_block_request; | 736 return should_block_request; |
731 } | 737 } |
732 | 738 |
(...skipping 11 matching lines...) Expand all Loading... |
744 | 750 |
745 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { | 751 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { |
746 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); | 752 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); |
747 } | 753 } |
748 | 754 |
749 bool FrameFetchContext::IsSVGImageChromeClient() const { | 755 bool FrameFetchContext::IsSVGImageChromeClient() const { |
750 return GetFrame()->GetChromeClient().IsSVGImageChromeClient(); | 756 return GetFrame()->GetChromeClient().IsSVGImageChromeClient(); |
751 } | 757 } |
752 | 758 |
753 void FrameFetchContext::CountUsage(UseCounter::Feature feature) const { | 759 void FrameFetchContext::CountUsage(UseCounter::Feature feature) const { |
754 UseCounter::Count(GetFrame()->GetDocument(), feature); | 760 UseCounter::Count(GetFrame(), feature); |
755 } | 761 } |
756 | 762 |
757 void FrameFetchContext::CountDeprecation(UseCounter::Feature feature) const { | 763 void FrameFetchContext::CountDeprecation(UseCounter::Feature feature) const { |
758 Deprecation::CountDeprecation(GetFrame()->GetDocument(), feature); | 764 Deprecation::CountDeprecation(GetFrame(), feature); |
759 } | 765 } |
760 | 766 |
761 bool FrameFetchContext::ShouldBlockFetchByMixedContentCheck( | 767 bool FrameFetchContext::ShouldBlockFetchByMixedContentCheck( |
762 const ResourceRequest& resource_request, | 768 const ResourceRequest& resource_request, |
763 const KURL& url, | 769 const KURL& url, |
764 SecurityViolationReportingPolicy reporting_policy) const { | 770 SecurityViolationReportingPolicy reporting_policy) const { |
765 return MixedContentChecker::ShouldBlockFetch(GetFrame(), resource_request, | 771 return MixedContentChecker::ShouldBlockFetch(GetFrame(), resource_request, |
766 url, reporting_policy); | 772 url, reporting_policy); |
767 } | 773 } |
768 | 774 |
769 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { | 775 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { |
770 return Platform::Current()->CreateURLLoader(); | 776 return Platform::Current()->CreateURLLoader(); |
771 } | 777 } |
772 | 778 |
773 DEFINE_TRACE(FrameFetchContext) { | 779 DEFINE_TRACE(FrameFetchContext) { |
774 visitor->Trace(document_loader_); | 780 visitor->Trace(document_loader_); |
775 BaseFetchContext::Trace(visitor); | 781 BaseFetchContext::Trace(visitor); |
776 } | 782 } |
777 | 783 |
778 } // namespace blink | 784 } // namespace blink |
OLD | NEW |