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

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

Issue 2844913002: Drop GetFrame()->GetDocument() usage in FrameFetchContext (Closed)
Patch Set: Add comment in SendMessageToConsoleForPossiblyNullDocument Created 3 years, 7 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 564 }
565 565
566 void FrameFetchContext::SendImagePing(const KURL& url) { 566 void FrameFetchContext::SendImagePing(const KURL& url) {
567 PingLoader::LoadImage(GetFrame(), url); 567 PingLoader::LoadImage(GetFrame(), url);
568 } 568 }
569 569
570 void FrameFetchContext::AddConsoleMessage(const String& message, 570 void FrameFetchContext::AddConsoleMessage(const String& message,
571 LogMessageType message_type) const { 571 LogMessageType message_type) const {
572 MessageLevel level = message_type == kLogWarningMessage ? kWarningMessageLevel 572 MessageLevel level = message_type == kLogWarningMessage ? kWarningMessageLevel
573 : kErrorMessageLevel; 573 : kErrorMessageLevel;
574 if (GetFrame()->GetDocument()) { 574 ConsoleMessage* console_message =
575 GetFrame()->GetDocument()->AddConsoleMessage( 575 ConsoleMessage::Create(kJSMessageSource, level, message);
576 ConsoleMessage::Create(kJSMessageSource, level, message)); 576 // Route the console message through Document if it's attached, so
577 } 577 // that script line numbers can be included. Otherwise, route directly to the
578 // FrameConsole, to ensure we never drop a message.
579 if (GetDocument() && GetDocument()->GetFrame())
580 GetDocument()->AddConsoleMessage(console_message);
581 else
582 GetFrame()->Console().AddMessage(console_message);
578 } 583 }
579 584
580 void FrameFetchContext::ModifyRequestForCSP(ResourceRequest& resource_request) { 585 void FrameFetchContext::ModifyRequestForCSP(ResourceRequest& resource_request) {
581 // Record the latest requiredCSP value that will be used when sending this 586 // Record the latest requiredCSP value that will be used when sending this
582 // request. 587 // request.
583 GetFrame()->Loader().RecordLatestRequiredCSP(); 588 GetFrame()->Loader().RecordLatestRequiredCSP();
584 GetFrame()->Loader().ModifyRequestForCSP(resource_request, GetDocument()); 589 GetFrame()->Loader().ModifyRequestForCSP(resource_request, GetDocument());
585 } 590 }
586 591
587 void FrameFetchContext::AddClientHintsIfNecessary( 592 void FrameFetchContext::AddClientHintsIfNecessary(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 Settings* FrameFetchContext::GetSettings() const { 702 Settings* FrameFetchContext::GetSettings() const {
698 DCHECK(GetFrame()); 703 DCHECK(GetFrame());
699 return GetFrame()->GetSettings(); 704 return GetFrame()->GetSettings();
700 } 705 }
701 706
702 SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const { 707 SubresourceFilter* FrameFetchContext::GetSubresourceFilter() const {
703 DocumentLoader* document_loader = MasterDocumentLoader(); 708 DocumentLoader* document_loader = MasterDocumentLoader();
704 return document_loader ? document_loader->GetSubresourceFilter() : nullptr; 709 return document_loader ? document_loader->GetSubresourceFilter() : nullptr;
705 } 710 }
706 711
707 SecurityContext* FrameFetchContext::GetMainResourceSecurityContext() const { 712 SecurityContext* FrameFetchContext::GetParentSecurityContext() const {
708 DCHECK(GetFrame()->GetDocument()); 713 if (Frame* parent = GetFrame()->Tree().Parent())
709 return GetFrame()->GetDocument(); 714 return parent->GetSecurityContext();
715 return nullptr;
710 } 716 }
711 717
712 bool FrameFetchContext::ShouldBlockRequestByInspector( 718 bool FrameFetchContext::ShouldBlockRequestByInspector(
713 const ResourceRequest& resource_request) const { 719 const ResourceRequest& resource_request) const {
714 bool should_block_request = false; 720 bool should_block_request = false;
715 probe::shouldBlockRequest(GetFrame(), resource_request, 721 probe::shouldBlockRequest(GetFrame(), resource_request,
716 &should_block_request); 722 &should_block_request);
717 return should_block_request; 723 return should_block_request;
718 } 724 }
719 725
(...skipping 11 matching lines...) Expand all
731 737
732 bool FrameFetchContext::ShouldBypassMainWorldCSP() const { 738 bool FrameFetchContext::ShouldBypassMainWorldCSP() const {
733 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP(); 739 return GetFrame()->GetScriptController().ShouldBypassMainWorldCSP();
734 } 740 }
735 741
736 bool FrameFetchContext::IsSVGImageChromeClient() const { 742 bool FrameFetchContext::IsSVGImageChromeClient() const {
737 return GetFrame()->GetChromeClient().IsSVGImageChromeClient(); 743 return GetFrame()->GetChromeClient().IsSVGImageChromeClient();
738 } 744 }
739 745
740 void FrameFetchContext::CountUsage(UseCounter::Feature feature) const { 746 void FrameFetchContext::CountUsage(UseCounter::Feature feature) const {
741 UseCounter::Count(GetFrame()->GetDocument(), feature); 747 UseCounter::Count(GetFrame(), feature);
742 } 748 }
743 749
744 void FrameFetchContext::CountDeprecation(UseCounter::Feature feature) const { 750 void FrameFetchContext::CountDeprecation(UseCounter::Feature feature) const {
745 Deprecation::CountDeprecation(GetFrame()->GetDocument(), feature); 751 Deprecation::CountDeprecation(GetFrame(), feature);
746 } 752 }
747 753
748 bool FrameFetchContext::ShouldBlockFetchByMixedContentCheck( 754 bool FrameFetchContext::ShouldBlockFetchByMixedContentCheck(
749 const ResourceRequest& resource_request, 755 const ResourceRequest& resource_request,
750 const KURL& url, 756 const KURL& url,
751 SecurityViolationReportingPolicy reporting_policy) const { 757 SecurityViolationReportingPolicy reporting_policy) const {
752 return MixedContentChecker::ShouldBlockFetch(GetFrame(), resource_request, 758 return MixedContentChecker::ShouldBlockFetch(GetFrame(), resource_request,
753 url, reporting_policy); 759 url, reporting_policy);
754 } 760 }
755 761
756 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() { 762 std::unique_ptr<WebURLLoader> FrameFetchContext::CreateURLLoader() {
757 return Platform::Current()->CreateURLLoader(); 763 return Platform::Current()->CreateURLLoader();
758 } 764 }
759 765
760 DEFINE_TRACE(FrameFetchContext) { 766 DEFINE_TRACE(FrameFetchContext) {
761 visitor->Trace(document_loader_); 767 visitor->Trace(document_loader_);
762 BaseFetchContext::Trace(visitor); 768 BaseFetchContext::Trace(visitor);
763 } 769 }
764 770
765 } // namespace blink 771 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameFetchContext.h ('k') | third_party/WebKit/Source/core/loader/LinkLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698