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

Side by Side Diff: third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp

Issue 2612793002: Implement ContentSecurityPolicy on the browser-side. (Closed)
Patch Set: Nit. Created 3 years, 10 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 // 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 "core/frame/csp/SourceListDirective.h" 5 #include "core/frame/csp/SourceListDirective.h"
6 6
7 #include "core/frame/csp/CSPSource.h" 7 #include "core/frame/csp/CSPSource.h"
8 #include "core/frame/csp/ContentSecurityPolicy.h" 8 #include "core/frame/csp/ContentSecurityPolicy.h"
9 #include "platform/network/ContentSecurityPolicyParsers.h" 9 #include "platform/network/ContentSecurityPolicyParsers.h"
10 #include "platform/weborigin/KURL.h" 10 #include "platform/weborigin/KURL.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // have no allowed CSPSources. 689 // have no allowed CSPSources.
690 return allowDynamicOther || !normalizedB.size(); 690 return allowDynamicOther || !normalizedB.size();
691 } 691 }
692 692
693 // If embedding CSP specifies `self`, `self` refers to the embedee's origin. 693 // If embedding CSP specifies `self`, `self` refers to the embedee's origin.
694 HeapVector<Member<CSPSource>> normalizedA = 694 HeapVector<Member<CSPSource>> normalizedA =
695 getSources(other[0]->m_policy->getSelfSource()); 695 getSources(other[0]->m_policy->getSelfSource());
696 return CSPSource::firstSubsumesSecond(normalizedA, normalizedB); 696 return CSPSource::firstSubsumesSecond(normalizedA, normalizedB);
697 } 697 }
698 698
699 WebContentSecurityPolicySourceList SourceListDirective::expose() const {
700 WebContentSecurityPolicySourceList sourceList;
701 sourceList.allowSelf = m_allowSelf;
702 sourceList.allowStar = m_allowStar;
703 WebVector<WebContentSecurityPolicySourceExpression> list(m_list.size());
704 for (size_t i = 0; i < m_list.size(); ++i)
705 list[i] = m_list[i]->expose();
706 sourceList.sources.swap(list);
707 return sourceList;
708 }
709
699 bool SourceListDirective::subsumesNoncesAndHashes( 710 bool SourceListDirective::subsumesNoncesAndHashes(
700 const HashSet<String>& nonces, 711 const HashSet<String>& nonces,
701 const HashSet<CSPHashValue> hashes) const { 712 const HashSet<CSPHashValue> hashes) const {
702 for (const auto& nonce : nonces) { 713 for (const auto& nonce : nonces) {
703 if (!m_nonces.contains(nonce)) 714 if (!m_nonces.contains(nonce))
704 return false; 715 return false;
705 } 716 }
706 for (const auto& hash : hashes) { 717 for (const auto& hash : hashes) {
707 if (!m_hashes.contains(hash)) 718 if (!m_hashes.contains(hash))
708 return false; 719 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 return normalized; 820 return normalized;
810 } 821 }
811 822
812 DEFINE_TRACE(SourceListDirective) { 823 DEFINE_TRACE(SourceListDirective) {
813 visitor->trace(m_policy); 824 visitor->trace(m_policy);
814 visitor->trace(m_list); 825 visitor->trace(m_list);
815 CSPDirective::trace(visitor); 826 CSPDirective::trace(visitor);
816 } 827 }
817 828
818 } // namespace blink 829 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698