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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 if (CORSEnabledSchemes.isEmpty()) { | 154 if (CORSEnabledSchemes.isEmpty()) { |
155 CORSEnabledSchemes.add("http"); | 155 CORSEnabledSchemes.add("http"); |
156 CORSEnabledSchemes.add("https"); | 156 CORSEnabledSchemes.add("https"); |
157 CORSEnabledSchemes.add("data"); | 157 CORSEnabledSchemes.add("data"); |
158 } | 158 } |
159 | 159 |
160 return CORSEnabledSchemes; | 160 return CORSEnabledSchemes; |
161 } | 161 } |
162 | 162 |
| 163 static URLSchemesSet& serviceWorkerSchemes() |
| 164 { |
| 165 assertLockHeld(); |
| 166 DEFINE_STATIC_LOCAL_NOASSERT(URLSchemesSet, serviceWorkerSchemes, ()); |
| 167 |
| 168 if (serviceWorkerSchemes.isEmpty()) { |
| 169 serviceWorkerSchemes.add("http"); |
| 170 serviceWorkerSchemes.add("https"); |
| 171 } |
| 172 |
| 173 return serviceWorkerSchemes; |
| 174 } |
| 175 |
163 static URLSchemesMap<SchemeRegistry::PolicyAreas>& ContentSecurityPolicyBypassin
gSchemes() | 176 static URLSchemesMap<SchemeRegistry::PolicyAreas>& ContentSecurityPolicyBypassin
gSchemes() |
164 { | 177 { |
165 assertLockHeld(); | 178 assertLockHeld(); |
166 DEFINE_STATIC_LOCAL_NOASSERT(URLSchemesMap<SchemeRegistry::PolicyAreas>, sch
emes, ()); | 179 DEFINE_STATIC_LOCAL_NOASSERT(URLSchemesMap<SchemeRegistry::PolicyAreas>, sch
emes, ()); |
167 return schemes; | 180 return schemes; |
168 } | 181 } |
169 | 182 |
170 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme) | 183 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme) |
171 { | 184 { |
172 if (scheme.isEmpty()) | 185 if (scheme.isEmpty()) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 builder.append(scheme); | 329 builder.append(scheme); |
317 } | 330 } |
318 return builder.toString(); | 331 return builder.toString(); |
319 } | 332 } |
320 | 333 |
321 bool SchemeRegistry::shouldTreatURLSchemeAsLegacy(const String& scheme) | 334 bool SchemeRegistry::shouldTreatURLSchemeAsLegacy(const String& scheme) |
322 { | 335 { |
323 return equalIgnoringCase("ftp", scheme) || equalIgnoringCase("gopher", schem
e); | 336 return equalIgnoringCase("ftp", scheme) || equalIgnoringCase("gopher", schem
e); |
324 } | 337 } |
325 | 338 |
| 339 void SchemeRegistry::registerURLSchemeAsAllowServiceWorkers(const String& scheme
) |
| 340 { |
| 341 MutexLocker locker(mutex()); |
| 342 serviceWorkerSchemes().add(scheme); |
| 343 } |
| 344 |
| 345 bool SchemeRegistry::shouldTreatURLSchemeAsAllowServiceWorkers(const String& sch
eme) |
| 346 { |
| 347 if (scheme.isEmpty()) |
| 348 return false; |
| 349 MutexLocker locker(mutex()); |
| 350 return serviceWorkerSchemes().contains(scheme); |
| 351 } |
| 352 |
326 void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str
ing& scheme, PolicyAreas policyAreas) | 353 void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str
ing& scheme, PolicyAreas policyAreas) |
327 { | 354 { |
328 MutexLocker locker(mutex()); | 355 MutexLocker locker(mutex()); |
329 ContentSecurityPolicyBypassingSchemes().add(scheme, policyAreas); | 356 ContentSecurityPolicyBypassingSchemes().add(scheme, policyAreas); |
330 } | 357 } |
331 | 358 |
332 void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c
onst String& scheme) | 359 void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c
onst String& scheme) |
333 { | 360 { |
334 MutexLocker locker(mutex()); | 361 MutexLocker locker(mutex()); |
335 ContentSecurityPolicyBypassingSchemes().remove(scheme); | 362 ContentSecurityPolicyBypassingSchemes().remove(scheme); |
336 } | 363 } |
337 | 364 |
338 bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem
e, PolicyAreas policyAreas) | 365 bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem
e, PolicyAreas policyAreas) |
339 { | 366 { |
340 ASSERT(policyAreas != PolicyAreaNone); | 367 ASSERT(policyAreas != PolicyAreaNone); |
341 if (scheme.isEmpty() || policyAreas == PolicyAreaNone) | 368 if (scheme.isEmpty() || policyAreas == PolicyAreaNone) |
342 return false; | 369 return false; |
343 | 370 |
344 // get() returns 0 (PolicyAreaNone) if there is no entry in the map. | 371 // get() returns 0 (PolicyAreaNone) if there is no entry in the map. |
345 // Thus by default, schemes do not bypass CSP. | 372 // Thus by default, schemes do not bypass CSP. |
346 MutexLocker locker(mutex()); | 373 MutexLocker locker(mutex()); |
347 return (ContentSecurityPolicyBypassingSchemes().get(scheme) & policyAreas) =
= policyAreas; | 374 return (ContentSecurityPolicyBypassingSchemes().get(scheme) & policyAreas) =
= policyAreas; |
348 } | 375 } |
349 | 376 |
350 } // namespace blink | 377 } // namespace blink |
OLD | NEW |