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

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 1299493003: Attach mixed content status to resource requests when sent to devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 Resource* ResourceFetcher::cachedResource(const KURL& resourceURL) const 206 Resource* ResourceFetcher::cachedResource(const KURL& resourceURL) const
207 { 207 {
208 KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL); 208 KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL);
209 return m_documentResources.get(url).get(); 209 return m_documentResources.get(url).get();
210 } 210 }
211 211
212 bool ResourceFetcher::canAccessResource(Resource* resource, SecurityOrigin* sour ceOrigin, const KURL& url, AccessControlLoggingDecision logErrorsDecision) const 212 bool ResourceFetcher::canAccessResource(Resource* resource, SecurityOrigin* sour ceOrigin, const KURL& url, AccessControlLoggingDecision logErrorsDecision) const
213 { 213 {
214 // Redirects can change the response URL different from one of request. 214 // Redirects can change the response URL different from one of request.
215 bool forPreload = resource->isUnusedPreload(); 215 bool forPreload = resource->isUnusedPreload();
216 if (!context().canRequest(resource->type(), resource->resourceRequest(), url , resource->options(), forPreload, FetchRequest::UseDefaultOriginRestrictionForT ype)) 216 if (!context().canRequest(resource->type(), resource->mutableResourceRequest (), url, resource->options(), forPreload, FetchRequest::UseDefaultOriginRestrict ionForType))
217 return false; 217 return false;
218 218
219 if (!sourceOrigin) 219 if (!sourceOrigin)
220 sourceOrigin = context().securityOrigin(); 220 sourceOrigin = context().securityOrigin();
221 221
222 if (sourceOrigin->canRequestNoSuborigin(url)) 222 if (sourceOrigin->canRequestNoSuborigin(url))
223 return true; 223 return true;
224 224
225 String errorDescription; 225 String errorDescription;
226 if (!resource->passesAccessControlCheck(sourceOrigin, errorDescription)) { 226 if (!resource->passesAccessControlCheck(sourceOrigin, errorDescription)) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", urlForTrace Event(url)); 296 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", urlForTrace Event(url));
297 297
298 WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource '%s', charset '%s ', priority=%d, forPreload=%u, type=%s", url.elidedString().latin1().data(), req uest.charset().latin1().data(), request.priority(), request.forPreload(), Resour ceTypeName(factory.type())); 298 WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource '%s', charset '%s ', priority=%d, forPreload=%u, type=%s", url.elidedString().latin1().data(), req uest.charset().latin1().data(), request.priority(), request.forPreload(), Resour ceTypeName(factory.type()));
299 299
300 // If only the fragment identifiers differ, it is the same resource. 300 // If only the fragment identifiers differ, it is the same resource.
301 url = MemoryCache::removeFragmentIdentifierIfNeeded(url); 301 url = MemoryCache::removeFragmentIdentifierIfNeeded(url);
302 302
303 if (!url.isValid()) 303 if (!url.isValid())
304 return nullptr; 304 return nullptr;
305 305
306 if (!context().canRequest(factory.type(), request.resourceRequest(), url, re quest.options(), request.forPreload(), request.originRestriction())) 306 if (!context().canRequest(factory.type(), request.mutableResourceRequest(), url, request.options(), request.forPreload(), request.originRestriction()))
307 return nullptr; 307 return nullptr;
308 308
309 context().dispatchWillRequestResource(&request); 309 context().dispatchWillRequestResource(&request);
310 310
311 if (!request.forPreload()) { 311 if (!request.forPreload()) {
312 V8DOMActivityLogger* activityLogger = nullptr; 312 V8DOMActivityLogger* activityLogger = nullptr;
313 if (request.options().initiatorInfo.name == FetchInitiatorTypeNames::xml httprequest) 313 if (request.options().initiatorInfo.name == FetchInitiatorTypeNames::xml httprequest)
314 activityLogger = V8DOMActivityLogger::currentActivityLogger(); 314 activityLogger = V8DOMActivityLogger::currentActivityLogger();
315 else 315 else
316 activityLogger = V8DOMActivityLogger::currentActivityLoggerIfIsolate dWorld(); 316 activityLogger = V8DOMActivityLogger::currentActivityLoggerIfIsolate dWorld();
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 willTerminateResourceLoader(resource->loader()); 870 willTerminateResourceLoader(resource->loader());
871 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit iatorTypeNames::internal; 871 bool isInternalRequest = resource->options().initiatorInfo.name == FetchInit iatorTypeNames::internal;
872 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); 872 context().dispatchDidFail(resource->identifier(), error, isInternalRequest);
873 } 873 }
874 874
875 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& in itiatorInfo) 875 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& in itiatorInfo)
876 { 876 {
877 context().dispatchWillSendRequest(identifier, request, redirectResponse, ini tiatorInfo); 877 context().dispatchWillSendRequest(identifier, request, redirectResponse, ini tiatorInfo);
878 } 878 }
879 879
880 void ResourceFetcher::didReceiveResponse(const Resource* resource, const Resourc eResponse& response) 880 void ResourceFetcher::didReceiveResponse(Resource* resource, const ResourceRespo nse& response)
881 { 881 {
882 // If the response is fetched via ServiceWorker, the original URL of the res ponse could be different from the URL of the request. 882 // If the response is fetched via ServiceWorker, the original URL of the res ponse could be different from the URL of the request.
883 // We check the URL not to load the resources which are forbidden by the pag e CSP. This behavior is not specified in the CSP specification yet. 883 // We check the URL not to load the resources which are forbidden by the pag e CSP. This behavior is not specified in the CSP specification yet.
884 // FIXME(mkwst): Fix this behavior when the CSP docs are updated. 884 // FIXME(mkwst): Fix this behavior when the CSP docs are updated.
885 if (response.wasFetchedViaServiceWorker()) { 885 if (response.wasFetchedViaServiceWorker()) {
886 const KURL& originalURL = response.originalURLViaServiceWorker(); 886 const KURL& originalURL = response.originalURLViaServiceWorker();
887 if (!originalURL.isEmpty() && !context().canRequest(resource->type(), re source->resourceRequest(), originalURL, resource->options(), false, FetchRequest ::UseDefaultOriginRestrictionForType)) { 887 if (!originalURL.isEmpty() && !context().canRequest(resource->type(), re source->mutableResourceRequest(), originalURL, resource->options(), false, Fetch Request::UseDefaultOriginRestrictionForType)) {
888 resource->loader()->cancel(); 888 resource->loader()->cancel();
889 bool isInternalRequest = resource->options().initiatorInfo.name == F etchInitiatorTypeNames::internal; 889 bool isInternalRequest = resource->options().initiatorInfo.name == F etchInitiatorTypeNames::internal;
890 context().dispatchDidFail(resource->identifier(), ResourceError(erro rDomainBlinkInternal, 0, originalURL.string(), "Unsafe attempt to load URL " + o riginalURL.elidedString() + " fetched by a ServiceWorker."), isInternalRequest); 890 context().dispatchDidFail(resource->identifier(), ResourceError(erro rDomainBlinkInternal, 0, originalURL.string(), "Unsafe attempt to load URL " + o riginalURL.elidedString() + " fetched by a ServiceWorker."), isInternalRequest);
891 return; 891 return;
892 } 892 }
893 } 893 }
894 context().dispatchDidReceiveResponse(resource->identifier(), response, resou rce->loader()); 894 context().dispatchDidReceiveResponse(resource->identifier(), response, resou rce->loader());
895 } 895 }
896 896
897 void ResourceFetcher::didReceiveData(const Resource* resource, const char* data, int dataLength, int encodedDataLength) 897 void ResourceFetcher::didReceiveData(const Resource* resource, const char* data, int dataLength, int encodedDataLength)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 visitor->trace(m_archiveResourceCollection); 1103 visitor->trace(m_archiveResourceCollection);
1104 visitor->trace(m_loaders); 1104 visitor->trace(m_loaders);
1105 visitor->trace(m_nonBlockingLoaders); 1105 visitor->trace(m_nonBlockingLoaders);
1106 #if ENABLE(OILPAN) 1106 #if ENABLE(OILPAN)
1107 visitor->trace(m_preloads); 1107 visitor->trace(m_preloads);
1108 visitor->trace(m_resourceTimingInfoMap); 1108 visitor->trace(m_resourceTimingInfoMap);
1109 #endif 1109 #endif
1110 } 1110 }
1111 1111
1112 } 1112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698