Chromium Code Reviews| Index: webkit/appcache/appcache_host.cc |
| diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc |
| index cb040ef0dd681472f9197704dc415344240c1379..5bff3323c803ff639dafee747ca9dd6937900d79 100644 |
| --- a/webkit/appcache/appcache_host.cc |
| +++ b/webkit/appcache/appcache_host.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/stringprintf.h" |
| #include "webkit/appcache/appcache.h" |
| #include "webkit/appcache/appcache_backend_impl.h" |
| +#include "webkit/appcache/appcache_policy.h" |
| #include "webkit/appcache/appcache_request_handler.h" |
| #include "webkit/quota/quota_manager.h" |
| @@ -95,6 +96,20 @@ void AppCacheHost::SelectCache(const GURL& document_url, |
| if (!manifest_url.is_empty() && |
| (manifest_url.GetOrigin() == document_url.GetOrigin())) { |
| + DCHECK(!first_party_url_.is_empty()); |
| + AppCachePolicy* policy = service()->appcache_policy(); |
| + if (policy && |
| + !policy->CanCreateAppCache(manifest_url, first_party_url_)) { |
| + FinishCacheSelection(NULL, NULL); |
| + std::vector<int> host_ids; |
| + host_ids.push_back(host_id_); |
|
michaeln
2011/09/02 19:32:04
there's a ctor for this single element vector case
marja
2011/09/05 10:42:24
Done.
|
| + frontend_->OnEventRaised(host_ids, CHECKING_EVENT); |
| + frontend_->OnErrorEventRaised( |
| + host_ids, "Cache creation was blocked by the content policy"); |
| + frontend_->OnContentBlocked(host_id_, manifest_url); |
| + return; |
| + } |
| + |
| // Note: The client detects if the document was not loaded using HTTP GET |
| // and invokes SelectCache without a manifest url, so that detection step |
| // is also skipped here. See WebApplicationCacheHostImpl.cc |
| @@ -267,8 +282,12 @@ AppCacheRequestHandler* AppCacheHost::CreateRequestHandler( |
| return NULL; |
| } |
| - if (AppCacheRequestHandler::IsMainResourceType(resource_type)) |
| + if (AppCacheRequestHandler::IsMainResourceType(resource_type)) { |
| + // Store the first party origin so that it can be used later in SelectCache |
| + // for checking whether the creation of the appcache is allowed. |
| + first_party_url_ = request->first_party_for_cookies(); |
| return new AppCacheRequestHandler(this, resource_type); |
| + } |
| if ((associated_cache() && associated_cache()->is_complete()) || |
| is_selection_pending()) { |
| @@ -421,10 +440,6 @@ void AppCacheHost::OnUpdateComplete(AppCacheGroup* group) { |
| } |
| } |
| -void AppCacheHost::OnContentBlocked(AppCacheGroup* group) { |
| - frontend_->OnContentBlocked(host_id_, group->manifest_url()); |
| -} |
| - |
| void AppCacheHost::SetSwappableCache(AppCacheGroup* group) { |
| if (!group) { |
| swappable_cache_ = NULL; |