| OLD | NEW |
| 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/CSPSourceList.h" | 6 #include "core/frame/csp/CSPSourceList.h" |
| 7 | 7 |
| 8 #include "core/frame/csp/CSPSource.h" | 8 #include "core/frame/csp/CSPSource.h" |
| 9 #include "core/frame/csp/ContentSecurityPolicy.h" | 9 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 10 #include "platform/ParsingUtilities.h" | 10 #include "platform/ParsingUtilities.h" |
| 11 #include "platform/weborigin/KURL.h" | 11 #include "platform/weborigin/KURL.h" |
| 12 #include "platform/weborigin/SecurityOrigin.h" | 12 #include "platform/weborigin/SecurityOrigin.h" |
| 13 #include "wtf/HashSet.h" | 13 #include "wtf/HashSet.h" |
| 14 #include "wtf/StringHasher.h" | |
| 15 #include "wtf/text/Base64.h" | 14 #include "wtf/text/Base64.h" |
| 16 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
| 17 | 16 |
| 18 namespace WTF { | |
| 19 | |
| 20 struct DigestValueHash { | |
| 21 static unsigned hash(const WebCore::DigestValue& v) | |
| 22 { | |
| 23 return StringHasher::computeHash(v.data(), v.size()); | |
| 24 } | |
| 25 static bool equal(const WebCore::DigestValue& a, const WebCore::DigestValue&
b) | |
| 26 { | |
| 27 return a == b; | |
| 28 }; | |
| 29 static const bool safeToCompareToEmptyOrDeleted = true; | |
| 30 }; | |
| 31 template <> | |
| 32 struct DefaultHash<WebCore::DigestValue> { | |
| 33 typedef DigestValueHash Hash; | |
| 34 }; | |
| 35 | |
| 36 template <> | |
| 37 struct DefaultHash<WebCore::ContentSecurityPolicyHashAlgorithm> { | |
| 38 typedef IntHash<WebCore::ContentSecurityPolicyHashAlgorithm> Hash; | |
| 39 }; | |
| 40 template <> | |
| 41 struct HashTraits<WebCore::ContentSecurityPolicyHashAlgorithm> : UnsignedWithZer
oKeyHashTraits<WebCore::ContentSecurityPolicyHashAlgorithm> { | |
| 42 }; | |
| 43 | |
| 44 } // namespace WTF | |
| 45 | |
| 46 namespace WebCore { | 17 namespace WebCore { |
| 47 | 18 |
| 48 static bool isSourceListNone(const UChar* begin, const UChar* end) | 19 static bool isSourceListNone(const UChar* begin, const UChar* end) |
| 49 { | 20 { |
| 50 skipWhile<UChar, isASCIISpace>(begin, end); | 21 skipWhile<UChar, isASCIISpace>(begin, end); |
| 51 | 22 |
| 52 const UChar* position = begin; | 23 const UChar* position = begin; |
| 53 skipWhile<UChar, isSourceCharacter>(position, end); | 24 skipWhile<UChar, isSourceCharacter>(position, end); |
| 54 if (!equalIgnoringCase("'none'", begin, position - begin)) | 25 if (!equalIgnoringCase("'none'", begin, position - begin)) |
| 55 return false; | 26 return false; |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 476 } |
| 506 | 477 |
| 507 void CSPSourceList::addSourceHash(const ContentSecurityPolicyHashAlgorithm& algo
rithm, const DigestValue& hash) | 478 void CSPSourceList::addSourceHash(const ContentSecurityPolicyHashAlgorithm& algo
rithm, const DigestValue& hash) |
| 508 { | 479 { |
| 509 m_hashes.add(CSPHashValue(algorithm, hash)); | 480 m_hashes.add(CSPHashValue(algorithm, hash)); |
| 510 m_hashAlgorithmsUsed |= algorithm; | 481 m_hashAlgorithmsUsed |= algorithm; |
| 511 } | 482 } |
| 512 | 483 |
| 513 | 484 |
| 514 } // namespace WebCore | 485 } // namespace WebCore |
| OLD | NEW |