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" |
32 #include "bindings/v8/ExceptionState.h" | 33 #include "bindings/v8/ExceptionState.h" |
33 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
34 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
35 #include "core/page/Frame.h" | 36 #include "core/page/Frame.h" |
36 #include "core/page/Navigator.h" | 37 #include "core/page/Navigator.h" |
37 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
38 #include "wtf/HashSet.h" | 39 #include "wtf/HashSet.h" |
39 | 40 |
40 namespace WebCore { | 41 namespace WebCore { |
41 | 42 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 initProtocolHandlerWhitelist(); | 103 initProtocolHandlerWhitelist(); |
103 return protocolWhitelist->contains(scheme); | 104 return protocolWhitelist->contains(scheme); |
104 } | 105 } |
105 | 106 |
106 static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionState& es
) | 107 static bool verifyProtocolHandlerScheme(const String& scheme, ExceptionState& es
) |
107 { | 108 { |
108 if (scheme.startsWith("web+")) { | 109 if (scheme.startsWith("web+")) { |
109 // The specification requires that the length of scheme is at least five
characteres (including 'web+' prefix). | 110 // The specification requires that the length of scheme is at least five
characteres (including 'web+' prefix). |
110 if (scheme.length() >= 5 && isValidProtocol(scheme)) | 111 if (scheme.length() >= 5 && isValidProtocol(scheme)) |
111 return true; | 112 return true; |
112 es.throwDOMException(SecurityError); | 113 if (scheme.length() < 5) |
| 114 es.throwSecurityError(ExceptionMessages::failedToExecute("registerPr
otocolHandler", "Navigator", "the scheme length (including 'web+') must be at le
ast 5 characters.")); |
| 115 else |
| 116 es.throwSecurityError(ExceptionMessages::failedToExecute("registerPr
otocolHandler", "Navigator", "the scheme '" + scheme + "' may not be registered.
")); |
113 return false; | 117 return false; |
114 } | 118 } |
115 | 119 |
116 if (isProtocolWhitelisted(scheme)) | 120 if (isProtocolWhitelisted(scheme)) |
117 return true; | 121 return true; |
118 es.throwDOMException(SecurityError); | 122 es.throwSecurityError(ExceptionMessages::failedToExecute("registerProtocolHa
ndler", "Navigator", "the scheme '" + scheme + "' may not be registered.")); |
119 return false; | 123 return false; |
120 } | 124 } |
121 | 125 |
122 NavigatorContentUtils* NavigatorContentUtils::from(Page* page) | 126 NavigatorContentUtils* NavigatorContentUtils::from(Page* page) |
123 { | 127 { |
124 return static_cast<NavigatorContentUtils*>(RefCountedSupplement<Page, Naviga
torContentUtils>::from(page, NavigatorContentUtils::supplementName())); | 128 return static_cast<NavigatorContentUtils*>(RefCountedSupplement<Page, Naviga
torContentUtils>::from(page, NavigatorContentUtils::supplementName())); |
125 } | 129 } |
126 | 130 |
127 NavigatorContentUtils::~NavigatorContentUtils() | 131 NavigatorContentUtils::~NavigatorContentUtils() |
128 { | 132 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 221 |
218 void provideNavigatorContentUtilsTo(Page* page, NavigatorContentUtilsClient* cli
ent) | 222 void provideNavigatorContentUtilsTo(Page* page, NavigatorContentUtilsClient* cli
ent) |
219 { | 223 { |
220 RefCountedSupplement<Page, NavigatorContentUtils>::provideTo(page, Navigator
ContentUtils::supplementName(), NavigatorContentUtils::create(client)); | 224 RefCountedSupplement<Page, NavigatorContentUtils>::provideTo(page, Navigator
ContentUtils::supplementName(), NavigatorContentUtils::create(client)); |
221 } | 225 } |
222 | 226 |
223 } // namespace WebCore | 227 } // namespace WebCore |
224 | 228 |
225 #endif // ENABLE(NAVIGATOR_CONTENT_UTILS) | 229 #endif // ENABLE(NAVIGATOR_CONTENT_UTILS) |
226 | 230 |
OLD | NEW |