| 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) 2012, Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2012, 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 11 matching lines...) Expand all Loading... |
| 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 24 * DAMAGE. | 24 * DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" | 28 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" |
| 29 | 29 |
| 30 #if ENABLE(NAVIGATOR_CONTENT_UTILS) | 30 #if ENABLE(NAVIGATOR_CONTENT_UTILS) |
| 31 | 31 |
| 32 #include "bindings/v8/ExceptionMessages.h" | |
| 33 #include "bindings/v8/ExceptionState.h" | 32 #include "bindings/v8/ExceptionState.h" |
| 34 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 35 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/frame/Frame.h" | 35 #include "core/frame/Frame.h" |
| 37 #include "core/frame/Navigator.h" | 36 #include "core/frame/Navigator.h" |
| 38 #include "core/page/Page.h" | 37 #include "core/page/Page.h" |
| 39 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
| 40 | 39 |
| 41 namespace WebCore { | 40 namespace WebCore { |
| 42 | 41 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return protocolWhitelist->contains(scheme); | 103 return protocolWhitelist->contains(scheme); |
| 105 } | 104 } |
| 106 | 105 |
| 107 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth
od, ExceptionState& exceptionState) | 106 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth
od, ExceptionState& exceptionState) |
| 108 { | 107 { |
| 109 if (scheme.startsWith("web+")) { | 108 if (scheme.startsWith("web+")) { |
| 110 // The specification requires that the length of scheme is at least five
characteres (including 'web+' prefix). | 109 // The specification requires that the length of scheme is at least five
characteres (including 'web+' prefix). |
| 111 if (scheme.length() >= 5 && isValidProtocol(scheme)) | 110 if (scheme.length() >= 5 && isValidProtocol(scheme)) |
| 112 return true; | 111 return true; |
| 113 if (!isValidProtocol(scheme)) | 112 if (!isValidProtocol(scheme)) |
| 114 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute
(method, "Navigator", "The scheme '" + scheme + "' is not a valid protocol.")); | 113 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no
t a valid protocol."); |
| 115 else | 114 else |
| 116 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute
(method, "Navigator", "The scheme '" + scheme + "' is less than five characters
long.")); | 115 exceptionState.throwSecurityError("The scheme '" + scheme + "' is le
ss than five characters long."); |
| 117 return false; | 116 return false; |
| 118 } | 117 } |
| 119 | 118 |
| 120 if (isProtocolWhitelisted(scheme)) | 119 if (isProtocolWhitelisted(scheme)) |
| 121 return true; | 120 return true; |
| 122 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute(method,
"Navigator", "The scheme '" + scheme + "' doesn't belong to the protocol whitel
ist. Please prefix non-whitelisted schemes with the string 'web+'.")); | 121 exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belon
g to the protocol whitelist. Please prefix non-whitelisted schemes with the stri
ng 'web+'."); |
| 123 return false; | 122 return false; |
| 124 } | 123 } |
| 125 | 124 |
| 126 NavigatorContentUtils* NavigatorContentUtils::from(Page* page) | 125 NavigatorContentUtils* NavigatorContentUtils::from(Page* page) |
| 127 { | 126 { |
| 128 return static_cast<NavigatorContentUtils*>(RefCountedSupplement<Page, Naviga
torContentUtils>::from(page, NavigatorContentUtils::supplementName())); | 127 return static_cast<NavigatorContentUtils*>(RefCountedSupplement<Page, Naviga
torContentUtils>::from(page, NavigatorContentUtils::supplementName())); |
| 129 } | 128 } |
| 130 | 129 |
| 131 NavigatorContentUtils::~NavigatorContentUtils() | 130 NavigatorContentUtils::~NavigatorContentUtils() |
| 132 { | 131 { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 220 |
| 222 void provideNavigatorContentUtilsTo(Page* page, NavigatorContentUtilsClient* cli
ent) | 221 void provideNavigatorContentUtilsTo(Page* page, NavigatorContentUtilsClient* cli
ent) |
| 223 { | 222 { |
| 224 RefCountedSupplement<Page, NavigatorContentUtils>::provideTo(page, Navigator
ContentUtils::supplementName(), NavigatorContentUtils::create(client)); | 223 RefCountedSupplement<Page, NavigatorContentUtils>::provideTo(page, Navigator
ContentUtils::supplementName(), NavigatorContentUtils::create(client)); |
| 225 } | 224 } |
| 226 | 225 |
| 227 } // namespace WebCore | 226 } // namespace WebCore |
| 228 | 227 |
| 229 #endif // ENABLE(NAVIGATOR_CONTENT_UTILS) | 228 #endif // ENABLE(NAVIGATOR_CONTENT_UTILS) |
| 230 | 229 |
| OLD | NEW |