This source file includes following definitions.
- localURLSchemes
- displayIsolatedURLSchemes
- secureSchemes
- schemesWithUniqueOrigins
- emptyDocumentSchemes
- schemesForbiddenFromDomainRelaxation
- canDisplayOnlyIfCanRequestSchemes
- notAllowingJavascriptURLsSchemes
- registerURLSchemeAsLocal
- removeURLSchemeRegisteredAsLocal
- localSchemes
- CORSEnabledSchemes
- ContentSecurityPolicyBypassingSchemes
- shouldTreatURLSchemeAsLocal
- registerURLSchemeAsNoAccess
- shouldTreatURLSchemeAsNoAccess
- registerURLSchemeAsDisplayIsolated
- shouldTreatURLSchemeAsDisplayIsolated
- registerURLSchemeAsSecure
- shouldTreatURLSchemeAsSecure
- registerURLSchemeAsEmptyDocument
- shouldLoadURLSchemeAsEmptyDocument
- setDomainRelaxationForbiddenForURLScheme
- isDomainRelaxationForbiddenForURLScheme
- canDisplayOnlyIfCanRequest
- registerAsCanDisplayOnlyIfCanRequest
- registerURLSchemeAsNotAllowingJavascriptURLs
- shouldTreatURLSchemeAsNotAllowingJavascriptURLs
- registerURLSchemeAsCORSEnabled
- shouldTreatURLSchemeAsCORSEnabled
- registerURLSchemeAsBypassingContentSecurityPolicy
- removeURLSchemeRegisteredAsBypassingContentSecurityPolicy
- schemeShouldBypassContentSecurityPolicy
#include "config.h"
#include "platform/weborigin/SchemeRegistry.h"
#include "wtf/MainThread.h"
namespace WebCore {
static URLSchemesMap& localURLSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ());
if (localSchemes.isEmpty())
localSchemes.add("file");
return localSchemes;
}
static URLSchemesMap& displayIsolatedURLSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, displayIsolatedSchemes, ());
return displayIsolatedSchemes;
}
static URLSchemesMap& secureSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, secureSchemes, ());
if (secureSchemes.isEmpty()) {
secureSchemes.add("https");
secureSchemes.add("about");
secureSchemes.add("data");
secureSchemes.add("wss");
}
return secureSchemes;
}
static URLSchemesMap& schemesWithUniqueOrigins()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, schemesWithUniqueOrigins, ());
if (schemesWithUniqueOrigins.isEmpty()) {
schemesWithUniqueOrigins.add("about");
schemesWithUniqueOrigins.add("javascript");
schemesWithUniqueOrigins.add("data");
}
return schemesWithUniqueOrigins;
}
static URLSchemesMap& emptyDocumentSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, emptyDocumentSchemes, ());
if (emptyDocumentSchemes.isEmpty())
emptyDocumentSchemes.add("about");
return emptyDocumentSchemes;
}
static HashSet<String>& schemesForbiddenFromDomainRelaxation()
{
DEFINE_STATIC_LOCAL(HashSet<String>, schemes, ());
return schemes;
}
static URLSchemesMap& canDisplayOnlyIfCanRequestSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, canDisplayOnlyIfCanRequestSchemes, ());
if (canDisplayOnlyIfCanRequestSchemes.isEmpty()) {
canDisplayOnlyIfCanRequestSchemes.add("blob");
canDisplayOnlyIfCanRequestSchemes.add("filesystem");
}
return canDisplayOnlyIfCanRequestSchemes;
}
static URLSchemesMap& notAllowingJavascriptURLsSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, notAllowingJavascriptURLsSchemes, ());
return notAllowingJavascriptURLsSchemes;
}
void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme)
{
localURLSchemes().add(scheme);
}
void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
{
if (scheme == "file")
return;
localURLSchemes().remove(scheme);
}
const URLSchemesMap& SchemeRegistry::localSchemes()
{
return localURLSchemes();
}
static URLSchemesMap& CORSEnabledSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, CORSEnabledSchemes, ());
if (CORSEnabledSchemes.isEmpty()) {
CORSEnabledSchemes.add("http");
CORSEnabledSchemes.add("https");
}
return CORSEnabledSchemes;
}
static URLSchemesMap& ContentSecurityPolicyBypassingSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, schemes, ());
return schemes;
}
bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
{
if (scheme.isEmpty())
return false;
return localURLSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme)
{
schemesWithUniqueOrigins().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsNoAccess(const String& scheme)
{
if (scheme.isEmpty())
return false;
return schemesWithUniqueOrigins().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsDisplayIsolated(const String& scheme)
{
displayIsolatedURLSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(const String& scheme)
{
if (scheme.isEmpty())
return false;
return displayIsolatedURLSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsSecure(const String& scheme)
{
secureSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsSecure(const String& scheme)
{
if (scheme.isEmpty())
return false;
return secureSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsEmptyDocument(const String& scheme)
{
emptyDocumentSchemes().add(scheme);
}
bool SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(const String& scheme)
{
if (scheme.isEmpty())
return false;
return emptyDocumentSchemes().contains(scheme);
}
void SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const String& scheme)
{
if (scheme.isEmpty())
return;
if (forbidden)
schemesForbiddenFromDomainRelaxation().add(scheme);
else
schemesForbiddenFromDomainRelaxation().remove(scheme);
}
bool SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(const String& scheme)
{
if (scheme.isEmpty())
return false;
return schemesForbiddenFromDomainRelaxation().contains(scheme);
}
bool SchemeRegistry::canDisplayOnlyIfCanRequest(const String& scheme)
{
if (scheme.isEmpty())
return false;
return canDisplayOnlyIfCanRequestSchemes().contains(scheme);
}
void SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest(const String& scheme)
{
canDisplayOnlyIfCanRequestSchemes().add(scheme);
}
void SchemeRegistry::registerURLSchemeAsNotAllowingJavascriptURLs(const String& scheme)
{
notAllowingJavascriptURLsSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(const String& scheme)
{
if (scheme.isEmpty())
return false;
return notAllowingJavascriptURLsSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsCORSEnabled(const String& scheme)
{
CORSEnabledSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(const String& scheme)
{
if (scheme.isEmpty())
return false;
return CORSEnabledSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme)
{
ContentSecurityPolicyBypassingSchemes().add(scheme);
}
void SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme)
{
ContentSecurityPolicyBypassingSchemes().remove(scheme);
}
bool SchemeRegistry::schemeShouldBypassContentSecurityPolicy(const String& scheme)
{
if (scheme.isEmpty())
return false;
return ContentSecurityPolicyBypassingSchemes().contains(scheme);
}
}