diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 04:00:01 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-12 04:00:01 +0000 |
commit | 71aaa7aa371e39947d951addfcdf32f2cda353ac (patch) | |
tree | ab138d9c44fde00390e5f5cc203f292d7aa80815 /chrome | |
parent | 6cd36ac0c3138c5c3e741e32dd6f3e3e6dff9d45 (diff) | |
download | chromium_src-71aaa7aa371e39947d951addfcdf32f2cda353ac.zip chromium_src-71aaa7aa371e39947d951addfcdf32f2cda353ac.tar.gz chromium_src-71aaa7aa371e39947d951addfcdf32f2cda353ac.tar.bz2 |
Pass notifications to the browser on access to the appcache main resource manifest.
BUG=45230
TEST=browser_tests
Review URL: http://codereview.chromium.org/2808046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
12 files changed, 63 insertions, 15 deletions
diff --git a/chrome/browser/appcache/appcache_frontend_proxy.cc b/chrome/browser/appcache/appcache_frontend_proxy.cc index fe39029..ded44a1 100644 --- a/chrome/browser/appcache/appcache_frontend_proxy.cc +++ b/chrome/browser/appcache/appcache_frontend_proxy.cc @@ -35,6 +35,7 @@ void AppCacheFrontendProxy::OnLogMessage(int host_id, sender_->Send(new AppCacheMsg_LogMessage(host_id, log_level, message)); } -void AppCacheFrontendProxy::OnContentBlocked(int host_id) { - sender_->Send(new AppCacheMsg_ContentBlocked(host_id)); +void AppCacheFrontendProxy::OnContentBlocked(int host_id, + const GURL& manifest_url) { + sender_->Send(new AppCacheMsg_ContentBlocked(host_id, manifest_url)); } diff --git a/chrome/browser/appcache/appcache_frontend_proxy.h b/chrome/browser/appcache/appcache_frontend_proxy.h index 90b9446..1476580 100644 --- a/chrome/browser/appcache/appcache_frontend_proxy.h +++ b/chrome/browser/appcache/appcache_frontend_proxy.h @@ -29,7 +29,8 @@ class AppCacheFrontendProxy : public appcache::AppCacheFrontend { int num_total, int num_complete); 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); private: IPC::Message::Sender* sender_; diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 4905ad5..92c2182 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -835,6 +835,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents) IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated) IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) + IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityTree, OnAccessibilityTree) IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) @@ -1931,6 +1932,15 @@ void RenderViewHost::OnContentBlocked(ContentSettingsType type) { content_settings_delegate->OnContentBlocked(type); } +void RenderViewHost::OnAppCacheAccessed(const GURL& manifest_url, + bool blocked_by_policy) { + RenderViewHostDelegate::ContentSettings* content_settings_delegate = + delegate_->GetContentSettingsDelegate(); + if (content_settings_delegate) + content_settings_delegate->OnAppCacheAccessed(manifest_url, + blocked_by_policy); +} + void RenderViewHost::OnWebDatabaseAccessed(const GURL& url, const string16& name, const string16& display_name, diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 25d3c15..c62f6ce 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -640,6 +640,7 @@ class RenderViewHost : public RenderWidgetHost { const std::string& translated_lang, TranslateErrors::Type error_type); void OnContentBlocked(ContentSettingsType type); + void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); void OnWebDatabaseAccessed(const GURL& url, const string16& name, const string16& display_name, diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index a0728a2..a5fca32 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -342,6 +342,13 @@ class RenderViewHostDelegate { unsigned long estimated_size, bool blocked_by_policy) = 0; + // Called when a specific appcache in the current page was accessed. If + // access was blocked due to the user's content settings, + // |blocked_by_policy| should eb true, and this function should invoke + // OnContentBlocked. + virtual void OnAppCacheAccessed(const GURL& manifest_url, + bool blocked_by_policy) = 0; + // Called when geolocation permission was set in a frame on the current // page. virtual void OnGeolocationPermissionSet(const GURL& requesting_frame, diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.cc b/chrome/browser/tab_contents/tab_specific_content_settings.cc index 891debd..21aaa3f 100644 --- a/chrome/browser/tab_contents/tab_specific_content_settings.cc +++ b/chrome/browser/tab_contents/tab_specific_content_settings.cc @@ -73,6 +73,16 @@ void TabSpecificContentSettings::OnWebDatabaseAccessed( } } +void TabSpecificContentSettings::OnAppCacheAccessed( + const GURL& manifest_url, bool blocked_by_policy) { + if (blocked_by_policy) { + blocked_local_shared_objects_.appcaches()->AddAppCache(manifest_url); + OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES); + } else { + allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url); + } +} + void TabSpecificContentSettings::OnGeolocationPermissionSet( const GURL& requesting_origin, bool allowed) { diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.h b/chrome/browser/tab_contents/tab_specific_content_settings.h index 8613b1a..648841e 100644 --- a/chrome/browser/tab_contents/tab_specific_content_settings.h +++ b/chrome/browser/tab_contents/tab_specific_content_settings.h @@ -65,6 +65,8 @@ class TabSpecificContentSettings const string16& display_name, unsigned long estimated_size, bool blocked_by_policy); + virtual void OnAppCacheAccessed(const GURL& manifest_url, + bool blocked_by_policy); virtual void OnGeolocationPermissionSet(const GURL& requesting_frame, bool allowed); diff --git a/chrome/common/appcache/appcache_dispatcher.cc b/chrome/common/appcache/appcache_dispatcher.cc index 97e1cba..ff44f92 100644 --- a/chrome/common/appcache/appcache_dispatcher.cc +++ b/chrome/common/appcache/appcache_dispatcher.cc @@ -48,6 +48,7 @@ void AppCacheDispatcher::OnLogMessage( host_id, static_cast<appcache::LogLevel>(log_level), message); } -void AppCacheDispatcher::OnContentBlocked(int host_id) { - frontend_impl_.OnContentBlocked(host_id); +void AppCacheDispatcher::OnContentBlocked(int host_id, + const GURL& manifest_url) { + frontend_impl_.OnContentBlocked(host_id, manifest_url); } diff --git a/chrome/common/appcache/appcache_dispatcher.h b/chrome/common/appcache/appcache_dispatcher.h index 39cb225..393e281 100644 --- a/chrome/common/appcache/appcache_dispatcher.h +++ b/chrome/common/appcache/appcache_dispatcher.h @@ -34,7 +34,8 @@ class AppCacheDispatcher { void OnProgressEventRaised(const std::vector<int>& host_ids, const GURL& url, int num_total, int num_complete); void OnLogMessage(int host_id, int log_level, const std::string& message); - void OnContentBlocked(int host_id); + void OnContentBlocked(int host_id, + const GURL& manifest_url); AppCacheBackendProxy backend_proxy_; appcache::AppCacheFrontendImpl frontend_impl_; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 20d5900..b7cda04 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -627,8 +627,9 @@ IPC_BEGIN_MESSAGES(View) std::string /* message */) // Notifies the renderer of the fact that AppCache access was blocked. - IPC_MESSAGE_CONTROL1(AppCacheMsg_ContentBlocked, - int /* host_id */) + IPC_MESSAGE_CONTROL2(AppCacheMsg_ContentBlocked, + int /* host_id */, + GURL /* manifest_url */) // Reply to the ViewHostMsg_QueryFormFieldAutoFill message with the // AutoFill suggestions. @@ -1264,6 +1265,12 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_ROUTED1(ViewHostMsg_ContentBlocked, ContentSettingsType /* type of blocked content */) + // Tells the browser that a specific Appcache manifest in the current page + // was accessed. + IPC_MESSAGE_ROUTED2(ViewHostMsg_AppCacheAccessed, + GURL /* manifest url */, + bool /* blocked by policy */) + // Tells the browser that a specific Web database in the current page was // accessed. IPC_MESSAGE_ROUTED5(ViewHostMsg_WebDatabaseAccessed, diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.cc b/chrome/renderer/renderer_webapplicationcachehost_impl.cc index 6a2d6e3..c4b6e71 100644 --- a/chrome/renderer/renderer_webapplicationcachehost_impl.cc +++ b/chrome/renderer/renderer_webapplicationcachehost_impl.cc @@ -35,12 +35,17 @@ void RendererWebApplicationCacheHostImpl::OnLogMessage( WebKit::WebString::fromUTF8(message.c_str()))); } -void RendererWebApplicationCacheHostImpl::OnContentBlocked() { - if (!content_blocked_) { - RenderThread::current()->Send(new ViewHostMsg_ContentBlocked( - routing_id_, CONTENT_SETTINGS_TYPE_COOKIES)); - content_blocked_ = true; - } +void RendererWebApplicationCacheHostImpl::OnContentBlocked( + const GURL& manifest_url) { + RenderThread::current()->Send(new ViewHostMsg_AppCacheAccessed( + routing_id_, manifest_url, true)); +} + +void RendererWebApplicationCacheHostImpl::OnCacheSelected( + int64 selected_cache_id, appcache::Status status) { + // TODO(jochen): Send a ViewHostMsg_AppCacheAccessed to the browser once this + // methods gets the manifest url passed. + WebApplicationCacheHostImpl::OnCacheSelected(selected_cache_id, status); } RenderView* RendererWebApplicationCacheHostImpl::GetRenderView() { diff --git a/chrome/renderer/renderer_webapplicationcachehost_impl.h b/chrome/renderer/renderer_webapplicationcachehost_impl.h index 0e4173e..e709fa9 100644 --- a/chrome/renderer/renderer_webapplicationcachehost_impl.h +++ b/chrome/renderer/renderer_webapplicationcachehost_impl.h @@ -20,7 +20,9 @@ class RendererWebApplicationCacheHostImpl // appcache::WebApplicationCacheHostImpl methods. virtual void OnLogMessage(appcache::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); private: RenderView* GetRenderView(); |