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

Side by Side Diff: content/browser/browser_plugin/guest_render_view_host_observer.cc

Issue 9924026: Browser side implementation of browser plugin (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated RenderProcessHostImpl Created 8 years, 8 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/browser_plugin/guest_render_view_host_observer.h"
6
7 #include "content/browser/browser_plugin/renderer_host/browser_plugin_message_fi lter.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 // static
18 GuestRenderViewHostObserver* GuestRenderViewHostObserver::Create(
19 BrowserPluginMessageFilter* filter,
20 content::RenderViewHost* render_view_host,
21 int host_routing_id,
22 int instance_id) {
23 return new GuestRenderViewHostObserver(filter,
24 render_view_host,
25 host_routing_id,
26 instance_id);
27 }
28
29 GuestRenderViewHostObserver::GuestRenderViewHostObserver(
30 BrowserPluginMessageFilter* filter,
31 content::RenderViewHost* render_view_host,
32 int host_routing_id,
33 int instance_id)
34 : RenderViewHostObserver(render_view_host),
35 filter_(filter),
36 host_routing_id_(host_routing_id),
37 instance_id_(instance_id) {
38 }
39
40 bool GuestRenderViewHostObserver::OnMessageReceived(const IPC::Message& msg) {
41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(GuestRenderViewHostObserver, msg)
43 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated,
44 OnRendererPluginChannelCreated)
45 IPC_MESSAGE_HANDLER(ViewHostMsg_ResizeGuest, OnMsgResizeGuest)
46 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady)
47 IPC_MESSAGE_UNHANDLED(handled = false)
48 IPC_END_MESSAGE_MAP()
49
50 return handled;
51 }
52
53 // Called when a new plugin <--> renderer channel has been created.
54 void GuestRenderViewHostObserver::OnRendererPluginChannelCreated(
55 const IPC::ChannelHandle& channel_handle) {
56 // Prepare the handle to send to the renderer.
57 base::ProcessHandle plugin_process =
58 render_view_host()->GetProcess()->GetHandle();
59 #if defined(OS_WIN)
60 base::ProcessHandle renderer_process = filter_->peer_handle();
61 int renderer_id = filter_->render_process_id();
62
63 base::ProcessHandle renderers_plugin_handle = NULL;
64 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
65 renderer_process, &renderers_plugin_handle,
66 0, FALSE, DUPLICATE_SAME_ACCESS);
67 #elif defined(OS_POSIX)
68 // Don't need to duplicate anything on POSIX since it's just a PID.
69 base::ProcessHandle renderers_plugin_handle = plugin_process;
70 #endif
71 // Tell the browser loading placeholder that we're done.
72 // and that it can begin using the guest renderer.
73 filter_->Send(
74 new ViewMsg_GuestReady(host_routing_id_,
75 instance_id_,
76 renderers_plugin_handle,
77 channel_handle));
78 }
79
80 void GuestRenderViewHostObserver::OnMsgRenderViewReady() {
81 // The renderer is now ready to receive ppapi messages.
82 // Let's tell it create a channel with the embedder/host.
83 PpapiMsg_CreateChannel* msg =
84 new PpapiMsg_CreateChannel(filter_->peer_handle(),
85 filter_->render_process_id());
86 msg->set_routing_id(render_view_host()->GetRoutingID());
87 msg->set_unblock(true);
88 // TODO(fsamuel): If we aren't able to successfully send this message
89 // to the guest then that probably means it crashed. Is there anything
90 // we can do that's cleaner than failing a check?
91 CHECK(Send(msg));
92 }
93
94 void GuestRenderViewHostObserver::OnMsgResizeGuest(int width, int height) {
95 // Tell the RenderWidgetHostView to adjust its size.
96 render_view_host()->GetView()->SetSize(gfx::Size(width, height));
97 }
98
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698