| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef SchemeRegistry_h | 27 #ifndef SchemeRegistry_h |
| 28 #define SchemeRegistry_h | 28 #define SchemeRegistry_h |
| 29 | 29 |
| 30 #include "platform/PlatformExport.h" | 30 #include "platform/PlatformExport.h" |
| 31 #include "wtf/HashMap.h" |
| 31 #include "wtf/HashSet.h" | 32 #include "wtf/HashSet.h" |
| 32 #include "wtf/text/StringHash.h" | 33 #include "wtf/text/StringHash.h" |
| 33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 typedef HashSet<String, CaseFoldingHash> URLSchemesMap; | 38 using URLSchemesSet = HashSet<String, CaseFoldingHash>; |
| 39 |
| 40 template <typename T> |
| 41 using URLSchemesMap = HashMap<String, T, CaseFoldingHash>; |
| 38 | 42 |
| 39 class PLATFORM_EXPORT SchemeRegistry { | 43 class PLATFORM_EXPORT SchemeRegistry { |
| 40 public: | 44 public: |
| 41 static void registerURLSchemeAsLocal(const String&); | 45 static void registerURLSchemeAsLocal(const String&); |
| 42 static void removeURLSchemeRegisteredAsLocal(const String&); | 46 static void removeURLSchemeRegisteredAsLocal(const String&); |
| 43 static const URLSchemesMap& localSchemes(); | 47 static const URLSchemesSet& localSchemes(); |
| 44 | 48 |
| 45 static bool shouldTreatURLSchemeAsLocal(const String&); | 49 static bool shouldTreatURLSchemeAsLocal(const String&); |
| 46 | 50 |
| 47 // Secure schemes do not trigger mixed content warnings. For example, | 51 // Secure schemes do not trigger mixed content warnings. For example, |
| 48 // https and data are secure schemes because they cannot be corrupted by | 52 // https and data are secure schemes because they cannot be corrupted by |
| 49 // active network attackers. | 53 // active network attackers. |
| 50 static void registerURLSchemeAsSecure(const String&); | 54 static void registerURLSchemeAsSecure(const String&); |
| 51 static bool shouldTreatURLSchemeAsSecure(const String&); | 55 static bool shouldTreatURLSchemeAsSecure(const String&); |
| 52 | 56 |
| 53 static void registerURLSchemeAsNoAccess(const String&); | 57 static void registerURLSchemeAsNoAccess(const String&); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 80 | 84 |
| 81 // Serialize the registered schemes in a comma-separated list. | 85 // Serialize the registered schemes in a comma-separated list. |
| 82 static String listOfCORSEnabledURLSchemes(); | 86 static String listOfCORSEnabledURLSchemes(); |
| 83 | 87 |
| 84 // "Legacy" schemes (e.g. 'ftp:', 'gopher:') which we might want to treat di
fferently from "webby" schemes. | 88 // "Legacy" schemes (e.g. 'ftp:', 'gopher:') which we might want to treat di
fferently from "webby" schemes. |
| 85 static void registerURLSchemeAsLegacy(const String& scheme); | 89 static void registerURLSchemeAsLegacy(const String& scheme); |
| 86 static bool shouldTreatURLSchemeAsLegacy(const String& scheme); | 90 static bool shouldTreatURLSchemeAsLegacy(const String& scheme); |
| 87 | 91 |
| 88 // Allow resources from some schemes to load on a page, regardless of its | 92 // Allow resources from some schemes to load on a page, regardless of its |
| 89 // Content Security Policy. | 93 // Content Security Policy. |
| 90 static void registerURLSchemeAsBypassingContentSecurityPolicy(const String&
scheme); | 94 // This enum should be kept in sync with public/web/WebSecurityPolicy.h. |
| 95 enum PolicyAreas : uint32_t { |
| 96 PolicyAreaNone = 0, |
| 97 PolicyAreaImage = 1 << 0, |
| 98 PolicyAreaStyle = 1 << 1, |
| 99 // Add more policy areas as needed by clients. |
| 100 PolicyAreaAll = ~static_cast<uint32_t>(0), |
| 101 }; |
| 102 static void registerURLSchemeAsBypassingContentSecurityPolicy(const String&
scheme, PolicyAreas = PolicyAreaAll); |
| 91 static void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const
String& scheme); | 103 static void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const
String& scheme); |
| 92 static bool schemeShouldBypassContentSecurityPolicy(const String& scheme); | 104 static bool schemeShouldBypassContentSecurityPolicy(const String& scheme, Po
licyAreas = PolicyAreaAll); |
| 93 }; | 105 }; |
| 94 | 106 |
| 95 } // namespace blink | 107 } // namespace blink |
| 96 | 108 |
| 97 #endif // SchemeRegistry_h | 109 #endif // SchemeRegistry_h |
| OLD | NEW |