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

Unified Diff: third_party/WebKit/Source/core/loader/FrameFetchContext.cpp

Issue 2415373002: Loading: bulk style errors fix in core/loader (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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 2864434de910ca3e42efc58728854fa8f5544e3b..8da9e294e34db20cb2470809582abad0cb3dd2c2 100644
--- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -234,9 +234,10 @@ void FrameFetchContext::addAdditionalRequestHeaders(ResourceRequest& request,
request.addHTTPOriginIfNeeded(outgoingOrigin.get());
}
- if (m_document)
+ if (m_document) {
request.setExternalRequestStateFromRequestorAddressSpace(
m_document->addressSpace());
+ }
// The remaining modifications are only necessary for HTTP and HTTPS.
if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily())
@@ -388,11 +389,12 @@ void FrameFetchContext::dispatchWillSendRequest(
// For initial requests, prepareRequest() is called in
// willStartLoadingResource(), before revalidation policy is determined. That
// call doesn't exist for redirects, so call preareRequest() here.
- if (!redirectResponse.isNull())
+ if (!redirectResponse.isNull()) {
prepareRequest(request);
- else
+ } else {
frame()->loader().progress().willStartLoading(identifier,
request.priority());
+ }
TRACE_EVENT_INSTANT1(
"devtools.timeline", "ResourceSendRequest", TRACE_EVENT_SCOPE_THREAD,
"data", InspectorSendRequestEvent::data(identifier, frame(), request));
@@ -480,10 +482,11 @@ void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(
resource->options().initiatorInfo);
InspectorInstrumentation::markResourceAsCached(frame(), identifier);
- if (!resource->response().isNull())
+ if (!resource->response().isNull()) {
dispatchDidReceiveResponseInternal(identifier, resource->response(),
frameType, requestContext, resource,
LinkLoader::DoNotLoadResources);
+ }
if (resource->encodedSize() > 0)
dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0);
@@ -521,11 +524,12 @@ void FrameFetchContext::willStartLoadingResource(unsigned long identifier,
if (!m_documentLoader || m_documentLoader->fetcher()->archive() ||
!request.url().isValid())
return;
- if (type == Resource::MainResource)
+ if (type == Resource::MainResource) {
m_documentLoader->applicationCacheHost()->willStartLoadingMainResource(
request);
- else
+ } else {
m_documentLoader->applicationCacheHost()->willStartLoadingResource(request);
+ }
}
void FrameFetchContext::didLoadResource(Resource* resource) {
@@ -554,16 +558,17 @@ void FrameFetchContext::printAccessDeniedMessage(const KURL& url) const {
return;
String message;
- if (!m_document || m_document->url().isNull())
+ if (!m_document || m_document->url().isNull()) {
message = "Unsafe attempt to load URL " + url.elidedString() + '.';
- else if (url.isLocalFile() || m_document->url().isLocalFile())
+ } else if (url.isLocalFile() || m_document->url().isLocalFile()) {
message = "Unsafe attempt to load URL " + url.elidedString() +
" from frame with URL " + m_document->url().elidedString() +
". 'file:' URLs are treated as unique security origins.\n";
- else
+ } else {
message = "Unsafe attempt to load URL " + url.elidedString() +
" from frame with URL " + m_document->url().elidedString() +
". Domains, protocols and ports must match.\n";
+ }
frame()->document()->addConsoleMessage(ConsoleMessage::create(
SecurityMessageSource, ErrorMessageLevel, message));
@@ -580,10 +585,11 @@ bool FrameFetchContext::canRequest(
canRequestInternal(type, resourceRequest, url, options, forPreload,
originRestriction, resourceRequest.redirectStatus());
if (reason != ResourceRequestBlockedReasonNone) {
- if (!forPreload)
+ if (!forPreload) {
InspectorInstrumentation::didBlockRequest(frame(), resourceRequest,
masterDocumentLoader(),
options.initiatorInfo, reason);
+ }
return false;
}
return true;
@@ -716,13 +722,15 @@ ResourceRequestBlockedReason FrameFetchContext::canRequestInternal(
DCHECK(frame()->document());
if (SchemeRegistry::shouldTreatURLSchemeAsLegacy(url.protocol()) &&
!SchemeRegistry::shouldTreatURLSchemeAsLegacy(
- frame()->document()->getSecurityOrigin()->protocol()))
+ frame()->document()->getSecurityOrigin()->protocol())) {
UseCounter::count(frame()->document(),
UseCounter::LegacyProtocolEmbeddedAsSubresource);
- if (!url.user().isEmpty() || !url.pass().isEmpty())
+ }
+ if (!url.user().isEmpty() || !url.pass().isEmpty()) {
UseCounter::count(
frame()->document(),
UseCounter::RequestedSubresourceWithEmbeddedCredentials);
+ }
}
// Check for mixed content. We do this second-to-last so that when folks block
@@ -764,9 +772,10 @@ bool FrameFetchContext::isControlledByServiceWorker() const {
if (getSecurityOrigin() && getSecurityOrigin()->hasSuborigin())
return false;
- if (m_documentLoader)
+ if (m_documentLoader) {
return frame()->loader().client()->isControlledByServiceWorker(
*m_documentLoader);
+ }
// m_documentLoader is null while loading resources from an HTML import. In
// such cases whether the request is controlled by ServiceWorker or not is
// determined by the document loader of the frame.
@@ -828,9 +837,10 @@ void FrameFetchContext::addConsoleMessage(const String& message,
LogMessageType messageType) const {
MessageLevel level = messageType == LogWarningMessage ? WarningMessageLevel
: ErrorMessageLevel;
- if (frame()->document())
+ if (frame()->document()) {
frame()->document()->addConsoleMessage(
ConsoleMessage::create(JSMessageSource, level, message));
+ }
}
SecurityOrigin* FrameFetchContext::getSecurityOrigin() const {
@@ -857,9 +867,10 @@ void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) {
m_document->clientHintsPreferences().shouldSendViewportWidth() ||
fetchRequest.clientHintsPreferences().shouldSendViewportWidth();
- if (shouldSendDPR)
+ if (shouldSendDPR) {
fetchRequest.mutableResourceRequest().addHTTPHeaderField(
"DPR", AtomicString(String::number(m_document->devicePixelRatio())));
+ }
if (shouldSendResourceWidth) {
FetchRequest::ResourceWidth resourceWidth = fetchRequest.getResourceWidth();
@@ -871,10 +882,11 @@ void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) {
}
}
- if (shouldSendViewportWidth && frame()->view())
+ if (shouldSendViewportWidth && frame()->view()) {
fetchRequest.mutableResourceRequest().addHTTPHeaderField(
"Viewport-Width",
AtomicString(String::number(frame()->view()->viewportWidth())));
+ }
}
void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type,
@@ -982,9 +994,10 @@ void FrameFetchContext::dispatchDidReceiveResponseInternal(
frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy,
LinkLoader::LoadAll, nullptr);
- if (response.hasMajorCertificateErrors())
+ if (response.hasMajorCertificateErrors()) {
MixedContentChecker::handleCertificateError(frame(), response, frameType,
requestContext);
+ }
frame()->loader().progress().incrementProgress(identifier, response);
frame()->loader().client()->dispatchDidReceiveResponse(response);

Powered by Google App Engine
This is Rietveld 408576698