| 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/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } while (id == 0 || | 204 } while (id == 0 || |
| 205 plugin_dispatchers_.find(id) != plugin_dispatchers_.end()); | 205 plugin_dispatchers_.find(id) != plugin_dispatchers_.end()); |
| 206 plugin_dispatchers_[id] = plugin_dispatcher; | 206 plugin_dispatchers_[id] = plugin_dispatcher; |
| 207 return id; | 207 return id; |
| 208 } | 208 } |
| 209 | 209 |
| 210 void PpapiThread::Unregister(uint32 plugin_dispatcher_id) { | 210 void PpapiThread::Unregister(uint32 plugin_dispatcher_id) { |
| 211 plugin_dispatchers_.erase(plugin_dispatcher_id); | 211 plugin_dispatchers_.erase(plugin_dispatcher_id); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void PpapiThread::OnMsgLoadPlugin(const FilePath& path) { | 214 void PpapiThread::OnMsgLoadPlugin(const FilePath& path, |
| 215 const ppapi::PpapiPermissions& permissions) { |
| 215 SavePluginName(path); | 216 SavePluginName(path); |
| 216 | 217 |
| 218 // This must be set before calling into the plugin so it can get the |
| 219 // interfaces it has permission for. |
| 220 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions(permissions); |
| 221 |
| 217 std::string error; | 222 std::string error; |
| 218 base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, &error)); | 223 base::ScopedNativeLibrary library(base::LoadNativeLibrary(path, &error)); |
| 219 | 224 |
| 220 #if defined(OS_WIN) | 225 #if defined(OS_WIN) |
| 221 // Once we lower the token the sandbox is locked down and no new modules | 226 // Once we lower the token the sandbox is locked down and no new modules |
| 222 // can be loaded. TODO(cpu): consider changing to the loading style of | 227 // can be loaded. TODO(cpu): consider changing to the loading style of |
| 223 // regular plugins. | 228 // regular plugins. |
| 224 if (g_target_services) { | 229 if (g_target_services) { |
| 225 // Cause advapi32 to load before the sandbox is turned on. | 230 // Cause advapi32 to load before the sandbox is turned on. |
| 226 unsigned int dummy_rand; | 231 unsigned int dummy_rand; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 int32_t init_error = init_module( | 292 int32_t init_error = init_module( |
| 288 local_pp_module_, | 293 local_pp_module_, |
| 289 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | 294 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); |
| 290 if (init_error != PP_OK) { | 295 if (init_error != PP_OK) { |
| 291 LOG(WARNING) << "InitModule failed with error " << init_error; | 296 LOG(WARNING) << "InitModule failed with error " << init_error; |
| 292 return; | 297 return; |
| 293 } | 298 } |
| 294 } | 299 } |
| 295 | 300 |
| 296 library_.Reset(library.Release()); | 301 library_.Reset(library.Release()); |
| 302 |
| 303 permissions_ = permissions; |
| 297 } | 304 } |
| 298 | 305 |
| 299 void PpapiThread::OnMsgCreateChannel(int renderer_id, | 306 void PpapiThread::OnMsgCreateChannel(int renderer_id, bool incognito) { |
| 300 bool incognito) { | |
| 301 IPC::ChannelHandle channel_handle; | 307 IPC::ChannelHandle channel_handle; |
| 302 if (!library_.is_valid() || // Plugin couldn't be loaded. | 308 if (!library_.is_valid() || // Plugin couldn't be loaded. |
| 303 !SetupRendererChannel(renderer_id, incognito, &channel_handle)) { | 309 !SetupRendererChannel(renderer_id, incognito, &channel_handle)) { |
| 304 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); | 310 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); |
| 305 return; | 311 return; |
| 306 } | 312 } |
| 307 | 313 |
| 308 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); | 314 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); |
| 309 } | 315 } |
| 310 | 316 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 if (is_broker_) { | 357 if (is_broker_) { |
| 352 BrokerProcessDispatcher* broker_dispatcher = | 358 BrokerProcessDispatcher* broker_dispatcher = |
| 353 new BrokerProcessDispatcher(get_plugin_interface_, | 359 new BrokerProcessDispatcher(get_plugin_interface_, |
| 354 connect_instance_func_); | 360 connect_instance_func_); |
| 355 init_result = broker_dispatcher->InitBrokerWithChannel(this, | 361 init_result = broker_dispatcher->InitBrokerWithChannel(this, |
| 356 plugin_handle, | 362 plugin_handle, |
| 357 false); | 363 false); |
| 358 dispatcher = broker_dispatcher; | 364 dispatcher = broker_dispatcher; |
| 359 } else { | 365 } else { |
| 360 PluginProcessDispatcher* plugin_dispatcher = | 366 PluginProcessDispatcher* plugin_dispatcher = |
| 361 new PluginProcessDispatcher(get_plugin_interface_, incognito); | 367 new PluginProcessDispatcher(get_plugin_interface_, |
| 368 permissions_, |
| 369 incognito); |
| 362 init_result = plugin_dispatcher->InitPluginWithChannel(this, | 370 init_result = plugin_dispatcher->InitPluginWithChannel(this, |
| 363 plugin_handle, | 371 plugin_handle, |
| 364 false); | 372 false); |
| 365 dispatcher = plugin_dispatcher; | 373 dispatcher = plugin_dispatcher; |
| 366 } | 374 } |
| 367 | 375 |
| 368 if (!init_result) { | 376 if (!init_result) { |
| 369 delete dispatcher; | 377 delete dispatcher; |
| 370 return false; | 378 return false; |
| 371 } | 379 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 389 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 397 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
| 390 path.BaseName().AsUTF8Unsafe()); | 398 path.BaseName().AsUTF8Unsafe()); |
| 391 | 399 |
| 392 // plugin() is NULL when in-process. Which is fine, because this is | 400 // plugin() is NULL when in-process. Which is fine, because this is |
| 393 // just a hook for setting the process name. | 401 // just a hook for setting the process name. |
| 394 if (content::GetContentClient()->plugin()) { | 402 if (content::GetContentClient()->plugin()) { |
| 395 content::GetContentClient()->plugin()->PluginProcessStarted( | 403 content::GetContentClient()->plugin()->PluginProcessStarted( |
| 396 path.BaseName().RemoveExtension().LossyDisplayName()); | 404 path.BaseName().RemoveExtension().LossyDisplayName()); |
| 397 } | 405 } |
| 398 } | 406 } |
| OLD | NEW |