SchemeRegistry.cpp [plain text]
#include "config.h"
#include "SchemeRegistry.h"
namespace WebCore {
static URLSchemesMap& localURLSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ());
if (localSchemes.isEmpty()) {
localSchemes.add("file");
#if PLATFORM(MAC)
localSchemes.add("applewebdata");
#endif
#if PLATFORM(QT)
localSchemes.add("qrc");
#endif
}
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");
}
return secureSchemes;
}
static URLSchemesMap& schemesWithUniqueOrigins()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, schemesWithUniqueOrigins, ());
if (schemesWithUniqueOrigins.isEmpty())
schemesWithUniqueOrigins.add("data");
return schemesWithUniqueOrigins;
}
static URLSchemesMap& emptyDocumentSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, emptyDocumentSchemes, ());
if (emptyDocumentSchemes.isEmpty())
emptyDocumentSchemes.add("about");
return emptyDocumentSchemes;
}
static URLSchemesMap& canDisplayOnlyIfCanRequestSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, canDisplayOnlyIfCanRequestSchemes, ());
#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
if (canDisplayOnlyIfCanRequestSchemes.isEmpty()) {
#if ENABLE(BLOB)
canDisplayOnlyIfCanRequestSchemes.add("blob");
#endif
#if ENABLE(FILE_SYSTEM)
canDisplayOnlyIfCanRequestSchemes.add("filesystem");
#endif
}
#endif // ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
return canDisplayOnlyIfCanRequestSchemes;
}
void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme)
{
localURLSchemes().add(scheme);
}
void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
{
if (scheme == "file")
return;
#if PLATFORM(MAC)
if (scheme == "applewebdata")
return;
#endif
localURLSchemes().remove(scheme);
}
const URLSchemesMap& SchemeRegistry::localSchemes()
{
return localURLSchemes();
}
static URLSchemesMap& schemesAllowingLocalStorageAccessInPrivateBrowsing()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, schemesAllowingLocalStorageAccessInPrivateBrowsing, ());
return schemesAllowingLocalStorageAccessInPrivateBrowsing;
}
static URLSchemesMap& schemesAllowingDatabaseAccessInPrivateBrowsing()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, schemesAllowingDatabaseAccessInPrivateBrowsing, ());
return schemesAllowingDatabaseAccessInPrivateBrowsing;
}
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);
}
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::registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing(const String& scheme)
{
schemesAllowingLocalStorageAccessInPrivateBrowsing().add(scheme);
}
bool SchemeRegistry::allowsLocalStorageAccessInPrivateBrowsing(const String& scheme)
{
if (scheme.isEmpty())
return false;
return schemesAllowingLocalStorageAccessInPrivateBrowsing().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing(const String& scheme)
{
schemesAllowingDatabaseAccessInPrivateBrowsing().add(scheme);
}
bool SchemeRegistry::allowsDatabaseAccessInPrivateBrowsing(const String& scheme)
{
if (scheme.isEmpty())
return false;
return schemesAllowingDatabaseAccessInPrivateBrowsing().contains(scheme);
}
}