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 #ifndef SubresourceIntegrity_h | 5 #ifndef SubresourceIntegrity_h |
6 #define SubresourceIntegrity_h | 6 #define SubresourceIntegrity_h |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "core/fetch/IntegrityMetadata.h" | 10 #include "core/fetch/IntegrityMetadata.h" |
11 #include "platform/Crypto.h" | 11 #include "platform/Crypto.h" |
12 #include "wtf/Allocator.h" | 12 #include "wtf/Allocator.h" |
13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class Document; | |
18 class Element; | 17 class Element; |
| 18 class ExecutionContext; |
19 class KURL; | 19 class KURL; |
20 class Resource; | 20 class Resource; |
21 | 21 |
22 class CORE_EXPORT SubresourceIntegrity { | 22 class CORE_EXPORT SubresourceIntegrity { |
23 STATIC_ONLY(SubresourceIntegrity); | 23 STATIC_ONLY(SubresourceIntegrity); |
24 | 24 |
25 public: | 25 public: |
26 enum IntegrityParseResult { | 26 enum IntegrityParseResult { |
27 IntegrityParseValidResult, | 27 IntegrityParseValidResult, |
28 IntegrityParseNoValidResult | 28 IntegrityParseNoValidResult |
(...skipping 10 matching lines...) Expand all Loading... |
39 static bool CheckSubresourceIntegrity(const IntegrityMetadataSet&, | 39 static bool CheckSubresourceIntegrity(const IntegrityMetadataSet&, |
40 const Element&, | 40 const Element&, |
41 const char* content, | 41 const char* content, |
42 size_t, | 42 size_t, |
43 const KURL& resourceUrl, | 43 const KURL& resourceUrl, |
44 const Resource&); | 44 const Resource&); |
45 static bool CheckSubresourceIntegrity(const String&, | 45 static bool CheckSubresourceIntegrity(const String&, |
46 const char*, | 46 const char*, |
47 size_t, | 47 size_t, |
48 const KURL& resourceUrl, | 48 const KURL& resourceUrl, |
49 Document&, | 49 ExecutionContext&, |
50 WTF::String&); | 50 WTF::String&); |
51 static bool CheckSubresourceIntegrity(const IntegrityMetadataSet&, | 51 static bool CheckSubresourceIntegrity(const IntegrityMetadataSet&, |
52 const char*, | 52 const char*, |
53 size_t, | 53 size_t, |
54 const KURL& resourceUrl, | 54 const KURL& resourceUrl, |
55 Document&, | 55 ExecutionContext&, |
56 WTF::String&); | 56 WTF::String&); |
57 | 57 |
58 // The IntegrityMetadataSet arguments are out parameters which contain the | 58 // The IntegrityMetadataSet arguments are out parameters which contain the |
59 // set of all valid, parsed metadata from |attribute|. | 59 // set of all valid, parsed metadata from |attribute|. |
60 static IntegrityParseResult parseIntegrityAttribute( | 60 static IntegrityParseResult parseIntegrityAttribute( |
61 const WTF::String& attribute, | 61 const WTF::String& attribute, |
62 IntegrityMetadataSet&); | 62 IntegrityMetadataSet&); |
63 static IntegrityParseResult parseIntegrityAttribute( | 63 static IntegrityParseResult parseIntegrityAttribute( |
64 const WTF::String& attribute, | 64 const WTF::String& attribute, |
65 IntegrityMetadataSet&, | 65 IntegrityMetadataSet&, |
66 Document*); | 66 ExecutionContext*); |
67 | 67 |
68 private: | 68 private: |
69 friend class SubresourceIntegrityTest; | 69 friend class SubresourceIntegrityTest; |
70 FRIEND_TEST_ALL_PREFIXES(SubresourceIntegrityTest, Parsing); | 70 FRIEND_TEST_ALL_PREFIXES(SubresourceIntegrityTest, Parsing); |
71 FRIEND_TEST_ALL_PREFIXES(SubresourceIntegrityTest, ParseAlgorithm); | 71 FRIEND_TEST_ALL_PREFIXES(SubresourceIntegrityTest, ParseAlgorithm); |
72 FRIEND_TEST_ALL_PREFIXES(SubresourceIntegrityTest, Prioritization); | 72 FRIEND_TEST_ALL_PREFIXES(SubresourceIntegrityTest, Prioritization); |
73 | 73 |
74 enum AlgorithmParseResult { | 74 enum AlgorithmParseResult { |
75 AlgorithmValid, | 75 AlgorithmValid, |
76 AlgorithmUnparsable, | 76 AlgorithmUnparsable, |
77 AlgorithmUnknown | 77 AlgorithmUnknown |
78 }; | 78 }; |
79 | 79 |
80 static HashAlgorithm getPrioritizedHashFunction(HashAlgorithm, HashAlgorithm); | 80 static HashAlgorithm getPrioritizedHashFunction(HashAlgorithm, HashAlgorithm); |
81 static AlgorithmParseResult parseAlgorithm(const UChar*& begin, | 81 static AlgorithmParseResult parseAlgorithm(const UChar*& begin, |
82 const UChar* end, | 82 const UChar* end, |
83 HashAlgorithm&); | 83 HashAlgorithm&); |
84 static bool parseDigest(const UChar*& begin, | 84 static bool parseDigest(const UChar*& begin, |
85 const UChar* end, | 85 const UChar* end, |
86 String& digest); | 86 String& digest); |
87 }; | 87 }; |
88 | 88 |
89 } // namespace blink | 89 } // namespace blink |
90 | 90 |
91 #endif | 91 #endif |
OLD | NEW |