Home | History | Annotate | Download | only in network
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef ContentSecurityPolicyParsers_h
      6 #define ContentSecurityPolicyParsers_h
      7 
      8 #include "platform/Crypto.h"
      9 #include "platform/PlatformExport.h"
     10 #include "wtf/unicode/Unicode.h"
     11 
     12 namespace blink {
     13 
     14 typedef std::pair<unsigned, DigestValue> CSPHashValue;
     15 
     16 enum ContentSecurityPolicyHeaderType {
     17     ContentSecurityPolicyHeaderTypeReport,
     18     ContentSecurityPolicyHeaderTypeEnforce
     19 };
     20 
     21 enum ContentSecurityPolicyHeaderSource {
     22     ContentSecurityPolicyHeaderSourceHTTP,
     23     ContentSecurityPolicyHeaderSourceMeta
     24 };
     25 
     26 enum ContentSecurityPolicyHashAlgorithm {
     27     ContentSecurityPolicyHashAlgorithmNone = 0,
     28     ContentSecurityPolicyHashAlgorithmSha1 = 1 << 1,
     29     ContentSecurityPolicyHashAlgorithmSha256 = 1 << 2,
     30     ContentSecurityPolicyHashAlgorithmSha384 = 1 << 3,
     31     ContentSecurityPolicyHashAlgorithmSha512 = 1 << 4
     32 };
     33 
     34 PLATFORM_EXPORT bool isCSPDirectiveNameCharacter(UChar);
     35 PLATFORM_EXPORT bool isCSPDirectiveValueCharacter(UChar);
     36 PLATFORM_EXPORT bool isNonceCharacter(UChar);
     37 PLATFORM_EXPORT bool isSourceCharacter(UChar);
     38 PLATFORM_EXPORT bool isPathComponentCharacter(UChar);
     39 PLATFORM_EXPORT bool isHostCharacter(UChar);
     40 PLATFORM_EXPORT bool isSchemeContinuationCharacter(UChar);
     41 PLATFORM_EXPORT bool isNotASCIISpace(UChar);
     42 PLATFORM_EXPORT bool isNotColonOrSlash(UChar);
     43 PLATFORM_EXPORT bool isMediaTypeCharacter(UChar);
     44 
     45 // Only checks for general Base64 encoded chars, not '=' chars since '=' is
     46 // positional and may only appear at the end of a Base64 encoded string.
     47 PLATFORM_EXPORT bool isBase64EncodedCharacter(UChar);
     48 
     49 } // namespace blink
     50 
     51 #endif
     52