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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache_host.h ('k') | webkit/appcache/appcache_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/appcache/appcache_host.h" 5 #include "webkit/appcache/appcache_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "webkit/appcache/appcache.h" 10 #include "webkit/appcache/appcache.h"
11 #include "webkit/appcache/appcache_backend_impl.h" 11 #include "webkit/appcache/appcache_backend_impl.h"
12 #include "webkit/appcache/appcache_policy.h"
12 #include "webkit/appcache/appcache_request_handler.h" 13 #include "webkit/appcache/appcache_request_handler.h"
13 #include "webkit/quota/quota_manager.h" 14 #include "webkit/quota/quota_manager.h"
14 15
15 namespace appcache { 16 namespace appcache {
16 17
17 namespace { 18 namespace {
18 19
19 void FillCacheInfo( 20 void FillCacheInfo(
20 const AppCache* cache, Status status, AppCacheInfo* info) { 21 const AppCache* cache, Status status, AppCacheInfo* info) {
21 DCHECK(cache); 22 DCHECK(cache);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // MarkAsForeignEntry is called in that case, so that detection 89 // MarkAsForeignEntry is called in that case, so that detection
89 // step is skipped here. See WebApplicationCacheHostImpl.cc 90 // step is skipped here. See WebApplicationCacheHostImpl.cc
90 91
91 if (cache_document_was_loaded_from != kNoCacheId) { 92 if (cache_document_was_loaded_from != kNoCacheId) {
92 LoadSelectedCache(cache_document_was_loaded_from); 93 LoadSelectedCache(cache_document_was_loaded_from);
93 return; 94 return;
94 } 95 }
95 96
96 if (!manifest_url.is_empty() && 97 if (!manifest_url.is_empty() &&
97 (manifest_url.GetOrigin() == document_url.GetOrigin())) { 98 (manifest_url.GetOrigin() == document_url.GetOrigin())) {
99 DCHECK(!first_party_url_.is_empty());
100 AppCachePolicy* policy = service()->appcache_policy();
101 if (policy &&
102 !policy->CanCreateAppCache(manifest_url, first_party_url_)) {
103 FinishCacheSelection(NULL, NULL);
104 std::vector<int> host_ids(1, host_id_);
105 frontend_->OnEventRaised(host_ids, CHECKING_EVENT);
106 frontend_->OnErrorEventRaised(
107 host_ids, "Cache creation was blocked by the content policy");
108 frontend_->OnContentBlocked(host_id_, manifest_url);
109 return;
110 }
111
98 // Note: The client detects if the document was not loaded using HTTP GET 112 // Note: The client detects if the document was not loaded using HTTP GET
99 // and invokes SelectCache without a manifest url, so that detection step 113 // and invokes SelectCache without a manifest url, so that detection step
100 // is also skipped here. See WebApplicationCacheHostImpl.cc 114 // is also skipped here. See WebApplicationCacheHostImpl.cc
101 set_preferred_manifest_url(manifest_url); 115 set_preferred_manifest_url(manifest_url);
102 new_master_entry_url_ = document_url; 116 new_master_entry_url_ = document_url;
103 LoadOrCreateGroup(manifest_url); 117 LoadOrCreateGroup(manifest_url);
104 return; 118 return;
105 } 119 }
106 120
107 // TODO(michaeln): If there was a manifest URL, the user agent may report 121 // TODO(michaeln): If there was a manifest URL, the user agent may report
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 AppCacheRequestHandler* AppCacheHost::CreateRequestHandler( 274 AppCacheRequestHandler* AppCacheHost::CreateRequestHandler(
261 net::URLRequest* request, 275 net::URLRequest* request,
262 ResourceType::Type resource_type) { 276 ResourceType::Type resource_type) {
263 if (is_for_dedicated_worker()) { 277 if (is_for_dedicated_worker()) {
264 AppCacheHost* parent_host = GetParentAppCacheHost(); 278 AppCacheHost* parent_host = GetParentAppCacheHost();
265 if (parent_host) 279 if (parent_host)
266 return parent_host->CreateRequestHandler(request, resource_type); 280 return parent_host->CreateRequestHandler(request, resource_type);
267 return NULL; 281 return NULL;
268 } 282 }
269 283
270 if (AppCacheRequestHandler::IsMainResourceType(resource_type)) 284 if (AppCacheRequestHandler::IsMainResourceType(resource_type)) {
285 // Store the first party origin so that it can be used later in SelectCache
286 // for checking whether the creation of the appcache is allowed.
287 first_party_url_ = request->first_party_for_cookies();
271 return new AppCacheRequestHandler(this, resource_type); 288 return new AppCacheRequestHandler(this, resource_type);
289 }
272 290
273 if ((associated_cache() && associated_cache()->is_complete()) || 291 if ((associated_cache() && associated_cache()->is_complete()) ||
274 is_selection_pending()) { 292 is_selection_pending()) {
275 return new AppCacheRequestHandler(this, resource_type); 293 return new AppCacheRequestHandler(this, resource_type);
276 } 294 }
277 return NULL; 295 return NULL;
278 } 296 }
279 297
280 void AppCacheHost::GetResourceList( 298 void AppCacheHost::GetResourceList(
281 AppCacheResourceInfoVector* resource_infos) { 299 AppCacheResourceInfoVector* resource_infos) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 432
415 if (associated_cache_info_pending_ && associated_cache_.get() && 433 if (associated_cache_info_pending_ && associated_cache_.get() &&
416 associated_cache_->is_complete()) { 434 associated_cache_->is_complete()) {
417 AppCacheInfo info; 435 AppCacheInfo info;
418 FillCacheInfo(associated_cache_.get(), GetStatus(), &info); 436 FillCacheInfo(associated_cache_.get(), GetStatus(), &info);
419 associated_cache_info_pending_ = false; 437 associated_cache_info_pending_ = false;
420 frontend_->OnCacheSelected(host_id_, info); 438 frontend_->OnCacheSelected(host_id_, info);
421 } 439 }
422 } 440 }
423 441
424 void AppCacheHost::OnContentBlocked(AppCacheGroup* group) {
425 frontend_->OnContentBlocked(host_id_, group->manifest_url());
426 }
427
428 void AppCacheHost::SetSwappableCache(AppCacheGroup* group) { 442 void AppCacheHost::SetSwappableCache(AppCacheGroup* group) {
429 if (!group) { 443 if (!group) {
430 swappable_cache_ = NULL; 444 swappable_cache_ = NULL;
431 } else { 445 } else {
432 AppCache* new_cache = group->newest_complete_cache(); 446 AppCache* new_cache = group->newest_complete_cache();
433 if (new_cache != associated_cache_) 447 if (new_cache != associated_cache_)
434 swappable_cache_ = new_cache; 448 swappable_cache_ = new_cache;
435 else 449 else
436 swappable_cache_ = NULL; 450 swappable_cache_ = NULL;
437 } 451 }
(...skipping 29 matching lines...) Expand all
467 associated_cache_info_pending_ = cache && !cache->is_complete(); 481 associated_cache_info_pending_ = cache && !cache->is_complete();
468 AppCacheInfo info; 482 AppCacheInfo info;
469 if (cache) { 483 if (cache) {
470 cache->AssociateHost(this); 484 cache->AssociateHost(this);
471 FillCacheInfo(cache, GetStatus(), &info); 485 FillCacheInfo(cache, GetStatus(), &info);
472 } 486 }
473 frontend_->OnCacheSelected(host_id_, info); 487 frontend_->OnCacheSelected(host_id_, info);
474 } 488 }
475 489
476 } // namespace appcache 490 } // namespace appcache
OLDNEW
« 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