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 UChar character = scheme[i]; | |
106 if (isASCIIUpper(character)) | |
107 builder.append(toASCIILower(character)); | |
108 else | |
109 builder.append(character); | |
haraken
2014/06/07 02:19:23
Do we need this branch? I guess builder.append(toA
gyuyoung-inactive
2014/06/07 06:28:51
Doesn't this operation always call toASCIILower()
haraken
2014/06/07 06:36:49
I mean, you can remove line 106 - 109 and just use
gyuyoung-inactive
2014/06/07 06:51:01
Ah...yes. we can avoid to call isASCIIUpper() when
| |
110 } | |
111 | |
112 return protocolWhitelist->contains(builder.toString()); | |
101 } | 113 } |
102 | 114 |
103 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth od, ExceptionState& exceptionState) | 115 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth od, ExceptionState& exceptionState) |
104 { | 116 { |
105 if (scheme.startsWith("web+")) { | 117 if (scheme.startsWith("web+")) { |
106 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix). | 118 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix). |
107 if (scheme.length() >= 5 && isValidProtocol(scheme)) | 119 if (scheme.length() >= 5 && isValidProtocol(scheme)) |
108 return true; | 120 return true; |
109 if (!isValidProtocol(scheme)) | 121 if (!isValidProtocol(scheme)) |
110 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no t a valid protocol."); | 122 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 { | 235 { |
224 return "NavigatorContentUtils"; | 236 return "NavigatorContentUtils"; |
225 } | 237 } |
226 | 238 |
227 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client) | 239 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client) |
228 { | 240 { |
229 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client)); | 241 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client)); |
230 } | 242 } |
231 | 243 |
232 } // namespace WebCore | 244 } // namespace WebCore |
OLD | NEW |