summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 13:10:21 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 13:10:21 +0000
commit035545f333d5f508bee18782784b17c3d6889924 (patch)
treebc7f79bb0f9aeb52bceca75741f0e1e68cb3228d
parentf16943a1cad260cdee0d20147ea947d9bff84d84 (diff)
downloadchromium_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
-rw-r--r--chrome/browser/appcache/appcache_frontend_proxy.cc6
-rw-r--r--chrome/browser/appcache/appcache_frontend_proxy.h3
-rwxr-xr-xchrome/chrome_renderer.gypi2
-rw-r--r--chrome/common/appcache/appcache_dispatcher.cc7
-rw-r--r--chrome/common/appcache/appcache_dispatcher.h3
-rw-r--r--chrome/common/render_messages_internal.h4
-rw-r--r--chrome/renderer/render_view.cc11
-rw-r--r--chrome/renderer/render_view.h4
-rw-r--r--chrome/renderer/renderer_webapplicationcachehost_impl.cc32
-rw-r--r--chrome/renderer/renderer_webapplicationcachehost_impl.h31
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc10
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h2
-rw-r--r--webkit/appcache/appcache_frontend_impl.cc8
-rw-r--r--webkit/appcache/appcache_frontend_impl.h3
-rw-r--r--webkit/appcache/appcache_group.cc7
-rw-r--r--webkit/appcache/appcache_group.h7
-rw-r--r--webkit/appcache/appcache_group_unittest.cc8
-rw-r--r--webkit/appcache/appcache_host.cc14
-rw-r--r--webkit/appcache/appcache_host.h12
-rw-r--r--webkit/appcache/appcache_host_unittest.cc3
-rw-r--r--webkit/appcache/appcache_interfaces.h1
-rw-r--r--webkit/appcache/appcache_request_handler.cc6
-rw-r--r--webkit/appcache/appcache_request_handler.h5
-rw-r--r--webkit/appcache/appcache_request_handler_unittest.cc4
-rw-r--r--webkit/appcache/appcache_storage.h5
-rw-r--r--webkit/appcache/appcache_storage_impl.cc4
-rw-r--r--webkit/appcache/appcache_storage_impl.h2
-rw-r--r--webkit/appcache/appcache_storage_impl_unittest.cc5
-rw-r--r--webkit/appcache/appcache_update_job.cc4
-rw-r--r--webkit/appcache/appcache_update_job_unittest.cc6
-rw-r--r--webkit/appcache/mock_appcache_storage.cc8
-rw-r--r--webkit/appcache/mock_appcache_storage_unittest.cc5
-rw-r--r--webkit/appcache/web_application_cache_host_impl.h3
-rw-r--r--webkit/glue/webkitclient_impl.cc7
-rw-r--r--webkit/glue/webkitclient_impl.h2
-rw-r--r--webkit/tools/test_shell/simple_appcache_system.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h6
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc8
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h2
39 files changed, 204 insertions, 58 deletions
diff --git a/chrome/browser/appcache/appcache_frontend_proxy.cc b/chrome/browser/appcache/appcache_frontend_proxy.cc
index c0448592..d81244c 100644
--- a/chrome/browser/appcache/appcache_frontend_proxy.cc
+++ b/chrome/browser/appcache/appcache_frontend_proxy.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.
@@ -20,3 +20,7 @@ void AppCacheFrontendProxy::OnEventRaised(const std::vector<int>& host_ids,
appcache::EventID event_id) {
sender_->Send(new AppCacheMsg_EventRaised(host_ids, event_id));
}
+
+void AppCacheFrontendProxy::OnContentBlocked(int host_id) {
+ sender_->Send(new AppCacheMsg_ContentBlocked(host_id));
+}
diff --git a/chrome/browser/appcache/appcache_frontend_proxy.h b/chrome/browser/appcache/appcache_frontend_proxy.h
index 78865ab..234e36cf 100644
--- a/chrome/browser/appcache/appcache_frontend_proxy.h
+++ b/chrome/browser/appcache/appcache_frontend_proxy.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.
@@ -24,6 +24,7 @@ class AppCacheFrontendProxy : public appcache::AppCacheFrontend {
appcache::Status status);
virtual void OnEventRaised(const std::vector<int>& host_ids,
appcache::EventID event_id);
+ virtual void OnContentBlocked(int host_id);
private:
IPC::Message::Sender* sender_;
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 7598f35..774af6d 100755
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -133,6 +133,8 @@
'renderer/renderer_main_platform_delegate_win.cc',
'renderer/renderer_sandbox_support_linux.cc',
'renderer/renderer_sandbox_support_linux.h',
+ 'renderer/renderer_webapplicationcachehost_impl.cc',
+ 'renderer/renderer_webapplicationcachehost_impl.h',
'renderer/renderer_webcookiejar_impl.cc',
'renderer/renderer_webcookiejar_impl.h',
'renderer/renderer_webkitclient_impl.cc',
diff --git a/chrome/common/appcache/appcache_dispatcher.cc b/chrome/common/appcache/appcache_dispatcher.cc
index 71461ba..eabb690 100644
--- a/chrome/common/appcache/appcache_dispatcher.cc
+++ b/chrome/common/appcache/appcache_dispatcher.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.
@@ -13,6 +13,7 @@ bool AppCacheDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(AppCacheMsg_CacheSelected, OnCacheSelected)
IPC_MESSAGE_HANDLER(AppCacheMsg_StatusChanged, OnStatusChanged)
IPC_MESSAGE_HANDLER(AppCacheMsg_EventRaised, OnEventRaised)
+ IPC_MESSAGE_HANDLER(AppCacheMsg_ContentBlocked, OnContentBlocked)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -32,3 +33,7 @@ void AppCacheDispatcher::OnEventRaised(const std::vector<int>& host_ids,
appcache::EventID event_id) {
frontend_impl_.OnEventRaised(host_ids, event_id);
}
+
+void AppCacheDispatcher::OnContentBlocked(int host_id) {
+ frontend_impl_.OnContentBlocked(host_id);
+}
diff --git a/chrome/common/appcache/appcache_dispatcher.h b/chrome/common/appcache/appcache_dispatcher.h
index 9eaef6a..4f3b50c 100644
--- a/chrome/common/appcache/appcache_dispatcher.h
+++ b/chrome/common/appcache/appcache_dispatcher.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.
@@ -31,6 +31,7 @@ class AppCacheDispatcher {
appcache::Status status);
void OnEventRaised(const std::vector<int>& host_ids,
appcache::EventID event_id);
+ void OnContentBlocked(int host_id);
AppCacheBackendProxy backend_proxy_;
appcache::AppCacheFrontendImpl frontend_impl_;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 17e5689..93b1a76 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -625,6 +625,10 @@ IPC_BEGIN_MESSAGES(View)
std::vector<int> /* host_ids */,
appcache::EventID)
+ // Notifies the renderer of the fact that AppCache access was blocked.
+ IPC_MESSAGE_CONTROL1(AppCacheMsg_ContentBlocked,
+ int /* host_id */)
+
// Reply to the ViewHostMsg_QueryFormFieldAutofill message with the
// autofill suggestions.
IPC_MESSAGE_ROUTED4(ViewMsg_AutoFillSuggestionsReturned,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a1353f7..9dc6442 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -22,6 +22,7 @@
#include "base/string_util.h"
#include "base/time.h"
#include "build/build_config.h"
+#include "chrome/common/appcache/appcache_dispatcher.h"
#include "chrome/common/bindings_policy.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
@@ -51,6 +52,7 @@
#include "chrome/renderer/print_web_view_helper.h"
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/renderer_webapplicationcachehost_impl.h"
#include "chrome/renderer/renderer_webstoragenamespace_impl.h"
#include "chrome/renderer/spellchecker/spellcheck.h"
#include "chrome/renderer/user_script_slave.h"
@@ -143,6 +145,8 @@ using webkit_glue::PasswordForm;
using webkit_glue::PasswordFormDomManager;
using WebKit::WebAccessibilityCache;
using WebKit::WebAccessibilityObject;
+using WebKit::WebApplicationCacheHost;
+using WebKit::WebApplicationCacheHostClient;
using WebKit::WebColor;
using WebKit::WebColorName;
using WebKit::WebConsoleMessage;
@@ -2145,6 +2149,13 @@ WebMediaPlayer* RenderView::createMediaPlayer(
return new webkit_glue::WebMediaPlayerImpl(client, factory, factory_factory);
}
+WebApplicationCacheHost* RenderView::createApplicationCacheHost(
+ WebFrame* frame, WebApplicationCacheHostClient* client) {
+ return new RendererWebApplicationCacheHostImpl(
+ FromWebView(frame->view()), client,
+ RenderThread::current()->appcache_dispatcher()->backend_proxy());
+}
+
WebCookieJar* RenderView::cookieJar() {
return &cookie_jar_;
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 3ef8732..6f67b4d 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -98,6 +98,8 @@ struct FileUploadData;
namespace WebKit {
class WebAccessibilityCache;
+class WebApplicationCacheHost;
+class WebApplicationCacheHostClient;
class WebDataSource;
class WebDragData;
class WebGeolocationServiceInterface;
@@ -301,6 +303,8 @@ class RenderView : public RenderWidget,
const WebKit::WebString& name, unsigned long long documentId);
virtual WebKit::WebMediaPlayer* createMediaPlayer(
WebKit::WebFrame* frame, WebKit::WebMediaPlayerClient* client);
+ virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
+ WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client);
virtual WebKit::WebCookieJar* cookieJar();
virtual void willClose(WebKit::WebFrame* frame);
virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.cc b/chrome/renderer/renderer_webapplicationcachehost_impl.cc
new file mode 100644
index 0000000..88ffd2c
--- /dev/null
+++ b/chrome/renderer/renderer_webapplicationcachehost_impl.cc
@@ -0,0 +1,32 @@
+// 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.
+
+#include "chrome/renderer/renderer_webapplicationcachehost_impl.h"
+
+#include "chrome/common/content_settings_types.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
+
+using appcache::AppCacheBackend;
+using WebKit::WebApplicationCacheHostClient;
+
+RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
+ RenderView* render_view,
+ WebApplicationCacheHostClient* client,
+ AppCacheBackend* backend)
+ : WebApplicationCacheHostImpl(client, backend),
+ content_blocked_(false),
+ routing_id_(render_view->routing_id()) {
+}
+
+RendererWebApplicationCacheHostImpl::~RendererWebApplicationCacheHostImpl() {
+}
+
+void RendererWebApplicationCacheHostImpl::OnContentBlocked() {
+ if (!content_blocked_) {
+ RenderThread::current()->Send(new ViewHostMsg_ContentBlocked(
+ routing_id_, CONTENT_SETTINGS_TYPE_COOKIES));
+ content_blocked_ = true;
+ }
+}
diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.h b/chrome/renderer/renderer_webapplicationcachehost_impl.h
new file mode 100644
index 0000000..8a00032
--- /dev/null
+++ b/chrome/renderer/renderer_webapplicationcachehost_impl.h
@@ -0,0 +1,31 @@
+// 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.
+
+#ifndef CHROME_RENDERER_RENDERER_WEBAPPLICATIONCACHEHOST_IMPL_H_
+#define CHROME_RENDERER_RENDERER_WEBAPPLICATIONCACHEHOST_IMPL_H_
+
+#include "webkit/appcache/web_application_cache_host_impl.h"
+
+class RenderView;
+
+class RendererWebApplicationCacheHostImpl
+ : public appcache::WebApplicationCacheHostImpl {
+ public:
+ RendererWebApplicationCacheHostImpl(
+ RenderView* render_view,
+ WebKit::WebApplicationCacheHostClient* client,
+ appcache::AppCacheBackend* backend);
+
+ virtual ~RendererWebApplicationCacheHostImpl();
+
+ // appcache::WebApplicationCacheHostImpl methods.
+ virtual void OnContentBlocked();
+
+ private:
+ bool content_blocked_;
+
+ int routing_id_;
+};
+
+#endif // CHROME_RENDERER_RENDERER_WEBAPPLICATIONCACHEHOST_IMPL_H_
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 70bccc9..c5b042a 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -13,7 +13,6 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/platform_file.h"
-#include "chrome/common/appcache/appcache_dispatcher.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/database_util.h"
#include "chrome/common/render_messages.h"
@@ -32,7 +31,6 @@
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
-#include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/glue/webkit_glue.h"
#if defined(OS_LINUX)
@@ -43,8 +41,6 @@
#include "base/file_descriptor_posix.h"
#endif
-using WebKit::WebApplicationCacheHost;
-using WebKit::WebApplicationCacheHostClient;
using WebKit::WebFrame;
using WebKit::WebKitClient;
using WebKit::WebStorageArea;
@@ -182,12 +178,6 @@ void RendererWebKitClientImpl::dispatchStorageEvent(
url, is_local_storage);
}
-WebApplicationCacheHost* RendererWebKitClientImpl::createApplicationCacheHost(
- WebApplicationCacheHostClient* client) {
- return new appcache::WebApplicationCacheHostImpl(client,
- RenderThread::current()->appcache_dispatcher()->backend_proxy());
-}
-
//------------------------------------------------------------------------------
WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension(
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index b9232d2..3606eaa 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -64,8 +64,6 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
unsigned key_size_index,
const WebKit::WebString& challenge,
const WebKit::WebURL& url);
- virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
- WebKit::WebApplicationCacheHostClient*);
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D();
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&);
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index 34c24c6..2ac34f8 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -44,8 +44,6 @@
#include "v8/include/v8.h"
#endif
-using WebKit::WebApplicationCacheHost;
-using WebKit::WebApplicationCacheHostClient;
using WebKit::WebCookie;
using WebKit::WebData;
using WebKit::WebLocalizedString;
@@ -170,11 +168,6 @@ WebKitClientImpl::WebKitClientImpl()
shared_timer_suspended_(0) {
}
-WebApplicationCacheHost* WebKitClientImpl::createApplicationCacheHost(
- WebApplicationCacheHostClient*) {
- return NULL;
-}
-
WebThemeEngine* WebKitClientImpl::themeEngine() {
#if defined(OS_WIN)
return &theme_engine_;
diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h
index 3017e94e..93e14e3 100644
--- a/webkit/glue/webkitclient_impl.h
+++ b/webkit/glue/webkitclient_impl.h
@@ -23,8 +23,6 @@ class WebKitClientImpl : public WebKit::WebKitClient {
// WebKitClient methods (partial implementation):
virtual WebKit::WebThemeEngine* themeEngine();
- virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
- WebKit::WebApplicationCacheHostClient*);
virtual bool fileExists(const WebKit::WebString& path);
virtual bool deleteFile(const WebKit::WebString& path);
virtual bool deleteEmptyDirectory(const WebKit::WebString& path);
diff --git a/webkit/tools/test_shell/simple_appcache_system.cc b/webkit/tools/test_shell/simple_appcache_system.cc
index 8627b66..2fbc12a 100644
--- a/webkit/tools/test_shell/simple_appcache_system.cc
+++ b/webkit/tools/test_shell/simple_appcache_system.cc
@@ -99,6 +99,8 @@ class SimpleFrontendProxy
NOTREACHED();
}
+ virtual void OnContentBlocked(int host_id) {}
+
private:
friend class base::RefCountedThreadSafe<SimpleFrontendProxy>;
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 1da9f7d..ace35ab 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -23,7 +23,6 @@
#include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
-#include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/database/vfs_backend.h"
#include "webkit/extensions/v8/gears_extension.h"
#include "webkit/extensions/v8/interval_extension.h"
@@ -215,11 +214,6 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
// The event is dispatched by the proxy.
}
- virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
- WebKit::WebApplicationCacheHostClient* client) {
- return SimpleAppCacheSystem::CreateApplicationCacheHost(client);
- }
-
#if defined(OS_WIN)
void SetThemeEngine(WebKit::WebThemeEngine* engine) {
active_theme_engine_ = engine ? engine : WebKitClientImpl::themeEngine();
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 7083247..45d5903 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -52,6 +52,7 @@
#include "webkit/support/webkit_support.h"
#include "webkit/tools/test_shell/accessibility_controller.h"
#include "webkit/tools/test_shell/mock_spellcheck.h"
+#include "webkit/tools/test_shell/simple_appcache_system.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
#include "webkit/tools/test_shell/test_shell.h"
#include "webkit/tools/test_shell/test_web_worker.h"
@@ -64,6 +65,8 @@
using appcache::WebApplicationCacheHostImpl;
using WebKit::WebAccessibilityObject;
+using WebKit::WebApplicationCacheHost;
+using WebKit::WebApplicationCacheHostClient;
using WebKit::WebConsoleMessage;
using WebKit::WebContextMenuData;
using WebKit::WebCookieJar;
@@ -653,6 +656,11 @@ WebMediaPlayer* TestWebViewDelegate::createMediaPlayer(
return webkit_support::CreateMediaPlayer(frame, client);
}
+WebApplicationCacheHost* TestWebViewDelegate::createApplicationCacheHost(
+ WebFrame* frame, WebApplicationCacheHostClient* client) {
+ return SimpleAppCacheSystem::CreateApplicationCacheHost(client);
+}
+
bool TestWebViewDelegate::allowPlugins(WebFrame* frame,
bool enabled_per_settings) {
return enabled_per_settings && shell_->allow_plugins();
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index ad42917b..16b042b 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -157,6 +157,8 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
WebKit::WebFrame*, WebKit::WebWorkerClient*);
virtual WebKit::WebMediaPlayer* createMediaPlayer(
WebKit::WebFrame*, WebKit::WebMediaPlayerClient*);
+ virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
+ WebKit::WebFrame*, WebKit::WebApplicationCacheHostClient*);
virtual bool allowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings);
virtual void loadURLExternally(