summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/web_application_cache_host_impl.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 20:36:46 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 20:36:46 +0000
commit62e1926b8b77d7335c14096028102e269cb77937 (patch)
tree0cf80b8fa0a0eacbc27ccdd682945adc79db49a7 /webkit/appcache/web_application_cache_host_impl.cc
parentdf24335d48570c985a6c6a53303d399c53d4c367 (diff)
downloadchromium_src-62e1926b8b77d7335c14096028102e269cb77937.zip
chromium_src-62e1926b8b77d7335c14096028102e269cb77937.tar.gz
chromium_src-62e1926b8b77d7335c14096028102e269cb77937.tar.bz2
AppCache: manifest attribute is ignored when navigating via POST (form submit) that results in a 302 to GET the page to load.
BUG=49202 TEST=manual Review URL: http://codereview.chromium.org/2806059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/web_application_cache_host_impl.cc')
-rw-r--r--webkit/appcache/web_application_cache_host_impl.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/webkit/appcache/web_application_cache_host_impl.cc b/webkit/appcache/web_application_cache_host_impl.cc
index 5b2dead..042a06f 100644
--- a/webkit/appcache/web_application_cache_host_impl.cc
+++ b/webkit/appcache/web_application_cache_host_impl.cc
@@ -24,19 +24,31 @@ using WebKit::WebURLResponse;
namespace appcache {
+namespace {
+
typedef IDMap<WebApplicationCacheHostImpl> HostsMap;
// Note: the order of the elements in this array must match those
// of the EventID enum in appcache_interfaces.h.
-static const char* kEventNames[] = {
+const char* kEventNames[] = {
"Checking", "Error", "NoUpdate", "Downloading", "Progress",
"UpdateReady", "Cached", "Obsolete"
};
-static HostsMap* all_hosts() {
+GURL ClearUrlRef(const GURL& url) {
+ if (!url.has_ref())
+ return url;
+ GURL::Replacements replacements;
+ replacements.ClearRef();
+ return url.ReplaceComponents(replacements);
+}
+
+HostsMap* all_hosts() {
return Singleton<HostsMap>::get();
}
+} // anon namespace
+
WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) {
return all_hosts()->Lookup(id);
}
@@ -133,6 +145,9 @@ void WebApplicationCacheHostImpl::OnErrorEventRaised(
void WebApplicationCacheHostImpl::willStartMainResourceRequest(
WebURLRequest& request) {
request.setAppCacheHostID(host_id_);
+
+ original_main_resource_url_ = ClearUrlRef(request.url());
+
std::string method = request.httpMethod().utf8();
is_get_method_ = (method == kHttpGETMethod);
DCHECK(method == StringToUpperASCII(method));
@@ -161,12 +176,7 @@ bool WebApplicationCacheHostImpl::selectCacheWithManifest(
has_status_ = false;
has_cached_status_ = false;
- GURL manifest_gurl(manifest_url);
- if (manifest_gurl.has_ref()) {
- GURL::Replacements replacements;
- replacements.ClearRef();
- manifest_gurl = manifest_gurl.ReplaceComponents(replacements);
- }
+ GURL manifest_gurl(ClearUrlRef(manifest_url));
// 6.9.6 The application cache selection algorithm
// Check for new 'master' entries.
@@ -206,12 +216,11 @@ bool WebApplicationCacheHostImpl::selectCacheWithManifest(
void WebApplicationCacheHostImpl::didReceiveResponseForMainResource(
const WebURLResponse& response) {
document_response_ = response;
- document_url_ = document_response_.url();
- if (document_url_.has_ref()) {
- GURL::Replacements replacements;
- replacements.ClearRef();
- document_url_ = document_url_.ReplaceComponents(replacements);
- }
+ document_url_ = ClearUrlRef(document_response_.url());
+ if (document_url_ != original_main_resource_url_)
+ is_get_method_ = true; // A redirect was involved.
+ original_main_resource_url_ = GURL();
+
is_scheme_supported_ = IsSchemeSupported(document_url_);
if ((document_response_.appCacheID() != kNoCacheId) ||
!is_scheme_supported_ || !is_get_method_)