diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 09:12:59 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 09:12:59 +0000 |
commit | 5c7d598adfc690fe676c54f62cd733d25ee20fa8 (patch) | |
tree | ab138d9c44fde00390e5f5cc203f292d7aa80815 /webkit/appcache | |
parent | ca10046545d16cfd705fbfc356d97710f47cedee (diff) | |
download | chromium_src-5c7d598adfc690fe676c54f62cd733d25ee20fa8.zip chromium_src-5c7d598adfc690fe676c54f62cd733d25ee20fa8.tar.gz chromium_src-5c7d598adfc690fe676c54f62cd733d25ee20fa8.tar.bz2 |
Reland r52072. Pass notifications to the browser on access to the appcache main resource manifest.
BUG=45230
TEST=browser_tests
TBR=vandebo
Review URL: http://codereview.chromium.org/2980001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52074 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_frontend_impl.cc | 5 | ||||
-rw-r--r-- | webkit/appcache/appcache_frontend_impl.h | 2 | ||||
-rw-r--r-- | webkit/appcache/appcache_group_unittest.cc | 3 | ||||
-rw-r--r-- | webkit/appcache/appcache_host.cc | 8 | ||||
-rw-r--r-- | webkit/appcache/appcache_host.h | 6 | ||||
-rw-r--r-- | webkit/appcache/appcache_host_unittest.cc | 2 | ||||
-rw-r--r-- | webkit/appcache/appcache_interfaces.h | 3 | ||||
-rw-r--r-- | webkit/appcache/appcache_request_handler.cc | 4 | ||||
-rw-r--r-- | webkit/appcache/appcache_request_handler_unittest.cc | 2 | ||||
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 2 | ||||
-rw-r--r-- | webkit/appcache/appcache_storage_impl_unittest.cc | 12 | ||||
-rw-r--r-- | webkit/appcache/appcache_update_job_unittest.cc | 2 | ||||
-rw-r--r-- | webkit/appcache/web_application_cache_host_impl.h | 5 |
13 files changed, 36 insertions, 20 deletions
diff --git a/webkit/appcache/appcache_frontend_impl.cc b/webkit/appcache/appcache_frontend_impl.cc index 2365a912d..5f490f3 100644 --- a/webkit/appcache/appcache_frontend_impl.cc +++ b/webkit/appcache/appcache_frontend_impl.cc @@ -60,10 +60,11 @@ void AppCacheFrontendImpl::OnLogMessage(int host_id, LogLevel log_level, host->OnLogMessage(log_level, message); } -void AppCacheFrontendImpl::OnContentBlocked(int host_id) { +void AppCacheFrontendImpl::OnContentBlocked(int host_id, + const GURL& manifest_url) { WebApplicationCacheHostImpl* host = GetHost(host_id); if (host) - host->OnContentBlocked(); + host->OnContentBlocked(manifest_url); } } // namespace appcache diff --git a/webkit/appcache/appcache_frontend_impl.h b/webkit/appcache/appcache_frontend_impl.h index 6617082..e5852c7 100644 --- a/webkit/appcache/appcache_frontend_impl.h +++ b/webkit/appcache/appcache_frontend_impl.h @@ -23,7 +23,7 @@ class AppCacheFrontendImpl : public AppCacheFrontend { int num_total, int num_complete); virtual void OnLogMessage(int host_id, LogLevel log_level, const std::string& message); - virtual void OnContentBlocked(int host_id); + virtual void OnContentBlocked(int host_id, const GURL& manifest_url); }; } // namespace diff --git a/webkit/appcache/appcache_group_unittest.cc b/webkit/appcache/appcache_group_unittest.cc index a88808d..0f3f0b7 100644 --- a/webkit/appcache/appcache_group_unittest.cc +++ b/webkit/appcache/appcache_group_unittest.cc @@ -42,7 +42,8 @@ class TestAppCacheFrontend : public appcache::AppCacheFrontend { const std::string& message) { } - virtual void OnContentBlocked(int host_id) { + virtual void OnContentBlocked(int host_id, + const GURL& manifest_url) { } int last_host_id_; diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc index 8553324..7b9e58d 100644 --- a/webkit/appcache/appcache_host.cc +++ b/webkit/appcache/appcache_host.cc @@ -48,7 +48,8 @@ void AppCacheHost::SelectCache(const GURL& document_url, !pending_get_status_callback_); if (main_resource_blocked_) - frontend_->OnContentBlocked(host_id_); + frontend_->OnContentBlocked(host_id_, + blocked_manifest_url_); // First we handle an unusual case of SelectCache being called a second // time. Generally this shouldn't happen, but with bad content I think @@ -379,7 +380,7 @@ void AppCacheHost::OnUpdateComplete(AppCacheGroup* group) { } void AppCacheHost::OnContentBlocked(AppCacheGroup* group) { - frontend_->OnContentBlocked(host_id_); + frontend_->OnContentBlocked(host_id_, group->manifest_url()); } void AppCacheHost::SetSwappableCache(AppCacheGroup* group) { @@ -404,8 +405,9 @@ void AppCacheHost::LoadMainResourceCache(int64 cache_id) { service_->storage()->LoadCache(cache_id, this); } -void AppCacheHost::NotifyMainResourceBlocked() { +void AppCacheHost::NotifyMainResourceBlocked(const GURL& manifest_url) { main_resource_blocked_ = true; + blocked_manifest_url_ = manifest_url; } void AppCacheHost::AssociateCache(AppCache* cache) { diff --git a/webkit/appcache/appcache_host.h b/webkit/appcache/appcache_host.h index 1c7534f..7701f95 100644 --- a/webkit/appcache/appcache_host.h +++ b/webkit/appcache/appcache_host.h @@ -88,8 +88,8 @@ class AppCacheHost : public AppCacheStorage::Delegate, void LoadMainResourceCache(int64 cache_id); // Used to notify the host that the main resource was blocked by a policy. To - // work properly, this method needs to by invokde prior to cache selection. - void NotifyMainResourceBlocked(); + // work properly, this method needs to by invoked prior to cache selection. + void NotifyMainResourceBlocked(const GURL& manifest_url); // Used by the update job to keep track of which hosts are associated // with which pending master entries. @@ -197,6 +197,8 @@ class AppCacheHost : public AppCacheStorage::Delegate, // True if requests for this host were blocked by a policy. bool main_resource_blocked_; + GURL blocked_manifest_url_; + // List of objects observing us. ObserverList<Observer> observers_; diff --git a/webkit/appcache/appcache_host_unittest.cc b/webkit/appcache/appcache_host_unittest.cc index f2e8a04..b3dc951 100644 --- a/webkit/appcache/appcache_host_unittest.cc +++ b/webkit/appcache/appcache_host_unittest.cc @@ -61,7 +61,7 @@ class AppCacheHostTest : public testing::Test { const std::string& message) { } - virtual void OnContentBlocked(int host_id) { + virtual void OnContentBlocked(int host_id, const GURL& manifest_url) { } int last_host_id_; diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h index b2a954e..2ff2da7 100644 --- a/webkit/appcache/appcache_interfaces.h +++ b/webkit/appcache/appcache_interfaces.h @@ -63,7 +63,8 @@ class AppCacheFrontend { virtual void OnProgressEventRaised(const std::vector<int>& host_ids, const GURL& url, int num_total, int num_complete) = 0; - virtual void OnContentBlocked(int host_id) = 0; + virtual void OnContentBlocked(int host_id, + const GURL& manifest_url) = 0; virtual void OnLogMessage(int host_id, LogLevel log_level, const std::string& message) = 0; virtual ~AppCacheFrontend() {} diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc index a0775ad..28a9149 100644 --- a/webkit/appcache/appcache_request_handler.cc +++ b/webkit/appcache/appcache_request_handler.cc @@ -196,7 +196,7 @@ void AppCacheRequestHandler::OnMainResponseFound( if (ResourceType::IsFrame(resource_type_)) { if (was_blocked_by_policy) - host_->NotifyMainResourceBlocked(); + host_->NotifyMainResourceBlocked(manifest_url); if (cache_id != kNoCacheId) { // AppCacheHost loads and holds a reference to the main resource cache @@ -208,7 +208,7 @@ void AppCacheRequestHandler::OnMainResponseFound( } else { DCHECK(ResourceType::IsSharedWorker(resource_type_)); if (was_blocked_by_policy) - host_->frontend()->OnContentBlocked(host_->host_id()); + host_->frontend()->OnContentBlocked(host_->host_id(), manifest_url); } // 6.11.1 Navigating across documents, steps 10 and 14. diff --git a/webkit/appcache/appcache_request_handler_unittest.cc b/webkit/appcache/appcache_request_handler_unittest.cc index 1793209..db1eda7 100644 --- a/webkit/appcache/appcache_request_handler_unittest.cc +++ b/webkit/appcache/appcache_request_handler_unittest.cc @@ -39,7 +39,7 @@ class AppCacheRequestHandlerTest : public testing::Test { virtual void OnLogMessage(int host_id, appcache::LogLevel log_level, const std::string& message) {} - virtual void OnContentBlocked(int host_id) {} + virtual void OnContentBlocked(int host_id, const GURL& manifest_url) {} }; // Helper class run a test on our io_thread. The io_thread diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index b853a0c..265ff30 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -1044,7 +1044,7 @@ void AppCacheStorageImpl::CheckPolicyAndCallOnMainResponseFound( FOR_EACH_DELEGATE( (*delegates), OnMainResponseFound(url, AppCacheEntry(), AppCacheEntry(), - kNoCacheId, GURL(), true)); + kNoCacheId, manifest_url, true)); return; } } diff --git a/webkit/appcache/appcache_storage_impl_unittest.cc b/webkit/appcache/appcache_storage_impl_unittest.cc index 204f5e6..fa3c367 100644 --- a/webkit/appcache/appcache_storage_impl_unittest.cc +++ b/webkit/appcache/appcache_storage_impl_unittest.cc @@ -74,7 +74,7 @@ class AppCacheStorageImplTest : public testing::Test { explicit MockStorageDelegate(AppCacheStorageImplTest* test) : loaded_cache_id_(0), stored_group_success_(false), obsoleted_success_(false), found_cache_id_(kNoCacheId), - test_(test) { + found_blocked_by_policy_(false), test_(test) { } void OnCacheLoaded(AppCache* cache, int64 cache_id) { @@ -113,6 +113,7 @@ class AppCacheStorageImplTest : public testing::Test { found_fallback_entry_ = fallback_entry; found_cache_id_ = cache_id; found_manifest_url_ = manifest_url; + found_blocked_by_policy_ = was_blocked_by_policy; test_->ScheduleNextTask(); } @@ -130,6 +131,7 @@ class AppCacheStorageImplTest : public testing::Test { AppCacheEntry found_fallback_entry_; int64 found_cache_id_; GURL found_manifest_url_; + bool found_blocked_by_policy_; AppCacheStorageImplTest* test_; }; @@ -682,7 +684,9 @@ class AppCacheStorageImplTest : public testing::Test { void Verify_FindNoMainResponse() { EXPECT_EQ(kEntryUrl, delegate()->found_url_); - EXPECT_TRUE(delegate()->found_manifest_url_.is_empty()); + // If the request was blocked by a policy, the manifest url is still valid. + EXPECT_TRUE(delegate()->found_manifest_url_.is_empty() || + delegate()->found_blocked_by_policy_); EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_); EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id()); EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id()); @@ -742,6 +746,7 @@ class AppCacheStorageImplTest : public testing::Test { if (policy_.can_load_return_value_) { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); + EXPECT_FALSE(delegate()->found_blocked_by_policy_); EXPECT_EQ(1, delegate()->found_cache_id_); EXPECT_EQ(1, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); @@ -800,6 +805,7 @@ class AppCacheStorageImplTest : public testing::Test { void Verify_BasicFindMainFallbackResponse() { EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); + EXPECT_FALSE(delegate()->found_blocked_by_policy_); EXPECT_EQ(1, delegate()->found_cache_id_); EXPECT_FALSE(delegate()->found_entry_.has_response_id()); EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id()); @@ -846,6 +852,7 @@ class AppCacheStorageImplTest : public testing::Test { void Verify_FindMainResponseWithMultipleHits() { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_); + EXPECT_FALSE(delegate()->found_blocked_by_policy_); EXPECT_EQ(2, delegate()->found_cache_id_); EXPECT_EQ(2, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); @@ -894,6 +901,7 @@ class AppCacheStorageImplTest : public testing::Test { void Verify_NotFound(GURL expected_url, bool test_finished) { EXPECT_EQ(expected_url, delegate()->found_url_); EXPECT_TRUE(delegate()->found_manifest_url_.is_empty()); + EXPECT_FALSE(delegate()->found_blocked_by_policy_); EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_); EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id()); EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id()); diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc index 06ac167..e75175d 100644 --- a/webkit/appcache/appcache_update_job_unittest.cc +++ b/webkit/appcache/appcache_update_job_unittest.cc @@ -220,7 +220,7 @@ class MockFrontend : public AppCacheFrontend { const std::string& message) { } - virtual void OnContentBlocked(int host_id) { + virtual void OnContentBlocked(int host_id, const GURL& manifest_url) { } void AddExpectedEvent(const std::vector<int>& host_ids, EventID event_id) { diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h index 84aa4d3..17d66d7 100644 --- a/webkit/appcache/web_application_cache_host_impl.h +++ b/webkit/appcache/web_application_cache_host_impl.h @@ -32,12 +32,13 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost { AppCacheBackend* backend() const { return backend_; } WebKit::WebApplicationCacheHostClient* client() const { return client_; } - void OnCacheSelected(int64 selected_cache_id, appcache::Status status); void OnStatusChanged(appcache::Status); void OnEventRaised(appcache::EventID); void OnProgressEventRaised(const GURL& url, int num_total, int num_complete); virtual void OnLogMessage(LogLevel log_level, const std::string& message) {} - virtual void OnContentBlocked() {} + virtual void OnContentBlocked(const GURL& manifest_url) {} + virtual void OnCacheSelected(int64 selected_cache_id, + appcache::Status status); // WebApplicationCacheHost methods virtual void willStartMainResourceRequest(WebKit::WebURLRequest&); |