diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 13:10:21 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 13:10:21 +0000 |
commit | 035545f333d5f508bee18782784b17c3d6889924 (patch) | |
tree | bc7f79bb0f9aeb52bceca75741f0e1e68cb3228d /webkit/appcache | |
parent | f16943a1cad260cdee0d20147ea947d9bff84d84 (diff) | |
download | chromium_src-035545f333d5f508bee18782784b17c3d6889924.zip chromium_src-035545f333d5f508bee18782784b17c3d6889924.tar.gz chromium_src-035545f333d5f508bee18782784b17c3d6889924.tar.bz2 |
Indicate in the tab UI if appcache creation was blocked by privacy settings.
TEST=manual
BUG=38362
Review URL: http://codereview.chromium.org/1600002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
21 files changed, 93 insertions, 27 deletions
diff --git a/webkit/appcache/appcache_frontend_impl.cc b/webkit/appcache/appcache_frontend_impl.cc index 45d812f..7a9c1b8 100644 --- a/webkit/appcache/appcache_frontend_impl.cc +++ b/webkit/appcache/appcache_frontend_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,4 +39,10 @@ void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, } } +void AppCacheFrontendImpl::OnContentBlocked(int host_id) { + WebApplicationCacheHostImpl* host = GetHost(host_id); + if (host) + host->OnContentBlocked(); +} + } // namespace appcache diff --git a/webkit/appcache/appcache_frontend_impl.h b/webkit/appcache/appcache_frontend_impl.h index d0c0820..e8658a8 100644 --- a/webkit/appcache/appcache_frontend_impl.h +++ b/webkit/appcache/appcache_frontend_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,6 +18,7 @@ class AppCacheFrontendImpl : public AppCacheFrontend { Status status); virtual void OnEventRaised(const std::vector<int>& host_ids, EventID event_id); + virtual void OnContentBlocked(int host_id); }; } // namespace diff --git a/webkit/appcache/appcache_group.cc b/webkit/appcache/appcache_group.cc index 0f9b4af..ddfb266 100644 --- a/webkit/appcache/appcache_group.cc +++ b/webkit/appcache/appcache_group.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -264,4 +264,9 @@ void AppCacheGroup::SetUpdateStatus(UpdateStatus status) { } } +void AppCacheGroup::NotifyContentBlocked() { + FOR_EACH_OBSERVER( + UpdateObserver, observers_, OnContentBlocked(this)); +} + } // namespace appcache diff --git a/webkit/appcache/appcache_group.h b/webkit/appcache/appcache_group.h index c1bb1fc..a811337 100644 --- a/webkit/appcache/appcache_group.h +++ b/webkit/appcache/appcache_group.h @@ -30,9 +30,12 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> { class UpdateObserver { public: + // Called if access to the appcache was blocked by a policy. + virtual void OnContentBlocked(AppCacheGroup* group) = 0; + // Called just after an appcache update has completed. virtual void OnUpdateComplete(AppCacheGroup* group) = 0; - virtual ~UpdateObserver() { } + virtual ~UpdateObserver() {} }; enum UpdateStatus { @@ -105,6 +108,8 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> { AppCacheUpdateJob* update_job() { return update_job_; } void SetUpdateStatus(UpdateStatus status); + void NotifyContentBlocked(); + const Caches& old_caches() const { return old_caches_; } // Update cannot be processed at this time. Queue it for a later run. diff --git a/webkit/appcache/appcache_group_unittest.cc b/webkit/appcache/appcache_group_unittest.cc index 3508ace..9f86bc0b 100644 --- a/webkit/appcache/appcache_group_unittest.cc +++ b/webkit/appcache/appcache_group_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,6 +33,9 @@ class TestAppCacheFrontend : public appcache::AppCacheFrontend { appcache::EventID event_id) { } + virtual void OnContentBlocked(int host_id) { + } + int last_host_id_; int64 last_cache_id_; appcache::Status last_status_; @@ -52,6 +55,9 @@ class TestUpdateObserver : public AppCacheGroup::UpdateObserver { group_has_cache_ = group->HasCache(); } + virtual void OnContentBlocked(AppCacheGroup* group) { + } + bool update_completed_; bool group_has_cache_; }; diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc index 4fb098f..d4ca661 100644 --- a/webkit/appcache/appcache_host.cc +++ b/webkit/appcache/appcache_host.cc @@ -16,7 +16,8 @@ AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend, pending_selected_cache_id_(kNoCacheId), frontend_(frontend), service_(service), pending_get_status_callback_(NULL), pending_start_update_callback_(NULL), - pending_swap_cache_callback_(NULL), pending_callback_param_(NULL) { + pending_swap_cache_callback_(NULL), pending_callback_param_(NULL), + main_resource_blocked_(false) { } AppCacheHost::~AppCacheHost() { @@ -43,6 +44,9 @@ void AppCacheHost::SelectCache(const GURL& document_url, !pending_swap_cache_callback_ && !pending_get_status_callback_); + if (main_resource_blocked_) + frontend_->OnContentBlocked(host_id_); + // First we handle an unusual case of SelectCache being called a second // time. Generally this shouldn't happen, but with bad content I think // this can occur... <html manifest=foo> <html manifest=bar></html></html> @@ -321,6 +325,10 @@ void AppCacheHost::OnUpdateComplete(AppCacheGroup* group) { newest_cache_of_group_being_updated_ = NULL; } +void AppCacheHost::OnContentBlocked(AppCacheGroup* group) { + frontend_->OnContentBlocked(host_id_); +} + void AppCacheHost::SetSwappableCache(AppCacheGroup* group) { if (!group) { swappable_cache_ = NULL; @@ -343,6 +351,10 @@ void AppCacheHost::LoadMainResourceCache(int64 cache_id) { service_->storage()->LoadCache(cache_id, this); } +void AppCacheHost::NotifyMainResourceBlocked() { + main_resource_blocked_ = true; +} + void AppCacheHost::AssociateCache(AppCache* cache) { if (associated_cache_.get()) { associated_cache_->UnassociateHost(this); diff --git a/webkit/appcache/appcache_host.h b/webkit/appcache/appcache_host.h index bb3ef49..2a2607e 100644 --- a/webkit/appcache/appcache_host.h +++ b/webkit/appcache/appcache_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -83,6 +83,10 @@ class AppCacheHost : public AppCacheStorage::Delegate, // Used to ensure that a loaded appcache survives a frame navigation. 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(); + // Used by the update job to keep track of which hosts are associated // with which pending master entries. const GURL& pending_master_entry_url() const { @@ -116,7 +120,8 @@ class AppCacheHost : public AppCacheStorage::Delegate, void ObserveGroupBeingUpdated(AppCacheGroup* group); - // AppCacheGroup::UpdateObserver method + // AppCacheGroup::UpdateObserver methods. + virtual void OnContentBlocked(AppCacheGroup* group); virtual void OnUpdateComplete(AppCacheGroup* group); // Identifies the corresponding appcache host in the child process. @@ -169,6 +174,9 @@ class AppCacheHost : public AppCacheStorage::Delegate, SwapCacheCallback* pending_swap_cache_callback_; void* pending_callback_param_; + // True if requests for this host were blocked by a policy. + bool main_resource_blocked_; + // 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 a7f9d5d..be287f7 100644 --- a/webkit/appcache/appcache_host_unittest.cc +++ b/webkit/appcache/appcache_host_unittest.cc @@ -49,6 +49,9 @@ class AppCacheHostTest : public testing::Test { last_event_id_ = event_id; } + virtual void OnContentBlocked(int host_id) { + } + int last_host_id_; int64 last_cache_id_; appcache::Status last_status_; diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h index b5d6424..9736789 100644 --- a/webkit/appcache/appcache_interfaces.h +++ b/webkit/appcache/appcache_interfaces.h @@ -53,6 +53,7 @@ class AppCacheFrontend { Status status) = 0; virtual void OnEventRaised(const std::vector<int>& host_ids, EventID event_id) = 0; + virtual void OnContentBlocked(int host_id) = 0; virtual ~AppCacheFrontend() {} }; diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc index a17e7e5..41143b2 100644 --- a/webkit/appcache/appcache_request_handler.cc +++ b/webkit/appcache/appcache_request_handler.cc @@ -186,13 +186,17 @@ void AppCacheRequestHandler::MaybeLoadMainResource(URLRequest* request) { void AppCacheRequestHandler::OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, const GURL& manifest_url, + bool was_blocked_by_policy) { DCHECK(host_); DCHECK(is_main_request_); DCHECK(!entry.IsForeign()); DCHECK(!fallback_entry.IsForeign()); DCHECK(!(entry.has_response_id() && fallback_entry.has_response_id())); + if (was_blocked_by_policy) + host_->NotifyMainResourceBlocked(); + if (cache_id != kNoCacheId) { // AppCacheHost loads and holds a reference to the main resource cache // for two reasons, firstly to preload the cache into the working set diff --git a/webkit/appcache/appcache_request_handler.h b/webkit/appcache/appcache_request_handler.h index 2e51d61..3a4c057 100644 --- a/webkit/appcache/appcache_request_handler.h +++ b/webkit/appcache/appcache_request_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,7 +62,8 @@ class AppCacheRequestHandler : public URLRequest::UserData, virtual void OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& mainfest_url); + int64 cache_id, const GURL& mainfest_url, + bool was_blocked_by_policy); // Sub-resource loading ------------------------------------- diff --git a/webkit/appcache/appcache_request_handler_unittest.cc b/webkit/appcache/appcache_request_handler_unittest.cc index 88f3d03..26091d9 100644 --- a/webkit/appcache/appcache_request_handler_unittest.cc +++ b/webkit/appcache/appcache_request_handler_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,6 +28,8 @@ class AppCacheRequestHandlerTest : public testing::Test { virtual void OnEventRaised(const std::vector<int>& host_ids, appcache::EventID event_id) {} + + virtual void OnContentBlocked(int host_id) {} }; // Helper class run a test on our io_thread. The io_thread diff --git a/webkit/appcache/appcache_storage.h b/webkit/appcache/appcache_storage.h index 5618be4..1126608 100644 --- a/webkit/appcache/appcache_storage.h +++ b/webkit/appcache/appcache_storage.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -63,7 +63,8 @@ class AppCacheStorage { virtual void OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& mainfest_url) {} + int64 cache_id, const GURL& mainfest_url, + bool was_blocked_by_policy) {} }; explicit AppCacheStorage(AppCacheService* service); diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index 69701e6..ee9c30b 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -1041,7 +1041,7 @@ void AppCacheStorageImpl::CheckPolicyAndCallOnMainResponseFound( FOR_EACH_DELEGATE( (*delegates), OnMainResponseFound(url, AppCacheEntry(), AppCacheEntry(), - kNoCacheId, GURL())); + kNoCacheId, GURL(), true)); return; } } @@ -1049,7 +1049,7 @@ void AppCacheStorageImpl::CheckPolicyAndCallOnMainResponseFound( FOR_EACH_DELEGATE( (*delegates), OnMainResponseFound(url, entry, fallback_entry, - cache_id, manifest_url)); + cache_id, manifest_url, false)); } void AppCacheStorageImpl::FindResponseForSubRequest( diff --git a/webkit/appcache/appcache_storage_impl.h b/webkit/appcache/appcache_storage_impl.h index 4fea4d4..5b0c1b3 100644 --- a/webkit/appcache/appcache_storage_impl.h +++ b/webkit/appcache/appcache_storage_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/webkit/appcache/appcache_storage_impl_unittest.cc b/webkit/appcache/appcache_storage_impl_unittest.cc index 02e5002..182c3d8 100644 --- a/webkit/appcache/appcache_storage_impl_unittest.cc +++ b/webkit/appcache/appcache_storage_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -106,7 +106,8 @@ class AppCacheStorageImplTest : public testing::Test { void OnMainResponseFound(const GURL& url, const AppCacheEntry& entry, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, const GURL& manifest_url, + bool was_blocked_by_policy) { found_url_ = url; found_entry_ = entry; found_fallback_entry_ = fallback_entry; diff --git a/webkit/appcache/appcache_update_job.cc b/webkit/appcache/appcache_update_job.cc index 0941fc3..fb2fad1 100644 --- a/webkit/appcache/appcache_update_job.cc +++ b/webkit/appcache/appcache_update_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -223,6 +223,8 @@ void AppCacheUpdateJob::OnPolicyCheckComplete(int rv) { return; } + group_->NotifyContentBlocked(); + MessageLoop::current()->PostTask(FROM_HERE, method_factory_.NewRunnableMethod( &AppCacheUpdateJob::HandleCacheFailure)); diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc index 2ce47b1..243d3c3 100644 --- a/webkit/appcache/appcache_update_job_unittest.cc +++ b/webkit/appcache/appcache_update_job_unittest.cc @@ -50,6 +50,9 @@ class MockFrontend : public AppCacheFrontend { } } + virtual void OnContentBlocked(int host_id) { + } + void AddExpectedEvent(const std::vector<int>& host_ids, EventID event_id) { expected_events_.push_back(RaisedEvent(host_ids, event_id)); } @@ -2559,6 +2562,9 @@ class AppCacheUpdateJobTest : public testing::Test, UpdateFinished(); } + void OnContentBlocked(AppCacheGroup* group) { + } + void UpdateFinished() { // We unwind the stack prior to finishing up to let stack-based objects // get deleted. diff --git a/webkit/appcache/mock_appcache_storage.cc b/webkit/appcache/mock_appcache_storage.cc index abdc250..7e86ce4 100644 --- a/webkit/appcache/mock_appcache_storage.cc +++ b/webkit/appcache/mock_appcache_storage.cc @@ -229,7 +229,7 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( if (delegate_ref->delegate) { delegate_ref->delegate->OnMainResponseFound( url, simulated_found_entry_, simulated_found_fallback_entry_, - simulated_found_cache_id_, simulated_found_manifest_url_); + simulated_found_cache_id_, simulated_found_manifest_url_, false); } return; } @@ -326,7 +326,7 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( if (found_candidate.entry.has_response_id()) { delegate_ref->delegate->OnMainResponseFound( url, found_candidate.entry, AppCacheEntry(), - found_candidate.cache_id, found_candidate.manifest_url); + found_candidate.cache_id, found_candidate.manifest_url, false); return; } @@ -335,13 +335,13 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( delegate_ref->delegate->OnMainResponseFound( url, AppCacheEntry(), found_fallback_candidate.entry, found_fallback_candidate.cache_id, - found_fallback_candidate.manifest_url); + found_fallback_candidate.manifest_url, false); return; } // Didn't find anything. delegate_ref->delegate->OnMainResponseFound( - url, AppCacheEntry(), AppCacheEntry(), kNoCacheId, GURL()); + url, AppCacheEntry(), AppCacheEntry(), kNoCacheId, GURL(), false); } void MockAppCacheStorage::ProcessMakeGroupObsolete( diff --git a/webkit/appcache/mock_appcache_storage_unittest.cc b/webkit/appcache/mock_appcache_storage_unittest.cc index a2ed818..80e3b59 100644 --- a/webkit/appcache/mock_appcache_storage_unittest.cc +++ b/webkit/appcache/mock_appcache_storage_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,7 +44,8 @@ class MockAppCacheStorageTest : public testing::Test { void OnMainResponseFound(const GURL& url, const AppCacheEntry& entry, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, const GURL& manifest_url, + bool was_blocked_by_policy) { found_url_ = url; found_entry_ = entry; found_fallback_entry_ = fallback_entry; diff --git a/webkit/appcache/web_application_cache_host_impl.h b/webkit/appcache/web_application_cache_host_impl.h index bb73e9a..b2e1e53 100644 --- a/webkit/appcache/web_application_cache_host_impl.h +++ b/webkit/appcache/web_application_cache_host_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,6 +33,7 @@ class WebApplicationCacheHostImpl : public WebKit::WebApplicationCacheHost { void OnCacheSelected(int64 selected_cache_id, appcache::Status status); void OnStatusChanged(appcache::Status); void OnEventRaised(appcache::EventID); + virtual void OnContentBlocked() {} // WebApplicationCacheHost methods virtual void willStartMainResourceRequest(WebKit::WebURLRequest&); |