diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 22:20:36 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 22:20:36 +0000 |
commit | ea776d0208899b770ea386b994216ef476197a46 (patch) | |
tree | cb614ced5bd6e764e01f244813d07b0a48870a0a /webkit/appcache/appcache_storage_impl.cc | |
parent | a3d3a7cf3b81cc8d00490bb7bfd92b57f0146d9c (diff) | |
download | chromium_src-ea776d0208899b770ea386b994216ef476197a46.zip chromium_src-ea776d0208899b770ea386b994216ef476197a46.tar.gz chromium_src-ea776d0208899b770ea386b994216ef476197a46.tar.bz2 |
Introduce an AppCachePolicy interface that allows the containing browser to determine appcache permissions. The policy can allow or deny loading existing manifests or the creation of new manifests. The policy check for creating new manifests can be async to allow for a user prompt.
BUG=none
TEST=new unit tests added
Review URL: http://codereview.chromium.org/565042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39280 0039d316-1c4b-4281-b951-d872f2087c98
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, |