| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/plugin_process_host.h" | 7 #include "chrome/browser/plugin_process_host.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return false; | 337 return false; |
| 338 | 338 |
| 339 // build command line for plugin, we have to quote the plugin's path to deal | 339 // build command line for plugin, we have to quote the plugin's path to deal |
| 340 // with spaces. | 340 // with spaces. |
| 341 std::wstring exe_path = GetChildPath(); | 341 std::wstring exe_path = GetChildPath(); |
| 342 if (exe_path.empty()) { | 342 if (exe_path.empty()) { |
| 343 return false; | 343 return false; |
| 344 } | 344 } |
| 345 | 345 |
| 346 CommandLine cmd_line(exe_path); | 346 CommandLine cmd_line(exe_path); |
| 347 // Put the process type and plugin path first so they're easier to see |
| 348 // in process listings using native process management tools. |
| 349 cmd_line.AppendSwitchWithValue(switches::kProcessType, |
| 350 switches::kPluginProcess); |
| 351 cmd_line.AppendSwitchWithValue(switches::kPluginPath, |
| 352 info.path.ToWStringHack()); |
| 353 |
| 347 if (logging::DialogsAreSuppressed()) | 354 if (logging::DialogsAreSuppressed()) |
| 348 cmd_line.AppendSwitch(switches::kNoErrorDialogs); | 355 cmd_line.AppendSwitch(switches::kNoErrorDialogs); |
| 349 | 356 |
| 350 // propagate the following switches to the plugin command line (along with | 357 // propagate the following switches to the plugin command line (along with |
| 351 // any associated values) if present in the browser command line | 358 // any associated values) if present in the browser command line |
| 352 static const wchar_t* const switch_names[] = { | 359 static const wchar_t* const switch_names[] = { |
| 353 switches::kPluginStartupDialog, | 360 switches::kPluginStartupDialog, |
| 354 switches::kNoSandbox, | 361 switches::kNoSandbox, |
| 355 switches::kSafePlugins, | 362 switches::kSafePlugins, |
| 356 switches::kTestSandbox, | 363 switches::kTestSandbox, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // prompt to install the desired plugin. | 397 // prompt to install the desired plugin. |
| 391 cmd_line.AppendSwitchWithValue(switches::kLang, locale); | 398 cmd_line.AppendSwitchWithValue(switches::kLang, locale); |
| 392 } | 399 } |
| 393 | 400 |
| 394 // Gears requires the data dir to be available on startup. | 401 // Gears requires the data dir to be available on startup. |
| 395 std::wstring data_dir = | 402 std::wstring data_dir = |
| 396 PluginService::GetInstance()->GetChromePluginDataDir().ToWStringHack(); | 403 PluginService::GetInstance()->GetChromePluginDataDir().ToWStringHack(); |
| 397 DCHECK(!data_dir.empty()); | 404 DCHECK(!data_dir.empty()); |
| 398 cmd_line.AppendSwitchWithValue(switches::kPluginDataDir, data_dir); | 405 cmd_line.AppendSwitchWithValue(switches::kPluginDataDir, data_dir); |
| 399 | 406 |
| 400 cmd_line.AppendSwitchWithValue(switches::kProcessType, | |
| 401 switches::kPluginProcess); | |
| 402 | |
| 403 cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, | 407 cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, |
| 404 ASCIIToWide(channel_id())); | 408 ASCIIToWide(channel_id())); |
| 405 | 409 |
| 406 cmd_line.AppendSwitchWithValue(switches::kPluginPath, | |
| 407 info.path.ToWStringHack()); | |
| 408 | |
| 409 SetCrashReporterCommandLine(&cmd_line); | 410 SetCrashReporterCommandLine(&cmd_line); |
| 410 | 411 |
| 411 base::ProcessHandle process = 0; | 412 base::ProcessHandle process = 0; |
| 412 #if defined(OS_WIN) | 413 #if defined(OS_WIN) |
| 413 process = sandbox::StartProcess(&cmd_line); | 414 process = sandbox::StartProcess(&cmd_line); |
| 414 #else | 415 #else |
| 415 // This code is duplicated with browser_render_process_host.cc, but | 416 // This code is duplicated with browser_render_process_host.cc, but |
| 416 // there's not a good place to de-duplicate it. | 417 // there's not a good place to de-duplicate it. |
| 417 base::file_handle_mapping_vector fds_to_map; | 418 base::file_handle_mapping_vector fds_to_map; |
| 418 const int ipcfd = channel().GetClientFileDescriptor(); | 419 const int ipcfd = channel().GetClientFileDescriptor(); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 DCHECK(MessageLoop::current() == | 634 DCHECK(MessageLoop::current() == |
| 634 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 635 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
| 635 | 636 |
| 636 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path); | 637 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path); |
| 637 if (chrome_plugin) { | 638 if (chrome_plugin) { |
| 638 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); | 639 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); |
| 639 uint32 data_len = static_cast<uint32>(data.size()); | 640 uint32 data_len = static_cast<uint32>(data.size()); |
| 640 chrome_plugin->functions().on_message(data_ptr, data_len); | 641 chrome_plugin->functions().on_message(data_ptr, data_len); |
| 641 } | 642 } |
| 642 } | 643 } |
| OLD | NEW |