Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: chrome/browser/plugin_process_host.cc

Issue 3012021: CommandLine: add a CopySwitchesFrom() for copying from another CommandLine (Closed)
Patch Set: minor cleanups Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/plugin_process_host.h" 5 #include "chrome/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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 browser_command_line.GetSwitchValue(switches::kPluginLauncher); 356 browser_command_line.GetSwitchValue(switches::kPluginLauncher);
357 FilePath exe_path = GetChildPath(plugin_launcher.empty()); 357 FilePath exe_path = GetChildPath(plugin_launcher.empty());
358 if (exe_path.empty()) 358 if (exe_path.empty())
359 return false; 359 return false;
360 360
361 CommandLine* cmd_line = new CommandLine(exe_path); 361 CommandLine* cmd_line = new CommandLine(exe_path);
362 // Put the process type and plugin path first so they're easier to see 362 // Put the process type and plugin path first so they're easier to see
363 // in process listings using native process management tools. 363 // in process listings using native process management tools.
364 cmd_line->AppendSwitchWithValue(switches::kProcessType, 364 cmd_line->AppendSwitchWithValue(switches::kProcessType,
365 switches::kPluginProcess); 365 switches::kPluginProcess);
366 cmd_line->AppendSwitchWithValue(switches::kPluginPath, 366 cmd_line->AppendSwitchPath(switches::kPluginPath, info.path);
367 info.path.ToWStringHack());
368 367
369 if (logging::DialogsAreSuppressed()) 368 if (logging::DialogsAreSuppressed())
370 cmd_line->AppendSwitch(switches::kNoErrorDialogs); 369 cmd_line->AppendSwitch(switches::kNoErrorDialogs);
371 370
372 // Propagate the following switches to the plugin command line (along with 371 // Propagate the following switches to the plugin command line (along with
373 // any associated values) if present in the browser command line 372 // any associated values) if present in the browser command line
374 static const char* const switch_names[] = { 373 static const char* const kSwitchNames[] = {
375 switches::kPluginStartupDialog, 374 switches::kPluginStartupDialog,
376 switches::kNoSandbox, 375 switches::kNoSandbox,
377 switches::kSafePlugins, 376 switches::kSafePlugins,
378 switches::kTestSandbox, 377 switches::kTestSandbox,
379 switches::kUserAgent, 378 switches::kUserAgent,
380 switches::kDisableBreakpad, 379 switches::kDisableBreakpad,
381 switches::kFullMemoryCrashReport, 380 switches::kFullMemoryCrashReport,
382 switches::kEnableLogging, 381 switches::kEnableLogging,
383 switches::kDisableLogging, 382 switches::kDisableLogging,
384 switches::kLoggingLevel, 383 switches::kLoggingLevel,
385 switches::kLogPluginMessages, 384 switches::kLogPluginMessages,
386 switches::kUserDataDir, 385 switches::kUserDataDir,
387 switches::kEnableDCHECK, 386 switches::kEnableDCHECK,
388 switches::kSilentDumpOnDCHECK, 387 switches::kSilentDumpOnDCHECK,
389 switches::kMemoryProfiling, 388 switches::kMemoryProfiling,
390 switches::kUseLowFragHeapCrt, 389 switches::kUseLowFragHeapCrt,
391 switches::kEnableStatsTable, 390 switches::kEnableStatsTable,
392 switches::kEnableGPUPlugin, 391 switches::kEnableGPUPlugin,
393 switches::kUseGL, 392 switches::kUseGL,
394 #if defined(OS_CHROMEOS) 393 #if defined(OS_CHROMEOS)
395 switches::kProfile, 394 switches::kProfile,
396 #endif 395 #endif
397 }; 396 };
398 397
399 for (size_t i = 0; i < arraysize(switch_names); ++i) { 398 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
400 if (browser_command_line.HasSwitch(switch_names[i])) { 399 arraysize(kSwitchNames));
401 cmd_line->AppendSwitchWithValue(
402 switch_names[i],
403 browser_command_line.GetSwitchValueASCII(switch_names[i]));
404 }
405 }
406 400
407 // If specified, prepend a launcher program to the command line. 401 // If specified, prepend a launcher program to the command line.
408 if (!plugin_launcher.empty()) 402 if (!plugin_launcher.empty())
409 cmd_line->PrependWrapper(plugin_launcher); 403 cmd_line->PrependWrapper(plugin_launcher);
410 404
411 if (!locale.empty()) { 405 if (!locale.empty()) {
412 // Pass on the locale so the null plugin will use the right language in the 406 // Pass on the locale so the null plugin will use the right language in the
413 // prompt to install the desired plugin. 407 // prompt to install the desired plugin.
414 cmd_line->AppendSwitchWithValue(switches::kLang, locale); 408 cmd_line->AppendSwitchWithValue(switches::kLang, locale);
415 } 409 }
416 410
417 // Gears requires the data dir to be available on startup. 411 // Gears requires the data dir to be available on startup.
418 std::wstring data_dir = 412 FilePath data_dir =
419 PluginService::GetInstance()->GetChromePluginDataDir().ToWStringHack(); 413 PluginService::GetInstance()->GetChromePluginDataDir();
420 DCHECK(!data_dir.empty()); 414 DCHECK(!data_dir.empty());
421 cmd_line->AppendSwitchWithValue(switches::kPluginDataDir, data_dir); 415 cmd_line->AppendSwitchPath(switches::kPluginDataDir, data_dir);
422 416
423 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, 417 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, channel_id());
424 ASCIIToWide(channel_id()));
425 418
426 SetCrashReporterCommandLine(cmd_line); 419 SetCrashReporterCommandLine(cmd_line);
427 420
428 #if defined(OS_POSIX) 421 #if defined(OS_POSIX)
429 base::environment_vector env; 422 base::environment_vector env;
430 #if defined(OS_MACOSX) && !defined(__LP64__) 423 #if defined(OS_MACOSX) && !defined(__LP64__)
431 // Add our interposing library for Carbon. This is stripped back out in 424 // Add our interposing library for Carbon. This is stripped back out in
432 // plugin_main.cc, so changes here should be reflected there. 425 // plugin_main.cc, so changes here should be reflected there.
433 std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath); 426 std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath);
434 const char* existing_list = 427 const char* existing_list =
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 const std::vector<uint8>& data) { 661 const std::vector<uint8>& data) {
669 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 662 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
670 663
671 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path); 664 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path);
672 if (chrome_plugin) { 665 if (chrome_plugin) {
673 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); 666 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0]));
674 uint32 data_len = static_cast<uint32>(data.size()); 667 uint32 data_len = static_cast<uint32>(data.size());
675 chrome_plugin->functions().on_message(data_ptr, data_len); 668 chrome_plugin->functions().on_message(data_ptr, data_len);
676 } 669 }
677 } 670 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context_unittest.cc ('k') | chrome/browser/pref_service_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698