| 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 634e4bc6dfde697fc60249ae0e4e95af09e57b26..0c24dc81d0d766fea2e7a56cc0c866066c5983cc 100644
|
| --- a/chrome/browser/plugins/plugin_info_message_filter.cc
|
| +++ b/chrome/browser/plugins/plugin_info_message_filter.cc
|
| @@ -11,6 +11,9 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/content_settings/content_settings_utils.h"
|
| #include "chrome/browser/content_settings/host_content_settings_map.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 "chrome/browser/plugins/chrome_plugin_service_filter.h"
|
| #include "chrome/browser/plugins/plugin_finder.h"
|
| #include "chrome/browser/plugins/plugin_metadata.h"
|
| @@ -20,15 +23,18 @@
|
| #include "chrome/common/content_settings.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/render_messages.h"
|
| +#include "content/common/browser_plugin/browser_plugin_constants.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/plugin_service.h"
|
| #include "content/public/browser/plugin_service_filter.h"
|
| +#include "content/public/common/webplugininfo.h"
|
| #include "url/gurl.h"
|
|
|
| #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
|
|
|
| #if defined(ENABLE_EXTENSIONS)
|
| #include "chrome/browser/guest_view/web_view/web_view_renderer_state.h"
|
| +#include "chrome/browser/guest_view/guest_view_constants.h"
|
| #endif
|
|
|
| #if defined(OS_WIN)
|
| @@ -90,6 +96,7 @@ PluginInfoMessageFilter::PluginInfoMessageFilter(
|
| Profile* profile)
|
| : BrowserMessageFilter(ChromeMsgStart),
|
| context_(render_process_id, profile),
|
| + profile_(profile),
|
| weak_ptr_factory_(this) {
|
| }
|
|
|
| @@ -124,6 +131,58 @@ struct PluginInfoMessageFilter::GetPluginInfo_Params {
|
| std::string mime_type;
|
| };
|
|
|
| +void PluginInfoMessageFilter::CreateGuestOnUI(
|
| + Profile* profile,
|
| + int render_process_id,
|
| + GURL top_origin_url,
|
| + const std::string& orig_mime_type,
|
| + 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(guestview::kMimeTypeParam, orig_mime_type);
|
| + guest_view_manager->CreateGuest(
|
| + MimeHandlerViewGuest::Type,
|
| + // TODO(lazyboy): CreateGuest should take GURL instead of std::string.
|
| + top_origin_url.possibly_invalid_spec(),
|
| + render_process_id,
|
| + create_params,
|
| + base::Bind(&PluginInfoMessageFilter::GuestCreatedOnUICallback,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + base::Passed(&output),
|
| + reply_msg));
|
| +}
|
| +
|
| +void PluginInfoMessageFilter::GuestCreatedOnUICallback(
|
| + scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output,
|
| + IPC::Message* reply_msg,
|
| + content::WebContents* guest_web_contents) {
|
| + int plugin_instance_id = content::browser_plugin::kInstanceIDNone;
|
| + MimeHandlerViewGuest* guest = MimeHandlerViewGuest::FromWebContents(
|
| + guest_web_contents);
|
| + if (guest)
|
| + plugin_instance_id = guest->GetGuestInstanceID();
|
| +
|
| + // Set the instance ID so content/ can call attach.
|
| + output->instance_id = plugin_instance_id;
|
| +
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&PluginInfoMessageFilter::GuestCreatedOnIO,
|
| + this, base::Passed(&output), reply_msg));
|
| +}
|
| +
|
| +void PluginInfoMessageFilter::GuestCreatedOnIO(
|
| + 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);
|
| +}
|
| +
|
| void PluginInfoMessageFilter::OnGetPluginInfo(
|
| int render_frame_id,
|
| const GURL& url,
|
| @@ -146,26 +205,43 @@ void PluginInfoMessageFilter::PluginsLoaded(
|
| const GetPluginInfo_Params& params,
|
| IPC::Message* reply_msg,
|
| const std::vector<WebPluginInfo>& plugins) {
|
| - ChromeViewHostMsg_GetPluginInfo_Output output;
|
| + 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);
|
| + 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,
|
| + this,
|
| + profile_,
|
| + context_.render_process_id(),
|
| + params.top_origin_url,
|
| + params.mime_type,
|
| + base::Passed(&output),
|
| + reply_msg));
|
| + return;
|
| + }
|
|
|
| - ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, output);
|
| + ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, *output);
|
| Send(reply_msg);
|
| }
|
|
|
|
|