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

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

Issue 2022783002: Skeleton of the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 6 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "core/timing/DOMWindowPerformance.h" 63 #include "core/timing/DOMWindowPerformance.h"
64 #include "core/timing/Performance.h" 64 #include "core/timing/Performance.h"
65 #include "platform/Logging.h" 65 #include "platform/Logging.h"
66 #include "platform/TracedValue.h" 66 #include "platform/TracedValue.h"
67 #include "platform/mhtml/MHTMLArchive.h" 67 #include "platform/mhtml/MHTMLArchive.h"
68 #include "platform/network/ResourceLoadPriority.h" 68 #include "platform/network/ResourceLoadPriority.h"
69 #include "platform/network/ResourceTimingInfo.h" 69 #include "platform/network/ResourceTimingInfo.h"
70 #include "platform/weborigin/SchemeRegistry.h" 70 #include "platform/weborigin/SchemeRegistry.h"
71 #include "platform/weborigin/SecurityPolicy.h" 71 #include "platform/weborigin/SecurityPolicy.h"
72 #include "public/platform/WebCachePolicy.h" 72 #include "public/platform/WebCachePolicy.h"
73 #include "public/platform/WebDocumentSubresourceFilter.h"
73 #include "public/platform/WebFrameScheduler.h" 74 #include "public/platform/WebFrameScheduler.h"
74 75
75 #include <algorithm> 76 #include <algorithm>
76 77
77 namespace blink { 78 namespace blink {
78 79
79 namespace { 80 namespace {
80 81
81 bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch Request::DeferOption defer, const Document& document) 82 bool shouldDisallowFetchForMainFrameScript(const ResourceRequest& request, Fetch Request::DeferOption defer, const Document& document)
82 { 83 {
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 566 }
566 567
567 // Measure the number of pages that load resources after a redirect 568 // Measure the number of pages that load resources after a redirect
568 // when a CSP is active, to see if implementing CSP 569 // when a CSP is active, to see if implementing CSP
569 // 'unsafe-redirect' is feasible. 570 // 'unsafe-redirect' is feasible.
570 if (csp && csp->isActive() && resourceRequest.frameType() != WebURLRequest:: FrameTypeTopLevel && resourceRequest.frameType() != WebURLRequest::FrameTypeAuxi liary && redirectStatus == RedirectStatus::FollowedRedirect) { 571 if (csp && csp->isActive() && resourceRequest.frameType() != WebURLRequest:: FrameTypeTopLevel && resourceRequest.frameType() != WebURLRequest::FrameTypeAuxi liary && redirectStatus == RedirectStatus::FollowedRedirect) {
571 ASSERT(frame()->document()); 572 ASSERT(frame()->document());
572 UseCounter::count(frame()->document(), UseCounter::ResourceLoadedAfterRe directWithCSP); 573 UseCounter::count(frame()->document(), UseCounter::ResourceLoadedAfterRe directWithCSP);
573 } 574 }
574 575
575 // Last of all, check for mixed content. We do this last so that when 576 // Check for mixed content. We do this second-to-last so that when folks blo ck
576 // folks block mixed content with a CSP policy, they don't get a warning. 577 // mixed content with a CSP policy, they don't get a warning. They'll still
577 // They'll still get a warning in the console about CSP blocking the load. 578 // get a warning in the console about CSP blocking the load.
578 MixedContentChecker::ReportingStatus mixedContentReporting = forPreload ? 579 MixedContentChecker::ReportingStatus mixedContentReporting = forPreload ?
579 MixedContentChecker::SuppressReport : MixedContentChecker::SendReport; 580 MixedContentChecker::SuppressReport : MixedContentChecker::SendReport;
580 if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url, mix edContentReporting)) 581 if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url, mix edContentReporting))
581 return ResourceRequestBlockedReasonMixedContent; 582 return ResourceRequestBlockedReasonMixedContent;
582 583
584 // Let the client have the final say into whether or not the load should pro ceed.
585 DocumentLoader* documentLoader = effectiveDocumentLoader();
586 if (documentLoader && documentLoader->subresourceFilter() && type != Resourc e::MainResource && type != Resource::ImportResource && !documentLoader->subresou rceFilter()->allowLoad(url, resourceRequest.requestContext()))
587 return ResourceRequestBlockedReasonSubresourceFilter;
588
583 return ResourceRequestBlockedReasonNone; 589 return ResourceRequestBlockedReasonNone;
584 } 590 }
585 591
586 bool FrameFetchContext::isControlledByServiceWorker() const 592 bool FrameFetchContext::isControlledByServiceWorker() const
587 { 593 {
588 ASSERT(m_documentLoader || frame()->loader().documentLoader()); 594 ASSERT(m_documentLoader || frame()->loader().documentLoader());
589 if (m_documentLoader) 595 if (m_documentLoader)
590 return frame()->loader().client()->isControlledByServiceWorker(*m_docume ntLoader); 596 return frame()->loader().client()->isControlledByServiceWorker(*m_docume ntLoader);
591 // m_documentLoader is null while loading resources from an HTML import. 597 // m_documentLoader is null while loading resources from an HTML import.
592 // In such cases whether the request is controlled by ServiceWorker or not 598 // In such cases whether the request is controlled by ServiceWorker or not
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 } 821 }
816 822
817 DEFINE_TRACE(FrameFetchContext) 823 DEFINE_TRACE(FrameFetchContext)
818 { 824 {
819 visitor->trace(m_document); 825 visitor->trace(m_document);
820 visitor->trace(m_documentLoader); 826 visitor->trace(m_documentLoader);
821 FetchContext::trace(visitor); 827 FetchContext::trace(visitor);
822 } 828 }
823 829
824 } // namespace blink 830 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698