| OLD | NEW |
| 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/browser/appcache/appcache_host.h" | 5 #include "webkit/browser/appcache/appcache_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
| 11 #include "webkit/browser/appcache/appcache.h" | 11 #include "webkit/browser/appcache/appcache.h" |
| 12 #include "webkit/browser/appcache/appcache_backend_impl.h" | 12 #include "webkit/browser/appcache/appcache_backend_impl.h" |
| 13 #include "webkit/browser/appcache/appcache_policy.h" | 13 #include "webkit/browser/appcache/appcache_policy.h" |
| 14 #include "webkit/browser/appcache/appcache_request_handler.h" | 14 #include "webkit/browser/appcache/appcache_request_handler.h" |
| 15 #include "webkit/browser/quota/quota_manager_proxy.h" | 15 #include "webkit/browser/quota/quota_manager_proxy.h" |
| 16 | 16 |
| 17 namespace appcache { | 17 namespace appcache { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 void FillCacheInfo(const AppCache* cache, | 21 void FillCacheInfo(const AppCache* cache, |
| 22 const GURL& manifest_url, | 22 const GURL& manifest_url, |
| 23 Status status, AppCacheInfo* info) { | 23 AppCacheStatus status, AppCacheInfo* info) { |
| 24 info->manifest_url = manifest_url; | 24 info->manifest_url = manifest_url; |
| 25 info->status = status; | 25 info->status = status; |
| 26 | 26 |
| 27 if (!cache) | 27 if (!cache) |
| 28 return; | 28 return; |
| 29 | 29 |
| 30 info->cache_id = cache->cache_id(); | 30 info->cache_id = cache->cache_id(); |
| 31 | 31 |
| 32 if (!cache->is_complete()) | 32 if (!cache->is_complete()) |
| 33 return; | 33 return; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 (manifest_url.GetOrigin() == document_url.GetOrigin())) { | 110 (manifest_url.GetOrigin() == document_url.GetOrigin())) { |
| 111 DCHECK(!first_party_url_.is_empty()); | 111 DCHECK(!first_party_url_.is_empty()); |
| 112 AppCachePolicy* policy = service()->appcache_policy(); | 112 AppCachePolicy* policy = service()->appcache_policy(); |
| 113 if (policy && | 113 if (policy && |
| 114 !policy->CanCreateAppCache(manifest_url, first_party_url_)) { | 114 !policy->CanCreateAppCache(manifest_url, first_party_url_)) { |
| 115 FinishCacheSelection(NULL, NULL); | 115 FinishCacheSelection(NULL, NULL); |
| 116 std::vector<int> host_ids(1, host_id_); | 116 std::vector<int> host_ids(1, host_id_); |
| 117 frontend_->OnEventRaised(host_ids, CHECKING_EVENT); | 117 frontend_->OnEventRaised(host_ids, CHECKING_EVENT); |
| 118 frontend_->OnErrorEventRaised( | 118 frontend_->OnErrorEventRaised( |
| 119 host_ids, | 119 host_ids, |
| 120 ErrorDetails("Cache creation was blocked by the content policy", | 120 AppCacheErrorDetails( |
| 121 POLICY_ERROR, | 121 "Cache creation was blocked by the content policy", |
| 122 GURL(), | 122 POLICY_ERROR, |
| 123 0, | 123 GURL(), |
| 124 false /*is_cross_origin*/)); | 124 0, |
| 125 false /*is_cross_origin*/)); |
| 125 frontend_->OnContentBlocked(host_id_, manifest_url); | 126 frontend_->OnContentBlocked(host_id_, manifest_url); |
| 126 return; | 127 return; |
| 127 } | 128 } |
| 128 | 129 |
| 129 // Note: The client detects if the document was not loaded using HTTP GET | 130 // Note: The client detects if the document was not loaded using HTTP GET |
| 130 // and invokes SelectCache without a manifest url, so that detection step | 131 // and invokes SelectCache without a manifest url, so that detection step |
| 131 // is also skipped here. See WebApplicationCacheHostImpl.cc | 132 // is also skipped here. See WebApplicationCacheHostImpl.cc |
| 132 set_preferred_manifest_url(manifest_url); | 133 set_preferred_manifest_url(manifest_url); |
| 133 new_master_entry_url_ = document_url; | 134 new_master_entry_url_ = document_url; |
| 134 LoadOrCreateGroup(manifest_url); | 135 LoadOrCreateGroup(manifest_url); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 306 } |
| 306 return NULL; | 307 return NULL; |
| 307 } | 308 } |
| 308 | 309 |
| 309 void AppCacheHost::GetResourceList( | 310 void AppCacheHost::GetResourceList( |
| 310 AppCacheResourceInfoVector* resource_infos) { | 311 AppCacheResourceInfoVector* resource_infos) { |
| 311 if (associated_cache_.get() && associated_cache_->is_complete()) | 312 if (associated_cache_.get() && associated_cache_->is_complete()) |
| 312 associated_cache_->ToResourceInfoVector(resource_infos); | 313 associated_cache_->ToResourceInfoVector(resource_infos); |
| 313 } | 314 } |
| 314 | 315 |
| 315 Status AppCacheHost::GetStatus() { | 316 AppCacheStatus AppCacheHost::GetStatus() { |
| 316 // 6.9.8 Application cache API | 317 // 6.9.8 Application cache API |
| 317 AppCache* cache = associated_cache(); | 318 AppCache* cache = associated_cache(); |
| 318 if (!cache) | 319 if (!cache) |
| 319 return UNCACHED; | 320 return UNCACHED; |
| 320 | 321 |
| 321 // A cache without an owning group represents the cache being constructed | 322 // A cache without an owning group represents the cache being constructed |
| 322 // during the application cache update process. | 323 // during the application cache update process. |
| 323 if (!cache->owning_group()) | 324 if (!cache->owning_group()) |
| 324 return DOWNLOADING; | 325 return DOWNLOADING; |
| 325 | 326 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 associated_cache_info_pending_ = cache && !cache->is_complete(); | 537 associated_cache_info_pending_ = cache && !cache->is_complete(); |
| 537 AppCacheInfo info; | 538 AppCacheInfo info; |
| 538 if (cache) | 539 if (cache) |
| 539 cache->AssociateHost(this); | 540 cache->AssociateHost(this); |
| 540 | 541 |
| 541 FillCacheInfo(cache, manifest_url, GetStatus(), &info); | 542 FillCacheInfo(cache, manifest_url, GetStatus(), &info); |
| 542 frontend_->OnCacheSelected(host_id_, info); | 543 frontend_->OnCacheSelected(host_id_, info); |
| 543 } | 544 } |
| 544 | 545 |
| 545 } // namespace appcache | 546 } // namespace appcache |
| OLD | NEW |