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

Side by Side Diff: Source/core/frame/csp/CSPDirectiveList.cpp

Issue 1136843011: Revert of Add CSP header for resources with an active policy (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « Source/core/frame/csp/CSPDirectiveList.h ('k') | Source/core/frame/csp/ContentSecurityPolicy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/frame/csp/CSPDirectiveList.h" 6 #include "core/frame/csp/CSPDirectiveList.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/SecurityContext.h" 9 #include "core/dom/SecurityContext.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 { 407 {
408 return checkHash(operativeDirective(m_styleSrc.get()), hashValue); 408 return checkHash(operativeDirective(m_styleSrc.get()), hashValue);
409 } 409 }
410 410
411 const String& CSPDirectiveList::pluginTypesText() const 411 const String& CSPDirectiveList::pluginTypesText() const
412 { 412 {
413 ASSERT(hasPluginTypes()); 413 ASSERT(hasPluginTypes());
414 return m_pluginTypes->text(); 414 return m_pluginTypes->text();
415 } 415 }
416 416
417 bool CSPDirectiveList::shouldSendCSPHeader(Resource::Type type) const
418 {
419 switch (type) {
420 case Resource::XSLStyleSheet:
421 ASSERT(RuntimeEnabledFeatures::xsltEnabled());
422 return !!operativeDirective(m_scriptSrc.get());
423 case Resource::Script:
424 case Resource::ImportResource:
425 return !!operativeDirective(m_scriptSrc.get());
426 case Resource::CSSStyleSheet:
427 return !!operativeDirective(m_styleSrc.get());
428 case Resource::SVGDocument:
429 case Resource::Image:
430 return !!operativeDirective(m_imgSrc.get());
431 case Resource::Font:
432 return !!operativeDirective(m_fontSrc.get());
433 case Resource::Media:
434 case Resource::TextTrack:
435 return !!operativeDirective(m_mediaSrc.get());
436 case Resource::Raw:
437 // This request could be for a plugin, a child frame, a worker, or
438 // something else. If there any potentially relevant policies,
439 // send the CSP header; sending it unnecessarily can't hurt.
440 return !!operativeDirective(m_objectSrc.get()) || !!m_pluginTypes.get() || !!operativeDirective(m_childSrc.get()) || !!operativeDirective(m_frameSrc.get ()) || !!operativeDirective(m_connectSrc.get()) || !!operativeDirective(m_manife stSrc.get()) || !!m_formAction.get();
441 case Resource::MainResource:
442 case Resource::LinkPrefetch:
443 case Resource::LinkSubresource:
444 return false;
445 }
446 ASSERT_NOT_REACHED();
447 return false;
448 }
449
450 // policy = directive-list 417 // policy = directive-list
451 // directive-list = [ directive *( ";" [ directive ] ) ] 418 // directive-list = [ directive *( ";" [ directive ] ) ]
452 // 419 //
453 void CSPDirectiveList::parse(const UChar* begin, const UChar* end) 420 void CSPDirectiveList::parse(const UChar* begin, const UChar* end)
454 { 421 {
455 m_header = String(begin, end - begin); 422 m_header = String(begin, end - begin);
456 423
457 if (begin == end) 424 if (begin == end)
458 return; 425 return;
459 426
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 enableInsecureRequestsUpgrade(name, value); 736 enableInsecureRequestsUpgrade(name, value);
770 else 737 else
771 m_policy->reportUnsupportedDirective(name); 738 m_policy->reportUnsupportedDirective(name);
772 } else { 739 } else {
773 m_policy->reportUnsupportedDirective(name); 740 m_policy->reportUnsupportedDirective(name);
774 } 741 }
775 } 742 }
776 743
777 744
778 } // namespace blink 745 } // namespace blink
OLDNEW
« 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