| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014, Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014, Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" | 28 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" |
| 29 | 29 |
| 30 #include "bindings/v8/ExceptionState.h" | 30 #include "bindings/v8/ExceptionState.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 34 #include "core/frame/Navigator.h" | 34 #include "core/frame/Navigator.h" |
| 35 #include "core/page/Page.h" | 35 #include "core/page/Page.h" |
| 36 #include "wtf/HashSet.h" | 36 #include "wtf/HashSet.h" |
| 37 #include "wtf/text/StringBuilder.h" |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 static HashSet<String>* protocolWhitelist; | 41 static HashSet<String>* protocolWhitelist; |
| 41 | 42 |
| 42 static void initProtocolHandlerWhitelist() | 43 static void initProtocolHandlerWhitelist() |
| 43 { | 44 { |
| 44 protocolWhitelist = new HashSet<String>; | 45 protocolWhitelist = new HashSet<String>; |
| 45 static const char* const protocols[] = { | 46 static const char* const protocols[] = { |
| 46 "bitcoin", | 47 "bitcoin", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return false; | 91 return false; |
| 91 } | 92 } |
| 92 | 93 |
| 93 return true; | 94 return true; |
| 94 } | 95 } |
| 95 | 96 |
| 96 static bool isProtocolWhitelisted(const String& scheme) | 97 static bool isProtocolWhitelisted(const String& scheme) |
| 97 { | 98 { |
| 98 if (!protocolWhitelist) | 99 if (!protocolWhitelist) |
| 99 initProtocolHandlerWhitelist(); | 100 initProtocolHandlerWhitelist(); |
| 100 return protocolWhitelist->contains(scheme); | 101 |
| 102 StringBuilder builder; |
| 103 unsigned length = scheme.length(); |
| 104 for (unsigned i = 0; i < length; ++i) |
| 105 builder.append(toASCIILower(scheme[i])); |
| 106 |
| 107 return protocolWhitelist->contains(builder.toString()); |
| 101 } | 108 } |
| 102 | 109 |
| 103 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth
od, ExceptionState& exceptionState) | 110 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth
od, ExceptionState& exceptionState) |
| 104 { | 111 { |
| 105 if (scheme.startsWith("web+")) { | 112 if (scheme.startsWith("web+")) { |
| 106 // The specification requires that the length of scheme is at least five
characteres (including 'web+' prefix). | 113 // The specification requires that the length of scheme is at least five
characteres (including 'web+' prefix). |
| 107 if (scheme.length() >= 5 && isValidProtocol(scheme)) | 114 if (scheme.length() >= 5 && isValidProtocol(scheme)) |
| 108 return true; | 115 return true; |
| 109 if (!isValidProtocol(scheme)) | 116 if (!isValidProtocol(scheme)) |
| 110 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no
t a valid protocol."); | 117 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no
t a valid protocol."); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 { | 230 { |
| 224 return "NavigatorContentUtils"; | 231 return "NavigatorContentUtils"; |
| 225 } | 232 } |
| 226 | 233 |
| 227 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils
Client> client) | 234 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils
Client> client) |
| 228 { | 235 { |
| 229 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName
(), NavigatorContentUtils::create(client)); | 236 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName
(), NavigatorContentUtils::create(client)); |
| 230 } | 237 } |
| 231 | 238 |
| 232 } // namespace WebCore | 239 } // namespace WebCore |
| OLD | NEW |