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

Side by Side Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc

Issue 11368019: Add support for external out-of-process PPAPI plugins in the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" 5 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
6 #include "content/browser/renderer_host/pepper/pepper_message_filter.h"
6 7
7 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
8 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
9 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
10 11
11 namespace content { 12 namespace content {
12 13
14 // static
15 CONTENT_EXPORT BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(
16 IPC::Sender* sender,
brettw 2012/11/07 00:18:11 Nit: should only be indented 4 spaces.
bbudge 2012/11/07 00:51:46 Done.
17 ppapi::PpapiPermissions permissions,
18 base::ProcessHandle plugin_child_process,
19 IPC::ChannelProxy* channel,
20 net::HostResolver* host_resolver,
21 int render_process_id,
22 int render_view_id) {
23 BrowserPpapiHostImpl* browser_ppapi_host =
24 new BrowserPpapiHostImpl(sender, permissions);
25 browser_ppapi_host->set_plugin_process_handle(plugin_child_process);
26
27 channel->AddFilter(
28 new PepperMessageFilter(PepperMessageFilter::NACL,
29 host_resolver,
30 render_process_id,
31 render_view_id));
32
33 return browser_ppapi_host;
34 }
35
13 BrowserPpapiHostImpl::BrowserPpapiHostImpl( 36 BrowserPpapiHostImpl::BrowserPpapiHostImpl(
14 IPC::Sender* sender, 37 IPC::Sender* sender,
15 const ppapi::PpapiPermissions& permissions) 38 const ppapi::PpapiPermissions& permissions)
16 : ppapi_host_(sender, permissions), 39 : ppapi_host_(sender, permissions),
17 plugin_process_handle_(base::kNullProcessHandle) { 40 plugin_process_handle_(base::kNullProcessHandle) {
41 message_filter_ = new HostMessageFilter(&ppapi_host_);
18 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 42 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
19 new ContentBrowserPepperHostFactory(this))); 43 new ContentBrowserPepperHostFactory(this)));
20 } 44 }
21 45
22 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { 46 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() {
23 } 47 }
24 48
25 bool BrowserPpapiHostImpl::OnMessageReceived(const IPC::Message& msg) {
26 /* TODO(brettw) when we add messages, here, the code should look like this:
27 bool handled = true;
28 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl, msg)
29 // Add necessary message handlers here.
30 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_.OnMessageReceived(msg))
31 IPC_END_MESSAGE_MAP();
32 return handled;
33 */
34 return ppapi_host_.OnMessageReceived(msg);
35 }
36
37 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() { 49 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() {
38 return &ppapi_host_; 50 return &ppapi_host_;
39 } 51 }
40 52
41 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const { 53 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const {
42 // Handle should previously have been set before use. 54 // Handle should previously have been set before use.
43 DCHECK(plugin_process_handle_ != base::kNullProcessHandle); 55 DCHECK(plugin_process_handle_ != base::kNullProcessHandle);
44 return plugin_process_handle_; 56 return plugin_process_handle_;
45 } 57 }
46 58
(...skipping 30 matching lines...) Expand all
77 89
78 void BrowserPpapiHostImpl::DeleteInstanceForView(PP_Instance instance) { 90 void BrowserPpapiHostImpl::DeleteInstanceForView(PP_Instance instance) {
79 InstanceToViewMap::iterator found = instance_to_view_.find(instance); 91 InstanceToViewMap::iterator found = instance_to_view_.find(instance);
80 if (found == instance_to_view_.end()) { 92 if (found == instance_to_view_.end()) {
81 NOTREACHED(); 93 NOTREACHED();
82 return; 94 return;
83 } 95 }
84 instance_to_view_.erase(found); 96 instance_to_view_.erase(found);
85 } 97 }
86 98
99 bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived(
100 const IPC::Message& msg) {
101 /* TODO(brettw) when we add messages, here, the code should look like this:
102 bool handled = true;
103 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl, msg)
104 // Add necessary message handlers here.
105 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_->OnMessageReceived(msg))
106 IPC_END_MESSAGE_MAP();
107 return handled;
108 */
109 return ppapi_host_->OnMessageReceived(msg);
brettw 2012/11/07 00:18:11 Don't forget to null check this when you add the n
bbudge 2012/11/07 00:51:46 Done.
110 }
111
87 } // namespace content 112 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698