Chromium Code Reviews| Index: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| index 7eee0125a243760fdbcb05e3f3ea4b57e8fc6096..7a94d8265822bad2a55f84ee9093d4abae3e89bd 100644 |
| --- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| +++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp |
| @@ -571,7 +571,7 @@ void FrameFetchContext::willStartLoadingResource( |
| ResourceRequest& request, |
| Resource::Type type, |
| const AtomicString& fetchInitiatorName, |
| - bool forPreload) { |
| + V8ActivityLoggingPolicy loggingPolicy) { |
| TRACE_EVENT_ASYNC_BEGIN1( |
| "blink.net", "Resource", identifier, "data", |
| loadResourceTraceData(identifier, request.url(), request.priority())); |
| @@ -586,7 +586,7 @@ void FrameFetchContext::willStartLoadingResource( |
| } else { |
| m_documentLoader->applicationCacheHost()->willStartLoadingResource(request); |
| } |
| - if (!forPreload) { |
| + if (loggingPolicy == V8ActivityLoggingPolicy::Log) { |
| V8DOMActivityLogger* activityLogger = nullptr; |
| if (fetchInitiatorName == FetchInitiatorTypeNames::xmlhttprequest) { |
| activityLogger = V8DOMActivityLogger::currentActivityLogger(); |
| @@ -652,12 +652,13 @@ ResourceRequestBlockedReason FrameFetchContext::canRequest( |
| const ResourceRequest& resourceRequest, |
| const KURL& url, |
| const ResourceLoaderOptions& options, |
| - bool forPreload, |
| + ReportingPolicy reportingPolicy, |
| FetchRequest::OriginRestriction originRestriction) const { |
| ResourceRequestBlockedReason blockedReason = |
| - canRequestInternal(type, resourceRequest, url, options, forPreload, |
| + canRequestInternal(type, resourceRequest, url, options, reportingPolicy, |
| originRestriction, resourceRequest.redirectStatus()); |
| - if (blockedReason != ResourceRequestBlockedReason::None && !forPreload) { |
| + if (blockedReason != ResourceRequestBlockedReason::None && |
| + reportingPolicy == ReportingPolicy::Report) { |
| InspectorInstrumentation::didBlockRequest( |
| frame(), resourceRequest, masterDocumentLoader(), options.initiatorInfo, |
| blockedReason); |
| @@ -670,10 +671,10 @@ ResourceRequestBlockedReason FrameFetchContext::allowResponse( |
| const ResourceRequest& resourceRequest, |
| const KURL& url, |
| const ResourceLoaderOptions& options) const { |
| - ResourceRequestBlockedReason blockedReason = |
| - canRequestInternal(type, resourceRequest, url, options, false, |
| - FetchRequest::UseDefaultOriginRestrictionForType, |
| - RedirectStatus::FollowedRedirect); |
| + ResourceRequestBlockedReason blockedReason = canRequestInternal( |
| + type, resourceRequest, url, options, ReportingPolicy::Report, |
| + FetchRequest::UseDefaultOriginRestrictionForType, |
| + RedirectStatus::FollowedRedirect); |
| if (blockedReason != ResourceRequestBlockedReason::None) { |
| InspectorInstrumentation::didBlockRequest( |
| frame(), resourceRequest, masterDocumentLoader(), options.initiatorInfo, |
| @@ -687,7 +688,7 @@ ResourceRequestBlockedReason FrameFetchContext::canRequestInternal( |
| const ResourceRequest& resourceRequest, |
| const KURL& url, |
| const ResourceLoaderOptions& options, |
| - bool forPreload, |
| + ReportingPolicy reportingPolicy, |
| FetchRequest::OriginRestriction originRestriction, |
| ResourceRequest::RedirectStatus redirectStatus) const { |
| if (InspectorInstrumentation::shouldBlockRequest(frame(), resourceRequest)) |
| @@ -699,7 +700,7 @@ ResourceRequestBlockedReason FrameFetchContext::canRequestInternal( |
| if (originRestriction != FetchRequest::NoOriginRestriction && |
| securityOrigin && !securityOrigin->canDisplay(url)) { |
| - if (!forPreload) |
| + if (reportingPolicy == ReportingPolicy::Report) |
| FrameLoader::reportLocalLoadFailed(frame(), url.elidedString()); |
| RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::requestResource URL was not " |
| "allowed by SecurityOrigin::canDisplay"; |
| @@ -749,8 +750,9 @@ ResourceRequestBlockedReason FrameFetchContext::canRequestInternal( |
| // Don't send CSP messages for preloads, we might never actually display those |
|
yhirano
2017/02/07 08:34:06
This comment should be moved to caller now.
Yoav Weiss
2017/02/07 09:10:27
agreed
|
| // items. |
|
kinuko
2017/02/07 08:20:26
nit: update the comment?
|
| ContentSecurityPolicy::ReportingStatus cspReporting = |
| - forPreload ? ContentSecurityPolicy::SuppressReport |
| - : ContentSecurityPolicy::SendReport; |
| + (reportingPolicy == ReportingPolicy::SuppressReporting) |
| + ? ContentSecurityPolicy::SuppressReport |
| + : ContentSecurityPolicy::SendReport; |
| if (m_document) { |
| DCHECK(m_document->contentSecurityPolicy()); |
| @@ -807,8 +809,9 @@ ResourceRequestBlockedReason FrameFetchContext::canRequestInternal( |
| // mixed content with a CSP policy, they don't get a warning. They'll still |
| // get a warning in the console about CSP blocking the load. |
| MixedContentChecker::ReportingStatus mixedContentReporting = |
| - forPreload ? MixedContentChecker::SuppressReport |
| - : MixedContentChecker::SendReport; |
| + (reportingPolicy == ReportingPolicy::SuppressReporting) |
| + ? MixedContentChecker::SuppressReport |
| + : MixedContentChecker::SendReport; |
| if (MixedContentChecker::shouldBlockFetch(frame(), resourceRequest, url, |
| mixedContentReporting)) |
| return ResourceRequestBlockedReason::MixedContent; |