Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(978)

Unified Diff: content/browser/guest_render_view_host_observer.cc

Issue 9609008: Implemented Browser Plugin (NOT FOR REVIEW) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merged with Tip-of-Tree Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/guest_render_view_host_observer.cc
diff --git a/content/browser/guest_render_view_host_observer.cc b/content/browser/guest_render_view_host_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..057e46d49c995e7f29ff580b7d595e0391ca9f85
--- /dev/null
+++ b/content/browser/guest_render_view_host_observer.cc
@@ -0,0 +1,97 @@
+// 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/guest_render_view_host_observer.h"
+
+#include "content/browser/renderer_host/browser_plugin_message_filter.h"
+#include "content/common/view_messages.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host_observer.h"
+#include "content/public/browser/render_widget_host_view.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+GuestRenderViewHostObserver::~GuestRenderViewHostObserver() {
+}
+
+GuestRenderViewHostObserver* GuestRenderViewHostObserver::Create(
+ BrowserPluginMessageFilter* filter,
+ content::RenderViewHost* render_view_host,
+ int host_routing_id,
+ int instance_id) {
+ return new GuestRenderViewHostObserver(filter,
+ render_view_host,
+ host_routing_id,
+ instance_id);
+}
+
+GuestRenderViewHostObserver::GuestRenderViewHostObserver(
+ BrowserPluginMessageFilter* filter,
+ content::RenderViewHost* render_view_host,
+ int host_routing_id,
+ int instance_id)
+ : RenderViewHostObserver(render_view_host),
+ filter_(filter),
+ host_routing_id_(host_routing_id),
+ instance_id_(instance_id) {
+}
+
+bool GuestRenderViewHostObserver::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(GuestRenderViewHostObserver, msg)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
+ OnRendererPluginChannelCreated)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ResizeGuest, OnMsgResizeGuest)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+// Called when a new plugin <--> renderer channel has been created.
+void GuestRenderViewHostObserver::OnRendererPluginChannelCreated(
+ const IPC::ChannelHandle& channel_handle) {
+ // Prepare the handle to send to the renderer.
+ base::ProcessHandle plugin_process =
+ render_view_host()->GetProcess()->GetHandle();
+#if defined(OS_WIN)
+ base::ProcessHandle renderer_process = filter_->peer_handle();
+ int renderer_id = filter_->render_process_id();
+
+ base::ProcessHandle renderers_plugin_handle = NULL;
+ ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
+ renderer_process, &renderers_plugin_handle,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+#elif defined(OS_POSIX)
+ // Don't need to duplicate anything on POSIX since it's just a PID.
+ base::ProcessHandle renderers_plugin_handle = plugin_process;
+#endif
+ // Tell the browser loading placeholder that we're done.
+ // and that it can begin using the guest renderer.
+ filter_->Send(
+ new ViewMsg_GuestReady(host_routing_id_,
+ instance_id_,
+ renderers_plugin_handle,
+ channel_handle));
+}
+
+void GuestRenderViewHostObserver::OnMsgRenderViewReady() {
+ // The renderer is now ready to receive ppapi messages.
+ // Let's tell it create a channel with the embedder/host.
+ PpapiMsg_CreateChannel* msg =
+ new PpapiMsg_CreateChannel(filter_->peer_handle(),
+ filter_->render_process_id());
+ msg->set_routing_id(render_view_host()->GetRoutingID());
+ msg->set_unblock(true);
+ // TODO(fsamuel): If we aren't able to successfully send this message
+ // to the guest then that probably means it crashed. Is there anything
+ // we can do that's cleaner than failing a check?
+ CHECK(Send(msg));
+}
+
+void GuestRenderViewHostObserver::OnMsgResizeGuest(int width, int height) {
+ // Tell the RenderWidgetHostView to adjust its size.
+ render_view_host()->GetView()->SetSize(gfx::Size(width, height));
+}
+
« no previous file with comments | « content/browser/guest_render_view_host_observer.h ('k') | content/browser/renderer_host/browser_plugin_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698