| 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/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/browser_child_process_host_impl.h" | 14 #include "content/browser/browser_child_process_host_impl.h" |
| 15 #include "content/browser/plugin_service_impl.h" | 15 #include "content/browser/plugin_service_impl.h" |
| 16 #include "content/browser/renderer_host/render_message_filter.h" | 16 #include "content/browser/renderer_host/render_message_filter.h" |
| 17 #include "content/common/child_process_host_impl.h" | 17 #include "content/common/child_process_host_impl.h" |
| 18 #include "content/common/child_process_messages.h" | 18 #include "content/common/child_process_messages.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/pepper_plugin_info.h" | 21 #include "content/public/common/pepper_plugin_info.h" |
| 22 #include "content/public/common/process_type.h" | 22 #include "content/public/common/process_type.h" |
| 23 #include "ipc/ipc_switches.h" | 23 #include "ipc/ipc_switches.h" |
| 24 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
| 25 #include "ppapi/proxy/ppapi_messages.h" | 25 #include "ppapi/proxy/ppapi_messages.h" |
| 26 #include "ui/base/ui_base_switches.h" | 26 #include "ui/base/ui_base_switches.h" |
| 27 #include "webkit/plugins/plugin_switches.h" | 27 #include "webkit/plugins/plugin_switches.h" |
| 28 | 28 |
| 29 #if defined(OS_WIN) |
| 30 #include "content/common/sandbox_win.h" |
| 31 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 32 #include "sandbox/win/src/sandbox_policy.h" |
| 33 #endif |
| 34 |
| 29 namespace content { | 35 namespace content { |
| 30 | 36 |
| 37 #if defined(OS_WIN) |
| 38 class PpapiPluginSandboxedProcessLauncherDelegate |
| 39 : public content::SandboxedProcessLauncherDelegate { |
| 40 public: |
| 41 PpapiPluginSandboxedProcessLauncherDelegate() {} |
| 42 virtual ~PpapiPluginSandboxedProcessLauncherDelegate() {} |
| 43 |
| 44 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy, |
| 45 bool* success) { |
| 46 // The Pepper process as locked-down as a renderer execpt that it can |
| 47 // create the server side of chrome pipes. |
| 48 sandbox::ResultCode result; |
| 49 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, |
| 50 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, |
| 51 L"\\\\.\\pipe\\chrome.*"); |
| 52 *success = (result == sandbox::SBOX_ALL_OK); |
| 53 } |
| 54 }; |
| 55 #endif // OS_WIN |
| 56 |
| 31 class PpapiPluginProcessHost::PluginNetworkObserver | 57 class PpapiPluginProcessHost::PluginNetworkObserver |
| 32 : public net::NetworkChangeNotifier::IPAddressObserver, | 58 : public net::NetworkChangeNotifier::IPAddressObserver, |
| 33 public net::NetworkChangeNotifier::ConnectionTypeObserver { | 59 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 34 public: | 60 public: |
| 35 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host) | 61 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host) |
| 36 : process_host_(process_host) { | 62 : process_host_(process_host) { |
| 37 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 63 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 38 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 64 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 39 } | 65 } |
| 40 | 66 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // the plugin is sandboxed, and we are not using a plugin launcher - having a | 303 // the plugin is sandboxed, and we are not using a plugin launcher - having a |
| 278 // plugin launcher means we need to use another process instead of just | 304 // plugin launcher means we need to use another process instead of just |
| 279 // forking the zygote. | 305 // forking the zygote. |
| 280 #if defined(OS_POSIX) | 306 #if defined(OS_POSIX) |
| 281 bool use_zygote = !is_broker_ && plugin_launcher.empty() && info.is_sandboxed; | 307 bool use_zygote = !is_broker_ && plugin_launcher.empty() && info.is_sandboxed; |
| 282 if (!info.is_sandboxed) | 308 if (!info.is_sandboxed) |
| 283 cmd_line->AppendSwitchASCII(switches::kNoSandbox, ""); | 309 cmd_line->AppendSwitchASCII(switches::kNoSandbox, ""); |
| 284 #endif // OS_POSIX | 310 #endif // OS_POSIX |
| 285 process_->Launch( | 311 process_->Launch( |
| 286 #if defined(OS_WIN) | 312 #if defined(OS_WIN) |
| 287 base::FilePath(), | 313 is_broker_ ? NULL : new PpapiPluginSandboxedProcessLauncherDelegate, |
| 288 #elif defined(OS_POSIX) | 314 #elif defined(OS_POSIX) |
| 289 use_zygote, | 315 use_zygote, |
| 290 base::EnvironmentVector(), | 316 base::EnvironmentVector(), |
| 291 #endif | 317 #endif |
| 292 cmd_line); | 318 cmd_line); |
| 293 return true; | 319 return true; |
| 294 } | 320 } |
| 295 | 321 |
| 296 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { | 322 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { |
| 297 base::ProcessHandle process_handle; | 323 base::ProcessHandle process_handle; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // sent_requests_ queue should be the one that the plugin just created. | 409 // sent_requests_ queue should be the one that the plugin just created. |
| 384 Client* client = sent_requests_.front(); | 410 Client* client = sent_requests_.front(); |
| 385 sent_requests_.pop(); | 411 sent_requests_.pop(); |
| 386 | 412 |
| 387 const ChildProcessData& data = process_->GetData(); | 413 const ChildProcessData& data = process_->GetData(); |
| 388 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), | 414 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), |
| 389 data.id); | 415 data.id); |
| 390 } | 416 } |
| 391 | 417 |
| 392 } // namespace content | 418 } // namespace content |
| OLD | NEW |