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

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

Issue 2022083002: Move 'frame-src' CSP checks into FrameFetchContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: redirects 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/DocumentLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/DocumentLoader.cpp b/third_party/WebKit/Source/core/loader/DocumentLoader.cpp
index 2a76e14272ea498a29abb8fc6931284c241d6a05..2d914d1efd502d08f4a124c9f792bf0162ae8ff7 100644
--- a/third_party/WebKit/Source/core/loader/DocumentLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/DocumentLoader.cpp
@@ -308,7 +308,7 @@ void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque
m_fetcher->stopFetching();
return;
}
- if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteData(), this, CheckContentSecurityPolicy, m_navigationType, NavigationPolicyCurrentTab, replacesCurrentHistoryItem(), isClientRedirect())) {
+ if (!frameLoader()->shouldContinueForNavigationPolicy(m_request, SubstituteData(), this, m_navigationType, NavigationPolicyCurrentTab, replacesCurrentHistoryItem(), isClientRedirect())) {
m_fetcher->stopFetching();
return;
}
@@ -608,7 +608,14 @@ bool DocumentLoader::maybeLoadEmpty()
return true;
}
-void DocumentLoader::startLoadingMainResource()
+void DocumentLoader::loadUnique()
+{
+ m_request = ResourceRequest(SecurityOrigin::urlWithUniqueSecurityOrigin());
+ m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String());
+ finishedLoading(monotonicallyIncreasingTime());
+}
+
+void DocumentLoader::startLoadingMainResource(ContentSecurityPolicyDisposition cspDisposition)
{
timing().markNavigationStart();
ASSERT(!m_mainResource);
@@ -625,10 +632,15 @@ void DocumentLoader::startLoadingMainResource()
DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
(DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext));
FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, mainResourceLoadOptions);
+ fetchRequest.setContentSecurityCheck(cspDisposition);
+
m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData);
if (!m_mainResource) {
- m_request = ResourceRequest(blankURL());
- maybeLoadEmpty();
+ // If we block a main resource request, ensure that the resulting frame's
+ // origin is unique, and that the redirect list is up-to-date with the
+ // resource we actually commit:
+ loadUnique();
+ appendRedirect(SecurityOrigin::urlWithUniqueSecurityOrigin());
Mike West 2016/06/06 08:40:10 Charlie: It seems reasonable to me to treat blocki
Charlie Reis 2016/06/06 20:43:07 Hmm, that feels weird/unfortunate to me, but maybe
return;
}
// A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.

Powered by Google App Engine
This is Rietveld 408576698