diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-03 13:46:05 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-03 13:46:05 +0000 |
commit | 7c33f764aace7eb1a1ac4c0afa2a200bced60ce9 (patch) | |
tree | 5eff22f46bdb3bab3128cdfe72da58876ea433e8 /webkit/appcache | |
parent | 1429aef8f9a235ee61bbf2aeaa7883316b764291 (diff) | |
download | chromium_src-7c33f764aace7eb1a1ac4c0afa2a200bced60ce9.zip chromium_src-7c33f764aace7eb1a1ac4c0afa2a200bced60ce9.tar.gz chromium_src-7c33f764aace7eb1a1ac4c0afa2a200bced60ce9.tar.bz2 |
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
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_interfaces.cc | 20 | ||||
-rw-r--r-- | webkit/appcache/appcache_interfaces.h | 2 |
2 files changed, 21 insertions, 1 deletions
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 <set> + +#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<std::set<std::string> >::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); |