Chromium Code Reviews| 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 serviceWorkerSchemes.add("chrome-extension"); | |
|
Devlin
2015/06/23 17:52:31
This shouldn't be added here (it's a layering viol
| |
| 172 } | |
| 173 | |
| 174 return serviceWorkerSchemes; | |
| 175 } | |
| 176 | |
| 163 static URLSchemesMap<SchemeRegistry::PolicyAreas>& ContentSecurityPolicyBypassin gSchemes() | 177 static URLSchemesMap<SchemeRegistry::PolicyAreas>& ContentSecurityPolicyBypassin gSchemes() |
| 164 { | 178 { |
| 165 assertLockHeld(); | 179 assertLockHeld(); |
| 166 DEFINE_STATIC_LOCAL_NOASSERT(URLSchemesMap<SchemeRegistry::PolicyAreas>, sch emes, ()); | 180 DEFINE_STATIC_LOCAL_NOASSERT(URLSchemesMap<SchemeRegistry::PolicyAreas>, sch emes, ()); |
| 167 return schemes; | 181 return schemes; |
| 168 } | 182 } |
| 169 | 183 |
| 170 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme) | 184 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme) |
| 171 { | 185 { |
| 172 if (scheme.isEmpty()) | 186 if (scheme.isEmpty()) |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 builder.append(scheme); | 330 builder.append(scheme); |
| 317 } | 331 } |
| 318 return builder.toString(); | 332 return builder.toString(); |
| 319 } | 333 } |
| 320 | 334 |
| 321 bool SchemeRegistry::shouldTreatURLSchemeAsLegacy(const String& scheme) | 335 bool SchemeRegistry::shouldTreatURLSchemeAsLegacy(const String& scheme) |
| 322 { | 336 { |
| 323 return equalIgnoringCase("ftp", scheme) || equalIgnoringCase("gopher", schem e); | 337 return equalIgnoringCase("ftp", scheme) || equalIgnoringCase("gopher", schem e); |
| 324 } | 338 } |
| 325 | 339 |
| 340 bool SchemeRegistry::shouldAllowServiceWorkers(const String& scheme) | |
| 341 { | |
| 342 if (scheme.isEmpty()) | |
| 343 return false; | |
| 344 MutexLocker lock(mutex()); | |
| 345 return serviceWorkerSchemes().contains(scheme); | |
| 346 } | |
| 347 | |
| 326 void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str ing& scheme, PolicyAreas policyAreas) | 348 void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const Str ing& scheme, PolicyAreas policyAreas) |
| 327 { | 349 { |
| 328 MutexLocker locker(mutex()); | 350 MutexLocker locker(mutex()); |
| 329 ContentSecurityPolicyBypassingSchemes().add(scheme, policyAreas); | 351 ContentSecurityPolicyBypassingSchemes().add(scheme, policyAreas); |
| 330 } | 352 } |
| 331 | 353 |
| 332 void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c onst String& scheme) | 354 void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(c onst String& scheme) |
| 333 { | 355 { |
| 334 MutexLocker locker(mutex()); | 356 MutexLocker locker(mutex()); |
| 335 ContentSecurityPolicyBypassingSchemes().remove(scheme); | 357 ContentSecurityPolicyBypassingSchemes().remove(scheme); |
| 336 } | 358 } |
| 337 | 359 |
| 338 bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem e, PolicyAreas policyAreas) | 360 bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& schem e, PolicyAreas policyAreas) |
| 339 { | 361 { |
| 340 ASSERT(policyAreas != PolicyAreaNone); | 362 ASSERT(policyAreas != PolicyAreaNone); |
| 341 if (scheme.isEmpty() || policyAreas == PolicyAreaNone) | 363 if (scheme.isEmpty() || policyAreas == PolicyAreaNone) |
| 342 return false; | 364 return false; |
| 343 | 365 |
| 344 // get() returns 0 (PolicyAreaNone) if there is no entry in the map. | 366 // get() returns 0 (PolicyAreaNone) if there is no entry in the map. |
| 345 // Thus by default, schemes do not bypass CSP. | 367 // Thus by default, schemes do not bypass CSP. |
| 346 MutexLocker locker(mutex()); | 368 MutexLocker locker(mutex()); |
| 347 return (ContentSecurityPolicyBypassingSchemes().get(scheme) & policyAreas) = = policyAreas; | 369 return (ContentSecurityPolicyBypassingSchemes().get(scheme) & policyAreas) = = policyAreas; |
| 348 } | 370 } |
| 349 | 371 |
| 350 } // namespace blink | 372 } // namespace blink |
| OLD | NEW |