| 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 ac2e82bac79f2b33da72310b806b07ac463fbc40..9bba33b53b22afaea8f30ff7e0d06493f9e052f4 100644
|
| --- a/chrome/browser/plugins/plugin_info_message_filter.cc
|
| +++ b/chrome/browser/plugins/plugin_info_message_filter.cc
|
| @@ -30,6 +30,11 @@
|
| #include "content/public/browser/plugin_service_filter.h"
|
| #include "url/gurl.h"
|
|
|
| +#include "chrome/browser/guest_view/guest_view_manager.h"
|
| +#include "chrome/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
| +#include "chrome/browser/guest_view/web_view/web_view_guest.h"
|
| +#include "content/public/common/webplugininfo.h"
|
| +
|
| #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
|
|
|
| #if defined(OS_WIN)
|
| @@ -91,6 +96,7 @@ PluginInfoMessageFilter::PluginInfoMessageFilter(
|
| Profile* profile)
|
| : BrowserMessageFilter(ChromeMsgStart),
|
| context_(render_process_id, profile),
|
| + profile_(profile),
|
| weak_ptr_factory_(this) {
|
| }
|
|
|
| @@ -147,26 +153,99 @@ void PluginInfoMessageFilter::PluginsLoaded(
|
| const GetPluginInfo_Params& params,
|
| IPC::Message* reply_msg,
|
| const std::vector<WebPluginInfo>& plugins) {
|
| - ChromeViewHostMsg_GetPluginInfo_Output output;
|
| + printf("+++++ PluginsLoaded\n");
|
| + scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output(
|
| + new ChromeViewHostMsg_GetPluginInfo_Output);
|
| // This also fills in |actual_mime_type|.
|
| scoped_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();
|
| + output->group_identifier = plugin_metadata->identifier();
|
| + output->group_name = plugin_metadata->name();
|
| + }
|
| +
|
| + context_.MaybeGrantAccess(output->status, output->plugin.path);
|
| +
|
| + if (output->plugin.type ==
|
| + content::WebPluginInfo::PluginType::PLUGIN_TYPE_BROWSER_PLUGIN) {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::UI,
|
| + FROM_HERE,
|
| + base::Bind(&PluginInfoMessageFilter::CreateGuestOnUI,
|
| + // TODO(lazyboy): This is bad.
|
| + //weak_ptr_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| + profile_,
|
| + context_.render_process_id(),
|
| + params.top_origin_url,
|
| + base::Passed(&output),
|
| + reply_msg));
|
| + return;
|
| }
|
|
|
| - context_.MaybeGrantAccess(output.status, output.plugin.path);
|
| + ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, *output);
|
| + Send(reply_msg);
|
| +}
|
|
|
| - ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output);
|
| +void PluginInfoMessageFilter::CreateGuestOnUI(
|
| + Profile* profile,
|
| + int render_process_id,
|
| + GURL top_origin_url,
|
| + scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output,
|
| + IPC::Message* reply_msg) {
|
| + GuestViewManager* guest_view_manager =
|
| + GuestViewManager::FromBrowserContext(profile);
|
| + DCHECK(guest_view_manager);
|
| + base::DictionaryValue create_params;
|
| + create_params.SetString("emburl", top_origin_url.possibly_invalid_spec());
|
| + guest_view_manager->CreateGuest(
|
| + "mimehandler",
|
| + "",
|
| + render_process_id,
|
| + create_params,
|
| + base::Bind(&PluginInfoMessageFilter::OnGuestCreatedCallback,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + base::Passed(&output),
|
| + reply_msg));
|
| +}
|
| +
|
| +void PluginInfoMessageFilter::OnGuestCreatedCallback(
|
| + scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output,
|
| + IPC::Message* reply_msg,
|
| + content::WebContents* guest_web_contents) {
|
| + //WebViewGuest* guest = WebViewGuest::FromWebContents(guest_web_contents);
|
| + MimeHandlerViewGuest* guest = MimeHandlerViewGuest::FromWebContents(guest_web_contents);
|
| + DCHECK(guest);
|
| + // Set the instance ID so content/ can call attach.
|
| + int guest_instance_id = guest->GetGuestInstanceID();
|
| + output->instance_id = guest_instance_id;
|
| +
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&PluginInfoMessageFilter::OnGuestCreatedOnUI,
|
| + // TODO(lazyboy): This is bad.
|
| + //weak_ptr_factory_.GetWeakPtr(),
|
| + base::Unretained(this),
|
| + guest_instance_id,
|
| + base::Passed(&output),
|
| + reply_msg));
|
| +}
|
| +
|
| +void PluginInfoMessageFilter::OnGuestCreatedOnUI(
|
| + int guest_instance_id,
|
| + const scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output>& output,
|
| + IPC::Message* reply_msg) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
| + ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, *output);
|
| Send(reply_msg);
|
| }
|
|
|
|
|