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

Unified Diff: Source/core/frame/csp/CSPDirectiveList.cpp

Issue 1009583003: Add CSP header for resources with an active policy (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add return statement to avoid compiler error Created 5 years, 9 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
« no previous file with comments | « Source/core/frame/csp/CSPDirectiveList.h ('k') | Source/core/frame/csp/ContentSecurityPolicy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/csp/CSPDirectiveList.cpp
diff --git a/Source/core/frame/csp/CSPDirectiveList.cpp b/Source/core/frame/csp/CSPDirectiveList.cpp
index 1f8bd418ed1300c5a8c2fd50f4e55857023ce2b6..2354f9d1905494abcdd5c0e9e30139a05e877613 100644
--- a/Source/core/frame/csp/CSPDirectiveList.cpp
+++ b/Source/core/frame/csp/CSPDirectiveList.cpp
@@ -414,6 +414,39 @@ const String& CSPDirectiveList::pluginTypesText() const
return m_pluginTypes->text();
}
+bool CSPDirectiveList::shouldSendCSPHeader(Resource::Type type) const
+{
+ switch (type) {
+ case Resource::XSLStyleSheet:
+ ASSERT(RuntimeEnabledFeatures::xsltEnabled());
+ return !!operativeDirective(m_scriptSrc.get());
+ case Resource::Script:
+ case Resource::ImportResource:
+ return !!operativeDirective(m_scriptSrc.get());
+ case Resource::CSSStyleSheet:
+ return !!operativeDirective(m_styleSrc.get());
+ case Resource::SVGDocument:
+ case Resource::Image:
+ return !!operativeDirective(m_imgSrc.get());
+ case Resource::Font:
+ return !!operativeDirective(m_fontSrc.get());
+ case Resource::Media:
+ case Resource::TextTrack:
+ return !!operativeDirective(m_mediaSrc.get());
+ case Resource::Raw:
+ // This request could be for a plugin, a child frame, a worker, or
+ // something else. If there any potentially relevant policies,
+ // send the CSP header; sending it unnecessarily can't hurt.
+ return !!operativeDirective(m_objectSrc.get()) || !!m_pluginTypes.get() || !!operativeDirective(m_childSrc.get()) || !!operativeDirective(m_frameSrc.get()) || !!operativeDirective(m_connectSrc.get()) || !!operativeDirective(m_manifestSrc.get()) || !!m_formAction.get();
+ case Resource::MainResource:
+ case Resource::LinkPrefetch:
+ case Resource::LinkSubresource:
+ return false;
+ }
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
// policy = directive-list
// directive-list = [ directive *( ";" [ directive ] ) ]
//
« no previous file with comments | « Source/core/frame/csp/CSPDirectiveList.h ('k') | Source/core/frame/csp/ContentSecurityPolicy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698