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 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
6 | 7 |
7 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 // static | 14 // static |
15 BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( | 15 BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( |
16 IPC::Sender* sender, | 16 IPC::Sender* sender, |
17 ppapi::PpapiPermissions permissions, | 17 ppapi::PpapiPermissions permissions, |
18 base::ProcessHandle plugin_child_process, | 18 base::ProcessHandle plugin_child_process, |
19 int plugin_child_process_id, | |
20 IPC::ChannelProxy* channel, | 19 IPC::ChannelProxy* channel, |
21 net::HostResolver* host_resolver, | 20 net::HostResolver* host_resolver, |
22 int render_process_id, | 21 int render_process_id, |
23 int render_view_id) { | 22 int render_view_id) { |
24 // TODO(raymes): Figure out how to plumb plugin_name and | |
25 // profile_data_directory through for NaCl. They are currently only needed for | |
26 // PPB_Flash_File interfaces so it doesn't matter. | |
27 std::string plugin_name; | |
28 FilePath profile_data_directory; | |
29 BrowserPpapiHostImpl* browser_ppapi_host = | 23 BrowserPpapiHostImpl* browser_ppapi_host = |
30 new BrowserPpapiHostImpl(sender, permissions, plugin_name, | 24 new BrowserPpapiHostImpl(sender, permissions); |
31 profile_data_directory, plugin_child_process_id); | |
32 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); | 25 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); |
33 | 26 |
34 channel->AddFilter( | 27 channel->AddFilter( |
35 new PepperMessageFilter(PepperMessageFilter::NACL, | 28 new PepperMessageFilter(PepperMessageFilter::NACL, |
36 permissions, | 29 permissions, |
37 host_resolver, | 30 host_resolver, |
38 render_process_id, | 31 render_process_id, |
39 render_view_id)); | 32 render_view_id)); |
40 channel->AddFilter(browser_ppapi_host->message_filter()); | 33 channel->AddFilter(browser_ppapi_host->message_filter()); |
41 | 34 |
42 return browser_ppapi_host; | 35 return browser_ppapi_host; |
43 } | 36 } |
44 | 37 |
45 BrowserPpapiHostImpl::BrowserPpapiHostImpl( | 38 BrowserPpapiHostImpl::BrowserPpapiHostImpl( |
46 IPC::Sender* sender, | 39 IPC::Sender* sender, |
47 const ppapi::PpapiPermissions& permissions, | 40 const ppapi::PpapiPermissions& permissions) |
48 const std::string& plugin_name, | |
49 const FilePath& profile_data_directory, | |
50 int plugin_process_id) | |
51 : ppapi_host_(sender, permissions), | 41 : ppapi_host_(sender, permissions), |
52 plugin_process_handle_(base::kNullProcessHandle), | 42 plugin_process_handle_(base::kNullProcessHandle) { |
53 plugin_name_(plugin_name), | |
54 profile_data_directory_(profile_data_directory), | |
55 plugin_process_id_(plugin_process_id) { | |
56 message_filter_ = new HostMessageFilter(&ppapi_host_); | 43 message_filter_ = new HostMessageFilter(&ppapi_host_); |
57 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( | 44 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( |
58 new ContentBrowserPepperHostFactory(this))); | 45 new ContentBrowserPepperHostFactory(this))); |
59 } | 46 } |
60 | 47 |
61 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { | 48 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { |
62 // Notify the filter so it won't foward messages to us. | 49 // Notify the filter so it won't foward messages to us. |
63 message_filter_->OnHostDestroyed(); | 50 message_filter_->OnHostDestroyed(); |
64 } | 51 } |
65 | 52 |
(...skipping 20 matching lines...) Expand all Loading... |
86 *render_process_id = 0; | 73 *render_process_id = 0; |
87 *render_view_id = 0; | 74 *render_view_id = 0; |
88 return false; | 75 return false; |
89 } | 76 } |
90 | 77 |
91 *render_process_id = found->second.process_id; | 78 *render_process_id = found->second.process_id; |
92 *render_view_id = found->second.view_id; | 79 *render_view_id = found->second.view_id; |
93 return true; | 80 return true; |
94 } | 81 } |
95 | 82 |
96 const std::string& BrowserPpapiHostImpl::GetPluginName() { | |
97 return plugin_name_; | |
98 } | |
99 | |
100 const FilePath& BrowserPpapiHostImpl::GetProfileDataDirectory() { | |
101 return profile_data_directory_; | |
102 } | |
103 | |
104 int BrowserPpapiHostImpl::GetPluginProcessID() { | |
105 return plugin_process_id_; | |
106 } | |
107 | |
108 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance, | 83 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance, |
109 int render_process_id, | 84 int render_process_id, |
110 int render_view_id) { | 85 int render_view_id) { |
111 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end()); | 86 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end()); |
112 | 87 |
113 RenderViewIDs ids; | 88 RenderViewIDs ids; |
114 ids.process_id = render_process_id; | 89 ids.process_id = render_process_id; |
115 ids.view_id = render_view_id; | 90 ids.view_id = render_view_id; |
116 instance_to_view_[instance] = ids; | 91 instance_to_view_[instance] = ids; |
117 } | 92 } |
(...skipping 23 matching lines...) Expand all Loading... |
141 */ | 116 */ |
142 return ppapi_host_->OnMessageReceived(msg); | 117 return ppapi_host_->OnMessageReceived(msg); |
143 } | 118 } |
144 | 119 |
145 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { | 120 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { |
146 DCHECK(ppapi_host_); | 121 DCHECK(ppapi_host_); |
147 ppapi_host_ = NULL; | 122 ppapi_host_ = NULL; |
148 } | 123 } |
149 | 124 |
150 } // namespace content | 125 } // namespace content |
OLD | NEW |