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

Side by Side Diff: content/renderer/guest_render_view_observer.cc

Issue 9609008: Implemented Browser Plugin (NOT FOR REVIEW) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Initial plumbing of a guest flag to RenderViewImpl (cleaner than early prototype) 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
« no previous file with comments | « content/renderer/guest_render_view_observer.h ('k') | content/renderer/guest_to_host_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/guest_render_view_observer.h"
6
7 #include "base/process_util.h"
8 #include "content/common/child_process.h"
9 #include "content/common/view_messages.h"
10 #include "content/renderer/plugins/browser_plugin_placeholder.h"
11 #include "content/renderer/render_view_impl.h"
12 #include "ppapi/proxy/ppapi_messages.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
14
15 using WebKit::WebGraphicsContext3D;
16
17 GuestRenderViewObserver::GuestRenderViewObserver(
18 RenderViewImpl* render_view)
19 : RenderViewObserver(render_view),
20 guest_to_host_channel_(this, render_view->GetWebView()) {
21 }
22
23 bool GuestRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
24 bool handled = true;
25 IPC_BEGIN_MESSAGE_MAP(GuestRenderViewObserver, message)
26 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnMsgCreateChannel)
27 IPC_MESSAGE_HANDLER(ViewMsg_GuestReady, OnMsgGuestReady)
28 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP()
30
31 return handled;
32 }
33
34 void GuestRenderViewObserver::OnMsgCreateChannel(
35 base::ProcessHandle host_process_handle,
36 int renderer_id) {
37 IPC::ChannelHandle plugin_handle;
38 plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(),
39 renderer_id);
40 bool success = guest_to_host_channel_.InitChannel(plugin_handle);
41 #if defined(OS_POSIX)
42 // On POSIX, transfer ownership of the renderer-side (client) FD.
43 // This ensures this process will be notified when it is closed even if a
44 // connection is not established.
45 plugin_handle.socket =
46 base::FileDescriptor(guest_to_host_channel_.TakeRendererFD(), true);
47 // Check the validity of fd for bug investigation. Remove after fixed.
48 // See for details: crbug.com/103957.
49 CHECK_NE(-1, plugin_handle.socket.fd);
50 if (plugin_handle.socket.fd == -1)
51 success = false;
52 #endif
53 PpapiHostMsg_ChannelCreated* msg;
54 if (success)
55 msg = new PpapiHostMsg_ChannelCreated(plugin_handle);
56 else
57 msg = new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle());
58 msg->set_routing_id(routing_id());
59 Send(msg);
60 }
61
62 void GuestRenderViewObserver::OnMsgGuestReady(
63 int instance_id,
64 base::ProcessHandle process_handle,
65 const IPC::ChannelHandle& channel_handle) {
66 BrowserPluginPlaceholder* placeholder =
67 BrowserPluginPlaceholder::FromID(instance_id);
68 if (placeholder)
69 placeholder->GuestReady(process_handle, channel_handle);
70 }
71
72 WebGraphicsContext3D* GuestRenderViewObserver::GetWebGraphicsContext3D() {
73 return guest_to_host_channel_.GetWebGraphicsContext3D();
74 }
75
76 void GuestRenderViewObserver::GraphicsContextCreated() {
77 // Tell the existing WebGraphicsContext3D to fake a
78 // lost context.
79 // By forcing a new layout and composite, we force WebKit
80 // to pick up a new WebGraphicsContext3D. In this case, it will
81 // grab a WebGraphicsContext3DGuest.
82 render_view()->GetWebView()->graphicsContext3D()->playDead();
83 render_view()->GetWebView()->layout();
84 render_view()->GetWebView()->composite(true);
85 }
OLDNEW
« no previous file with comments | « content/renderer/guest_render_view_observer.h ('k') | content/renderer/guest_to_host_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698