| Index: content/browser/browser_plugin/browser_plugin_message_filter.cc
|
| diff --git a/content/browser/browser_plugin/browser_plugin_message_filter.cc b/content/browser/browser_plugin/browser_plugin_message_filter.cc
|
| index 512f8a7df8c0aaa9c5d8134b6d2f897ba5dd76e5..93d58d9e0f616211a5b4e01719aa2fa6ddeb5a6d 100644
|
| --- a/content/browser/browser_plugin/browser_plugin_message_filter.cc
|
| +++ b/content/browser/browser_plugin/browser_plugin_message_filter.cc
|
| @@ -6,7 +6,6 @@
|
|
|
| #include "base/supports_user_data.h"
|
| #include "content/browser/browser_plugin/browser_plugin_guest.h"
|
| -#include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
|
| #include "content/browser/gpu/gpu_process_host.h"
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| #include "content/common/browser_plugin/browser_plugin_constants.h"
|
| @@ -14,6 +13,7 @@
|
| #include "content/common/gpu/gpu_messages.h"
|
| #include "content/common/view_messages.h"
|
| #include "content/public/browser/browser_context.h"
|
| +#include "content/public/browser/browser_plugin_guest_manager_delegate.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/render_view_host.h"
|
|
|
| @@ -36,10 +36,7 @@ bool BrowserPluginMessageFilter::OnMessageReceived(
|
| // Any message requested by a BrowserPluginGuest should be routed through
|
| // a BrowserPluginGuestManager.
|
| if (BrowserPluginGuest::ShouldForwardToBrowserPluginGuest(message)) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager();
|
| - if (guest_manager)
|
| - guest_manager->OnMessageReceived(message, render_process_id_);
|
| + ForwardMessageToGuest(message);
|
| // We always swallow messages destined for BrowserPluginGuestManager because
|
| // we're on the UI thread and fallback code is expected to be run on the IO
|
| // thread.
|
| @@ -65,18 +62,33 @@ void BrowserPluginMessageFilter::OverrideThreadForMessage(
|
| *thread = BrowserThread::UI;
|
| }
|
|
|
| -BrowserPluginGuestManager*
|
| - BrowserPluginMessageFilter::GetBrowserPluginGuestManager() {
|
| +static void BrowserPluginGuestMessageCallback(const IPC::Message& message,
|
| + WebContents* guest_web_contents) {
|
| + if (!guest_web_contents)
|
| + return;
|
| + static_cast<WebContentsImpl*>(guest_web_contents)->GetBrowserPluginGuest()->
|
| + OnMessageReceivedFromEmbedder(message);
|
| +}
|
| +
|
| +void BrowserPluginMessageFilter::ForwardMessageToGuest(
|
| + const IPC::Message& message) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>(
|
| RenderProcessHost::FromID(render_process_id_));
|
| if (!host)
|
| - return NULL;
|
| + return;
|
|
|
| - BrowserContext* browser_context = host->GetBrowserContext();
|
| - return static_cast<BrowserPluginGuestManager*>(
|
| - browser_context->GetUserData(
|
| - browser_plugin::kBrowserPluginGuestManagerKeyName));
|
| + int instance_id = 0;
|
| + // All allowed messages must have instance_id as their first parameter.
|
| + PickleIterator iter(message);
|
| + bool success = iter.ReadInt(&instance_id);
|
| + DCHECK(success);
|
| + host->GetBrowserContext()->GetGuestManagerDelegate()->
|
| + MaybeGetGuestByInstanceIDOrKill(
|
| + instance_id,
|
| + render_process_id_,
|
| + base::Bind(&BrowserPluginGuestMessageCallback,
|
| + message));
|
| }
|
|
|
| void BrowserPluginMessageFilter::OnSwapBuffersACK(
|
|
|