diff options
Diffstat (limited to 'webkit/appcache/appcache_storage_impl.cc')
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index ed893c1..0d908aa 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -12,11 +12,14 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "net/base/cache_type.h" +#include "net/base/net_errors.h" #include "webkit/appcache/appcache.h" #include "webkit/appcache/appcache_database.h" #include "webkit/appcache/appcache_entry.h" #include "webkit/appcache/appcache_group.h" +#include "webkit/appcache/appcache_policy.h" #include "webkit/appcache/appcache_response.h" +#include "webkit/appcache/appcache_service.h" #include "webkit/appcache/appcache_thread.h" namespace appcache { @@ -562,9 +565,8 @@ void AppCacheStorageImpl::FindMainResponseTask::Run() { } void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() { - FOR_EACH_DELEGATE(delegates_, - OnMainResponseFound(url_, entry_, fallback_entry_, - cache_id_, manifest_url_)); + storage_->CheckPolicyAndCallOnMainResponseFound( + &delegates_, url_, entry_, fallback_entry_, cache_id_, manifest_url_); } // MarkEntryAsForeignTask ------- @@ -902,13 +904,36 @@ void AppCacheStorageImpl::DeliverShortCircuitedFindMainResponse( scoped_refptr<AppCacheGroup> group, scoped_refptr<AppCache> cache, scoped_refptr<DelegateReference> delegate_ref) { if (delegate_ref->delegate) { - delegate_ref->delegate->OnMainResponseFound( - url, found_entry, AppCacheEntry(), + DelegateReferenceVector delegates(1, delegate_ref); + CheckPolicyAndCallOnMainResponseFound( + &delegates, url, found_entry, AppCacheEntry(), cache.get() ? cache->cache_id() : kNoCacheId, group.get() ? group->manifest_url() : GURL()); } } +void AppCacheStorageImpl::CheckPolicyAndCallOnMainResponseFound( + DelegateReferenceVector* delegates, const GURL& url, + const AppCacheEntry& entry, const AppCacheEntry& fallback_entry, + int64 cache_id, const GURL& manifest_url) { + if (!manifest_url.is_empty()) { + // Check the policy prior to returning a main resource from the appcache. + AppCachePolicy* policy = service()->appcache_policy(); + if (policy && !policy->CanLoadAppCache(manifest_url)) { + FOR_EACH_DELEGATE( + (*delegates), + OnMainResponseFound(url, AppCacheEntry(), AppCacheEntry(), + kNoCacheId, GURL())); + return; + } + } + + FOR_EACH_DELEGATE( + (*delegates), + OnMainResponseFound(url, entry, fallback_entry, + cache_id, manifest_url)); +} + void AppCacheStorageImpl::FindResponseForSubRequest( AppCache* cache, const GURL& url, AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, |