| 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 "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/Crypto.h" | 9 #include "platform/Crypto.h" |
| 10 | 10 |
| 11 namespace WTF { | 11 namespace WTF { |
| 12 class String; | 12 class String; |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class Document; | 17 class Document; |
| 18 class Element; | 18 class Element; |
| 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 public: | 23 public: |
| 24 enum IntegrityParseResult { | 24 enum IntegrityParseResult { |
| 25 IntegrityParseValidResult, | 25 IntegrityParseValidResult, |
| 26 IntegrityParseNoValidResult | 26 IntegrityParseNoValidResult |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 static bool CheckSubresourceIntegrity(const Element&, const WTF::String& con
tent, const KURL& resourceUrl, const WTF::String& mimeType, const Resource&); | 29 static bool CheckSubresourceIntegrity(const Element&, const WTF::String& con
tent, const KURL& resourceUrl, const Resource&); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 // FIXME: After the merge with the Chromium repo, this should be refactored | 32 // FIXME: After the merge with the Chromium repo, this should be refactored |
| 33 // to use FRIEND_TEST in base/gtest_prod_util.h. | 33 // to use FRIEND_TEST in base/gtest_prod_util.h. |
| 34 friend class SubresourceIntegrityTest; | 34 friend class SubresourceIntegrityTest; |
| 35 friend class SubresourceIntegrityTest_Parsing_Test; | 35 friend class SubresourceIntegrityTest_Parsing_Test; |
| 36 friend class SubresourceIntegrityTest_ParseAlgorithm_Test; | 36 friend class SubresourceIntegrityTest_ParseAlgorithm_Test; |
| 37 | 37 |
| 38 enum AlgorithmParseResult { | 38 enum AlgorithmParseResult { |
| 39 AlgorithmValid, | 39 AlgorithmValid, |
| 40 AlgorithmUnparsable, | 40 AlgorithmUnparsable, |
| 41 AlgorithmUnknown | 41 AlgorithmUnknown |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 struct IntegrityMetadata { | 44 struct IntegrityMetadata { |
| 45 WTF::String digest; | 45 WTF::String digest; |
| 46 HashAlgorithm algorithm; | 46 HashAlgorithm algorithm; |
| 47 WTF::String type; | |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 static AlgorithmParseResult parseAlgorithm(const UChar*& begin, const UChar*
end, HashAlgorithm&); | 49 static AlgorithmParseResult parseAlgorithm(const UChar*& begin, const UChar*
end, HashAlgorithm&); |
| 51 static bool parseDigest(const UChar*& begin, const UChar* end, String& diges
t); | 50 static bool parseDigest(const UChar*& begin, const UChar* end, String& diges
t); |
| 52 static bool parseMimeType(const UChar*& begin, const UChar* end, String& typ
e); | |
| 53 | 51 |
| 54 static IntegrityParseResult parseIntegrityAttribute(const WTF::String& attri
bute, WTF::Vector<IntegrityMetadata>& metadataList, Document&); | 52 static IntegrityParseResult parseIntegrityAttribute(const WTF::String& attri
bute, WTF::Vector<IntegrityMetadata>& metadataList, Document&); |
| 55 }; | 53 }; |
| 56 | 54 |
| 57 } // namespace blink | 55 } // namespace blink |
| 58 | 56 |
| 59 #endif | 57 #endif |
| OLD | NEW |