Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: webkit/appcache/appcache_host.cc

Issue 7720022: Third-party appcache blocking. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Keeping up to date with trunk. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/appcache/appcache_host.h ('k') | webkit/appcache/appcache_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_host.cc
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc
index cb040ef0dd681472f9197704dc415344240c1379..ddc9bd2ede544daada51b5a33252798104c0132f 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,19 @@ 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(1, host_id_);
+ 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 +281,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 +439,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;
« no previous file with comments | « webkit/appcache/appcache_host.h ('k') | webkit/appcache/appcache_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698