| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/appcache_interfaces.h" | 5 #include "content/common/appcache_interfaces.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "content/public/common/url_constants.h" |
| 10 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
| 11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 #include "url/url_constants.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 const char kHttpScheme[] = "http"; | |
| 16 const char kHttpsScheme[] = "https"; | |
| 17 const char kDevToolsScheme[] = "chrome-devtools"; | |
| 18 const char kHttpGETMethod[] = "GET"; | 17 const char kHttpGETMethod[] = "GET"; |
| 19 const char kHttpHEADMethod[] = "HEAD"; | 18 const char kHttpHEADMethod[] = "HEAD"; |
| 20 | 19 |
| 21 const char kEnableExecutableHandlers[] = "enable-appcache-executable-handlers"; | 20 const char kEnableExecutableHandlers[] = "enable-appcache-executable-handlers"; |
| 22 | 21 |
| 23 const base::FilePath::CharType kAppCacheDatabaseName[] = | 22 const base::FilePath::CharType kAppCacheDatabaseName[] = |
| 24 FILE_PATH_LITERAL("Index"); | 23 FILE_PATH_LITERAL("Index"); |
| 25 | 24 |
| 26 AppCacheInfo::AppCacheInfo() | 25 AppCacheInfo::AppCacheInfo() |
| 27 : cache_id(kAppCacheNoCacheId), | 26 : cache_id(kAppCacheNoCacheId), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // as wildcards which we don't want here, we only do '*'s. | 104 // as wildcards which we don't want here, we only do '*'s. |
| 106 std::string pattern = namespace_url.spec(); | 105 std::string pattern = namespace_url.spec(); |
| 107 if (namespace_url.has_query()) | 106 if (namespace_url.has_query()) |
| 108 ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?"); | 107 ReplaceSubstringsAfterOffset(&pattern, 0, "?", "\\?"); |
| 109 return MatchPattern(url.spec(), pattern); | 108 return MatchPattern(url.spec(), pattern); |
| 110 } | 109 } |
| 111 return StartsWithASCII(url.spec(), namespace_url.spec(), true); | 110 return StartsWithASCII(url.spec(), namespace_url.spec(), true); |
| 112 } | 111 } |
| 113 | 112 |
| 114 bool IsSchemeSupportedForAppCache(const GURL& url) { | 113 bool IsSchemeSupportedForAppCache(const GURL& url) { |
| 115 bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme) || | 114 bool supported = url.SchemeIs(url::kHttpScheme) || |
| 116 url.SchemeIs(kDevToolsScheme); | 115 url.SchemeIs(url::kHttpsScheme) || |
| 116 url.SchemeIs(kChromeDevToolsScheme); |
| 117 | 117 |
| 118 #ifndef NDEBUG | 118 #ifndef NDEBUG |
| 119 // TODO(michaeln): It would be really nice if this could optionally work for | 119 // TODO(michaeln): It would be really nice if this could optionally work for |
| 120 // file and filesystem urls too to help web developers experiment and test | 120 // file and filesystem urls too to help web developers experiment and test |
| 121 // their apps, perhaps enabled via a cmd line flag or some other developer | 121 // their apps, perhaps enabled via a cmd line flag or some other developer |
| 122 // tool setting. Unfortunately file scheme net::URLRequests don't produce the | 122 // tool setting. Unfortunately file scheme net::URLRequests don't produce the |
| 123 // same signalling (200 response codes, headers) as http URLRequests, so this | 123 // same signalling (200 response codes, headers) as http URLRequests, so this |
| 124 // doesn't work just yet. | 124 // doesn't work just yet. |
| 125 // supported |= url.SchemeIsFile(); | 125 // supported |= url.SchemeIsFile(); |
| 126 #endif | 126 #endif |
| 127 return supported; | 127 return supported; |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool IsMethodSupportedForAppCache(const std::string& method) { | 130 bool IsMethodSupportedForAppCache(const std::string& method) { |
| 131 return (method == kHttpGETMethod) || (method == kHttpHEADMethod); | 131 return (method == kHttpGETMethod) || (method == kHttpHEADMethod); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { | 134 bool IsSchemeAndMethodSupportedForAppCache(const net::URLRequest* request) { |
| 135 return IsSchemeSupportedForAppCache(request->url()) && | 135 return IsSchemeSupportedForAppCache(request->url()) && |
| 136 IsMethodSupportedForAppCache(request->method()); | 136 IsMethodSupportedForAppCache(request->method()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace content | 139 } // namespace content |
| OLD | NEW |