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

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,
17 ppapi::PpapiPermissions permissions,
18 base::ProcessHandle plugin_child_process,
19 IPC::ChannelProxy* channel,
20 net::HostResolver* host_resolver) {
21 BrowserPpapiHostImpl* browser_ppapi_host =
22 new BrowserPpapiHostImpl(sender, permissions);
23 browser_ppapi_host->set_plugin_process_handle(plugin_child_process);
24
25 channel->AddFilter(
26 new PepperMessageFilter(PepperMessageFilter::PLUGIN, host_resolver));
27
28 return browser_ppapi_host;
29 }
30
13 BrowserPpapiHostImpl::BrowserPpapiHostImpl( 31 BrowserPpapiHostImpl::BrowserPpapiHostImpl(
14 IPC::Sender* sender, 32 IPC::Sender* sender,
15 const ppapi::PpapiPermissions& permissions) 33 const ppapi::PpapiPermissions& permissions)
16 : ppapi_host_(sender, permissions), 34 : ppapi_host_(sender, permissions),
17 plugin_process_handle_(base::kNullProcessHandle) { 35 plugin_process_handle_(base::kNullProcessHandle) {
36 message_filter_ = new HostMessageFilter(&ppapi_host_);
18 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 37 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
19 new ContentBrowserPepperHostFactory(this))); 38 new ContentBrowserPepperHostFactory(this)));
20 } 39 }
21 40
22 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { 41 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() {
23 } 42 }
24 43
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() { 44 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() {
38 return &ppapi_host_; 45 return &ppapi_host_;
39 } 46 }
40 47
41 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const { 48 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const {
42 // Handle should previously have been set before use. 49 // Handle should previously have been set before use.
43 DCHECK(plugin_process_handle_ != base::kNullProcessHandle); 50 DCHECK(plugin_process_handle_ != base::kNullProcessHandle);
44 return plugin_process_handle_; 51 return plugin_process_handle_;
45 } 52 }
46 53
(...skipping 30 matching lines...) Expand all
77 84
78 void BrowserPpapiHostImpl::DeleteInstanceForView(PP_Instance instance) { 85 void BrowserPpapiHostImpl::DeleteInstanceForView(PP_Instance instance) {
79 InstanceToViewMap::iterator found = instance_to_view_.find(instance); 86 InstanceToViewMap::iterator found = instance_to_view_.find(instance);
80 if (found == instance_to_view_.end()) { 87 if (found == instance_to_view_.end()) {
81 NOTREACHED(); 88 NOTREACHED();
82 return; 89 return;
83 } 90 }
84 instance_to_view_.erase(found); 91 instance_to_view_.erase(found);
85 } 92 }
86 93
94 bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived(
95 const IPC::Message& msg) {
96 /* TODO(brettw) when we add messages, here, the code should look like this:
97 bool handled = true;
98 IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl, msg)
99 // Add necessary message handlers here.
100 IPC_MESSAGE_UNHANDLED(handled = ppapi_host_->OnMessageReceived(msg))
101 IPC_END_MESSAGE_MAP();
102 return handled;
103 */
104 return ppapi_host_->OnMessageReceived(msg);
105 }
106
87 } // namespace content 107 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698