Chromium Code Reviews| Index: chrome/browser/plugins/plugin_info_message_filter.cc |
| diff --git a/chrome/browser/plugins/plugin_info_message_filter.cc b/chrome/browser/plugins/plugin_info_message_filter.cc |
| index 6f6e18fd1c146abba9a960857812b3174e2e28e2..073c284e93a7a6384c1808b9d04a9dd5ae78cb49 100644 |
| --- a/chrome/browser/plugins/plugin_info_message_filter.cc |
| +++ b/chrome/browser/plugins/plugin_info_message_filter.cc |
| @@ -10,6 +10,7 @@ |
| #include <utility> |
| #include "base/bind.h" |
| +#include "base/memory/ptr_util.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| @@ -24,6 +25,7 @@ |
| #include "chrome/browser/ui/browser_otr_state.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/common/render_messages.h" |
| +#include "components/component_updater/component_updater_service.h" |
| #include "components/content_settings/core/browser/content_settings_utils.h" |
| #include "components/content_settings/core/browser/host_content_settings_map.h" |
| #include "components/content_settings/core/browser/plugins_field_trial.h" |
| @@ -251,32 +253,32 @@ void PluginInfoMessageFilter::PluginsLoaded( |
| const GetPluginInfo_Params& params, |
| IPC::Message* reply_msg, |
| const std::vector<WebPluginInfo>& plugins) { |
| - ChromeViewHostMsg_GetPluginInfo_Output output; |
| + std::unique_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output( |
| + new ChromeViewHostMsg_GetPluginInfo_Output()); |
| // This also fills in |actual_mime_type|. |
| std::unique_ptr<PluginMetadata> plugin_metadata; |
| if (context_.FindEnabledPlugin(params.render_frame_id, params.url, |
| params.top_origin_url, params.mime_type, |
| - &output.status, &output.plugin, |
| - &output.actual_mime_type, |
| + &output->status, &output->plugin, |
| + &output->actual_mime_type, |
| &plugin_metadata)) { |
| - context_.DecidePluginStatus(params, output.plugin, plugin_metadata.get(), |
| - &output.status); |
| + context_.DecidePluginStatus(params, output->plugin, plugin_metadata.get(), |
| + &output->status); |
| } |
| - if (plugin_metadata) { |
| - output.group_identifier = plugin_metadata->identifier(); |
| - output.group_name = plugin_metadata->name(); |
| - } |
| - |
| - context_.MaybeGrantAccess(output.status, output.plugin.path); |
| - |
| - ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output); |
| - Send(reply_msg); |
| - if (output.status != |
| - ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) { |
| + if (output->status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) { |
| + // Check to see if the component updater can fetch an implementation. |
| + scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner( |
| + base::ThreadTaskRunnerHandle::Get()); |
| main_thread_task_runner_->PostTask( |
|
Bernhard Bauer
2016/07/28 10:25:10
You could do this with PostTaskAndReply().
waffles
2016/07/28 20:06:27
Hm, I avoided this the first time because (IIUC) i
Bernhard Bauer
2016/07/29 09:14:24
No, the callbacks would be exactly the same. The o
waffles
2016/07/29 21:07:25
I think I'm still confused about what you mean her
|
| - FROM_HERE, base::Bind(&ReportMetrics, output.actual_mime_type, |
| - params.url, params.top_origin_url)); |
| + FROM_HERE, |
| + base::Bind(&PluginInfoMessageFilter::FindComponentUpdatePlugin, |
| + this, params, |
| + base::Passed(&output), base::Passed(&plugin_metadata), |
| + reply_msg, reply_task_runner)); |
| + } else { |
| + GetPluginInfoReply(params, std::move(output), std::move(plugin_metadata), |
| + reply_msg); |
| } |
| } |
| @@ -460,6 +462,57 @@ bool PluginInfoMessageFilter::Context::FindEnabledPlugin( |
| return enabled; |
| } |
| +void PluginInfoMessageFilter::FindComponentUpdatePlugin( |
| + const GetPluginInfo_Params& params, |
| + std::unique_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output, |
| + std::unique_ptr<PluginMetadata> plugin_metadata, |
| + IPC::Message* reply_msg, |
| + scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner) { |
| + // See if we can fetch the plugin using a component update. |
| + component_updater::ComponentInfo cus_plugin_info; |
| + if (g_browser_process->component_updater()->GetComponentForMimeType( |
| + params.mime_type, &cus_plugin_info)) { |
| + output->status = |
| + ChromeViewHostMsg_GetPluginInfo_Status::kComponentUpdateRequired; |
| + plugin_metadata = base::WrapUnique(new PluginMetadata( |
|
Bernhard Bauer
2016/07/28 10:25:10
You could even use base::MakeUnique<PluginMetadata
waffles
2016/07/28 20:06:27
Done. (used reset().)
|
| + cus_plugin_info.id, |
| + cus_plugin_info.name, |
| + false, |
| + GURL(), |
| + GURL(), |
| + base::ASCIIToUTF16(cus_plugin_info.id), |
| + std::string())); |
| + } |
| + reply_task_runner->PostTask( |
| + FROM_HERE, |
| + base::Bind(&PluginInfoMessageFilter::GetPluginInfoReply, |
| + this, params, base::Passed(&output), |
| + base::Passed(&plugin_metadata), reply_msg)); |
| +} |
| + |
| +void PluginInfoMessageFilter::GetPluginInfoReply( |
| + const GetPluginInfo_Params& params, |
| + std::unique_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output, |
| + std::unique_ptr<PluginMetadata> plugin_metadata, |
| + IPC::Message* reply_msg) { |
| + if (plugin_metadata) { |
| + output->group_identifier = plugin_metadata->identifier(); |
| + output->group_name = plugin_metadata->name(); |
| + } |
| + |
| + context_.MaybeGrantAccess(output->status, output->plugin.path); |
| + |
| + ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, *output); |
| + Send(reply_msg); |
| + if (output->status != |
| + ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) { |
| + main_thread_task_runner_->PostTask( |
| + FROM_HERE, base::Bind(&ReportMetrics, output->actual_mime_type, |
| + params.url, params.top_origin_url)); |
| + } |
| +} |
| + |
| + |
| void PluginInfoMessageFilter::Context::GetPluginContentSetting( |
| const WebPluginInfo& plugin, |
| const GURL& policy_url, |