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/Crypto.h" | |
abarth-chromium
2014/04/01 23:46:48
You already addes this to CSPSourceList.h. No nee
jww
2014/04/02 01:11:50
Done.
| |
10 #include "platform/ParsingUtilities.h" | 11 #include "platform/ParsingUtilities.h" |
11 #include "platform/weborigin/KURL.h" | 12 #include "platform/weborigin/KURL.h" |
12 #include "platform/weborigin/SecurityOrigin.h" | 13 #include "platform/weborigin/SecurityOrigin.h" |
13 #include "wtf/HashSet.h" | 14 #include "wtf/HashSet.h" |
14 #include "wtf/StringHasher.h" | |
15 #include "wtf/text/Base64.h" | 15 #include "wtf/text/Base64.h" |
16 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
17 | 17 |
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 { | 18 namespace WebCore { |
47 | 19 |
48 static bool isSourceListNone(const UChar* begin, const UChar* end) | 20 static bool isSourceListNone(const UChar* begin, const UChar* end) |
49 { | 21 { |
50 skipWhile<UChar, isASCIISpace>(begin, end); | 22 skipWhile<UChar, isASCIISpace>(begin, end); |
51 | 23 |
52 const UChar* position = begin; | 24 const UChar* position = begin; |
53 skipWhile<UChar, isSourceCharacter>(position, end); | 25 skipWhile<UChar, isSourceCharacter>(position, end); |
54 if (!equalIgnoringCase("'none'", begin, position - begin)) | 26 if (!equalIgnoringCase("'none'", begin, position - begin)) |
55 return false; | 27 return false; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 } | 479 } |
508 | 480 |
509 void CSPSourceList::addSourceHash(const ContentSecurityPolicyHashAlgorithm& algo rithm, const DigestValue& hash) | 481 void CSPSourceList::addSourceHash(const ContentSecurityPolicyHashAlgorithm& algo rithm, const DigestValue& hash) |
510 { | 482 { |
511 m_hashes.add(CSPHashValue(algorithm, hash)); | 483 m_hashes.add(CSPHashValue(algorithm, hash)); |
512 m_hashAlgorithmsUsed |= algorithm; | 484 m_hashAlgorithmsUsed |= algorithm; |
513 } | 485 } |
514 | 486 |
515 | 487 |
516 } // namespace WebCore | 488 } // namespace WebCore |
OLD | NEW |