Chromium Code Reviews| Index: content/browser/renderer_host/render_message_filter.cc |
| diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc |
| index 0e076ca6174b3641e10fbb750be9f14e85f64aac..67c56f514c59744b9690f1ba10dc359b94d421be 100644 |
| --- a/content/browser/renderer_host/render_message_filter.cc |
| +++ b/content/browser/renderer_host/render_message_filter.cc |
| @@ -20,7 +20,6 @@ |
| #include "content/browser/child_process_security_policy.h" |
| #include "content/browser/content_browser_client.h" |
| #include "content/browser/plugin_process_host.h" |
| -#include "content/browser/plugin_service.h" |
| #include "content/browser/ppapi_plugin_process_host.h" |
| #include "content/browser/ppapi_broker_process_host.h" |
| #include "content/browser/renderer_host/browser_render_process_host.h" |
| @@ -118,27 +117,34 @@ class OpenChannelToNpapiPluginCallback : public RenderMessageCompletionCallback, |
| public PluginProcessHost::Client { |
| public: |
| OpenChannelToNpapiPluginCallback(RenderMessageFilter* filter, |
| + const content::ResourceContext* context, |
| IPC::Message* reply_msg) |
| - : RenderMessageCompletionCallback(filter, reply_msg) { |
| + : RenderMessageCompletionCallback(filter, reply_msg), |
| + context_(context) { |
| } |
| - virtual int ID() { |
| + virtual int ID() OVERRIDE { |
| return filter()->render_process_id(); |
| } |
| - virtual bool OffTheRecord() { |
| + virtual const content::ResourceContext* GetResourceContext() OVERRIDE { |
| + return context_; |
| + } |
| + |
| + virtual bool OffTheRecord() OVERRIDE { |
| return filter()->OffTheRecord(); |
| } |
| - virtual void SetPluginInfo(const webkit::npapi::WebPluginInfo& info) { |
| + virtual void SetPluginInfo( |
| + const webkit::npapi::WebPluginInfo& info) OVERRIDE { |
| info_ = info; |
| } |
| - virtual void OnChannelOpened(const IPC::ChannelHandle& handle) { |
| + virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE { |
| WriteReplyAndDeleteThis(handle); |
| } |
| - virtual void OnError() { |
| + virtual void OnError() OVERRIDE { |
| WriteReplyAndDeleteThis(IPC::ChannelHandle()); |
| } |
| @@ -149,6 +155,7 @@ class OpenChannelToNpapiPluginCallback : public RenderMessageCompletionCallback, |
| SendReplyAndDeleteThis(); |
| } |
| + const content::ResourceContext* context_; |
| webkit::npapi::WebPluginInfo info_; |
| }; |
| @@ -293,21 +300,6 @@ RenderMessageFilter::~RenderMessageFilter() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| } |
| -void RenderMessageFilter::OverrideThreadForMessage(const IPC::Message& message, |
|
jam
2011/08/01 03:25:44
i believe the changes to this file wouldn't be req
|
| - BrowserThread::ID* thread) { |
| - switch (message.type()) { |
| - // Can't load plugins on IO thread. |
| - case ViewHostMsg_GetPlugins::ID: |
| - // The PluginService::GetPluginInfo may need to load the plugins. Don't do |
| - // it on the IO thread. |
| - case ViewHostMsg_GetPluginInfo::ID: |
| - *thread = BrowserThread::FILE; |
| - break; |
| - default: |
| - break; |
| - } |
| -} |
| - |
| bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message, |
| bool* message_was_ok) { |
| bool handled = true; |
| @@ -337,8 +329,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message, |
| #if defined(OS_MACOSX) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) |
| #endif |
| - IPC_MESSAGE_HANDLER(ViewHostMsg_GetPlugins, OnGetPlugins) |
| - IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginInfo, OnGetPluginInfo) |
| + IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) |
| + IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPluginInfo, OnGetPluginInfo) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) |
| IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin, |
| OnOpenChannelToPlugin) |
| @@ -514,7 +506,7 @@ void RenderMessageFilter::OnPreCacheFont(const LOGFONT& font) { |
| void RenderMessageFilter::OnGetPlugins( |
| bool refresh, |
| - std::vector<webkit::npapi::WebPluginInfo>* plugins) { |
| + IPC::Message* reply_msg) { |
| // Don't refresh if the specified threshold has not been passed. Note that |
| // this check is performed before off-loading to the file thread. The reason |
| // we do this is that some pages tend to request that the list of plugins be |
| @@ -532,12 +524,25 @@ void RenderMessageFilter::OnGetPlugins( |
| } |
| } |
| - std::vector<webkit::npapi::WebPluginInfo> all_plugins; |
| - webkit::npapi::PluginList::Singleton()->GetPlugins(&all_plugins); |
| - for (size_t i = 0; i < all_plugins.size(); ++i) { |
| - if (webkit::npapi::IsPluginEnabled(all_plugins[i])) |
| - plugins->push_back(all_plugins[i]); |
| - } |
| + // The filter needs to be created on the IO thread, but can be used |
| + // on any thread. |
| + int routing_id = MSG_ROUTING_NONE; |
| + PluginService::Filter* filter = |
| + content::GetContentClient()->browser()->CreatePluginFilter( |
| + render_process_id_, routing_id, resource_context_, GURL(), GURL()); |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, NewRunnableMethod( |
| + this, &RenderMessageFilter::GetPluginsOnFileThread, |
| + refresh, filter, reply_msg)); |
| +} |
| + |
| +void RenderMessageFilter::GetPluginsOnFileThread(bool refresh, |
| + PluginService::Filter* filter, |
| + IPC::Message* reply_msg) { |
| + std::vector<webkit::npapi::WebPluginInfo> plugins; |
| + PluginService::GetInstance()->GetPlugins(filter, &plugins); |
| + ViewHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); |
| + Send(reply_msg); |
| } |
| void RenderMessageFilter::OnGetPluginInfo( |
| @@ -545,25 +550,46 @@ void RenderMessageFilter::OnGetPluginInfo( |
| const GURL& url, |
| const GURL& policy_url, |
| const std::string& mime_type, |
| - bool* found, |
| - webkit::npapi::WebPluginInfo* info, |
| - std::string* actual_mime_type) { |
| - *found = plugin_service_->GetPluginInfo( |
| - render_process_id_, routing_id, url, mime_type, info, actual_mime_type); |
| + IPC::Message* reply_msg) { |
| + // The filter needs to be created on the IO thread, but can be used |
| + // on any thread. |
| + PluginService::Filter* filter = |
| + content::GetContentClient()->browser()->CreatePluginFilter( |
| + render_process_id_, routing_id, resource_context_, url, policy_url); |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, NewRunnableMethod( |
| + this, &RenderMessageFilter::GetPluginInfoOnFileThread, |
| + url, mime_type, filter, reply_msg)); |
| +} |
| - if (*found) { |
| - if (!plugin_service_->PluginAllowedForURL(info->path, policy_url)) |
| - info->enabled |= webkit::npapi::WebPluginInfo::POLICY_DISABLED; |
| - } |
| +void RenderMessageFilter::GetPluginInfoOnFileThread( |
| + const GURL& url, |
| + const std::string& mime_type, |
| + PluginService::Filter* filter, |
| + IPC::Message* reply_msg) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| + bool allow_wildcard = true; |
| + webkit::npapi::WebPluginInfo info; |
| + std::string actual_mime_type; |
| + bool found = plugin_service_->GetPluginInfo( |
| + url, mime_type, allow_wildcard, filter, |
| + NULL, &info, &actual_mime_type); |
| + ViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, |
| + found, info, actual_mime_type); |
| + Send(reply_msg); |
| } |
| void RenderMessageFilter::OnOpenChannelToPlugin(int routing_id, |
| const GURL& url, |
| + const GURL& policy_url, |
| const std::string& mime_type, |
| IPC::Message* reply_msg) { |
| plugin_service_->OpenChannelToNpapiPlugin( |
| - render_process_id_, routing_id, url, mime_type, |
| - new OpenChannelToNpapiPluginCallback(this, reply_msg)); |
| + render_process_id_, routing_id, |
| + url, policy_url, mime_type, |
| + new OpenChannelToNpapiPluginCallback(this, |
| + &resource_context_, |
| + reply_msg)); |
| } |
| void RenderMessageFilter::OnOpenChannelToPepperPlugin( |