Chromium Code Reviews| Index: chrome/browser/renderer_host/chrome_render_message_filter.cc |
| diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc |
| index 0b150234da552fc4342ed62a5ac4e07dec744e0f..3ccee3aba8be2b5b4278fd7d2d5ca4ae6ec6b5c9 100644 |
| --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc |
| +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| +#include "base/bind.h" |
| #include "base/file_util.h" |
| #include "base/metrics/histogram.h" |
| #include "chrome/browser/automation/automation_resource_message_filter.h" |
| @@ -26,12 +27,15 @@ |
| #include "chrome/common/extensions/extension_messages.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/render_messages.h" |
| +#include "content/browser/plugin_service.h" |
| +#include "content/browser/plugin_service_filter.h" |
| #include "content/browser/renderer_host/render_process_host.h" |
| #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| #include "content/common/url_constants.h" |
| #include "googleurl/src/gurl.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| +#include "webkit/plugins/npapi/plugin_list.h" |
| #if defined(USE_TCMALLOC) |
| #include "chrome/browser/browser_about_handler.h" |
| @@ -83,6 +87,7 @@ ChromeRenderMessageFilter::ChromeRenderMessageFilter( |
| profile_(profile), |
| request_context_(request_context), |
| extension_info_map_(profile->GetExtensionInfoMap()), |
| + resource_context_(profile->GetResourceContext()), |
| weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated, |
| profile_->GetPrefs(), NULL); |
| @@ -134,6 +139,8 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetPluginContentSetting, |
| OnGetPluginContentSetting) |
| + IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetPluginInfo, |
| + OnGetPluginInfo) |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardRead, |
| OnCanTriggerClipboardRead) |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CanTriggerClipboardWrite, |
| @@ -491,6 +498,79 @@ void ChromeRenderMessageFilter::OnGetPluginContentSetting( |
| resource); |
| } |
| +void ChromeRenderMessageFilter::OnGetPluginInfo( |
| + int render_view_id, |
| + const GURL& url, |
| + const GURL& top_origin_url, |
| + const std::string& mime_type, |
| + IPC::Message* reply_msg) { |
| + PluginService::GetInstance()->EnsurePluginsLoaded( |
| + base::Bind(&ChromeRenderMessageFilter::PluginsLoaded, this, |
| + base::Bind(&ChromeRenderMessageFilter::GetPluginInfo, this, |
| + render_view_id, url, top_origin_url, mime_type), |
| + reply_msg)); |
| +} |
| + |
| +void ChromeRenderMessageFilter::PluginsLoaded( |
| + const GetPluginInfoCallback& callback, |
|
jam
2011/09/30 17:01:21
it seems unnecessary to make a function in one cla
Bernhard Bauer
2011/09/30 17:22:21
Ok. I guess I just like currying stuff now that I
|
| + IPC::Message* reply_msg) { |
| + ChromeViewHostMsg_GetPluginInfo_Params params; |
| + callback.Run(¶ms); |
| + ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, params); |
| + Send(reply_msg); |
| +} |
| + |
| +void ChromeRenderMessageFilter::GetPluginInfo( |
| + int render_view_id, |
| + const GURL& url, |
| + const GURL& top_origin_url, |
| + const std::string& mime_type, |
| + ChromeViewHostMsg_GetPluginInfo_Params* params) { |
| + bool allow_wildcard = true; |
| + std::vector<webkit::WebPluginInfo> matching_plugins; |
| + std::vector<std::string> mime_types; |
| + PluginService::GetInstance()->GetPluginInfoArray( |
| + url, mime_type, allow_wildcard, &matching_plugins, &mime_types); |
| + if (matching_plugins.empty()) { |
| + params->status = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; |
| + return; |
| + } |
| + |
| + if (matching_plugins.size() > 1 && |
| + matching_plugins.back().path == |
| + FilePath(webkit::npapi::kDefaultPluginLibraryName)) { |
| + // If there is at least one plug-in handling the required MIME type (apart |
| + // from the default plug-in), we don't need the default plug-in. |
| + matching_plugins.pop_back(); |
| + } |
| + |
| + content::PluginServiceFilter* filter = PluginService::GetInstance()->filter(); |
| + bool allowed = false; |
| + for (size_t i = 0; i < matching_plugins.size(); ++i) { |
| + if (!filter || filter->ShouldUsePlugin(render_process_id_, |
| + render_view_id, |
| + &resource_context_, |
| + url, |
| + top_origin_url, |
| + &matching_plugins[i])) { |
| + params->plugin = matching_plugins[i]; |
| + params->actual_mime_type = mime_types[i]; |
| + allowed = true; |
| + break; |
| + } else if (i == 0) { |
| + params->plugin = matching_plugins[i]; |
| + params->actual_mime_type = mime_types[i]; |
| + } |
| + } |
| + |
| + if (!allowed) { |
| + params->status = ChromeViewHostMsg_GetPluginInfo_Status::kDisabled; |
| + return; |
| + } |
| + |
| + params->status = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; |
| +} |
| + |
| void ChromeRenderMessageFilter::OnCanTriggerClipboardRead(const GURL& url, |
| bool* allowed) { |
| const Extension* extension = |