michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "chrome/common/debug_flags.h" michael@0: michael@0: #include "base/base_switches.h" michael@0: #include "base/command_line.h" michael@0: #include "chrome/common/chrome_switches.h" michael@0: michael@0: bool DebugFlags::ProcessDebugFlags(CommandLine* command_line, michael@0: ChildProcessInfo::ProcessType type, michael@0: bool is_in_sandbox) { michael@0: bool should_help_child = false; michael@0: const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess(); michael@0: if (current_cmd_line.HasSwitch(switches::kDebugChildren)) { michael@0: // Look to pass-on the kDebugOnStart flag. michael@0: std::wstring value; michael@0: value = current_cmd_line.GetSwitchValue(switches::kDebugChildren); michael@0: if (value.empty() || michael@0: (type == ChildProcessInfo::RENDER_PROCESS && michael@0: value == switches::kRendererProcess) || michael@0: (type == ChildProcessInfo::PLUGIN_PROCESS && michael@0: value == switches::kPluginProcess)) { michael@0: command_line->AppendSwitch(switches::kDebugOnStart); michael@0: should_help_child = true; michael@0: } michael@0: command_line->AppendSwitchWithValue(switches::kDebugChildren, value); michael@0: } else if (current_cmd_line.HasSwitch(switches::kWaitForDebuggerChildren)) { michael@0: // Look to pass-on the kWaitForDebugger flag. michael@0: std::wstring value; michael@0: value = current_cmd_line.GetSwitchValue(switches::kWaitForDebuggerChildren); michael@0: if (value.empty() || michael@0: (type == ChildProcessInfo::RENDER_PROCESS && michael@0: value == switches::kRendererProcess) || michael@0: (type == ChildProcessInfo::PLUGIN_PROCESS && michael@0: value == switches::kPluginProcess)) { michael@0: command_line->AppendSwitch(switches::kWaitForDebugger); michael@0: } michael@0: command_line->AppendSwitchWithValue(switches::kWaitForDebuggerChildren, michael@0: value); michael@0: } michael@0: return should_help_child; michael@0: }