diff options
author | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 10:55:19 +0000 |
---|---|---|
committer | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-08 10:55:19 +0000 |
commit | 0a60884751e554f218bc88a4948c9d0a0d736375 (patch) | |
tree | 90b0f87f8aad4310be13425641b500ed11fd250a /webkit/appcache/appcache_request_handler.cc | |
parent | b3d0768e00a91fb32b4de82f7961b92a4d119383 (diff) | |
download | chromium_src-0a60884751e554f218bc88a4948c9d0a0d736375.zip chromium_src-0a60884751e554f218bc88a4948c9d0a0d736375.tar.gz chromium_src-0a60884751e554f218bc88a4948c9d0a0d736375.tar.bz2 |
Third-party appcache blocking.
BUG=72586
TEST=AppCacheHostTest.SelectCacheAllowed, AppCacheHostTest.SelectCacheBlocked, AppCacheRequestHandlerTest.MainResource_Blocked
Review URL: http://codereview.chromium.org/7720022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100131 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_request_handler.cc')
-rw-r--r-- | webkit/appcache/appcache_request_handler.cc | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc index 583df28..f4d74b1 100644 --- a/webkit/appcache/appcache_request_handler.cc +++ b/webkit/appcache/appcache_request_handler.cc @@ -7,6 +7,7 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" #include "webkit/appcache/appcache.h" +#include "webkit/appcache/appcache_policy.h" #include "webkit/appcache/appcache_url_request_job.h" namespace appcache { @@ -217,8 +218,7 @@ void AppCacheRequestHandler::MaybeLoadMainResource(net::URLRequest* request) { void AppCacheRequestHandler::OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url, - bool was_blocked_by_policy) { + int64 cache_id, const GURL& manifest_url) { DCHECK(job_); DCHECK(host_); DCHECK(is_main_resource()); @@ -229,22 +229,28 @@ void AppCacheRequestHandler::OnMainResponseFound( if (!job_) return; - if (ResourceType::IsFrame(resource_type_)) { - if (was_blocked_by_policy) - host_->NotifyMainResourceBlocked(manifest_url); + AppCachePolicy* policy = host_->service()->appcache_policy(); + bool was_blocked_by_policy = !manifest_url.is_empty() && policy && + !policy->CanLoadAppCache(manifest_url, host_->first_party_url()); - if (cache_id != kNoCacheId) { - // AppCacheHost loads and holds a reference to the main resource cache - // for two reasons, firstly to preload the cache into the working set - // in advance of subresource loads happening, secondly to prevent the - // AppCache from falling out of the working set on frame navigations. - host_->LoadMainResourceCache(cache_id); - host_->set_preferred_manifest_url(manifest_url); - } - } else { - DCHECK(ResourceType::IsSharedWorker(resource_type_)); - if (was_blocked_by_policy) + if (was_blocked_by_policy) { + if (ResourceType::IsFrame(resource_type_)) { + host_->NotifyMainResourceBlocked(manifest_url); + } else { + DCHECK(ResourceType::IsSharedWorker(resource_type_)); host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); + } + DeliverNetworkResponse(); + return; + } + + if (ResourceType::IsFrame(resource_type_) && cache_id != kNoCacheId) { + // AppCacheHost loads and holds a reference to the main resource cache + // for two reasons, firstly to preload the cache into the working set + // in advance of subresource loads happening, secondly to prevent the + // AppCache from falling out of the working set on frame navigations. + host_->LoadMainResourceCache(cache_id); + host_->set_preferred_manifest_url(manifest_url); } // 6.11.1 Navigating across documents, steps 10 and 14. |