| 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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // create the server side of chrome pipes. | 63 // create the server side of chrome pipes. |
| 64 sandbox::ResultCode result; | 64 sandbox::ResultCode result; |
| 65 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, | 65 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, |
| 66 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, | 66 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, |
| 67 L"\\\\.\\pipe\\chrome.*"); | 67 L"\\\\.\\pipe\\chrome.*"); |
| 68 *success = (result == sandbox::SBOX_ALL_OK); | 68 *success = (result == sandbox::SBOX_ALL_OK); |
| 69 } | 69 } |
| 70 | 70 |
| 71 #elif defined(OS_POSIX) | 71 #elif defined(OS_POSIX) |
| 72 virtual bool ShouldUseZygote() OVERRIDE { | 72 virtual bool ShouldUseZygote() OVERRIDE { |
| 73 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 73 const base::CommandLine& browser_command_line = |
| 74 CommandLine::StringType plugin_launcher = browser_command_line | 74 *base::CommandLine::ForCurrentProcess(); |
| 75 base::CommandLine::StringType plugin_launcher = browser_command_line |
| 75 .GetSwitchValueNative(switches::kPpapiPluginLauncher); | 76 .GetSwitchValueNative(switches::kPpapiPluginLauncher); |
| 76 return !is_broker_ && plugin_launcher.empty() && info_.is_sandboxed; | 77 return !is_broker_ && plugin_launcher.empty() && info_.is_sandboxed; |
| 77 } | 78 } |
| 78 virtual int GetIpcFd() OVERRIDE { | 79 virtual int GetIpcFd() OVERRIDE { |
| 79 return ipc_fd_; | 80 return ipc_fd_; |
| 80 } | 81 } |
| 81 #endif // OS_WIN | 82 #endif // OS_WIN |
| 82 | 83 |
| 83 private: | 84 private: |
| 84 #if defined(OS_POSIX) | 85 #if defined(OS_POSIX) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } else { | 282 } else { |
| 282 process_->SetName(base::UTF8ToUTF16(info.name)); | 283 process_->SetName(base::UTF8ToUTF16(info.name)); |
| 283 } | 284 } |
| 284 | 285 |
| 285 std::string channel_id = process_->GetHost()->CreateChannel(); | 286 std::string channel_id = process_->GetHost()->CreateChannel(); |
| 286 if (channel_id.empty()) { | 287 if (channel_id.empty()) { |
| 287 VLOG(1) << "Could not create pepper host channel."; | 288 VLOG(1) << "Could not create pepper host channel."; |
| 288 return false; | 289 return false; |
| 289 } | 290 } |
| 290 | 291 |
| 291 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 292 const base::CommandLine& browser_command_line = |
| 292 CommandLine::StringType plugin_launcher = | 293 *base::CommandLine::ForCurrentProcess(); |
| 294 base::CommandLine::StringType plugin_launcher = |
| 293 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher); | 295 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher); |
| 294 | 296 |
| 295 #if defined(OS_LINUX) | 297 #if defined(OS_LINUX) |
| 296 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : | 298 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : |
| 297 ChildProcessHost::CHILD_NORMAL; | 299 ChildProcessHost::CHILD_NORMAL; |
| 298 #else | 300 #else |
| 299 int flags = ChildProcessHost::CHILD_NORMAL; | 301 int flags = ChildProcessHost::CHILD_NORMAL; |
| 300 #endif | 302 #endif |
| 301 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); | 303 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); |
| 302 if (exe_path.empty()) { | 304 if (exe_path.empty()) { |
| 303 VLOG(1) << "Pepper plugin exe path is empty."; | 305 VLOG(1) << "Pepper plugin exe path is empty."; |
| 304 return false; | 306 return false; |
| 305 } | 307 } |
| 306 | 308 |
| 307 CommandLine* cmd_line = new CommandLine(exe_path); | 309 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
| 308 cmd_line->AppendSwitchASCII(switches::kProcessType, | 310 cmd_line->AppendSwitchASCII(switches::kProcessType, |
| 309 is_broker_ ? switches::kPpapiBrokerProcess | 311 is_broker_ ? switches::kPpapiBrokerProcess |
| 310 : switches::kPpapiPluginProcess); | 312 : switches::kPpapiPluginProcess); |
| 311 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 313 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 312 | 314 |
| 313 // These switches are forwarded to both plugin and broker pocesses. | 315 // These switches are forwarded to both plugin and broker pocesses. |
| 314 static const char* kCommonForwardSwitches[] = { | 316 static const char* kCommonForwardSwitches[] = { |
| 315 switches::kVModule | 317 switches::kVModule |
| 316 }; | 318 }; |
| 317 cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches, | 319 cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 // sent_requests_ queue should be the one that the plugin just created. | 464 // sent_requests_ queue should be the one that the plugin just created. |
| 463 Client* client = sent_requests_.front(); | 465 Client* client = sent_requests_.front(); |
| 464 sent_requests_.pop(); | 466 sent_requests_.pop(); |
| 465 | 467 |
| 466 const ChildProcessData& data = process_->GetData(); | 468 const ChildProcessData& data = process_->GetData(); |
| 467 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), | 469 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), |
| 468 data.id); | 470 data.id); |
| 469 } | 471 } |
| 470 | 472 |
| 471 } // namespace content | 473 } // namespace content |
| OLD | NEW |