From 7c33f764aace7eb1a1ac4c0afa2a200bced60ce9 Mon Sep 17 00:00:00 2001 From: "pfeldman@chromium.org" Date: Wed, 3 Apr 2013 13:46:05 +0000 Subject: AppCache: support custom schemes in appcache interfaces. Review URL: https://codereview.chromium.org/13469005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192064 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/appcache/appcache_interfaces.cc | 20 +++++++++++++++++++- webkit/appcache/appcache_interfaces.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'webkit/appcache') diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc index a3b6f31..d7941be 100644 --- a/webkit/appcache/appcache_interfaces.cc +++ b/webkit/appcache/appcache_interfaces.cc @@ -4,6 +4,9 @@ #include "webkit/appcache/appcache_interfaces.h" +#include + +#include "base/lazy_instance.h" #include "base/string_util.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request.h" @@ -13,6 +16,13 @@ using WebKit::WebApplicationCacheHost; using WebKit::WebConsoleMessage; +namespace { + +base::LazyInstance >::Leaky g_supported_schemes = + LAZY_INSTANCE_INITIALIZER; + +} // namespace + namespace appcache { const char kHttpScheme[] = "http"; @@ -77,8 +87,16 @@ bool Namespace::IsMatch(const GURL& url) const { return StartsWithASCII(url.spec(), namespace_url.spec(), true); } +void AddSupportedScheme(const char* scheme) { + g_supported_schemes.Get().insert(scheme); +} + bool IsSchemeSupported(const GURL& url) { - bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme); + bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme) || + (!(g_supported_schemes == NULL) && + g_supported_schemes.Get().find(url.scheme()) != + g_supported_schemes.Get().end()); + #ifndef NDEBUG // TODO(michaeln): It would be really nice if this could optionally work for // file and filesystem urls too to help web developers experiment and test diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h index b45ee8f..0dfa4c4 100644 --- a/webkit/appcache/appcache_interfaces.h +++ b/webkit/appcache/appcache_interfaces.h @@ -171,6 +171,8 @@ extern const char kHttpsScheme[]; extern const char kHttpGETMethod[]; extern const char kHttpHEADMethod[]; +WEBKIT_STORAGE_EXPORT void AddSupportedScheme(const char* scheme); + bool IsSchemeSupported(const GURL& url); bool IsMethodSupported(const std::string& method); bool IsSchemeAndMethodSupported(const net::URLRequest* request); -- cgit v1.1