OLD | NEW |
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 | 6 |
7 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 7 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
8 #include "content/browser/trace_message_filter.h" | 8 #include "content/browser/trace_message_filter.h" |
9 #include "content/common/pepper_renderer_instance_data.h" | 9 #include "content/common/pepper_renderer_instance_data.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // static | 16 // static |
17 BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( | 17 BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( |
18 IPC::Sender* sender, | 18 IPC::Sender* sender, |
19 ppapi::PpapiPermissions permissions, | 19 ppapi::PpapiPermissions permissions, |
20 base::ProcessHandle plugin_child_process, | 20 base::ProcessHandle plugin_child_process, |
| 21 ProcessType plugin_child_process_type, |
21 IPC::ChannelProxy* channel, | 22 IPC::ChannelProxy* channel, |
22 net::HostResolver* host_resolver, | 23 net::HostResolver* host_resolver, |
23 int render_process_id, | 24 int render_process_id, |
24 int render_view_id) { | 25 int render_view_id) { |
25 // TODO(raymes): Figure out how to plumb plugin_name and | 26 // TODO(raymes): Figure out how to plumb plugin_name and |
26 // profile_data_directory through for NaCl. They are currently only needed for | 27 // profile_data_directory through for NaCl. They are currently only needed for |
27 // PPB_Flash_File interfaces so it doesn't matter. | 28 // PPB_Flash_File interfaces so it doesn't matter. |
28 std::string plugin_name; | 29 std::string plugin_name; |
29 FilePath profile_data_directory; | 30 FilePath profile_data_directory; |
30 BrowserPpapiHostImpl* browser_ppapi_host = | 31 BrowserPpapiHostImpl* browser_ppapi_host = |
31 new BrowserPpapiHostImpl(sender, permissions, plugin_name, | 32 new BrowserPpapiHostImpl(sender, permissions, plugin_name, |
32 profile_data_directory); | 33 profile_data_directory, |
| 34 plugin_child_process_type); |
33 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); | 35 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); |
34 | 36 |
35 channel->AddFilter( | 37 channel->AddFilter( |
36 new PepperMessageFilter(PepperMessageFilter::NACL, | 38 new PepperMessageFilter(plugin_child_process_type, |
37 permissions, | 39 permissions, |
38 host_resolver, | 40 host_resolver, |
39 render_process_id, | 41 render_process_id, |
40 render_view_id)); | 42 render_view_id)); |
41 channel->AddFilter(browser_ppapi_host->message_filter()); | 43 channel->AddFilter(browser_ppapi_host->message_filter()); |
42 channel->AddFilter(new TraceMessageFilter()); | 44 channel->AddFilter(new TraceMessageFilter()); |
43 | 45 |
44 return browser_ppapi_host; | 46 return browser_ppapi_host; |
45 } | 47 } |
46 | 48 |
47 BrowserPpapiHostImpl::BrowserPpapiHostImpl( | 49 BrowserPpapiHostImpl::BrowserPpapiHostImpl( |
48 IPC::Sender* sender, | 50 IPC::Sender* sender, |
49 const ppapi::PpapiPermissions& permissions, | 51 const ppapi::PpapiPermissions& permissions, |
50 const std::string& plugin_name, | 52 const std::string& plugin_name, |
51 const FilePath& profile_data_directory) | 53 const FilePath& profile_data_directory, |
| 54 ProcessType plugin_process_type) |
52 : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), | 55 : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), |
53 plugin_process_handle_(base::kNullProcessHandle), | 56 plugin_process_handle_(base::kNullProcessHandle), |
54 plugin_name_(plugin_name), | 57 plugin_name_(plugin_name), |
55 profile_data_directory_(profile_data_directory) { | 58 profile_data_directory_(profile_data_directory), |
| 59 plugin_process_type_(plugin_process_type) { |
56 message_filter_ = new HostMessageFilter(ppapi_host_.get()); | 60 message_filter_ = new HostMessageFilter(ppapi_host_.get()); |
57 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( | 61 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( |
58 new ContentBrowserPepperHostFactory(this))); | 62 new ContentBrowserPepperHostFactory(this))); |
59 } | 63 } |
60 | 64 |
61 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { | 65 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { |
62 // Notify the filter so it won't foward messages to us. | 66 // Notify the filter so it won't foward messages to us. |
63 message_filter_->OnHostDestroyed(); | 67 message_filter_->OnHostDestroyed(); |
64 | 68 |
65 // Delete the host explicitly first. This shutdown will destroy the | 69 // Delete the host explicitly first. This shutdown will destroy the |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 */ | 156 */ |
153 return ppapi_host_->OnMessageReceived(msg); | 157 return ppapi_host_->OnMessageReceived(msg); |
154 } | 158 } |
155 | 159 |
156 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { | 160 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { |
157 DCHECK(ppapi_host_); | 161 DCHECK(ppapi_host_); |
158 ppapi_host_ = NULL; | 162 ppapi_host_ = NULL; |
159 } | 163 } |
160 | 164 |
161 } // namespace content | 165 } // namespace content |
OLD | NEW |