| 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/plugin_process_host.h" | 5 #include "content/browser/plugin_process_host.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <utility> // for pair<> | 10 #include <utility> // for pair<> |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool PluginProcessHost::Init(const WebPluginInfo& info) { | 153 bool PluginProcessHost::Init(const WebPluginInfo& info) { |
| 154 info_ = info; | 154 info_ = info; |
| 155 process_->SetName(info_.name); | 155 process_->SetName(info_.name); |
| 156 | 156 |
| 157 std::string channel_id = process_->GetHost()->CreateChannel(); | 157 std::string channel_id = process_->GetHost()->CreateChannel(); |
| 158 if (channel_id.empty()) | 158 if (channel_id.empty()) |
| 159 return false; | 159 return false; |
| 160 | 160 |
| 161 // Build command line for plugin. When we have a plugin launcher, we can't | 161 // Build command line for plugin. When we have a plugin launcher, we can't |
| 162 // allow "self" on linux and we need the real file path. | 162 // allow "self" on linux and we need the real file path. |
| 163 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 163 const base::CommandLine& browser_command_line = |
| 164 CommandLine::StringType plugin_launcher = | 164 *base::CommandLine::ForCurrentProcess(); |
| 165 base::CommandLine::StringType plugin_launcher = |
| 165 browser_command_line.GetSwitchValueNative(switches::kPluginLauncher); | 166 browser_command_line.GetSwitchValueNative(switches::kPluginLauncher); |
| 166 | 167 |
| 167 #if defined(OS_MACOSX) | 168 #if defined(OS_MACOSX) |
| 168 // Run the plug-in process in a mode tolerant of heap execution without | 169 // Run the plug-in process in a mode tolerant of heap execution without |
| 169 // explicit mprotect calls. Some plug-ins still rely on this quaint and | 170 // explicit mprotect calls. Some plug-ins still rely on this quaint and |
| 170 // archaic "feature." See http://crbug.com/93551. | 171 // archaic "feature." See http://crbug.com/93551. |
| 171 int flags = ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION; | 172 int flags = ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION; |
| 172 #elif defined(OS_LINUX) | 173 #elif defined(OS_LINUX) |
| 173 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : | 174 int flags = plugin_launcher.empty() ? ChildProcessHost::CHILD_ALLOW_SELF : |
| 174 ChildProcessHost::CHILD_NORMAL; | 175 ChildProcessHost::CHILD_NORMAL; |
| 175 #else | 176 #else |
| 176 int flags = ChildProcessHost::CHILD_NORMAL; | 177 int flags = ChildProcessHost::CHILD_NORMAL; |
| 177 #endif | 178 #endif |
| 178 | 179 |
| 179 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); | 180 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); |
| 180 if (exe_path.empty()) | 181 if (exe_path.empty()) |
| 181 return false; | 182 return false; |
| 182 | 183 |
| 183 CommandLine* cmd_line = new CommandLine(exe_path); | 184 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
| 184 // Put the process type and plugin path first so they're easier to see | 185 // Put the process type and plugin path first so they're easier to see |
| 185 // in process listings using native process management tools. | 186 // in process listings using native process management tools. |
| 186 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kPluginProcess); | 187 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kPluginProcess); |
| 187 cmd_line->AppendSwitchPath(switches::kPluginPath, info.path); | 188 cmd_line->AppendSwitchPath(switches::kPluginPath, info.path); |
| 188 | 189 |
| 189 // Propagate the following switches to the plugin command line (along with | 190 // Propagate the following switches to the plugin command line (along with |
| 190 // any associated values) if present in the browser command line | 191 // any associated values) if present in the browser command line |
| 191 static const char* const kSwitchNames[] = { | 192 static const char* const kSwitchNames[] = { |
| 192 switches::kDisableBreakpad, | 193 switches::kDisableBreakpad, |
| 193 switches::kDisableDirectNPAPIRequests, | 194 switches::kDisableDirectNPAPIRequests, |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 397 |
| 397 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, | 398 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, |
| 398 ResourceContext** resource_context, | 399 ResourceContext** resource_context, |
| 399 net::URLRequestContext** request_context) { | 400 net::URLRequestContext** request_context) { |
| 400 *resource_context = | 401 *resource_context = |
| 401 resource_context_map_[request.origin_pid].resource_context; | 402 resource_context_map_[request.origin_pid].resource_context; |
| 402 *request_context = (*resource_context)->GetRequestContext(); | 403 *request_context = (*resource_context)->GetRequestContext(); |
| 403 } | 404 } |
| 404 | 405 |
| 405 } // namespace content | 406 } // namespace content |
| OLD | NEW |