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