| Index: content/browser/renderer_host/browser_plugin_message_filter.cc
 | 
| diff --git a/content/browser/renderer_host/browser_plugin_message_filter.cc b/content/browser/renderer_host/browser_plugin_message_filter.cc
 | 
| new file mode 100644
 | 
| index 0000000000000000000000000000000000000000..8097bc9ddb024db3eed7268f4b4cd412abf17a4d
 | 
| --- /dev/null
 | 
| +++ b/content/browser/renderer_host/browser_plugin_message_filter.cc
 | 
| @@ -0,0 +1,91 @@
 | 
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
 | 
| +// Use of this source code is governed by a BSD-style license that can be
 | 
| +// found in the LICENSE file.
 | 
| +
 | 
| +#include "content/browser/renderer_host/browser_plugin_message_filter.h"
 | 
| +
 | 
| +#include "base/bind.h"
 | 
| +#include "base/synchronization/waitable_event.h"
 | 
| +#include "content/browser/guest_render_view_host_observer.h"
 | 
| +#include "content/browser/renderer_host/render_widget_helper.h"
 | 
| +#include "content/public/browser/navigation_controller.h"
 | 
| +#include "content/public/browser/render_process_host.h"
 | 
| +#include "content/public/browser/web_contents.h"
 | 
| +#include "content/common/view_messages.h"
 | 
| +#include "content/public/browser/browser_thread.h"
 | 
| +#include "content/public/browser/render_view_host.h"
 | 
| +#include "content/public/browser/site_instance.h"
 | 
| +#include "content/public/common/content_client.h"
 | 
| +#include "ipc/ipc_message_macros.h"
 | 
| +
 | 
| +BrowserPluginMessageFilter::BrowserPluginMessageFilter(int render_process_id)
 | 
| +    : render_process_id_(render_process_id)
 | 
| +{
 | 
| +}
 | 
| +
 | 
| +BrowserPluginMessageFilter::~BrowserPluginMessageFilter() {
 | 
| +}
 | 
| +
 | 
| +bool BrowserPluginMessageFilter::OnMessageReceived(const IPC::Message& message,
 | 
| +                                                   bool* message_was_ok) {
 | 
| +  bool handled = true;
 | 
| +  IPC_BEGIN_MESSAGE_MAP_EX(BrowserPluginMessageFilter, message, *message_was_ok)
 | 
| +    IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToBrowserPlugin,
 | 
| +                        OnOpenChannelToBrowserPlugin)
 | 
| +    IPC_MESSAGE_UNHANDLED(handled = false)
 | 
| +  IPC_END_MESSAGE_MAP_EX()
 | 
| +  return handled;
 | 
| +}
 | 
| +
 | 
| +void BrowserPluginMessageFilter::InitBrowserPluginOnUIThread(
 | 
| +    int32 routing_id,
 | 
| +    int32 instance_id,
 | 
| +    const std::string& src) {
 | 
| +
 | 
| +  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
 | 
| +
 | 
| +  content::RenderViewHost* render_view_host =
 | 
| +      content::RenderViewHost::FromID(render_process_id_, routing_id);
 | 
| +  DCHECK(render_view_host);
 | 
| +  content::BrowserContext* browser_context =
 | 
| +      render_view_host->GetProcess()->GetBrowserContext();
 | 
| +  DCHECK(browser_context);
 | 
| +
 | 
| +  GURL url(src);
 | 
| +  content::SiteInstance* site_instance =
 | 
| +      content::SiteInstance::CreateForURL(
 | 
| +          browser_context, url);
 | 
| +  content::WebContents* web_contents = content::WebContents::Create(
 | 
| +      browser_context,
 | 
| +      site_instance,
 | 
| +      MSG_ROUTING_NONE,
 | 
| +      NULL, // base tab contents
 | 
| +      NULL  // session storage namespace
 | 
| +  );
 | 
| +  // TODO(fsamuel): Set the WebContentsDelegate here.
 | 
| +
 | 
| +  // This should also create a RenderViewHost
 | 
| +  web_contents->GetController().LoadURL(
 | 
| +      url,
 | 
| +      content::Referrer(),
 | 
| +      content::PAGE_TRANSITION_HOME_PAGE,
 | 
| +      std::string());
 | 
| +  content::RenderViewHost* host = web_contents->GetRenderViewHost();
 | 
| +  DCHECK(host);
 | 
| +
 | 
| +  GuestRenderViewHostObserver::Create(this, host, routing_id, instance_id);
 | 
| +}
 | 
| +
 | 
| +// TODO(fsamuel): Can we get the initial URL to navigate to here too?
 | 
| +void BrowserPluginMessageFilter::OnOpenChannelToBrowserPlugin(
 | 
| +    int32 host_id,
 | 
| +    int instance_id,
 | 
| +    const std::string& src) {
 | 
| +  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
 | 
| +  content::BrowserThread::PostTask(
 | 
| +      content::BrowserThread::UI,
 | 
| +      FROM_HERE,
 | 
| +      base::Bind(&BrowserPluginMessageFilter::InitBrowserPluginOnUIThread,
 | 
| +          base::Unretained(this), host_id, instance_id, src));
 | 
| +}
 | 
| +
 | 
| 
 |