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 "chrome/renderer/pepper/ppb_nacl_private_impl.h" | 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" |
6 | 6 |
7 #ifndef DISABLE_NACL | 7 #ifndef DISABLE_NACL |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 | 154 |
155 class OutOfProcessProxy : public PluginDelegate::OutOfProcessProxy { | 155 class OutOfProcessProxy : public PluginDelegate::OutOfProcessProxy { |
156 public: | 156 public: |
157 OutOfProcessProxy() {} | 157 OutOfProcessProxy() {} |
158 virtual ~OutOfProcessProxy() {} | 158 virtual ~OutOfProcessProxy() {} |
159 | 159 |
160 bool Init(const IPC::ChannelHandle& channel_handle, | 160 bool Init(const IPC::ChannelHandle& channel_handle, |
161 PP_Module pp_module, | 161 PP_Module pp_module, |
162 PP_GetInterface_Func local_get_interface, | 162 PP_GetInterface_Func local_get_interface, |
163 const ppapi::Preferences& preferences, | 163 const ppapi::Preferences& preferences, |
164 SyncMessageStatusReceiver* status_receiver) { | 164 SyncMessageStatusReceiver* status_receiver, |
165 const ppapi::PpapiPermissions& permissions) { | |
165 dispatcher_delegate_.reset(new ProxyChannelDelegate); | 166 dispatcher_delegate_.reset(new ProxyChannelDelegate); |
166 dispatcher_.reset(new ppapi::proxy::HostDispatcher( | 167 dispatcher_.reset(new ppapi::proxy::HostDispatcher( |
167 pp_module, local_get_interface, status_receiver)); | 168 pp_module, local_get_interface, status_receiver, permissions)); |
168 | 169 |
169 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), | 170 if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(), |
170 channel_handle, | 171 channel_handle, |
171 true, // Client. | 172 true, // Client. |
172 preferences)) { | 173 preferences)) { |
173 dispatcher_.reset(); | 174 dispatcher_.reset(); |
174 dispatcher_delegate_.reset(); | 175 dispatcher_delegate_.reset(); |
175 return false; | 176 return false; |
176 } | 177 } |
177 | 178 |
(...skipping 13 matching lines...) Expand all Loading... | |
191 } | 192 } |
192 virtual void RemoveInstance(PP_Instance instance) OVERRIDE { | 193 virtual void RemoveInstance(PP_Instance instance) OVERRIDE { |
193 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); | 194 ppapi::proxy::HostDispatcher::RemoveForInstance(instance); |
194 } | 195 } |
195 | 196 |
196 private: | 197 private: |
197 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; | 198 scoped_ptr<ppapi::proxy::HostDispatcher> dispatcher_; |
198 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; | 199 scoped_ptr<ppapi::proxy::ProxyChannel::Delegate> dispatcher_delegate_; |
199 }; | 200 }; |
200 | 201 |
201 PP_Bool StartPpapiProxy(PP_Instance instance) { | 202 PP_Bool StartPpapiProxy(PP_Instance instance) { |
bbudge
2012/10/01 17:32:01
This is called by the NaCl plugin, which knows whe
brettw
2012/10/01 23:04:48
We also need to hook this up in the browser proces
| |
202 if (CommandLine::ForCurrentProcess()->HasSwitch( | 203 if (CommandLine::ForCurrentProcess()->HasSwitch( |
203 switches::kEnableNaClIPCProxy)) { | 204 switches::kEnableNaClIPCProxy)) { |
204 ChannelHandleMap& map = g_channel_handle_map.Get(); | 205 ChannelHandleMap& map = g_channel_handle_map.Get(); |
205 ChannelHandleMap::iterator it = map.find(instance); | 206 ChannelHandleMap::iterator it = map.find(instance); |
206 if (it == map.end()) | 207 if (it == map.end()) |
207 return PP_FALSE; | 208 return PP_FALSE; |
208 IPC::ChannelHandle channel_handle = it->second; | 209 IPC::ChannelHandle channel_handle = it->second; |
209 map.erase(it); | 210 map.erase(it); |
210 | 211 |
211 PluginInstance* plugin_instance = | 212 PluginInstance* plugin_instance = |
(...skipping 10 matching lines...) Expand all Loading... | |
222 scoped_refptr<SyncMessageStatusReceiver> | 223 scoped_refptr<SyncMessageStatusReceiver> |
223 status_receiver(new SyncMessageStatusReceiver()); | 224 status_receiver(new SyncMessageStatusReceiver()); |
224 scoped_ptr<OutOfProcessProxy> out_of_process_proxy(new OutOfProcessProxy); | 225 scoped_ptr<OutOfProcessProxy> out_of_process_proxy(new OutOfProcessProxy); |
225 // Create a new module for each instance of the NaCl plugin that is using | 226 // Create a new module for each instance of the NaCl plugin that is using |
226 // the IPC based out-of-process proxy. We can't use the existing module, | 227 // the IPC based out-of-process proxy. We can't use the existing module, |
227 // because it is configured for the in-process NaCl plugin, and we must | 228 // because it is configured for the in-process NaCl plugin, and we must |
228 // keep it that way to allow the page to create other instances. | 229 // keep it that way to allow the page to create other instances. |
229 scoped_refptr<PluginModule> nacl_plugin_module( | 230 scoped_refptr<PluginModule> nacl_plugin_module( |
230 plugin_module->CreateModuleForNaClInstance()); | 231 plugin_module->CreateModuleForNaClInstance()); |
231 | 232 |
233 // TODO(brettw) bug 153036 set NaCl permissions to allow dev interface | |
234 // usage when necessary. | |
235 ppapi::PpapiPermissions permissions; | |
236 | |
232 if (out_of_process_proxy->Init( | 237 if (out_of_process_proxy->Init( |
233 channel_handle, | 238 channel_handle, |
234 nacl_plugin_module->pp_module(), | 239 nacl_plugin_module->pp_module(), |
235 PluginModule::GetLocalGetInterfaceFunc(), | 240 PluginModule::GetLocalGetInterfaceFunc(), |
236 ppapi::Preferences(render_view->GetWebkitPreferences()), | 241 ppapi::Preferences(render_view->GetWebkitPreferences()), |
237 status_receiver.get())) { | 242 status_receiver.get(), |
243 permissions)) { | |
238 nacl_plugin_module->InitAsProxiedNaCl( | 244 nacl_plugin_module->InitAsProxiedNaCl( |
239 out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), | 245 out_of_process_proxy.PassAs<PluginDelegate::OutOfProcessProxy>(), |
240 instance); | 246 instance); |
241 return PP_TRUE; | 247 return PP_TRUE; |
242 } | 248 } |
243 } | 249 } |
244 | 250 |
245 return PP_FALSE; | 251 return PP_FALSE; |
246 } | 252 } |
247 | 253 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 &IsPnaclEnabled | 345 &IsPnaclEnabled |
340 }; | 346 }; |
341 | 347 |
342 } // namespace | 348 } // namespace |
343 | 349 |
344 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 350 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
345 return &nacl_interface; | 351 return &nacl_interface; |
346 } | 352 } |
347 | 353 |
348 #endif // DISABLE_NACL | 354 #endif // DISABLE_NACL |
OLD | NEW |