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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/guest_render_view_host_observer.h"
6
7 #include "content/browser/renderer_host/browser_plugin_message_filter.h"
8 #include "content/common/view_messages.h"
9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/browser/render_view_host_observer.h"
11 #include "content/public/browser/render_widget_host_view.h"
12 #include "ppapi/proxy/ppapi_messages.h"
13
14 GuestRenderViewHostObserver::~GuestRenderViewHostObserver() {
15 }
16
17 GuestRenderViewHostObserver* GuestRenderViewHostObserver::Create(
18 BrowserPluginMessageFilter* filter,
19 content::RenderViewHost* render_view_host,
20 int host_routing_id,
21 int instance_id) {
22 return new GuestRenderViewHostObserver(filter,
23 render_view_host,
24 host_routing_id,
25 instance_id);
26 }
27
28 GuestRenderViewHostObserver::GuestRenderViewHostObserver(
29 BrowserPluginMessageFilter* filter,
30 content::RenderViewHost* render_view_host,
31 int host_routing_id,
32 int instance_id)
33 : RenderViewHostObserver(render_view_host),
34 filter_(filter),
35 host_routing_id_(host_routing_id),
36 instance_id_(instance_id) {
37 }
38
39 bool GuestRenderViewHostObserver::OnMessageReceived(const IPC::Message& msg) {
40 bool handled = true;
41 IPC_BEGIN_MESSAGE_MAP(GuestRenderViewHostObserver, msg)
42 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
43 OnRendererPluginChannelCreated)
44 IPC_MESSAGE_HANDLER(ViewHostMsg_ResizeGuest, OnMsgResizeGuest)
45 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady)
46 IPC_MESSAGE_UNHANDLED(handled = false)
47 IPC_END_MESSAGE_MAP()
48
49 return handled;
50 }
51
52 // Called when a new plugin <--> renderer channel has been created.
53 void GuestRenderViewHostObserver::OnRendererPluginChannelCreated(
54 const IPC::ChannelHandle& channel_handle) {
55 // Prepare the handle to send to the renderer.
56 base::ProcessHandle plugin_process =
57 render_view_host()->GetProcess()->GetHandle();
58 #if defined(OS_WIN)
59 base::ProcessHandle renderer_process = filter_->peer_handle();
60 int renderer_id = filter_->render_process_id();
61
62 base::ProcessHandle renderers_plugin_handle = NULL;
63 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
64 renderer_process, &renderers_plugin_handle,
65 0, FALSE, DUPLICATE_SAME_ACCESS);
66 #elif defined(OS_POSIX)
67 // Don't need to duplicate anything on POSIX since it's just a PID.
68 base::ProcessHandle renderers_plugin_handle = plugin_process;
69 #endif
70 // Tell the browser loading placeholder that we're done.
71 // and that it can begin using the guest renderer.
72 filter_->Send(
73 new ViewMsg_GuestReady(host_routing_id_,
74 instance_id_,
75 renderers_plugin_handle,
76 channel_handle));
77 }
78
79 void GuestRenderViewHostObserver::OnMsgRenderViewReady() {
80 // The renderer is now ready to receive ppapi messages.
81 // Let's tell it create a channel with the embedder/host.
82 PpapiMsg_CreateChannel* msg =
83 new PpapiMsg_CreateChannel(filter_->peer_handle(),
84 filter_->render_process_id());
85 msg->set_routing_id(render_view_host()->GetRoutingID());
86 msg->set_unblock(true);
87 // TODO(fsamuel): If we aren't able to successfully send this message
88 // to the guest then that probably means it crashed. Is there anything
89 // we can do that's cleaner than failing a check?
90 CHECK(Send(msg));
91 }
92
93 void GuestRenderViewHostObserver::OnMsgResizeGuest(int width, int height) {
94 // Tell the RenderWidgetHostView to adjust its size.
95 render_view_host()->GetView()->SetSize(gfx::Size(width, height));
96 }
97
OLDNEW
« 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