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 #include "config.h" | 27 #include "config.h" |
28 #include "platform/weborigin/SchemeRegistry.h" | 28 #include "platform/weborigin/SchemeRegistry.h" |
29 | 29 |
30 #include "wtf/MainThread.h" | 30 #include "wtf/MainThread.h" |
| 31 #include "wtf/text/StringBuilder.h" |
31 | 32 |
32 namespace WebCore { | 33 namespace WebCore { |
33 | 34 |
34 static URLSchemesMap& localURLSchemes() | 35 static URLSchemesMap& localURLSchemes() |
35 { | 36 { |
36 DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ()); | 37 DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ()); |
37 | 38 |
38 if (localSchemes.isEmpty()) | 39 if (localSchemes.isEmpty()) |
39 localSchemes.add("file"); | 40 localSchemes.add("file"); |
40 | 41 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 CORSEnabledSchemes().add(scheme); | 250 CORSEnabledSchemes().add(scheme); |
250 } | 251 } |
251 | 252 |
252 bool SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(const String& scheme) | 253 bool SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(const String& scheme) |
253 { | 254 { |
254 if (scheme.isEmpty()) | 255 if (scheme.isEmpty()) |
255 return false; | 256 return false; |
256 return CORSEnabledSchemes().contains(scheme); | 257 return CORSEnabledSchemes().contains(scheme); |
257 } | 258 } |
258 | 259 |
| 260 String SchemeRegistry::listOfCORSEnabledURLSchemes() |
| 261 { |
| 262 StringBuilder builder; |
| 263 const URLSchemesMap& corsEnabledSchemes = CORSEnabledSchemes(); |
| 264 |
| 265 bool addSeparator = false; |
| 266 for (URLSchemesMap::const_iterator it = corsEnabledSchemes.begin(); it != co
rsEnabledSchemes.end(); ++it) { |
| 267 if (addSeparator) |
| 268 builder.append(", "); |
| 269 else |
| 270 addSeparator = true; |
| 271 |
| 272 builder.append(*it); |
| 273 } |
| 274 return builder.toString(); |
| 275 } |
| 276 |
259 void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str
ing& scheme) | 277 void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str
ing& scheme) |
260 { | 278 { |
261 ContentSecurityPolicyBypassingSchemes().add(scheme); | 279 ContentSecurityPolicyBypassingSchemes().add(scheme); |
262 } | 280 } |
263 | 281 |
264 void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c
onst String& scheme) | 282 void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c
onst String& scheme) |
265 { | 283 { |
266 ContentSecurityPolicyBypassingSchemes().remove(scheme); | 284 ContentSecurityPolicyBypassingSchemes().remove(scheme); |
267 } | 285 } |
268 | 286 |
269 bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem
e) | 287 bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem
e) |
270 { | 288 { |
271 if (scheme.isEmpty()) | 289 if (scheme.isEmpty()) |
272 return false; | 290 return false; |
273 return ContentSecurityPolicyBypassingSchemes().contains(scheme); | 291 return ContentSecurityPolicyBypassingSchemes().contains(scheme); |
274 } | 292 } |
275 | 293 |
276 } // namespace WebCore | 294 } // namespace WebCore |
OLD | NEW |