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/tracing/trace_message_filter.h" | 8 #include "content/browser/tracing/trace_message_filter.h" |
8 #include "content/common/pepper_renderer_instance_data.h" | 9 #include "content/common/pepper_renderer_instance_data.h" |
9 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/common/process_type.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 int render_process_id, | 22 int render_process_id, |
23 int render_view_id, | 23 int render_view_id, |
24 const base::FilePath& profile_directory) { | 24 const base::FilePath& profile_directory) { |
25 scoped_refptr<PepperMessageFilter> pepper_message_filter( | |
26 new PepperMessageFilter(permissions, | |
27 host_resolver, | |
28 render_process_id, | |
29 render_view_id)); | |
30 | |
31 // The plugin name and path shouldn't be needed for external plugins. | 25 // The plugin name and path shouldn't be needed for external plugins. |
32 BrowserPpapiHostImpl* browser_ppapi_host = | 26 BrowserPpapiHostImpl* browser_ppapi_host = |
33 new BrowserPpapiHostImpl(sender, permissions, std::string(), | 27 new BrowserPpapiHostImpl(sender, permissions, std::string(), |
34 base::FilePath(), profile_directory, true, | 28 base::FilePath(), profile_directory, true); |
35 pepper_message_filter); | |
36 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); | 29 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); |
37 | 30 |
| 31 scoped_refptr<PepperMessageFilter> pepper_message_filter( |
| 32 PepperMessageFilter::CreateForExternalPluginProcess(permissions)); |
38 channel->AddFilter(pepper_message_filter); | 33 channel->AddFilter(pepper_message_filter); |
39 channel->AddFilter(browser_ppapi_host->message_filter().get()); | 34 channel->AddFilter(browser_ppapi_host->message_filter().get()); |
40 channel->AddFilter(new TraceMessageFilter()); | 35 channel->AddFilter(new TraceMessageFilter()); |
41 | 36 |
42 return browser_ppapi_host; | 37 return browser_ppapi_host; |
43 } | 38 } |
44 | 39 |
45 BrowserPpapiHostImpl::BrowserPpapiHostImpl( | 40 BrowserPpapiHostImpl::BrowserPpapiHostImpl( |
46 IPC::Sender* sender, | 41 IPC::Sender* sender, |
47 const ppapi::PpapiPermissions& permissions, | 42 const ppapi::PpapiPermissions& permissions, |
48 const std::string& plugin_name, | 43 const std::string& plugin_name, |
49 const base::FilePath& plugin_path, | 44 const base::FilePath& plugin_path, |
50 const base::FilePath& profile_data_directory, | 45 const base::FilePath& profile_data_directory, |
51 bool external_plugin, | 46 bool external_plugin) |
52 const scoped_refptr<PepperMessageFilter>& pepper_message_filter) | |
53 : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), | 47 : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), |
54 plugin_process_handle_(base::kNullProcessHandle), | 48 plugin_process_handle_(base::kNullProcessHandle), |
55 plugin_name_(plugin_name), | 49 plugin_name_(plugin_name), |
56 plugin_path_(plugin_path), | 50 plugin_path_(plugin_path), |
57 profile_data_directory_(profile_data_directory), | 51 profile_data_directory_(profile_data_directory), |
58 external_plugin_(external_plugin) { | 52 external_plugin_(external_plugin), |
| 53 ssl_context_helper_(new SSLContextHelper()) { |
59 message_filter_ = new HostMessageFilter(ppapi_host_.get()); | 54 message_filter_ = new HostMessageFilter(ppapi_host_.get()); |
60 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( | 55 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( |
61 new ContentBrowserPepperHostFactory(this, pepper_message_filter))); | 56 new ContentBrowserPepperHostFactory(this))); |
62 } | 57 } |
63 | 58 |
64 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { | 59 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { |
65 // Notify the filter so it won't foward messages to us. | 60 // Notify the filter so it won't foward messages to us. |
66 message_filter_->OnHostDestroyed(); | 61 message_filter_->OnHostDestroyed(); |
67 | 62 |
68 // Delete the host explicitly first. This shutdown will destroy the | 63 // Delete the host explicitly first. This shutdown will destroy the |
69 // resources, which may want to do cleanup in their destructors and expect | 64 // resources, which may want to do cleanup in their destructors and expect |
70 // their pointers to us to be valid. | 65 // their pointers to us to be valid. |
71 ppapi_host_.reset(); | 66 ppapi_host_.reset(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 */ | 154 */ |
160 return ppapi_host_->OnMessageReceived(msg); | 155 return ppapi_host_->OnMessageReceived(msg); |
161 } | 156 } |
162 | 157 |
163 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { | 158 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { |
164 DCHECK(ppapi_host_); | 159 DCHECK(ppapi_host_); |
165 ppapi_host_ = NULL; | 160 ppapi_host_ = NULL; |
166 } | 161 } |
167 | 162 |
168 } // namespace content | 163 } // namespace content |
OLD | NEW |