diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 07:29:32 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 07:29:32 +0000 |
commit | 8093a5439afecec131b78422abdeb7038de6f7a3 (patch) | |
tree | a2f7dc196c51970186615d10d0a884e18c2b7ae9 | |
parent | 697a650a1084ef9c77f9c5675f891d6157f36e99 (diff) | |
download | chromium_src-8093a5439afecec131b78422abdeb7038de6f7a3.zip chromium_src-8093a5439afecec131b78422abdeb7038de6f7a3.tar.gz chromium_src-8093a5439afecec131b78422abdeb7038de6f7a3.tar.bz2 |
Get rid of the remaining content settings code in the content module.
Add user data to content::ResourceContext that points to chrome's ProfileIOData. That way when the embedder code is called by content, it can get back to its profile specific data structures like HostContentSettingsMap.
BUG=76793
Review URL: http://codereview.chromium.org/7014025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85247 0039d316-1c4b-4281-b951-d872f2087c98
38 files changed, 291 insertions, 405 deletions
diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc index 70271ed..b77e9c7 100644 --- a/chrome/browser/automation/automation_resource_message_filter.cc +++ b/chrome/browser/automation/automation_resource_message_filter.cc @@ -8,6 +8,7 @@ #include "base/metrics/histogram.h" #include "base/stl_util-inl.h" #include "chrome/browser/automation/url_request_automation_job.h" +#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/net/url_request_failed_dns_job.h" #include "chrome/browser/net/url_request_mock_http_job.h" #include "chrome/browser/net/url_request_mock_util.h" @@ -17,7 +18,6 @@ #include "chrome/common/chrome_paths.h" #include "content/browser/browser_message_filter.h" #include "content/browser/browser_thread.h" -#include "content/browser/renderer_host/render_view_host_notification_task.h" #include "content/common/view_messages.h" #include "googleurl/src/gurl.h" #include "net/base/net_errors.h" @@ -507,10 +507,12 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponse( GetCookieMonster(); net::CookieList cookie_list = cookie_monster->GetAllCookiesForURLWithOptions( url, net::CookieOptions()); - CallRenderViewHostContentSettingsDelegate( - index->second.render_process_id, render_view_id, - &RenderViewHostDelegate::ContentSettings::OnCookiesRead, - url, cookie_list, !success); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + NewRunnableFunction( + &TabSpecificContentSettings::CookiesRead, + index->second.render_process_id, render_view_id, url, cookie_list, + !success)); // The cookie for this URL is only valid until it is read by the callback. cookie_store->SetCookieWithOptions(url, "", net::CookieOptions()); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 8efed98..56233bfc 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -10,6 +10,7 @@ #include "chrome/browser/character_encoding.h" #include "chrome/browser/chrome_worker_message_filter.h" #include "chrome/browser/content_settings/host_content_settings_map.h" +#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/debugger/devtools_handler.h" #include "chrome/browser/desktop_notification_handler.h" #include "chrome/browser/extensions/extension_message_handler.h" @@ -18,6 +19,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/printing/printing_message_filter.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/renderer_host/chrome_render_message_filter.h" #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" #include "chrome/browser/renderer_host/text_input_client_message_filter.h" @@ -33,7 +35,6 @@ #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/browser_render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/renderer_host/render_view_host_notification_task.h" #include "content/browser/resource_context.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents.h" @@ -237,7 +238,10 @@ std::string ChromeContentBrowserClient::GetApplicationLocale() { bool ChromeContentBrowserClient::AllowAppCache( const GURL& manifest_url, const content::ResourceContext& context) { - ContentSetting setting = context.host_content_settings_map()-> + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + ProfileIOData* io_data = + reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); + ContentSetting setting = io_data->host_content_settings_map()-> GetContentSetting(manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); DCHECK(setting != CONTENT_SETTING_DEFAULT); return setting != CONTENT_SETTING_BLOCK; @@ -252,7 +256,9 @@ bool ChromeContentBrowserClient::AllowGetCookie( int render_view_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); bool allow = true; - if (context.host_content_settings_map()->BlockThirdPartyCookies()) { + ProfileIOData* io_data = + reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); + if (io_data->host_content_settings_map()->BlockThirdPartyCookies()) { bool strict = CommandLine::ForCurrentProcess()->HasSwitch( switches::kBlockReadingThirdPartyCookies); net::StaticCookiePolicy policy(strict ? @@ -265,16 +271,17 @@ bool ChromeContentBrowserClient::AllowGetCookie( } if (allow) { - ContentSetting setting = context.host_content_settings_map()-> + ContentSetting setting = io_data->host_content_settings_map()-> GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, ""); allow = setting == CONTENT_SETTING_ALLOW || setting == CONTENT_SETTING_SESSION_ONLY; } - CallRenderViewHostContentSettingsDelegate( - render_process_id, render_view_id, - &RenderViewHostDelegate::ContentSettings::OnCookiesRead, - url, cookie_list, !allow); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + NewRunnableFunction( + &TabSpecificContentSettings::CookiesRead, + render_process_id, render_view_id, url, cookie_list, !allow)); return allow; } @@ -288,7 +295,9 @@ bool ChromeContentBrowserClient::AllowSetCookie( net::CookieOptions* options) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); bool allow = true; - if (context.host_content_settings_map()->BlockThirdPartyCookies()) { + ProfileIOData* io_data = + reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); + if (io_data->host_content_settings_map()->BlockThirdPartyCookies()) { bool strict = CommandLine::ForCurrentProcess()->HasSwitch( switches::kBlockReadingThirdPartyCookies); net::StaticCookiePolicy policy(strict ? @@ -300,7 +309,7 @@ bool ChromeContentBrowserClient::AllowSetCookie( } if (allow) { - ContentSetting setting = context.host_content_settings_map()-> + ContentSetting setting = io_data->host_content_settings_map()-> GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, ""); if (setting == CONTENT_SETTING_SESSION_ONLY) @@ -310,10 +319,12 @@ bool ChromeContentBrowserClient::AllowSetCookie( setting == CONTENT_SETTING_SESSION_ONLY; } - CallRenderViewHostContentSettingsDelegate( - render_process_id, render_view_id, - &RenderViewHostDelegate::ContentSettings::OnCookieChanged, - url, cookie_line, *options, !allow); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + NewRunnableFunction( + &TabSpecificContentSettings::CookieChanged, + render_process_id, render_view_id, url, cookie_line, *options, + !allow)); return allow; } diff --git a/chrome/browser/chrome_worker_message_filter.cc b/chrome/browser/chrome_worker_message_filter.cc index babf251..659c0e5 100644 --- a/chrome/browser/chrome_worker_message_filter.cc +++ b/chrome/browser/chrome_worker_message_filter.cc @@ -6,14 +6,16 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" +#include "chrome/browser/profiles/profile_io_data.h" #include "content/browser/resource_context.h" #include "content/browser/worker_host/worker_process_host.h" #include "content/common/worker_messages.h" ChromeWorkerMessageFilter::ChromeWorkerMessageFilter(WorkerProcessHost* process) : process_(process) { - host_content_settings_map_ = - process->resource_context()->host_content_settings_map(); + ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>( + process->resource_context()->GetUserData(NULL)); + host_content_settings_map_ = io_data->host_content_settings_map(); } ChromeWorkerMessageFilter::~ChromeWorkerMessageFilter() { diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc index 5a3d49b..720bb60 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc @@ -12,12 +12,17 @@ #include "chrome/browser/browsing_data_database_helper.h" #include "chrome/browser/browsing_data_indexed_db_helper.h" #include "chrome/browser/browsing_data_local_storage_helper.h" +#include "chrome/browser/content_settings/content_settings_details.h" +#include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/cookies_tree_model.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/common/render_messages.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_delegate.h" +#include "content/common/notification_service.h" +#include "content/common/view_messages.h" #include "net/base/cookie_monster.h" namespace { @@ -44,6 +49,9 @@ TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) ClearBlockedContentSettingsExceptForCookies(); ClearCookieSpecificContentSettings(); g_tab_specific.Get().push_back(this); + + registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, + NotificationService::AllSources()); } TabSpecificContentSettings::~TabSpecificContentSettings() { @@ -53,18 +61,44 @@ TabSpecificContentSettings::~TabSpecificContentSettings() { TabSpecificContentSettings* TabSpecificContentSettings::Get( int render_process_id, int render_view_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + RenderViewHost* view = RenderViewHost::FromID( + render_process_id, render_view_id); + if (!view) + return NULL; + // We loop through the tab contents and compare them with |view|, instead of + // getting the RVH from each tab contents and comparing its IDs because the + // latter will miss provisional RenderViewHosts. for (TabSpecificList::iterator i = g_tab_specific.Get().begin(); i != g_tab_specific.Get().end(); ++i) { - RenderViewHost* view = (*i)->tab_contents()->render_view_host(); - if (view->process()->id() == render_process_id && - view->routing_id() == render_view_id) { - return (*i); - } + if (view->delegate() == (*i)->tab_contents()) + return (*i); } return NULL; } +void TabSpecificContentSettings::CookiesRead(int render_process_id, + int render_view_id, + const GURL& url, + const net::CookieList& cookie_list, + bool blocked_by_policy) { + TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); + if (settings) + settings->OnCookiesRead(url, cookie_list, blocked_by_policy); +} + +void TabSpecificContentSettings::CookieChanged( + int render_process_id, + int render_view_id, + const GURL& url, + const std::string& cookie_line, + const net::CookieOptions& options, + bool blocked_by_policy) { + TabSpecificContentSettings* settings = Get(render_process_id, render_view_id); + if (settings) + settings->OnCookieChanged(url, cookie_line, options, blocked_by_policy); +} + void TabSpecificContentSettings::WebDatabaseAccessed( int render_process_id, int render_view_id, @@ -338,6 +372,17 @@ CookiesTreeModel* TabSpecificContentSettings::GetBlockedCookiesTreeModel() { return blocked_local_shared_objects_.GetCookiesTreeModel(); } +bool TabSpecificContentSettings::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(TabSpecificContentSettings, message) + IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) + IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + void TabSpecificContentSettings::DidNavigateMainFramePostCommit( const NavigationController::LoadCommittedDetails& details, const ViewHostMsg_FrameNavigate_Params& params) { @@ -352,7 +397,8 @@ void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( int64 frame_id, bool is_main_frame, const GURL& validated_url, - bool is_error_page) { + bool is_error_page, + RenderViewHost* render_view_host) { if (!is_main_frame) return; @@ -362,6 +408,31 @@ void TabSpecificContentSettings::DidStartProvisionalLoadForFrame( if (!is_error_page) ClearCookieSpecificContentSettings(); ClearGeolocationContentSettings(); + + HostContentSettingsMap* map = + tab_contents()->profile()->GetHostContentSettingsMap(); + render_view_host->Send(new ViewMsg_SetContentSettingsForLoadingURL( + render_view_host->routing_id(), validated_url, + map->GetContentSettings(validated_url))); +} + +void TabSpecificContentSettings::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(type.value == NotificationType::CONTENT_SETTINGS_CHANGED); + + Details<const ContentSettingsDetails> settings_details(details); + const NavigationController& controller = tab_contents()->controller(); + NavigationEntry* entry = controller.GetActiveEntry(); + GURL entry_url; + if (entry) + entry_url = entry->url(); + if (settings_details.ptr()->update_all() || + settings_details.ptr()->pattern().Matches(entry_url)) { + Send(new ViewMsg_SetContentSettingsForCurrentURL( + entry_url, tab_contents()->profile()->GetHostContentSettingsMap()-> + GetContentSettings(entry_url))); + } } TabSpecificContentSettings::LocalSharedObjectsContainer:: diff --git a/chrome/browser/content_settings/tab_specific_content_settings.h b/chrome/browser/content_settings/tab_specific_content_settings.h index ddeaf58..f8924ea 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.h +++ b/chrome/browser/content_settings/tab_specific_content_settings.h @@ -10,9 +10,11 @@ #include "chrome/browser/geolocation/geolocation_settings_state.h" #include "chrome/common/content_settings.h" #include "chrome/common/content_settings_types.h" -#include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/tab_contents_observer.h" +#include "content/common/dom_storage_common.h" +#include "content/common/notification_observer.h" +#include "content/common/notification_registrar.h" class CannedBrowsingDataAppCacheHelper; class CannedBrowsingDataDatabaseHelper; @@ -21,14 +23,16 @@ class CannedBrowsingDataLocalStorageHelper; class CookiesTreeModel; class TabContents; class Profile; +struct ContentSettings; namespace net { +class CookieList; class CookieMonster; +class CookieOptions; } -class TabSpecificContentSettings - : public RenderViewHostDelegate::ContentSettings, - public TabContentsObserver { +class TabSpecificContentSettings : public TabContentsObserver, + public NotificationObserver { public: TabSpecificContentSettings(TabContents* tab); @@ -39,6 +43,27 @@ class TabSpecificContentSettings int render_view_id); // Static methods called on the UI threads. + // Called when cookies for the given URL were read either from within the + // current page or while loading it. |blocked_by_policy| should be true, if + // reading cookies was blocked due to the user's content settings. In that + // case, this function should invoke OnContentBlocked. + static void CookiesRead(int render_process_id, + int render_view_id, + const GURL& url, + const net::CookieList& cookie_list, + bool blocked_by_policy); + + // Called when a specific cookie in the current page was changed. + // |blocked_by_policy| should be true, if the cookie was blocked due to the + // user's content settings. In that case, this function should invoke + // OnContentBlocked. + static void CookieChanged(int render_process_id, + int render_view_id, + const GURL& url, + const std::string& cookie_line, + const net::CookieOptions& options, + bool blocked_by_policy); + // Called when a specific Web database in the current page was accessed. If // access was blocked due to the user's content settings, // |blocked_by_policy| should be true, and this function should invoke @@ -120,39 +145,44 @@ class TabSpecificContentSettings load_plugins_link_enabled_ = enabled; } - // RenderViewHostDelegate::ContentSettings implementation. - virtual void OnContentBlocked(ContentSettingsType type, - const std::string& resource_identifier); - virtual void OnCookiesRead(const GURL& url, - const net::CookieList& cookie_list, - bool blocked_by_policy); - virtual void OnCookieChanged(const GURL& url, - const std::string& cookie_line, - const net::CookieOptions& options, - bool blocked_by_policy); - virtual void OnIndexedDBAccessed(const GURL& url, - const string16& description, - bool blocked_by_policy); - virtual void OnLocalStorageAccessed(const GURL& url, - DOMStorageType storage_type, - bool blocked_by_policy); - virtual void OnWebDatabaseAccessed(const GURL& url, - const string16& name, - const string16& display_name, - bool blocked_by_policy); - virtual void OnAppCacheAccessed(const GURL& manifest_url, - bool blocked_by_policy); - virtual void OnGeolocationPermissionSet(const GURL& requesting_frame, - bool allowed); - // TabContentsObserver overrides. + virtual bool OnMessageReceived(const IPC::Message& message); virtual void DidNavigateMainFramePostCommit( const NavigationController::LoadCommittedDetails& details, const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; - virtual void DidStartProvisionalLoadForFrame(int64 frame_id, - bool is_main_frame, - const GURL& validated_url, - bool is_error_page) OVERRIDE; + virtual void DidStartProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + bool is_error_page, + RenderViewHost* render_view_host) OVERRIDE; + + // Message handlers. Public for testing. + void OnContentBlocked(ContentSettingsType type, + const std::string& resource_identifier); + void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); + + // These methods are invoked on the UI thread by the static functions above. + // Public for testing. + void OnCookiesRead(const GURL& url, + const net::CookieList& cookie_list, + bool blocked_by_policy); + void OnCookieChanged(const GURL& url, + const std::string& cookie_line, + const net::CookieOptions& options, + bool blocked_by_policy); + void OnIndexedDBAccessed(const GURL& url, + const string16& description, + bool blocked_by_policy); + void OnLocalStorageAccessed(const GURL& url, + DOMStorageType storage_type, + bool blocked_by_policy); + void OnWebDatabaseAccessed(const GURL& url, + const string16& name, + const string16& display_name, + bool blocked_by_policy); + void OnGeolocationPermissionSet(const GURL& requesting_frame, + bool allowed); private: class LocalSharedObjectsContainer { @@ -200,6 +230,11 @@ class TabSpecificContentSettings void OnContentAccessed(ContentSettingsType type); + // NotificationObserver implementation. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + // Stores which content setting types actually have blocked content. bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; @@ -224,6 +259,8 @@ class TabSpecificContentSettings // Stores whether the user can load blocked plugins on this page. bool load_plugins_link_enabled_; + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettings); }; diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index d17e607..04da675 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -303,7 +303,8 @@ void ExtensionWebNavigationTabObserver::DidStartProvisionalLoadForFrame( int64 frame_id, bool is_main_frame, const GURL& validated_url, - bool is_error_page) { + bool is_error_page, + RenderViewHost* render_view_host) { navigation_state_.TrackFrame(frame_id, validated_url, is_main_frame, diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h index 9510c7c..9f475dc 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.h +++ b/chrome/browser/extensions/extension_webnavigation_api.h @@ -87,10 +87,12 @@ class ExtensionWebNavigationTabObserver : public TabContentsObserver { virtual ~ExtensionWebNavigationTabObserver(); // TabContentsObserver implementation. - virtual void DidStartProvisionalLoadForFrame(int64 frame_id, - bool is_main_frame, - const GURL& validated_url, - bool is_error_page) OVERRIDE; + virtual void DidStartProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + bool is_error_page, + RenderViewHost* render_view_host) OVERRIDE; virtual void DidCommitProvisionalLoadForFrame( int64 frame_id, bool is_main_frame, diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index e12daa4..a57e113 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -208,6 +208,7 @@ ProfileIOData::ProfileIOData(bool is_incognito) : initialized_(false), ALLOW_THIS_IN_INITIALIZER_LIST(resource_context_(this)) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + resource_context_.SetUserData(NULL, this); } ProfileIOData::~ProfileIOData() { @@ -327,7 +328,6 @@ void ProfileIOData::LazyInitialize() const { resource_context_.set_file_system_context(file_system_context_); resource_context_.set_quota_manager(quota_manager_); resource_context_.set_host_zoom_map(host_zoom_map_); - resource_context_.set_host_content_settings_map(host_content_settings_map_); resource_context_.set_extension_info_map(extension_info_map_); resource_context_.set_prerender_manager(prerender_manager_); diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index a46d142..5625c96 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -75,6 +75,13 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { const std::string& app_id) const; const content::ResourceContext& GetResourceContext() const; + // These getters are useful when the Chrome layer is called from the content + // layer with a content::ResourceContext, and they want access to Chrome data + // for that profile. + HostContentSettingsMap* host_content_settings_map() const { + return host_content_settings_map_; + } + protected: friend class base::RefCountedThreadSafe<ProfileIOData>; diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index 56caebd..63f19b5 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -84,6 +84,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, IPC_MESSAGE_HANDLER(ViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) IPC_MESSAGE_HANDLER(ViewHostMsg_AllowFileSystem, OnAllowFileSystem) IPC_MESSAGE_HANDLER(ViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) + IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginContentSetting, + OnGetPluginContentSetting) IPC_MESSAGE_HANDLER(ViewHostMsg_CanTriggerClipboardRead, OnCanTriggerClipboardRead) IPC_MESSAGE_HANDLER(ViewHostMsg_CanTriggerClipboardWrite, @@ -396,6 +398,14 @@ void ChromeRenderMessageFilter::OnAllowIndexedDB(int render_view_id, render_process_id_, render_view_id, url, name, !*allowed)); } +void ChromeRenderMessageFilter::OnGetPluginContentSetting( + const GURL& policy_url, + const std::string& resource, + ContentSetting* setting) { + *setting = host_content_settings_map_->GetContentSetting( + policy_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource); +} + void ChromeRenderMessageFilter::OnCanTriggerClipboardRead(const GURL& url, bool* allowed) { ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h index a3293b3..59b34de 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.h +++ b/chrome/browser/renderer_host/chrome_render_message_filter.h @@ -98,6 +98,9 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { const string16& origin_url, const string16& name, bool* allowed); + void OnGetPluginContentSetting(const GURL& policy_url, + const std::string& resource, + ContentSetting* setting); void OnCanTriggerClipboardRead(const GURL& url, bool* allowed); void OnCanTriggerClipboardWrite(const GURL& url, bool* allowed); void OnGetCookies(const GURL& url, diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc index 32b5b4c..fe472a6 100644 --- a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc +++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc @@ -96,7 +96,7 @@ void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents, NEW_POPUP, initial_pos, true); // user_gesture - tab_contents()->GetContentSettingsDelegate()->OnContentBlocked( + tab_contents()->GetTabSpecificContentSettings()->OnContentBlocked( CONTENT_SETTINGS_TYPE_POPUPS, std::string()); } } diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index c3db8f6..90816ea 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -330,6 +330,25 @@ IPC_SYNC_MESSAGE_CONTROL3_1(ViewHostMsg_AllowIndexedDB, string16 /* database name */, bool /* allowed */) +// Gets the content setting for a plugin. +// If |setting| is set to CONTENT_SETTING_BLOCK, the plug-in is +// blocked by the content settings for |policy_url|. It still +// appears in navigator.plugins in Javascript though, and can be +// loaded via click-to-play. +// +// If |setting| is set to CONTENT_SETTING_ALLOW, the domain is +// explicitly white-listed for the plug-in, or the user has chosen +// not to block nonsandboxed plugins. +// +// If |setting| is set to CONTENT_SETTING_DEFAULT, the plug-in is +// neither blocked nor white-listed, which means that it's allowed +// by default and can still be blocked if it's non-sandboxed. +// +IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_GetPluginContentSetting, + GURL /* policy_url */, + std::string /* resource */, + ContentSetting /* setting */) + // Specifies the URL as the first parameter (a wstring) and thumbnail as // binary data as the second parameter. IPC_MESSAGE_ROUTED3(ViewHostMsg_Thumbnail, diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 4d38a15..05a62ac 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -244,22 +244,29 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( WebFrame* frame, const WebPluginParams& original_params) { bool found = false; - int plugin_setting = CONTENT_SETTING_DEFAULT; CommandLine* cmd = CommandLine::ForCurrentProcess(); webkit::npapi::WebPluginInfo info; GURL url(original_params.url); std::string actual_mime_type; render_view->Send(new ViewHostMsg_GetPluginInfo( render_view->routing_id(), url, frame->top()->url(), - original_params.mimeType.utf8(), &found, &info, &plugin_setting, - &actual_mime_type)); + original_params.mimeType.utf8(), &found, &info, &actual_mime_type)); if (!found) return NULL; - DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); if (!webkit::npapi::IsPluginEnabled(info)) return NULL; + const webkit::npapi::PluginGroup* group = + webkit::npapi::PluginList::Singleton()->GetPluginGroup(info); + DCHECK(group != NULL); + + ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; + std::string resource = group->identifier(); + render_view->Send(new ViewHostMsg_GetPluginContentSetting( + frame->top()->url(), resource, &plugin_setting)); + DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); + WebPluginParams params(original_params); for (size_t i = 0; i < info.mime_types.size(); ++i) { if (info.mime_types[i].mime_type == actual_mime_type) { @@ -271,10 +278,6 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( } } - const webkit::npapi::PluginGroup* group = - webkit::npapi::PluginList::Singleton()->GetPluginGroup(info); - DCHECK(group != NULL); - ContentSetting outdated_policy = CONTENT_SETTING_ASK; ContentSetting authorize_policy = CONTENT_SETTING_ASK; if (group->IsVulnerable() || group->RequiresAuthorization()) { @@ -342,10 +345,9 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( frame, params, info.path, actual_mime_type); } - std::string resource; - if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) - resource = group->identifier(); - observer->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); + observer->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, + cmd->HasSwitch(switches::kEnableResourceContentSettings) ? + resource : std::string()); if (plugin_setting == CONTENT_SETTING_ASK) { return CreatePluginPlaceholder( render_view, frame, params, *group, IDR_CLICK_TO_PLAY_PLUGIN_HTML, diff --git a/chrome/renderer/chrome_render_view_observer.h b/chrome/renderer/chrome_render_view_observer.h index 863a5b9..6fe6c11 100644 --- a/chrome/renderer/chrome_render_view_observer.h +++ b/chrome/renderer/chrome_render_view_observer.h @@ -69,8 +69,7 @@ class ChromeRenderViewObserver : public RenderViewObserver, const WebKit::WebString& name, const WebKit::WebString& display_name, unsigned long estimated_size) OVERRIDE; - // TODO(jam): add OVERRIDE once WebKit is rolled. - virtual bool allowFileSystem(WebKit::WebFrame* frame); + virtual bool allowFileSystem(WebKit::WebFrame* frame) OVERRIDE; virtual bool allowImages(WebKit::WebFrame* frame, bool enabled_per_settings) OVERRIDE; virtual bool allowIndexedDB(WebKit::WebFrame* frame, diff --git a/content/browser/DEPS b/content/browser/DEPS index 8515ee5..ca5f7c5 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS @@ -15,10 +15,8 @@ include_rules = [ "+chrome/browser/browser_url_handler.h",
# http://crbug.com/76793
- "+chrome/browser/content_settings/content_settings_details.h",
"+chrome/browser/content_settings/host_content_settings_map.h",
"+chrome/browser/content_settings/tab_specific_content_settings.h",
- "+chrome/common/content_settings.h",
"+chrome/common/content_settings_types.h",
"+chrome/browser/chromeos/cros/cros_library.h",
diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc index 8265d09..bc40db4 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" #include "content/browser/browser_thread.h" #include "content/browser/in_process_webkit/indexed_db_callbacks.h" #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" @@ -60,10 +59,8 @@ void DeleteOnWebKitThread(T* obj) { } IndexedDBDispatcherHost::IndexedDBDispatcherHost( - int process_id, WebKitContext* webkit_context, - HostContentSettingsMap* host_content_settings_map) + int process_id, WebKitContext* webkit_context) : webkit_context_(webkit_context), - host_content_settings_map_(host_content_settings_map), ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( new DatabaseDispatcherHost(this))), ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h index 2376834..fbe8bfc 100644 --- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -12,7 +12,6 @@ #include "content/browser/in_process_webkit/webkit_context.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" -class HostContentSettingsMap; class IndexedDBKey; class NullableString16; class Profile; @@ -37,9 +36,7 @@ class WebIDBTransaction; class IndexedDBDispatcherHost : public BrowserMessageFilter { public: // Only call the constructor from the UI thread. - IndexedDBDispatcherHost( - int process_id, WebKitContext* webkit_context, - HostContentSettingsMap* host_content_settings_map); + IndexedDBDispatcherHost(int process_id, WebKitContext* webkit_context); // BrowserMessageFilter implementation. virtual void OnChannelClosing(); @@ -258,9 +255,6 @@ class IndexedDBDispatcherHost : public BrowserMessageFilter { // Data shared between renderer processes with the same profile. scoped_refptr<WebKitContext> webkit_context_; - // Tells us whether the user wants to allow databases to be opened. - scoped_refptr<HostContentSettingsMap> host_content_settings_map_; - // Only access on WebKit thread. scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc index 735266c..7c0e621 100644 --- a/content/browser/renderer_host/async_resource_handler.cc +++ b/content/browser/renderer_host/async_resource_handler.cc @@ -11,7 +11,6 @@ #include "base/logging.h" #include "base/shared_memory.h" #include "chrome/browser/debugger/devtools_netlog_observer.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/net/load_timing_observer.h" #include "chrome/common/render_messages.h" #include "content/browser/host_zoom_map.h" @@ -82,12 +81,10 @@ AsyncResourceHandler::AsyncResourceHandler( int routing_id, const GURL& url, HostZoomMap* host_zoom_map, - HostContentSettingsMap* host_content_settings_map, ResourceDispatcherHost* resource_dispatcher_host) : filter_(filter), routing_id_(routing_id), host_zoom_map_(host_zoom_map), - host_content_settings_map_(host_content_settings_map), rdh_(resource_dispatcher_host), next_buffer_size_(kInitialReadBufSize) { } @@ -132,9 +129,6 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, if (info->resource_type() == ResourceType::MAIN_FRAME && request->context()) { GURL request_url(request->url()); - filter_->Send(new ViewMsg_SetContentSettingsForLoadingURL( - info->route_id(), request_url, - host_content_settings_map_->GetContentSettings(request_url))); filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( info->route_id(), request_url, host_zoom_map_->GetZoomLevel(request_url))); diff --git a/content/browser/renderer_host/async_resource_handler.h b/content/browser/renderer_host/async_resource_handler.h index 8c60256..ea33a19 100644 --- a/content/browser/renderer_host/async_resource_handler.h +++ b/content/browser/renderer_host/async_resource_handler.h @@ -10,7 +10,6 @@ #include "content/browser/renderer_host/resource_handler.h" -class HostContentSettingsMap; class HostZoomMap; class ResourceDispatcherHost; class ResourceMessageFilter; @@ -24,7 +23,6 @@ class AsyncResourceHandler : public ResourceHandler { int routing_id, const GURL& url, HostZoomMap* host_zoom_map, - HostContentSettingsMap* host_content_settings_map, ResourceDispatcherHost* resource_dispatcher_host); // ResourceHandler implementation: @@ -51,7 +49,6 @@ class AsyncResourceHandler : public ResourceHandler { ResourceMessageFilter* filter_; int routing_id_; HostZoomMap* host_zoom_map_; - HostContentSettingsMap* host_content_settings_map_; ResourceDispatcherHost* rdh_; // |next_buffer_size_| is the size of the buffer to be allocated on the next diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index 9245a06..ef8d040 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -356,8 +356,7 @@ void BrowserRenderProcessHost::CreateMessageFilters() { channel_->AddFilter( new DOMStorageMessageFilter(id(), profile()->GetWebKitContext())); channel_->AddFilter( - new IndexedDBDispatcherHost(id(), profile()->GetWebKitContext(), - profile()->GetHostContentSettingsMap())); + new IndexedDBDispatcherHost(id(), profile()->GetWebKitContext())); channel_->AddFilter( GeolocationDispatcherHost::New( id(), profile()->GetGeolocationPermissionContext())); diff --git a/content/browser/renderer_host/database_message_filter.h b/content/browser/renderer_host/database_message_filter.h index 9d14d32..1cfc659 100644 --- a/content/browser/renderer_host/database_message_filter.h +++ b/content/browser/renderer_host/database_message_filter.h @@ -8,7 +8,6 @@ #include "base/hash_tables.h" #include "base/string16.h" -#include "chrome/common/content_settings.h" #include "content/browser/browser_message_filter.h" #include "webkit/database/database_connections.h" #include "webkit/database/database_tracker.h" diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 2deb61b..6529ea3 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -13,7 +13,6 @@ #include "base/threading/worker_pool.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/download/download_types.h" #include "chrome/browser/download/download_util.h" #include "chrome/browser/extensions/extension_info_map.h" @@ -277,7 +276,6 @@ RenderMessageFilter::RenderMessageFilter( plugin_service_(plugin_service), profile_(profile), extension_info_map_(profile->GetExtensionInfoMap()), - content_settings_(profile->GetHostContentSettingsMap()), request_context_(request_context), resource_context_(profile->GetResourceContext()), extensions_request_context_(profile->GetRequestContextForExtensions()), @@ -585,21 +583,13 @@ void RenderMessageFilter::OnGetPluginInfo( const std::string& mime_type, bool* found, webkit::npapi::WebPluginInfo* info, - int* setting, std::string* actual_mime_type) { *found = plugin_service_->GetFirstAllowedPluginInfo( render_process_id_, routing_id, url, mime_type, info, actual_mime_type); - *setting = CONTENT_SETTING_DEFAULT; if (*found) { if (!plugin_service_->PluginAllowedForURL(info->path, policy_url)) info->enabled |= webkit::npapi::WebPluginInfo::POLICY_DISABLED; - std::string resource = - webkit::npapi::PluginList::Singleton()->GetPluginGroupIdentifier(*info); - *setting = content_settings_->GetContentSetting( - policy_url, - CONTENT_SETTINGS_TYPE_PLUGINS, - resource); } } diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index efd471c..d1702c0 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h @@ -19,7 +19,6 @@ #include "base/string16.h" #include "base/task.h" #include "build/build_config.h" -#include "chrome/common/content_settings.h" #include "content/browser/browser_message_filter.h" #include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -157,7 +156,6 @@ class RenderMessageFilter : public BrowserMessageFilter { const std::string& mime_type, bool* found, webkit::npapi::WebPluginInfo* info, - int* setting, std::string* actual_mime_type); void OnOpenChannelToPlugin(int routing_id, const GURL& url, @@ -241,10 +239,6 @@ class RenderMessageFilter : public BrowserMessageFilter { // access it on other threads. ExtensionInfoMap* extension_info_map_; - // The host content settings map. Stored separately from the profile so we can - // access it on other threads. - HostContentSettingsMap* content_settings_; - // Contextual information to be used for requests created here. scoped_refptr<net::URLRequestContextGetter> request_context_; diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 1b5f88f..bd54a62 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -771,8 +771,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, OnAccessibilityNotifications) IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) - IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) - IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) @@ -1332,11 +1330,6 @@ void RenderViewHost::PerformCustomContextMenuAction( action)); } -void RenderViewHost::SendContentSettings(const GURL& url, - const ContentSettings& settings) { - Send(new ViewMsg_SetContentSettingsForCurrentURL(url, settings)); -} - void RenderViewHost::EnablePreferredSizeChangedMode(int flags) { Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id(), flags)); } @@ -1406,23 +1399,6 @@ void RenderViewHost::OnCSSInserted() { delegate_->DidInsertCSS(); } -void RenderViewHost::OnContentBlocked(ContentSettingsType type, - const std::string& resource_identifier) { - RenderViewHostDelegate::ContentSettings* content_settings_delegate = - delegate_->GetContentSettingsDelegate(); - if (content_settings_delegate) - content_settings_delegate->OnContentBlocked(type, resource_identifier); -} - -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::OnUpdateZoomLimits(int minimum_percent, int maximum_percent, bool remember) { diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index abc2bf0..958df19 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -13,7 +13,6 @@ #include "base/observer_list.h" #include "base/process_util.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" -#include "chrome/common/content_settings_types.h" #include "chrome/common/view_types.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/common/page_zoom.h" @@ -36,7 +35,6 @@ class SessionStorageNamespace; class SiteInstance; class SkBitmap; class ViewMsg_Navigate; -struct ContentSettings; struct ContextMenuParams; struct MediaPlayerAction; struct ViewHostMsg_AccessibilityNotification_Params; @@ -421,10 +419,6 @@ class RenderViewHost : public RenderWidgetHost { const webkit_glue::CustomContextMenuContext& custom_context, unsigned action); - // Informs renderer of updated content settings. - void SendContentSettings(const GURL& url, - const ContentSettings& settings); - // Tells the renderer to notify us when the page contents preferred size // changed. |flags| is a combination of // |ViewHostMsg_EnablePreferredSizeChangedMode_Flags| values, which is defined @@ -536,9 +530,6 @@ class RenderViewHost : public RenderWidgetHost { void OnAccessibilityNotifications( const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params); void OnCSSInserted(); - void OnContentBlocked(ContentSettingsType type, - const std::string& resource_identifier); - void OnAppCacheAccessed(const GURL& manifest_url, bool blocked_by_policy); void OnUpdateZoomLimits(int minimum_percent, int maximum_percent, bool remember); diff --git a/content/browser/renderer_host/render_view_host_delegate.cc b/content/browser/renderer_host/render_view_host_delegate.cc index e6e7df3..c2fcd8a 100644 --- a/content/browser/renderer_host/render_view_host_delegate.cc +++ b/content/browser/renderer_host/render_view_host_delegate.cc @@ -20,11 +20,6 @@ RenderViewHostDelegate::GetRendererManagementDelegate() { return NULL; } -RenderViewHostDelegate::ContentSettings* -RenderViewHostDelegate::GetContentSettingsDelegate() { - return NULL; -} - RenderViewHostDelegate::BookmarkDrag* RenderViewHostDelegate::GetBookmarkDragDelegate() { return NULL; diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h index cb48801..2cc0b0c 100644 --- a/content/browser/renderer_host/render_view_host_delegate.h +++ b/content/browser/renderer_host/render_view_host_delegate.h @@ -13,9 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/process_util.h" #include "base/string16.h" -#include "chrome/common/content_settings_types.h" #include "chrome/common/view_types.h" -#include "content/common/dom_storage_common.h" #include "content/common/window_container_type.h" #include "ipc/ipc_channel.h" #include "net/base/load_states.h" @@ -239,66 +237,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener { virtual ~RendererManagement() {} }; - // ContentSettings------------------------------------------------------------ - // Interface for content settings related events. - - class ContentSettings { - public: - // Called when content in the current page was blocked due to the user's - // content settings. - virtual void OnContentBlocked(ContentSettingsType type, - const std::string& resource_identifier) = 0; - - // Called when cookies for the given URL were read either from within the - // current page or while loading it. |blocked_by_policy| should be true, if - // reading cookies was blocked due to the user's content settings. In that - // case, this function should invoke OnContentBlocked. - virtual void OnCookiesRead( - const GURL& url, - const net::CookieList& cookie_list, - bool blocked_by_policy) = 0; - - // Called when a specific cookie in the current page was changed. - // |blocked_by_policy| should be true, if the cookie was blocked due to the - // user's content settings. In that case, this function should invoke - // OnContentBlocked. - virtual void OnCookieChanged(const GURL& url, - const std::string& cookie_line, - const net::CookieOptions& options, - bool blocked_by_policy) = 0; - - // Called when a specific indexed db factory in the current page was - // accessed. If access was blocked due to the user's content settings, - // |blocked_by_policy| should be true, and this function should invoke - // OnContentBlocked. - virtual void OnIndexedDBAccessed(const GURL& url, - const string16& description, - bool blocked_by_policy) = 0; - - // Called when a specific local storage area in the current page was - // accessed. If access was blocked due to the user's content settings, - // |blocked_by_policy| should be true, and this function should invoke - // OnContentBlocked. - virtual void OnLocalStorageAccessed(const GURL& url, - DOMStorageType storage_type, - 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, - bool allowed) = 0; - - protected: - virtual ~ContentSettings() {} - }; - // BookmarkDrag -------------------------------------------------------------- // Interface for forwarding bookmark drag and drop to extenstions. @@ -360,7 +298,6 @@ class RenderViewHostDelegate : public IPC::Channel::Listener { // there is no corresponding delegate. virtual View* GetViewDelegate(); virtual RendererManagement* GetRendererManagementDelegate(); - virtual ContentSettings* GetContentSettingsDelegate(); virtual BookmarkDrag* GetBookmarkDragDelegate(); virtual SSL* GetSSLDelegate(); diff --git a/content/browser/renderer_host/render_view_host_notification_task.h b/content/browser/renderer_host/render_view_host_notification_task.h index c1904ba..c5e79da 100644 --- a/content/browser/renderer_host/render_view_host_notification_task.h +++ b/content/browser/renderer_host/render_view_host_notification_task.h @@ -70,33 +70,6 @@ inline void CallRenderViewHostHelper(int render_process_id, int render_view_id, params)); } -// For proxying calls to RenderViewHostDelegate::ContentSettings - -class RenderViewHostToContentSettingsDelegate { - public: - typedef RenderViewHostDelegate::ContentSettings MappedType; - static MappedType* Map(RenderViewHost* rvh) { - return rvh ? rvh->delegate()->GetContentSettingsDelegate() : NULL; - } -}; - -template <typename Method, typename Params> -inline void CallRenderViewHostContentSettingsDelegateHelper( - int render_process_id, - int render_view_id, - Method method, - const Params& params) { - - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - new RenderViewHostNotificationTask< - Method, Params, RenderViewHostToContentSettingsDelegate>( - render_process_id, - render_view_id, - method, - params)); -} - // For proxying calls to RenderViewHostDelegate::RendererManagement class RenderViewHostToRendererManagementDelegate { @@ -188,84 +161,6 @@ inline void CallRenderViewHost(int render_process_id, } // ---------------------------------------------------------------------------- -// Proxy calls to the specified RenderViewHost's ContentSettings delegate. - -template <typename Method> -inline void CallRenderViewHostContentSettingsDelegate(int render_process_id, - int render_view_id, - Method method) { - internal::CallRenderViewHostContentSettingsDelegateHelper(render_process_id, - render_view_id, - method, - MakeTuple()); -} - -template <typename Method, typename A> -inline void CallRenderViewHostContentSettingsDelegate(int render_process_id, - int render_view_id, - Method method, - const A& a) { - internal::CallRenderViewHostContentSettingsDelegateHelper(render_process_id, - render_view_id, - method, - MakeTuple(a)); - } - -template <typename Method, typename A, typename B> -inline void CallRenderViewHostContentSettingsDelegate(int render_process_id, - int render_view_id, - Method method, - const A& a, - const B& b) { - internal::CallRenderViewHostContentSettingsDelegateHelper(render_process_id, - render_view_id, - method, - MakeTuple(a, b)); -} - -template <typename Method, typename A, typename B, typename C> -inline void CallRenderViewHostContentSettingsDelegate(int render_process_id, - int render_view_id, - Method method, - const A& a, - const B& b, - const C& c) { - internal::CallRenderViewHostContentSettingsDelegateHelper(render_process_id, - render_view_id, - method, - MakeTuple(a, b, c)); -} - -template <typename Method, typename A, typename B, typename C, typename D> -inline void CallRenderViewHostContentSettingsDelegate(int render_process_id, - int render_view_id, - Method method, - const A& a, - const B& b, - const C& c, - const D& d) { - internal::CallRenderViewHostContentSettingsDelegateHelper( - render_process_id, - render_view_id, - method, - MakeTuple(a, b, c, d)); -} - -template <typename Method, - typename A, typename B, typename C, typename D, typename E> -inline void CallRenderViewHostContentSettingsDelegate(int render_process_id, - int render_view_id, - Method method, - const A& a, - const B& b, - const C& c, - const D& d, - const E& e) { - internal::CallRenderViewHostContentSettingsDelegateHelper( - render_process_id, render_view_id, method, MakeTuple(a, b, c, d, e)); -} - -// ---------------------------------------------------------------------------- // Proxy calls to the specified RenderViewHost's RendererManagement delegate. template <typename Method> diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index a9525dd..fac9a705 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -454,9 +454,7 @@ void ResourceDispatcherHost::BeginRequest( filter_, request_data.url, sync_result, this); } else { handler = new AsyncResourceHandler( - filter_, route_id, request_data.url, - resource_context.host_zoom_map(), - resource_context.host_content_settings_map(), + filter_, route_id, request_data.url, resource_context.host_zoom_map(), this); } diff --git a/content/browser/resource_context.cc b/content/browser/resource_context.cc index d167c77..6af4651 100644 --- a/content/browser/resource_context.cc +++ b/content/browser/resource_context.cc @@ -22,6 +22,17 @@ ResourceContext::ResourceContext() ResourceContext::~ResourceContext() {} +void* ResourceContext::GetUserData(const void* key) const { + UserDataMap::const_iterator found = user_data_.find(key); + if (found != user_data_.end()) + return found->second; + return NULL; +} + +void ResourceContext::SetUserData(const void* key, void* data) { + user_data_[key] = data; +} + net::HostResolver* ResourceContext::host_resolver() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); EnsureInitialized(); @@ -117,18 +128,6 @@ void ResourceContext::set_host_zoom_map(HostZoomMap* host_zoom_map) { host_zoom_map_ = host_zoom_map; } -HostContentSettingsMap* ResourceContext::host_content_settings_map() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - EnsureInitialized(); - return host_content_settings_map_; -} - -void ResourceContext::set_host_content_settings_map( - HostContentSettingsMap* host_content_settings_map) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - host_content_settings_map_ = host_content_settings_map; -} - const ExtensionInfoMap* ResourceContext::extension_info_map() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); EnsureInitialized(); diff --git a/content/browser/resource_context.h b/content/browser/resource_context.h index 85376d0..3e71ef4 100644 --- a/content/browser/resource_context.h +++ b/content/browser/resource_context.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_RESOURCE_CONTEXT_H_ #define CONTENT_BROWSER_RESOURCE_CONTEXT_H_ +#include <map> + #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -12,7 +14,6 @@ class ChromeAppCacheService; class ChromeBlobStorageContext; class ExtensionInfoMap; -class HostContentSettingsMap; class HostZoomMap; namespace fileapi { class FileSystemContext; @@ -41,6 +42,11 @@ class ResourceContext { public: virtual ~ResourceContext(); + // The user data allows the clients to associate data with this request. + // Multiple user data values can be stored under different keys. + void* GetUserData(const void* key) const; + void SetUserData(const void* key, void* data); + net::HostResolver* host_resolver() const; void set_host_resolver(net::HostResolver* host_resolver); @@ -68,11 +74,6 @@ class ResourceContext { // ======================================================================= // TODO(willchan): These don't belong in content/. Remove them eventually. - // TODO(jam): Kill this one. - HostContentSettingsMap* host_content_settings_map() const; - void set_host_content_settings_map( - HostContentSettingsMap* host_content_settings_map); - // TODO(mpcomplete): Kill this one. const ExtensionInfoMap* extension_info_map() const; void set_extension_info_map(ExtensionInfoMap* extension_info_map); @@ -97,10 +98,14 @@ class ResourceContext { quota::QuotaManager* quota_manager_; HostZoomMap* host_zoom_map_; + // Externally-defined data accessible by key. + typedef std::map<const void*, void*> UserDataMap; + UserDataMap user_data_; + + // ======================================================================= // TODO(willchan): These don't belong in content/. Remove them eventually. - HostContentSettingsMap* host_content_settings_map_; ExtensionInfoMap* extension_info_map_; base::WeakPtr<prerender::PrerenderManager> prerender_manager_; diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 4d33f4e..fc201e4 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -15,8 +15,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" -#include "chrome/browser/content_settings/content_settings_details.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/defaults.h" @@ -270,10 +268,6 @@ TabContents::TabContents(Profile* profile, registrar_.Add(this, NotificationType::USER_STYLE_SHEET_UPDATED, NotificationService::AllSources()); - // Register for notifications about content setting changes. - registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, - NotificationService::AllSources()); - // Listen for Google URL changes. registrar_.Add(this, NotificationType::GOOGLE_URL_UPDATED, NotificationService::AllSources()); @@ -1029,10 +1023,13 @@ void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), GetRenderProcessHost()->id(), &validated_url); + RenderViewHost* rvh = + render_manager_.pending_render_view_host() ? + render_manager_.pending_render_view_host() : render_view_host(); // Notify observers about the start of the provisional load. FOR_EACH_OBSERVER(TabContentsObserver, observers_, DidStartProvisionalLoadForFrame(frame_id, is_main_frame, - validated_url, is_error_page)); + validated_url, is_error_page, rvh)); if (is_main_frame) { // Notify observers about the provisional change in the main frame URL. @@ -1503,11 +1500,6 @@ TabContents::GetRendererManagementDelegate() { return &render_manager_; } -RenderViewHostDelegate::ContentSettings* -TabContents::GetContentSettingsDelegate() { - return content_settings_delegate_.get(); -} - RenderViewHostDelegate::SSL* TabContents::GetSSLDelegate() { return GetSSLHelper(); } @@ -2189,21 +2181,6 @@ void TabContents::Observe(NotificationType type, UpdateWebPreferences(); break; - case NotificationType::CONTENT_SETTINGS_CHANGED: { - Details<const ContentSettingsDetails> settings_details(details); - NavigationEntry* entry = controller_.GetActiveEntry(); - GURL entry_url; - if (entry) - entry_url = entry->url(); - if (settings_details.ptr()->update_all() || - settings_details.ptr()->pattern().Matches(entry_url)) { - render_view_host()->SendContentSettings(entry_url, - profile()->GetHostContentSettingsMap()-> - GetContentSettings(entry_url)); - } - break; - } - case NotificationType::GOOGLE_URL_UPDATED: UpdateAlternateErrorPageURL(); break; diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 6f124435..87e0fde 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -554,8 +554,6 @@ class TabContents : public PageNavigator, // the pending WebUI, the committed WebUI, or NULL. WebUI* GetWebUIForCurrentState(); - // From RenderViewHostDelegate. - virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate(); protected: friend class TabContentsObserver; diff --git a/content/browser/tab_contents/tab_contents_observer.cc b/content/browser/tab_contents/tab_contents_observer.cc index 5649de6..3056608 100644 --- a/content/browser/tab_contents/tab_contents_observer.cc +++ b/content/browser/tab_contents/tab_contents_observer.cc @@ -44,7 +44,8 @@ void TabContentsObserver::DidStartProvisionalLoadForFrame( int64 frame_id, bool is_main_frame, const GURL& validated_url, - bool is_error_page) { + bool is_error_page, + RenderViewHost* render_view_host) { } void TabContentsObserver::ProvisionalChangeToMainFrameUrl(const GURL& url) { diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h index bc1aba2..cc73b4f 100644 --- a/content/browser/tab_contents/tab_contents_observer.h +++ b/content/browser/tab_contents/tab_contents_observer.h @@ -10,6 +10,7 @@ #include "ipc/ipc_channel.h" #include "webkit/glue/window_open_disposition.h" +class RenderViewHost; struct ViewHostMsg_FrameNavigate_Params; // An observer API implemented by classes which are interested in various page @@ -47,10 +48,14 @@ class TabContentsObserver : public IPC::Channel::Listener, virtual void DidNavigateAnyFramePostCommit( const NavigationController::LoadCommittedDetails& details, const ViewHostMsg_FrameNavigate_Params& params); - virtual void DidStartProvisionalLoadForFrame(int64 frame_id, - bool is_main_frame, - const GURL& validated_url, - bool is_error_page); + // |render_view_host| is the RenderViewHost for which the provisional load is + // happening. + virtual void DidStartProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + bool is_error_page, + RenderViewHost* render_view_host); virtual void ProvisionalChangeToMainFrameUrl(const GURL& url); virtual void DidCommitProvisionalLoadForFrame( int64 frame_id, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 16e07a2..dfbc1be 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1489,34 +1489,16 @@ IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetPlugins, // type. If there is no matching plugin, |found| is false. If // |enabled| in the WebPluginInfo struct is false, the plug-in is // treated as if it was not installed at all. -// -// TODO(jam): until we get ContentSetting out of content completely, sending it -// as int temporarily so we can move these messages to content. -// -// If |setting| is set to CONTENT_SETTING_BLOCK, the plug-in is -// blocked by the content settings for |policy_url|. It still -// appears in navigator.plugins in Javascript though, and can be -// loaded via click-to-play. -// -// If |setting| is set to CONTENT_SETTING_ALLOW, the domain is -// explicitly white-listed for the plug-in, or the user has chosen -// not to block nonsandboxed plugins. -// -// If |setting| is set to CONTENT_SETTING_DEFAULT, the plug-in is -// neither blocked nor white-listed, which means that it's allowed -// by default and can still be blocked if it's non-sandboxed. -// // |actual_mime_type| is the actual mime type supported by the // plugin found that match the URL given (one for each item in // |info|). -IPC_SYNC_MESSAGE_CONTROL4_4(ViewHostMsg_GetPluginInfo, +IPC_SYNC_MESSAGE_CONTROL4_3(ViewHostMsg_GetPluginInfo, int /* routing_id */, GURL /* url */, GURL /* policy_url */, std::string /* mime_type */, bool /* found */, webkit::npapi::WebPluginInfo /* plugin info */, - int /* setting */, std::string /* actual_mime_type */) // A renderer sends this to the browser process when it wants to diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index 2469fcf..25c3763 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -530,11 +530,10 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, const WebPluginParams& params) { webkit::npapi::WebPluginInfo info; bool found; - int content_setting; std::string mime_type; Send(new ViewHostMsg_GetPluginInfo( routing_id_, params.url, frame->top()->url(), params.mimeType.utf8(), - &found, &info, &content_setting, &mime_type)); + &found, &info, &mime_type)); if (!found || !webkit::npapi::IsPluginEnabled(info)) return NULL; |