summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/breakpad.cc4
-rw-r--r--chrome/app/chrome_dll_main.cc8
-rw-r--r--chrome/app/chrome_exe_main.cc2
-rw-r--r--chrome/app/chrome_main_uitest.cc2
-rw-r--r--chrome/browser/browser.cc6
-rw-r--r--chrome/browser/browser_init.cc50
-rw-r--r--chrome/browser/browser_main.cc9
-rw-r--r--chrome/browser/browser_process_impl.cc2
-rw-r--r--chrome/browser/browser_process_impl.h2
-rw-r--r--chrome/browser/browsing_instance.cc5
-rw-r--r--chrome/browser/chrome_plugin_host.cc4
-rw-r--r--chrome/browser/debugger/debugger_contents.cc3
-rwxr-xr-xchrome/browser/first_run.cc10
-rw-r--r--chrome/browser/first_run.h2
-rw-r--r--chrome/browser/images_uitest.cc6
-rw-r--r--chrome/browser/locale_tests_uitest.cc6
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc4
-rw-r--r--chrome/browser/plugin_process_host.cc42
-rw-r--r--chrome/browser/printing/printing_layout_uitest.cc7
-rw-r--r--chrome/browser/render_view_context_menu_controller.cc2
-rw-r--r--chrome/browser/render_view_host_manager.cc4
-rw-r--r--chrome/browser/render_widget_host_view_win.cc3
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc43
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database.cc4
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_unittest.cc3
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc3
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc3
-rw-r--r--chrome/browser/sessions/session_restore_uitest.cc16
-rw-r--r--chrome/browser/tab_contents/web_contents.cc2
-rw-r--r--chrome/browser/unload_uitest.cc8
-rw-r--r--chrome/browser/user_data_manager.cc9
-rw-r--r--chrome/browser/views/frame/browser_view.cc4
-rw-r--r--chrome/common/child_process.cc2
-rw-r--r--chrome/common/chrome_paths.cc4
-rw-r--r--chrome/common/chrome_plugin_lib.cc3
-rw-r--r--chrome/common/chrome_plugin_util.cc8
-rw-r--r--chrome/common/common_glue.cc2
-rw-r--r--chrome/common/debug_flags.cc17
-rw-r--r--chrome/common/debug_flags.h18
-rw-r--r--chrome/common/ipc_channel_posix.cc3
-rw-r--r--chrome/common/ipc_logging.cc2
-rw-r--r--chrome/common/ipc_tests.cc11
-rw-r--r--chrome/common/l10n_util.cc2
-rw-r--r--chrome/common/logging_chrome_uitest.cc9
-rw-r--r--chrome/common/main_function_params.h6
-rw-r--r--chrome/common/pref_service_uitest.cc5
-rw-r--r--chrome/common/temp_scaffolding_stubs.cpp2
-rw-r--r--chrome/common/temp_scaffolding_stubs.h4
-rwxr-xr-xchrome/installer/setup/main.cc3
-rwxr-xr-xchrome/installer/setup/setup.cc1
-rw-r--r--chrome/plugin/plugin_main.cc2
-rw-r--r--chrome/plugin/webplugin_delegate_stub.cc2
-rw-r--r--chrome/renderer/render_process.cc2
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/renderer_glue.cc2
-rw-r--r--chrome/renderer/renderer_main.cc2
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc12
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc12
-rw-r--r--chrome/test/memory_test/memory_test.cc15
-rw-r--r--chrome/test/page_cycler/page_cycler_test.cc5
-rw-r--r--chrome/test/plugin/plugin_test.cpp21
-rw-r--r--chrome/test/reliability/reliability_test_suite.h2
-rw-r--r--chrome/test/startup/startup_test.cc2
-rw-r--r--chrome/test/ui/inspector_controller_uitest.cc2
-rw-r--r--chrome/test/ui/omnibox_uitest.cc3
-rw-r--r--chrome/test/ui/sandbox_uitests.cc5
-rw-r--r--chrome/test/ui/ui_test.cc94
-rw-r--r--chrome/test/ui/ui_test.h7
-rw-r--r--chrome/test/ui/ui_test_suite.h2
-rw-r--r--chrome/test/unit/chrome_test_suite.h3
-rw-r--r--chrome/tools/test/image_diff/image_diff.cc22
-rw-r--r--chrome/views/window.cc2
72 files changed, 295 insertions, 310 deletions
diff --git a/chrome/app/breakpad.cc b/chrome/app/breakpad.cc
index c0245ad..70aaf97 100644
--- a/chrome/app/breakpad.cc
+++ b/chrome/app/breakpad.cc
@@ -163,7 +163,7 @@ static DWORD __stdcall InitCrashReporterThread(void* param) {
// we do it here so it can run in a separate thread.
info->custom_info = GetCustomInfo(info->dll_path, info->process_type);
- CommandLine command;
+ const CommandLine& command = *CommandLine::ForCurrentProcess();
bool full_dump = command.HasSwitch(switches::kFullMemoryCrashReport);
bool use_crash_service = command.HasSwitch(switches::kNoErrorDialogs) ||
GetEnvironmentVariable(L"CHROME_HEADLESS", NULL, 0);
@@ -238,7 +238,7 @@ void InitDefaultCrashCallback() {
}
void InitCrashReporter(std::wstring dll_path) {
- CommandLine command;
+ const CommandLine& command = *CommandLine::ForCurrentProcess();
if (!command.HasSwitch(switches::kDisableBreakpad)) {
// Disable the message box for assertions.
_CrtSetReportMode(_CRT_ASSERT, 0);
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 48d5b21..29429d0 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -204,10 +204,12 @@ int ChromeMain(int argc, const char** argv) {
base::ScopedNSAutoreleasePool autorelease_pool;
// Initialize the command line.
-#if defined(OS_POSIX)
- CommandLine::SetArgcArgv(argc, argv);
+#if defined(OS_WIN)
+ CommandLine::Init(0, NULL);
+#else
+ CommandLine::Init(argc, argv);
#endif
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
SetupCRT(parsed_command_line);
diff --git a/chrome/app/chrome_exe_main.cc b/chrome/app/chrome_exe_main.cc
index 85a3462..6399198 100644
--- a/chrome/app/chrome_exe_main.cc
+++ b/chrome/app/chrome_exe_main.cc
@@ -42,6 +42,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
if (!sandbox_info.broker_services)
sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices();
+ CommandLine::Init(0, NULL);
+
const wchar_t* dll_name = L"chrome.dll";
#if defined(GOOGLE_CHROME_BUILD)
google_update::GoogleUpdateClient client;
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc
index 4217c3b..4689d27 100644
--- a/chrome/app/chrome_main_uitest.cc
+++ b/chrome/app/chrome_main_uitest.cc
@@ -35,7 +35,7 @@ TEST_F(ChromeMainTest, SecondLaunch) {
include_testing_id_ = false;
use_existing_browser_ = true;
- LaunchBrowser(std::wstring(), false);
+ LaunchBrowser(CommandLine(L""), false);
int window_count;
ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count,
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 54f3789..3e12603 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -321,7 +321,7 @@ void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
}
gfx::Rect Browser::GetSavedWindowBounds() const {
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode);
bool playback_mode = parsed_command_line.HasSwitch(switches::kPlaybackMode);
if (record_mode || playback_mode) {
@@ -343,7 +343,7 @@ gfx::Rect Browser::GetSavedWindowBounds() const {
// TODO(beng): obtain maximized state some other way so we don't need to go
// through all this hassle.
bool Browser::GetSavedMaximizedState() const {
- if (CommandLine().HasSwitch(switches::kStartMaximized))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
return true;
gfx::Rect restored_bounds;
@@ -1489,7 +1489,7 @@ void Browser::OpenURLFromTab(TabContents* source,
// TODO(creis): should this apply to applications?
SiteInstance* instance = NULL;
// Don't use this logic when "--process-per-tab" is specified.
- if (!CommandLine().HasSwitch(switches::kProcessPerTab)) {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab)) {
if (current_tab) {
const WebContents* const web_contents = current_tab->AsWebContents();
if (web_contents) {
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index eba5365..3a0794e 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -403,7 +403,8 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
DCHECK(profile);
profile_ = profile;
- CommandLine parsed_command_line(command_line_);
+ CommandLine parsed_command_line(L"");
+ parsed_command_line.ParseFromString(command_line_);
if (parsed_command_line.HasSwitch(switches::kDnsLogDetails))
chrome_browser_net::EnableDnsDetailedLog(true);
if (parsed_command_line.HasSwitch(switches::kDnsPrefetchDisable))
@@ -569,30 +570,27 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
const CommandLine& command_line, Profile* profile) {
std::vector<GURL> urls;
- if (command_line.GetLooseValueCount() > 0) {
- for (CommandLine::LooseValueIterator iter =
- command_line.GetLooseValuesBegin();
- iter != command_line.GetLooseValuesEnd(); ++iter) {
- std::wstring value = *iter;
- // Handle Vista way of searching - "? <search-term>"
- if (value.find(L"? ") == 0) {
- const TemplateURL* const default_provider =
- profile->GetTemplateURLModel()->GetDefaultSearchProvider();
- if (!default_provider || !default_provider->url()) {
- // No search provider available. Just treat this as regular URL.
- urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_,
- value)));
- continue;
- }
- const TemplateURLRef* const search_url = default_provider->url();
- DCHECK(search_url->SupportsReplacement());
- urls.push_back(GURL(search_url->ReplaceSearchTerms(*default_provider,
- value.substr(2), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
- std::wstring())));
- } else {
- // This will create a file URL or a regular URL.
- urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_, value)));
+ std::vector<std::wstring> params = command_line.GetLooseValues();
+ for (size_t i = 0; i < params.size(); ++i) {
+ const std::wstring& value = params[i];
+ // Handle Vista way of searching - "? <search-term>"
+ if (value.find(L"? ") == 0) {
+ const TemplateURL* const default_provider =
+ profile->GetTemplateURLModel()->GetDefaultSearchProvider();
+ if (!default_provider || !default_provider->url()) {
+ // No search provider available. Just treat this as regular URL.
+ urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_,
+ value)));
+ continue;
}
+ const TemplateURLRef* const search_url = default_provider->url();
+ DCHECK(search_url->SupportsReplacement());
+ urls.push_back(GURL(search_url->ReplaceSearchTerms(*default_provider,
+ value.substr(2), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
+ std::wstring())));
+ } else {
+ // This will create a file URL or a regular URL.
+ urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_, value)));
}
}
return urls;
@@ -633,7 +631,7 @@ bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
CreateAutomationProvider<TestingAutomationProvider>(
testing_channel_id,
profile,
- std::max(static_cast<int>(parsed_command_line.GetLooseValueCount()),
+ std::max(static_cast<int>(parsed_command_line.GetLooseValues().size()),
1));
}
}
@@ -651,7 +649,7 @@ bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
// If there are any loose parameters, we expect each one to generate a
// new tab; if there are none then we have no tabs
size_t expected_tabs =
- std::max(static_cast<int>(parsed_command_line.GetLooseValueCount()),
+ std::max(static_cast<int>(parsed_command_line.GetLooseValues().size()),
0);
if (expected_tabs == 0) {
silent_launch = true;
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 2645013..29d984e 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -176,7 +176,7 @@ StringPiece NetResourceProvider(int key) {
// Main routine for running as the Browser process.
int BrowserMain(const MainFunctionParams& parameters) {
- CommandLine& parsed_command_line = parameters.command_line_;
+ const CommandLine& parsed_command_line = parameters.command_line_;
// WARNING: If we get a WM_ENDSESSION objects created on the stack here
// are NOT deleted. If you need something to run during WM_ENDSESSION add it
@@ -327,10 +327,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
// --user-data-dir switch. The last flag of the same name wins.
// TODO(tc): It would be nice to remove the flag we don't want, but that
// sounds risky if we parse differently than CommandLineToArgvW.
- std::wstring new_command_line =
- parsed_command_line.command_line_string();
- CommandLine::AppendSwitchWithValue(&new_command_line,
- switches::kUserDataDir, user_data_dir);
+ CommandLine new_command_line = parsed_command_line;
+ new_command_line.AppendSwitchWithValue(switches::kUserDataDir,
+ user_data_dir);
base::LaunchApp(new_command_line, false, false, NULL);
}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 20188cc1..3fa75d5 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -82,7 +82,7 @@ class BrowserProcessSubThread : public ChromeThread {
} // namespace
-BrowserProcessImpl::BrowserProcessImpl(CommandLine& command_line)
+BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
: created_resource_dispatcher_host_(false),
created_metrics_service_(false),
created_io_thread_(false),
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 3b8732c..bcbb862 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -28,7 +28,7 @@ class NotificationService;
// Real implementation of BrowserProcess that creates and returns the services.
class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
public:
- BrowserProcessImpl(CommandLine& command_line);
+ BrowserProcessImpl(const CommandLine& command_line);
virtual ~BrowserProcessImpl();
virtual void EndSession();
diff --git a/chrome/browser/browsing_instance.cc b/chrome/browser/browsing_instance.cc
index 527feb1a..f15deca 100644
--- a/chrome/browser/browsing_instance.cc
+++ b/chrome/browser/browsing_instance.cc
@@ -17,10 +17,11 @@ bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) {
// the case if the --process-per-site switch is specified, or in
// process-per-site-instance for particular sites (e.g., the new tab page).
- if (CommandLine().HasSwitch(switches::kProcessPerSite))
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kProcessPerSite))
return true;
- if (!CommandLine().HasSwitch(switches::kProcessPerTab)) {
+ if (!command_line.HasSwitch(switches::kProcessPerTab)) {
// We are not in process-per-site or process-per-tab, so we must be in the
// default (process-per-site-instance). Only use the process-per-site
// logic for particular sites that we want to consolidate.
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc
index 55f1dd1..f501764 100644
--- a/chrome/browser/chrome_plugin_host.cc
+++ b/chrome/browser/chrome_plugin_host.cc
@@ -640,8 +640,8 @@ CPProcessType STDCALL CPB_GetProcessType(CPID id) {
}
CPError STDCALL CPB_SendMessage(CPID id, const void *data, uint32 data_len) {
- CommandLine cmd;
- if (cmd.HasSwitch(switches::kGearsInRenderer)) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kGearsInRenderer)) {
ChromePluginLib* plugin = ChromePluginLib::FromCPID(id);
CHECK(plugin);
diff --git a/chrome/browser/debugger/debugger_contents.cc b/chrome/browser/debugger/debugger_contents.cc
index a6dd254..c3d2e4b 100644
--- a/chrome/browser/debugger/debugger_contents.cc
+++ b/chrome/browser/debugger/debugger_contents.cc
@@ -40,7 +40,8 @@ class DebuggerHTMLSource : public ChromeURLDataManager::DataSource {
}
std::wstring debugger_path =
- CommandLine().GetSwitchValue(switches::kJavaScriptDebuggerPath);
+ CommandLine::ForCurrentProcess()->GetSwitchValue(
+ switches::kJavaScriptDebuggerPath);
std::string data_str;
if (!debugger_path.empty() && file_util::PathExists(debugger_path)) {
if (path.empty())
diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc
index c6f4f29..8522a8b 100755
--- a/chrome/browser/first_run.cc
+++ b/chrome/browser/first_run.cc
@@ -450,8 +450,8 @@ bool DecodeImportParams(const std::wstring& encoded,
bool FirstRun::ImportSettings(Profile* profile, int browser,
int items_to_import, HWND parent_window) {
- CommandLine cmdline;
- std::wstring import_cmd(cmdline.program());
+ const CommandLine& cmdline = *CommandLine::ForCurrentProcess();
+ CommandLine import_cmd(cmdline.program());
// Propagate the following switches to the importer command line.
static const wchar_t* const switch_names[] = {
switches::kUserDataDir,
@@ -459,12 +459,12 @@ bool FirstRun::ImportSettings(Profile* profile, int browser,
};
for (int i = 0; i < arraysize(switch_names); ++i) {
if (cmdline.HasSwitch(switch_names[i])) {
- CommandLine::AppendSwitchWithValue(
- &import_cmd, switch_names[i],
+ import_cmd.AppendSwitchWithValue(
+ switch_names[i],
cmdline.GetSwitchValue(switch_names[i]));
}
}
- CommandLine::AppendSwitchWithValue(&import_cmd, switches::kImport,
+ import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport,
EncodeImportParams(browser, items_to_import, parent_window));
// Time to launch the process that is going to do the import.
diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h
index 4332b8b..676bd49 100644
--- a/chrome/browser/first_run.h
+++ b/chrome/browser/first_run.h
@@ -105,7 +105,7 @@ class Upgrade {
// so we don't fetch as we have no IO thread (see bug #1292702).
class FirstRunBrowserProcess : public BrowserProcessImpl {
public:
- FirstRunBrowserProcess(CommandLine& command_line)
+ FirstRunBrowserProcess(const CommandLine& command_line)
: BrowserProcessImpl(command_line) {
}
virtual ~FirstRunBrowserProcess() { }
diff --git a/chrome/browser/images_uitest.cc b/chrome/browser/images_uitest.cc
index cfe0938..0b5a4be 100644
--- a/chrome/browser/images_uitest.cc
+++ b/chrome/browser/images_uitest.cc
@@ -9,8 +9,10 @@
class ImagesTest : public UITest {
protected:
ImagesTest() : UITest() {
- launch_arguments_ = test_data_directory_;
- file_util::AppendToPath(&launch_arguments_, L"animated-gifs.html");
+ std::wstring path = test_data_directory_;
+ file_util::AppendToPath(&path, L"animated-gifs.html");
+ launch_arguments_ = CommandLine(L"");
+ launch_arguments_.AppendLooseValue(path);
}
};
diff --git a/chrome/browser/locale_tests_uitest.cc b/chrome/browser/locale_tests_uitest.cc
index 5c20f76..d707705 100644
--- a/chrome/browser/locale_tests_uitest.cc
+++ b/chrome/browser/locale_tests_uitest.cc
@@ -7,21 +7,21 @@
class LocaleTestsDa : public UITest {
public:
LocaleTestsDa() : UITest() {
- launch_arguments_.append(L" --lang=da");
+ launch_arguments_.AppendSwitchWithValue(L"lang", L"da");
}
};
class LocaleTestsHe : public UITest {
public:
LocaleTestsHe() : UITest() {
- launch_arguments_.append(L" --lang=he");
+ launch_arguments_.AppendSwitchWithValue(L"lang", L"he");
}
};
class LocaleTestsZhTw : public UITest {
public:
LocaleTestsZhTw() : UITest() {
- launch_arguments_.append(L" --lang=zh-tw");
+ launch_arguments_.AppendSwitchWithValue(L"lang", L"zh-tw");
}
};
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 5ba3f63..d834e57 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -23,7 +23,7 @@
static net::ProxyInfo* CreateProxyInfo() {
net::ProxyInfo* proxy_info = NULL;
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kProxyServer)) {
proxy_info = new net::ProxyInfo();
const std::wstring& proxy_server =
@@ -47,7 +47,7 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginal(
net::HttpCache* cache =
new net::HttpCache(context->proxy_service_, disk_cache_path, 0);
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
bool record_mode = chrome::kRecordModeEnabled &&
command_line.HasSwitch(switches::kRecordMode);
bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode);
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index 50ca1b9..9da52d2 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -461,13 +461,11 @@ bool PluginProcessHost::Init(const FilePath& plugin_path,
if (!PathService::Get(base::FILE_EXE, &exe_path))
return false;
- std::wstring cmd_line(L"\"");
- cmd_line += exe_path;
- cmd_line += L"\"";
+ CommandLine cmd_line(exe_path);
if (logging::DialogsAreSuppressed())
- CommandLine::AppendSwitch(&cmd_line, switches::kNoErrorDialogs);
+ cmd_line.AppendSwitch(switches::kNoErrorDialogs);
- CommandLine browser_command_line;
+ const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
// propagate the following switches to the plugin command line (along with
// any associated values) if present in the browser command line
@@ -492,8 +490,8 @@ bool PluginProcessHost::Init(const FilePath& plugin_path,
for (int i = 0; i < arraysize(switch_names); ++i) {
if (browser_command_line.HasSwitch(switch_names[i])) {
- CommandLine::AppendSwitchWithValue(
- &cmd_line, switch_names[i],
+ cmd_line.AppendSwitchWithValue(
+ switch_names[i],
browser_command_line.GetSwitchValue(switch_names[i]));
}
}
@@ -501,26 +499,26 @@ bool PluginProcessHost::Init(const FilePath& plugin_path,
// If specified, prepend a launcher program to the command line.
std::wstring plugin_launcher =
browser_command_line.GetSwitchValue(switches::kPluginLauncher);
- if (!plugin_launcher.empty())
- cmd_line = plugin_launcher + L" " + cmd_line;
+ if (!plugin_launcher.empty()) {
+ CommandLine new_cmd_line = CommandLine(plugin_launcher);
+ new_cmd_line.AppendArguments(cmd_line, true);
+ cmd_line = new_cmd_line;
+ }
if (!locale.empty()) {
// Pass on the locale so the null plugin will use the right language in the
// prompt to install the desired plugin.
- CommandLine::AppendSwitchWithValue(&cmd_line, switches::kLang, locale);
+ cmd_line.AppendSwitchWithValue(switches::kLang, locale);
}
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kProcessType,
- switches::kPluginProcess);
+ cmd_line.AppendSwitchWithValue(switches::kProcessType,
+ switches::kPluginProcess);
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kProcessChannelID,
- channel_id_);
+ cmd_line.AppendSwitchWithValue(switches::kProcessChannelID,
+ channel_id_);
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kPluginPath,
- plugin_path.ToWStringHack());
+ cmd_line.AppendSwitchWithValue(switches::kPluginPath,
+ plugin_path.ToWStringHack());
bool in_sandbox = !browser_command_line.HasSwitch(switches::kNoSandbox) &&
browser_command_line.HasSwitch(switches::kSafePlugins);
@@ -550,8 +548,10 @@ bool PluginProcessHost::Init(const FilePath& plugin_path,
return false;
}
- result = broker_service->SpawnTarget(exe_path.c_str(),
- cmd_line.c_str(), policy, &target);
+ result =
+ broker_service->SpawnTarget(exe_path.c_str(),
+ cmd_line.command_line_string().c_str(),
+ policy, &target);
policy->Release();
if (sandbox::SBOX_ALL_OK != result)
return false;
diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc
index 086c2b9..038ee5d 100644
--- a/chrome/browser/printing/printing_layout_uitest.cc
+++ b/chrome/browser/printing/printing_layout_uitest.cc
@@ -204,10 +204,7 @@ class PrintingLayoutTest : public PrintingTest<UITest> {
PrintingLayoutTest() {
emf_path_ = browser_directory_;
file_util::AppendToPath(&emf_path_, L"emf_dumps");
- std::wstring arg(L" --debug-print=\"");
- arg += emf_path_;
- arg += L"\"";
- launch_arguments_.append(arg);
+ launch_arguments_.AppendSwitchWithValue(L"debug-print", L'"' + emf_path_ + L'"');
show_window_ = true;
}
@@ -371,7 +368,7 @@ class PrintingLayoutTest : public PrintingTest<UITest> {
}
static bool GenerateFiles() {
- return CommandLine().HasSwitch(kGenerateSwitch);
+ return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch);
}
const std::wstring& emf_path() const { return emf_path_; }
diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc
index bdb34e7..307bae4 100644
--- a/chrome/browser/render_view_context_menu_controller.cc
+++ b/chrome/browser/render_view_context_menu_controller.cc
@@ -475,7 +475,7 @@ void RenderViewContextMenuController::ExecuteCommand(int id) {
}
bool RenderViewContextMenuController::IsDevCommandEnabled(int id) const {
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kAlwaysEnableDevTools))
return true;
diff --git a/chrome/browser/render_view_host_manager.cc b/chrome/browser/render_view_host_manager.cc
index 622df9e..05d07f5 100644
--- a/chrome/browser/render_view_host_manager.cc
+++ b/chrome/browser/render_view_host_manager.cc
@@ -232,7 +232,7 @@ void RenderViewHostManager::OnJavaScriptMessageBoxClosed(
bool RenderViewHostManager::ShouldTransitionCrossSite() {
// True if we are using process-per-site-instance (default) or
// process-per-site (kProcessPerSite).
- return !CommandLine().HasSwitch(switches::kProcessPerTab);
+ return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab);
}
SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
@@ -254,7 +254,7 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
// NOTE: This can be removed once we have a way to transition between
// RenderViews in response to a link click.
//
- if (CommandLine().HasSwitch(switches::kProcessPerSite) &&
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) &&
entry.transition_type() == PageTransition::GENERATED)
return curr_instance;
diff --git a/chrome/browser/render_widget_host_view_win.cc b/chrome/browser/render_widget_host_view_win.cc
index 4fd0f18..0aa756d 100644
--- a/chrome/browser/render_widget_host_view_win.cc
+++ b/chrome/browser/render_widget_host_view_win.cc
@@ -79,7 +79,8 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
activatable_(true) {
render_widget_host_->set_view(this);
renderer_accessible_ =
- CommandLine().HasSwitch(switches::kEnableRendererAccessibility);
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRendererAccessibility);
}
RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 198d886..cb43eb9 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -167,7 +167,7 @@ bool BrowserRenderProcessHost::Init() {
widget_helper_,
profile()->GetSpellChecker());
- CommandLine browser_command_line;
+ const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
// setup IPC channel
std::wstring channel_id = GenerateRandomChannelID(this);
@@ -188,10 +188,9 @@ bool BrowserRenderProcessHost::Init() {
if (renderer_path.empty())
if (!GetRendererPath(&renderer_path))
return false;
- std::wstring cmd_line;
- cmd_line = L"\"" + renderer_path + L"\"";
+ CommandLine cmd_line(renderer_path);
if (logging::DialogsAreSuppressed())
- CommandLine::AppendSwitch(&cmd_line, switches::kNoErrorDialogs);
+ cmd_line.AppendSwitch(switches::kNoErrorDialogs);
// propagate the following switches to the renderer command line
// (along with any associated values) if present in the browser command line
@@ -229,15 +228,14 @@ bool BrowserRenderProcessHost::Init() {
for (int i = 0; i < arraysize(switch_names); ++i) {
if (browser_command_line.HasSwitch(switch_names[i])) {
- CommandLine::AppendSwitchWithValue(
- &cmd_line, switch_names[i],
+ cmd_line.AppendSwitchWithValue(switch_names[i],
browser_command_line.GetSwitchValue(switch_names[i]));
}
}
// Pass on the browser locale.
const std::wstring locale = g_browser_process->GetApplicationLocale();
- CommandLine::AppendSwitchWithValue(&cmd_line, switches::kLang, locale);
+ cmd_line.AppendSwitchWithValue(switches::kLang, locale);
bool in_sandbox = !browser_command_line.HasSwitch(switches::kNoSandbox);
if (browser_command_line.HasSwitch(switches::kInProcessPlugins)) {
@@ -249,19 +247,17 @@ bool BrowserRenderProcessHost::Init() {
DebugFlags::ProcessDebugFlags(&cmd_line,
DebugFlags::RENDERER,
in_sandbox);
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kProcessType,
- switches::kRendererProcess);
+ cmd_line.AppendSwitchWithValue(switches::kProcessType,
+ switches::kRendererProcess);
- CommandLine::AppendSwitchWithValue(&cmd_line,
- switches::kProcessChannelID,
- channel_id);
+ cmd_line.AppendSwitchWithValue(switches::kProcessChannelID,
+ channel_id);
const std::wstring& profile_path =
browser_command_line.GetSwitchValue(switches::kUserDataDir);
if (!profile_path.empty())
- CommandLine::AppendSwitchWithValue(&cmd_line, switches::kUserDataDir,
- profile_path);
+ cmd_line.AppendSwitchWithValue(switches::kUserDataDir,
+ profile_path);
bool run_in_process = run_renderer_in_process();
if (run_in_process) {
@@ -286,7 +282,8 @@ bool BrowserRenderProcessHost::Init() {
g_browser_process->local_state()->GetBoolean(
prefs::kStartRenderersManually)) {
std::wstring message =
- L"Please start a renderer process using:\n" + cmd_line;
+ L"Please start a renderer process using:\n" +
+ cmd_line.command_line_string();
// We don't know the owner window for BrowserRenderProcessHost and therefore we
// pass a NULL HWND argument.
@@ -328,8 +325,7 @@ bool BrowserRenderProcessHost::Init() {
return false;
}
- CommandLine command_line;
- if (command_line.HasSwitch(switches::kGearsInRenderer)) {
+ if (browser_command_line.HasSwitch(switches::kGearsInRenderer)) {
if (!AddPolicyForGearsInRenderer(policy)) {
NOTREACHED();
return false;
@@ -341,9 +337,10 @@ bool BrowserRenderProcessHost::Init() {
return false;
}
- result = broker_service->SpawnTarget(renderer_path.c_str(),
- cmd_line.c_str(),
- policy, &target);
+ result =
+ broker_service->SpawnTarget(renderer_path.c_str(),
+ cmd_line.command_line_string().c_str(),
+ policy, &target);
policy->Release();
if (desktop)
@@ -465,8 +462,8 @@ void BrowserRenderProcessHost::InitVisitedLinks() {
}
void BrowserRenderProcessHost::InitUserScripts() {
- CommandLine command_line;
- if (!command_line.HasSwitch(switches::kEnableUserScripts)) {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableUserScripts)) {
return;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index fc3254d..174c867 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -20,8 +20,10 @@ static const wchar_t kBloomFilterFile[] = L" Filter";
// Factory method.
SafeBrowsingDatabase* SafeBrowsingDatabase::Create() {
- if (CommandLine().HasSwitch(switches::kUseOldSafeBrowsing))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseOldSafeBrowsing)) {
return new SafeBrowsingDatabaseImpl;
+ }
return new SafeBrowsingDatabaseBloom;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
index 9e3f5e7..62910c5 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
@@ -909,7 +909,8 @@ TEST(SafeBrowsingDatabase, HashCaching) {
// Test receiving a full add chunk. The old implementation doesn't support
// this test, so we bail here.
- if (CommandLine().HasSwitch(switches::kUseOldSafeBrowsing)) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseOldSafeBrowsing)) {
TearDownTestDatabase(database);
return;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 60da2b5..14f31bc 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -36,7 +36,8 @@ SafeBrowsingService::SafeBrowsingService()
resetting_(false),
database_loaded_(false),
update_in_progress_(false) {
- new_safe_browsing_ = !CommandLine().HasSwitch(switches::kUseOldSafeBrowsing);
+ new_safe_browsing_ = !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseOldSafeBrowsing);
base::SystemMonitor* monitor = base::SystemMonitor::Get();
DCHECK(monitor);
if (monitor)
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index 826787b..a8d242b 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -2680,9 +2680,8 @@ LONG GetCurrentGeoID() {
int GetGeoIDFromPrefs(PrefService* prefs) {
// See if the user overrode the GeoID on the command line.
- CommandLine parsed_command_line;
const std::wstring geoID(
- parsed_command_line.GetSwitchValue(switches::kGeoID));
+ CommandLine::ForCurrentProcess()->GetSwitchValue(switches::kGeoID));
if (!geoID.empty())
return _wtoi(geoID.c_str());
diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc
index 85bb5fd..ae8803e 100644
--- a/chrome/browser/sessions/session_restore_uitest.cc
+++ b/chrome/browser/sessions/session_restore_uitest.cc
@@ -38,8 +38,7 @@ class SessionRestoreUITest : public UITest {
clear_profile_ = false;
- CommandLine::AppendSwitch(&launch_arguments_,
- switches::kRestoreLastSession);
+ launch_arguments_.AppendSwitch(switches::kRestoreLastSession);
UITest::SetUp();
}
@@ -283,7 +282,7 @@ TEST_F(SessionRestoreUITest, DISABLED_DontRestoreWhileIncognito) {
include_testing_id_ = false;
use_existing_browser_ = true;
clear_profile_ = false;
- CommandLine::AppendSwitch(&launch_arguments_, switches::kRestoreLastSession);
+ launch_arguments_.AppendSwitch(switches::kRestoreLastSession);
LaunchBrowser(launch_arguments_, false);
// A new window should appear;
@@ -345,9 +344,9 @@ TEST_F(SessionRestoreUITest,
include_testing_id_ = false;
use_existing_browser_ = true;
clear_profile_ = false;
- std::wstring app_launch_arguments = launch_arguments_;
- CommandLine::AppendSwitchWithValue(
- &app_launch_arguments, switches::kApp, UTF8ToWide(url2.spec()));
+ CommandLine app_launch_arguments = launch_arguments_;
+ app_launch_arguments.AppendSwitchWithValue(switches::kApp,
+ UTF8ToWide(url2.spec()));
LaunchBrowser(app_launch_arguments, false);
int window_count;
ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count,
@@ -358,9 +357,8 @@ TEST_F(SessionRestoreUITest,
CloseWindow(0, 2);
// Restore it, which should bring back the first window with url1.
- std::wstring restore_launch_arguments = launch_arguments_;
- CommandLine::AppendSwitch(&restore_launch_arguments,
- switches::kRestoreLastSession);
+ CommandLine restore_launch_arguments = launch_arguments_;
+ restore_launch_arguments.AppendSwitch(switches::kRestoreLastSession);
LaunchBrowser(restore_launch_arguments, false);
ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count,
action_timeout_ms()));
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index c73fc2e..9062894 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -1218,7 +1218,7 @@ WebPreferences WebContents::GetWebkitPrefs() {
prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
{ // Command line switches are used for preferences with no user interface.
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
web_prefs.developer_extras_enabled =
!command_line.HasSwitch(switches::kDisableDevTools) &&
prefs->GetBoolean(prefs::kWebKitDeveloperExtrasEnabled);
diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc
index 471a3e8..3089e82 100644
--- a/chrome/browser/unload_uitest.cc
+++ b/chrome/browser/unload_uitest.cc
@@ -153,7 +153,7 @@ class UnloadTest : public UITest {
// we don't get confused and think we're closing the tab.
TEST_F(UnloadTest, CrossSiteInfiniteUnloadAsync) {
// Tests makes no sense in single-process mode since the renderer is hung.
- if (CommandLine().HasSwitch(switches::kSingleProcess))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
return;
NavigateToDataURL(INFINITE_UNLOAD_HTML, L"infiniteunload");
@@ -167,7 +167,7 @@ TEST_F(UnloadTest, CrossSiteInfiniteUnloadAsync) {
// we correctly nav to each one.
TEST_F(UnloadTest, CrossSiteInfiniteUnloadSync) {
// Tests makes no sense in single-process mode since the renderer is hung.
- if (CommandLine().HasSwitch(switches::kSingleProcess))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
return;
NavigateToDataURL(INFINITE_UNLOAD_HTML, L"infiniteunload");
@@ -181,7 +181,7 @@ TEST_F(UnloadTest, CrossSiteInfiniteUnloadSync) {
// we don't get confused and think we're closing the tab.
TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadAsync) {
// Tests makes no sense in single-process mode since the renderer is hung.
- if (CommandLine().HasSwitch(switches::kSingleProcess))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
return;
NavigateToDataURL(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload");
@@ -195,7 +195,7 @@ TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadAsync) {
// we correctly nav to each one.
TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadSync) {
// Tests makes no sense in single-process mode since the renderer is hung.
- if (CommandLine().HasSwitch(switches::kSingleProcess))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
return;
NavigateToDataURL(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload");
diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc
index 3353016..554c53f 100644
--- a/chrome/browser/user_data_manager.cc
+++ b/chrome/browser/user_data_manager.cc
@@ -177,15 +177,14 @@ std::wstring UserDataManager::GetCommandForProfile(
std::wstring user_data_dir = GetUserDataFolderForProfile(profile_name);
std::wstring command;
PathService::Get(base::FILE_EXE, &command);
- CommandLine::AppendSwitchWithValue(&command,
- switches::kUserDataDir,
+ CommandLine command_line(command);
+ command_line.AppendSwitchWithValue(switches::kUserDataDir,
user_data_dir);
std::wstring local_state_path;
PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
- CommandLine::AppendSwitchWithValue(&command,
- switches::kParentProfile,
+ command_line.AppendSwitchWithValue(switches::kParentProfile,
local_state_path);
- return command;
+ return command_line.command_line_string();
}
void UserDataManager::LaunchChromeForProfile(
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 7bf7156e..6dae951 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -327,8 +327,10 @@ void BrowserView::Init() {
// Start a hung plugin window detector for this browser object (as long as
// hang detection is not disabled).
- if (!CommandLine().HasSwitch(switches::kDisableHangMonitor))
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableHangMonitor)) {
InitHangMonitor();
+ }
LoadAccelerators();
SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
diff --git a/chrome/common/child_process.cc b/chrome/common/child_process.cc
index 112fceb..b64984c 100644
--- a/chrome/common/child_process.cc
+++ b/chrome/common/child_process.cc
@@ -77,7 +77,7 @@ bool ChildProcess::GlobalInit(const std::wstring &channel_name,
child_process_ = factory->Create(channel_name);
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kUserAgent)) {
#if defined(OS_WIN)
// TODO(port): calling this connects an, otherwise disconnected, subgraph
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 297b963..e842cbc 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -49,8 +49,8 @@ bool GetDefaultUserDataDirectory(std::wstring* result) {
bool GetGearsPluginPathFromCommandLine(std::wstring *path) {
#ifndef NDEBUG
// for debugging, support a cmd line based override
- CommandLine command_line;
- *path = command_line.GetSwitchValue(switches::kGearsPluginPathOverride);
+ *path = CommandLine::ForCurrentProcess()->GetSwitchValue(
+ switches::kGearsPluginPathOverride);
return !path->empty();
#else
return false;
diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc
index 4af7a558..1587a2d 100644
--- a/chrome/common/chrome_plugin_lib.cc
+++ b/chrome/common/chrome_plugin_lib.cc
@@ -44,8 +44,7 @@ CPError STDCALL Gears_CP_Initialize(CPID id, const CPBrowserFuncs *bfuncs,
static bool IsSingleProcessMode() {
// We don't support ChromePlugins in single-process mode.
- CommandLine command_line;
- return command_line.HasSwitch(switches::kSingleProcess);
+ return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
}
// static
diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc
index 56b1f54..610c0b9 100644
--- a/chrome/common/chrome_plugin_util.cc
+++ b/chrome/common/chrome_plugin_util.cc
@@ -121,7 +121,7 @@ int PluginResponseUtils::GetResponseInfo(
CPError CPB_GetCommandLineArgumentsCommon(const char* url,
std::string* arguments) {
- CommandLine cmd;
+ const CommandLine cmd = *CommandLine::ForCurrentProcess();
std::wstring arguments_w;
// Use the same UserDataDir for new launches that we currently have set.
@@ -131,8 +131,8 @@ CPError CPB_GetCommandLineArgumentsCommon(const char* url,
wchar_t user_data_dir_full[MAX_PATH];
if (_wfullpath(user_data_dir_full, user_data_dir.c_str(), MAX_PATH) &&
file_util::PathExists(user_data_dir_full)) {
- CommandLine::AppendSwitchWithValue(
- &arguments_w, switches::kUserDataDir, user_data_dir_full);
+ arguments_w += std::wstring(L"--") + switches::kUserDataDir +
+ L'=' + user_data_dir_full;
}
}
@@ -140,7 +140,7 @@ CPError CPB_GetCommandLineArgumentsCommon(const char* url,
// chrome.
// Note: Do not change this flag! Old Gears shortcuts will break if you do!
std::wstring url_w = UTF8ToWide(url);
- CommandLine::AppendSwitchWithValue(&arguments_w, switches::kApp, url_w);
+ arguments_w += std::wstring(L"--") + switches::kApp + L'=' + url_w;
*arguments = WideToUTF8(arguments_w);
diff --git a/chrome/common/common_glue.cc b/chrome/common/common_glue.cc
index 6c33f1e..7d32310 100644
--- a/chrome/common/common_glue.cc
+++ b/chrome/common/common_glue.cc
@@ -29,7 +29,7 @@ std::wstring GetWebKitLocale() {
// The browser process should have passed the locale to the renderer via the
// --lang command line flag. In single process mode, this will return the
// wrong value. TODO(tc): Fix this for single process mode.
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
const std::wstring& lang =
parsed_command_line.GetSwitchValue(switches::kLang);
DCHECK(!lang.empty() ||
diff --git a/chrome/common/debug_flags.cc b/chrome/common/debug_flags.cc
index 1e10b78..9f62cbe 100644
--- a/chrome/common/debug_flags.cc
+++ b/chrome/common/debug_flags.cc
@@ -8,11 +8,11 @@
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
-bool DebugFlags::ProcessDebugFlags(std::wstring* command_line,
+bool DebugFlags::ProcessDebugFlags(CommandLine* command_line,
ChildProcessType type,
bool is_in_sandbox) {
bool should_help_child = false;
- CommandLine current_cmd_line;
+ const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess();
if (current_cmd_line.HasSwitch(switches::kDebugChildren)) {
// Look to pass-on the kDebugOnStart flag.
std::wstring value;
@@ -20,12 +20,10 @@ bool DebugFlags::ProcessDebugFlags(std::wstring* command_line,
if (value.empty() ||
(type == RENDERER && value == switches::kRendererProcess) ||
(type == PLUGIN && value == switches::kPluginProcess)) {
- CommandLine::AppendSwitch(command_line, switches::kDebugOnStart);
+ command_line->AppendSwitch(switches::kDebugOnStart);
should_help_child = true;
}
- CommandLine::AppendSwitchWithValue(command_line,
- switches::kDebugChildren,
- value);
+ command_line->AppendSwitchWithValue(switches::kDebugChildren, value);
} else if (current_cmd_line.HasSwitch(switches::kWaitForDebuggerChildren)) {
// Look to pass-on the kWaitForDebugger flag.
std::wstring value;
@@ -33,11 +31,10 @@ bool DebugFlags::ProcessDebugFlags(std::wstring* command_line,
if (value.empty() ||
(type == RENDERER && value == switches::kRendererProcess) ||
(type == PLUGIN && value == switches::kPluginProcess)) {
- CommandLine::AppendSwitch(command_line, switches::kWaitForDebugger);
+ command_line->AppendSwitch(switches::kWaitForDebugger);
}
- CommandLine::AppendSwitchWithValue(command_line,
- switches::kWaitForDebuggerChildren,
- value);
+ command_line->AppendSwitchWithValue(switches::kWaitForDebuggerChildren,
+ value);
}
return should_help_child;
}
diff --git a/chrome/common/debug_flags.h b/chrome/common/debug_flags.h
index 9d4ebba..c2115a9 100644
--- a/chrome/common/debug_flags.h
+++ b/chrome/common/debug_flags.h
@@ -5,7 +5,7 @@
#ifndef CHROME_COMMON_DEBUG_FLAGS_H__
#define CHROME_COMMON_DEBUG_FLAGS_H__
-#include <string>
+class CommandLine;
class DebugFlags {
public:
@@ -15,13 +15,15 @@ class DebugFlags {
UNKNOWN
};
- // Updates the command line arguments with debug-related flags. If debug flags
- // have been used with this process, they will be filtered and added to
- // command_line as needed. is_in_sandbox must be true if the child process will
- // be in a sandbox.
- // Returns true if the caller should "help" the child process by calling the JIT
- // debugger on it. It may only happen if is_in_sandbox is true.
- static bool ProcessDebugFlags(std::wstring* command_line,
+ // Updates the command line arguments with debug-related flags. If
+ // debug flags have been used with this process, they will be
+ // filtered and added to command_line as needed. is_in_sandbox must
+ // be true if the child process will be in a sandbox.
+ //
+ // Returns true if the caller should "help" the child process by
+ // calling the JIT debugger on it. It may only happen if
+ // is_in_sandbox is true.
+ static bool ProcessDebugFlags(CommandLine* command_line,
ChildProcessType type,
bool is_in_sandbox);
};
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc
index 57d30bf..6c6f17c 100644
--- a/chrome/common/ipc_channel_posix.cc
+++ b/chrome/common/ipc_channel_posix.cc
@@ -244,7 +244,8 @@ Channel::ChannelImpl::ChannelImpl(const std::wstring& channel_id, Mode mode,
: mode_(mode),
is_blocked_on_write_(false),
message_send_bytes_written_(0),
- uses_fifo_(CommandLine().HasSwitch(switches::kTestingChannelID)),
+ uses_fifo_(CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kTestingChannelID)),
server_listen_pipe_(-1),
pipe_(-1),
client_pipe_(-1),
diff --git a/chrome/common/ipc_logging.cc b/chrome/common/ipc_logging.cc
index db8bf84..ec2fe82 100644
--- a/chrome/common/ipc_logging.cc
+++ b/chrome/common/ipc_logging.cc
@@ -45,7 +45,7 @@ Logging::Logging()
// enabled, so child processes can know when logging is enabled.
int browser_pid;
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
std::wstring process_type =
parsed_command_line.GetSwitchValue(switches::kProcessType);
if (process_type.empty()) {
diff --git a/chrome/common/ipc_tests.cc b/chrome/common/ipc_tests.cc
index be3b0d9..b0add18 100644
--- a/chrome/common/ipc_tests.cc
+++ b/chrome/common/ipc_tests.cc
@@ -52,7 +52,8 @@ void IPCChannelTest::TearDown() {
base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
IPC::Channel *channel) {
// kDebugChildren support.
- bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren);
+ bool debug_on_start =
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
switch (child_type) {
case TEST_CLIENT:
@@ -73,7 +74,8 @@ base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
IPC::Channel *channel) {
// kDebugChildren support.
- bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren);
+ bool debug_on_start =
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
base::file_handle_mapping_vector fds_to_map;
int src_fd;
@@ -225,9 +227,10 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
channel_listener.Init(&chan);
#if defined(OS_WIN)
- base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL);
+ base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL);
#elif defined(OS_POSIX)
- bool debug_on_start = CommandLine().HasSwitch(switches::kDebugChildren);
+ bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDebugChildren);
base::file_handle_mapping_vector fds_to_map;
int src_fd;
int dest_fd;
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc
index d9fb299..86a36eb 100644
--- a/chrome/common/l10n_util.cc
+++ b/chrome/common/l10n_util.cc
@@ -261,7 +261,7 @@ std::wstring GetApplicationLocale(const std::wstring& pref_locale) {
std::wstring resolved_locale;
// First, check to see if there's a --lang flag.
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
const std::wstring& lang_arg =
parsed_command_line.GetSwitchValue(switches::kLang);
if (!lang_arg.empty()) {
diff --git a/chrome/common/logging_chrome_uitest.cc b/chrome/common/logging_chrome_uitest.cc
index f1a121c..b88deb6 100644
--- a/chrome/common/logging_chrome_uitest.cc
+++ b/chrome/common/logging_chrome_uitest.cc
@@ -72,8 +72,7 @@ class AssertionTest : public UITest {
// We're testing the renderer rather than the browser assertion here,
// because the browser assertion would flunk the test during SetUp()
// (since TAU wouldn't be able to find the browser window).
- CommandLine::AppendSwitch(&launch_arguments_,
- switches::kRendererAssertTest);
+ launch_arguments_.AppendSwitch(switches::kRendererAssertTest);
}
};
@@ -98,8 +97,7 @@ class RendererCrashTest : public UITest {
// Initial loads will never complete due to crash.
wait_for_initial_loads_ = false;
- CommandLine::AppendSwitch(&launch_arguments_,
- switches::kRendererCrashTest);
+ launch_arguments_.AppendSwitch(switches::kRendererCrashTest);
}
};
@@ -123,8 +121,7 @@ class BrowserCrashTest : public UITest {
// Initial loads will never complete due to crash.
wait_for_initial_loads_ = false;
- CommandLine::AppendSwitch(&launch_arguments_,
- switches::kBrowserCrashTest);
+ launch_arguments_.AppendSwitch(switches::kBrowserCrashTest);
}
};
diff --git a/chrome/common/main_function_params.h b/chrome/common/main_function_params.h
index b8156ae..e3a1c55 100644
--- a/chrome/common/main_function_params.h
+++ b/chrome/common/main_function_params.h
@@ -12,12 +12,10 @@
#include "base/command_line.h"
#include "chrome/common/sandbox_init_wrapper.h"
-// TODO(pinkerton): |cl| should be const, but can't be due to bug 6144.
-
struct MainFunctionParams {
- MainFunctionParams(CommandLine& cl, const SandboxInitWrapper& sb)
+ MainFunctionParams(const CommandLine& cl, const SandboxInitWrapper& sb)
: command_line_(cl), sandbox_info_(sb) { }
- CommandLine& command_line_;
+ const CommandLine& command_line_;
const SandboxInitWrapper& sandbox_info_;
};
diff --git a/chrome/common/pref_service_uitest.cc b/chrome/common/pref_service_uitest.cc
index 0ecd114..4ffd4e7 100644
--- a/chrome/common/pref_service_uitest.cc
+++ b/chrome/common/pref_service_uitest.cc
@@ -43,9 +43,8 @@ public:
ASSERT_TRUE(::SetFileAttributesW(tmp_pref_file_.c_str(),
FILE_ATTRIBUTE_NORMAL));
- CommandLine::AppendSwitchWithValue(&launch_arguments_,
- switches::kUserDataDir,
- tmp_profile_);
+ launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir,
+ tmp_profile_);
}
bool LaunchAppWithProfile() {
diff --git a/chrome/common/temp_scaffolding_stubs.cpp b/chrome/common/temp_scaffolding_stubs.cpp
index 756c8c2..af74d6d 100644
--- a/chrome/common/temp_scaffolding_stubs.cpp
+++ b/chrome/common/temp_scaffolding_stubs.cpp
@@ -14,7 +14,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_service.h"
-BrowserProcessImpl::BrowserProcessImpl(CommandLine& command_line)
+BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
: created_local_state_(), created_metrics_service_(),
created_profile_manager_() {
g_browser_process = this;
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index f7f2bbb..603e7ca 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -83,7 +83,7 @@ class GoogleUpdateSettings {
class BrowserProcessImpl : public BrowserProcess {
public:
- BrowserProcessImpl(CommandLine& command_line);
+ BrowserProcessImpl(const CommandLine& command_line);
virtual ~BrowserProcessImpl();
virtual void EndSession() { }
@@ -126,7 +126,7 @@ class BrowserProcessImpl : public BrowserProcess {
class FirstRunBrowserProcess : public BrowserProcessImpl {
public:
- FirstRunBrowserProcess(CommandLine& command_line)
+ FirstRunBrowserProcess(const CommandLine& command_line)
: BrowserProcessImpl(command_line) {
}
virtual ~FirstRunBrowserProcess() { }
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index e888f0b..8f57e06 100755
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -457,7 +457,8 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
wchar_t* command_line, int show_command) {
// The exit manager is in charge of calling the dtors of singletons.
base::AtExitManager exit_manager;
- CommandLine parsed_command_line;
+ CommandLine::Init(0, NULL);
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
installer::InitInstallerLogging(parsed_command_line);
int options = GetInstallOptions(parsed_command_line);
if (options & installer_util::VERBOSE_LOGGING)
diff --git a/chrome/installer/setup/setup.cc b/chrome/installer/setup/setup.cc
index 27475242..0fe3afb 100755
--- a/chrome/installer/setup/setup.cc
+++ b/chrome/installer/setup/setup.cc
@@ -51,7 +51,6 @@ void DoFirstInstallTasks(std::wstring install_path, int options) {
// will work only if current user has admin rights.
std::wstring chrome_exe(install_path);
file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe);
- CommandLine cmd_line;
LOG(INFO) << "Registering Chrome as browser";
ShellUtil::RegisterStatus ret = ShellUtil::FAILURE;
if (options & installer_util::MAKE_CHROME_DEFAULT) {
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc
index ac9fd90..e2416f0 100644
--- a/chrome/plugin/plugin_main.cc
+++ b/chrome/plugin/plugin_main.cc
@@ -16,7 +16,7 @@
// mainline routine for running as the plugin process
int PluginMain(const MainFunctionParams& parameters) {
- CommandLine& parsed_command_line = parameters.command_line_;
+ const CommandLine& parsed_command_line = parameters.command_line_;
sandbox::TargetServices* target_services =
parameters.sandbox_info_.TargetServices();
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc
index 28c0e63..31444b6 100644
--- a/chrome/plugin/webplugin_delegate_stub.cc
+++ b/chrome/plugin/webplugin_delegate_stub.cc
@@ -123,7 +123,7 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
argv[i] = const_cast<char*>(params.arg_values[i].c_str());
}
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
FilePath path =
FilePath(command_line.GetSwitchValue(switches::kPluginPath));
delegate_ = WebPluginDelegateImpl::Create(
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc
index b2b4606..2fe1af7 100644
--- a/chrome/renderer/render_process.cc
+++ b/chrome/renderer/render_process.cc
@@ -63,7 +63,7 @@ bool RenderProcess::GlobalInit(const std::wstring &channel_name) {
}
}
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
webkit_glue::SetJavaScriptFlags(
command_line.GetSwitchValue(switches::kJavaScriptFlags));
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 9927171..8f08add 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -289,7 +289,7 @@ void RenderView::Init(HWND parent_hwnd,
host_window_ = parent_hwnd;
modal_dialog_event_.reset(modal_dialog_event);
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
enable_dom_automation_ =
command_line.HasSwitch(switches::kDomAutomationController);
disable_popup_blocking_ =
@@ -1834,8 +1834,8 @@ static bool ShouldLoadPluginInProcess(const std::string& mime_type,
if (mime_type == "application/x-googlegears") {
*is_gears = true;
- CommandLine cmd;
- return cmd.HasSwitch(switches::kGearsInRenderer);
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kGearsInRenderer);
}
return false;
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 7516ace..3bc7c63 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -136,7 +136,7 @@ ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
namespace webkit_glue {
bool IsMediaPlayerAvailable() {
- return CommandLine().HasSwitch(switches::kEnableVideo);
+ return CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableVideo);
}
void PrefetchDns(const std::string& hostname) {
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index 476e4f7..b3d9fec 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -46,7 +46,7 @@ static void HandleRendererErrorTestParameters(const CommandLine& command_line) {
// mainline routine for running as the Rendererer process
int RendererMain(const MainFunctionParams& parameters) {
- CommandLine& parsed_command_line = parameters.command_line_;
+ const CommandLine& parsed_command_line = parameters.command_line_;
sandbox::TargetServices* target_services =
parameters.sandbox_info_.TargetServices();
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index dcbac5b..81d0f0b 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -79,7 +79,7 @@ AutomatedUITest::AutomatedUITest()
post_action_delay_(0) {
show_window_ = true;
GetSystemTimeAsFileTime(&test_start_time_);
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kDebugModeSwitch))
debug_logging_enabled_ = true;
if (parsed_command_line.HasSwitch(kWaitSwitch)) {
@@ -95,7 +95,7 @@ AutomatedUITest::AutomatedUITest()
AutomatedUITest::~AutomatedUITest() {}
void AutomatedUITest::RunReproduction() {
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
xml_writer_.StartWriting();
xml_writer_.StartElement("Report");
std::string action_string =
@@ -863,7 +863,7 @@ bool AutomatedUITest::SimulateKeyPressInActiveWindow(wchar_t key, int flags) {
bool AutomatedUITest::InitXMLReader() {
std::wstring input_path;
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kInputFilePathSwitch))
input_path = parsed_command_line.GetSwitchValue(kInputFilePathSwitch);
else
@@ -877,7 +877,7 @@ bool AutomatedUITest::InitXMLReader() {
bool AutomatedUITest::WriteReportToFile() {
std::ofstream error_file;
std::wstring path;
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kOutputFilePathSwitch))
path = parsed_command_line.GetSwitchValue(kOutputFilePathSwitch);
else
@@ -897,7 +897,7 @@ bool AutomatedUITest::WriteReportToFile() {
void AutomatedUITest::AppendToOutputFile(const std::string &append_string) {
std::ofstream error_file;
std::wstring path;
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kOutputFilePathSwitch))
path = parsed_command_line.GetSwitchValue(kOutputFilePathSwitch);
else
@@ -1001,7 +1001,7 @@ bool AutomatedUITest::DidCrash(bool update_total_crashes) {
}
TEST_F(AutomatedUITest, TheOneAndOnlyTest) {
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kReproSwitch))
RunReproduction();
else
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index 33c6a30..add33f4 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -25,9 +25,8 @@ class AutomationProxyTest : public UITest {
protected:
AutomationProxyTest() {
dom_automation_enabled_ = true;
- CommandLine::AppendSwitchWithValue(&launch_arguments_,
- switches::kLang,
- L"en-us");
+ launch_arguments_.AppendSwitchWithValue(switches::kLang,
+ L"en-us");
}
};
@@ -371,7 +370,9 @@ class AutomationProxyTest2 : public AutomationProxyVisibleTest {
document2_ = test_data_directory_;
file_util::AppendToPath(&document2_, L"title2.html");
- launch_arguments_ = document1_ + L" " + document2_;
+ launch_arguments_ = CommandLine(L"");
+ launch_arguments_.AppendLooseValue(document1_);
+ launch_arguments_.AppendLooseValue(document2_);
}
std::wstring document1_;
@@ -576,7 +577,8 @@ class AutomationProxyTest3 : public UITest {
file_util::AppendToPath(&document1_, L"frame_dom_access.html");
dom_automation_enabled_ = true;
- launch_arguments_ = document1_;
+ launch_arguments_ = CommandLine(L"");
+ launch_arguments_.AppendLooseValue(document1_);
}
std::wstring document1_;
diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc
index 23cb072..2ef79d1 100644
--- a/chrome/test/memory_test/memory_test.cc
+++ b/chrome/test/memory_test/memory_test.cc
@@ -32,17 +32,17 @@ class MemoryTest : public UITest {
// For now, turn off plugins because they crash like crazy.
// TODO(mbelshe): Fix Chrome to not crash with plugins.
- CommandLine::AppendSwitch(&launch_arguments_, switches::kDisablePlugins);
+ launch_arguments_.AppendSwitch(switches::kDisablePlugins);
- CommandLine::AppendSwitch(&launch_arguments_, switches::kEnableLogging);
+ launch_arguments_.AppendSwitch(switches::kEnableLogging);
// Use the playback cache, but don't use playback events.
- CommandLine::AppendSwitch(&launch_arguments_, switches::kPlaybackMode);
- CommandLine::AppendSwitch(&launch_arguments_, switches::kNoEvents);
+ launch_arguments_.AppendSwitch(switches::kPlaybackMode);
+ launch_arguments_.AppendSwitch(switches::kNoEvents);
// Get the specified user data dir (optional)
std::wstring profile_dir =
- CommandLine().GetSwitchValue(switches::kUserDataDir);
+ CommandLine::ForCurrentProcess()->GetSwitchValue(switches::kUserDataDir);
if (profile_dir.length() == 0) {
// Compute the user-data-dir which contains our test cache.
@@ -63,9 +63,8 @@ class MemoryTest : public UITest {
}
}
- CommandLine::AppendSwitchWithValue(&launch_arguments_,
- switches::kUserDataDir,
- user_data_dir_);
+ launch_arguments_.AppendSwitchWithValue(switches::kUserDataDir,
+ user_data_dir_);
}
~MemoryTest() {
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index e42cf14..8f5fead 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -38,9 +38,8 @@ class PageCyclerTest : public UITest {
show_window_ = true;
// Expose garbage collection for the page cycler tests.
- CommandLine::AppendSwitchWithValue(&launch_arguments_,
- switches::kJavaScriptFlags,
- L"--expose_gc");
+ launch_arguments_.AppendSwitchWithValue(switches::kJavaScriptFlags,
+ L"--expose_gc");
}
// For HTTP tests, the name must be safe for use in a URL without escaping.
diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp
index d458662..0faaf8e 100644
--- a/chrome/test/plugin/plugin_test.cpp
+++ b/chrome/test/plugin/plugin_test.cpp
@@ -76,27 +76,16 @@ class PluginTest : public UITest {
KEY_WRITE)) {
regkey.CreateKey(L"CHROME.EXE", KEY_READ);
}
- if (!launch_arguments_.empty())
- launch_arguments_.append(L" ");
- launch_arguments_.append(L"--" kNoNativeActiveXShimSwitch);
+ launch_arguments_.AppendSwitch(kNoNativeActiveXShimSwitch);
} else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) {
// When testing the old WMP plugin, we need to force Chrome to not load
// the new plugin.
- if (!launch_arguments_.empty())
- launch_arguments_.append(L" ");
-
- launch_arguments_.append(L"--" kUseOldWMPPluginSwitch);
- launch_arguments_.append(L" ");
- launch_arguments_.append(L"--" kNoNativeActiveXShimSwitch);
+ launch_arguments_.AppendSwitch(kUseOldWMPPluginSwitch);
+ launch_arguments_.AppendSwitch(kNoNativeActiveXShimSwitch);
} else if (strcmp(test_info->name(), "FlashSecurity") == 0) {
- if (!launch_arguments_.empty())
- launch_arguments_.append(L" ");
-
- launch_arguments_.append(L"--");
- launch_arguments_.append(switches::kTestSandbox);
- launch_arguments_.append(L"=");
- launch_arguments_.append(L"security_tests.dll");
+ launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox,
+ L"security_tests.dll");
}
UITest::SetUp();
diff --git a/chrome/test/reliability/reliability_test_suite.h b/chrome/test/reliability/reliability_test_suite.h
index 6170d63..809ca52 100644
--- a/chrome/test/reliability/reliability_test_suite.h
+++ b/chrome/test/reliability/reliability_test_suite.h
@@ -18,7 +18,7 @@ protected:
virtual void Initialize() {
UITestSuite::Initialize();
- SetPageRange(CommandLine());
+ SetPageRange(CommandLine(L""));
}
};
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index 34f91b9..70b54de 100644
--- a/chrome/test/startup/startup_test.cc
+++ b/chrome/test/startup/startup_test.cc
@@ -110,7 +110,7 @@ class StartupFileTest : public StartupTest {
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &file_url));
file_util::AppendToPath(&file_url, L"empty.html");
ASSERT_TRUE(file_util::PathExists(file_url));
- launch_arguments_ += file_url;
+ launch_arguments_.AppendLooseValue(file_url);
pages_ = WideToUTF8(file_url);
}
diff --git a/chrome/test/ui/inspector_controller_uitest.cc b/chrome/test/ui/inspector_controller_uitest.cc
index 29b1489..289cca0 100644
--- a/chrome/test/ui/inspector_controller_uitest.cc
+++ b/chrome/test/ui/inspector_controller_uitest.cc
@@ -34,7 +34,7 @@ TEST_F(InspectorControllerTest, DISABLED_InspectElement) {
if (IsTestCaseDisabled())
return;
- if (CommandLine().HasSwitch(switches::kSingleProcess))
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
return;
scoped_refptr<HTTPTestServer> server =
diff --git a/chrome/test/ui/omnibox_uitest.cc b/chrome/test/ui/omnibox_uitest.cc
index 83e14fd..7b317af 100644
--- a/chrome/test/ui/omnibox_uitest.cc
+++ b/chrome/test/ui/omnibox_uitest.cc
@@ -133,7 +133,8 @@ void OmniboxTest::RunQueryChain(const std::wstring& input_text) {
// </omnibox_tests>
TEST_F(OmniboxTest, Measure) {
- if (!CommandLine().HasSwitch(kRunOmniboxTest)) return;
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunOmniboxTest))
+ return;
std::wstring omnibox_tests_path;
PathService::Get(chrome::DIR_TEST_DATA, &omnibox_tests_path);
diff --git a/chrome/test/ui/sandbox_uitests.cc b/chrome/test/ui/sandbox_uitests.cc
index cbfaa65..d898cf5 100644
--- a/chrome/test/ui/sandbox_uitests.cc
+++ b/chrome/test/ui/sandbox_uitests.cc
@@ -14,9 +14,8 @@ class SandboxTest : public UITest {
protected:
// Launches chrome with the --test-sandbox=security_tests.dll flag.
SandboxTest() : UITest() {
- CommandLine::AppendSwitchWithValue(&launch_arguments_,
- switches::kTestSandbox,
- L"security_tests.dll");
+ launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox,
+ L"security_tests.dll");
}
};
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 06591ec..597b0af 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/test/ui/ui_test.h"
+
#include <set>
#include <vector>
-#include "chrome/test/ui/ui_test.h"
-
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/file_util.h"
@@ -92,6 +92,7 @@ bool UITest::DieFileDie(const std::wstring& file, bool recurse) {
UITest::UITest()
: testing::Test(),
+ launch_arguments_(L""),
expected_errors_(0),
expected_crashes_(0),
homepage_(L"about:blank"),
@@ -177,28 +178,29 @@ void UITest::TearDown() {
// Pick up the various test time out values from the command line.
void UITest::InitializeTimeouts() {
- if (CommandLine().HasSwitch(kUiTestTimeout)) {
- std::wstring timeout_str = CommandLine().GetSwitchValue(kUiTestTimeout);
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(kUiTestTimeout)) {
+ std::wstring timeout_str = command_line.GetSwitchValue(kUiTestTimeout);
int timeout = StringToInt(timeout_str);
command_execution_timeout_ms_ = std::max(kMaxTestExecutionTime, timeout);
}
- if (CommandLine().HasSwitch(kUiTestActionTimeout)) {
- std::wstring act_str = CommandLine().GetSwitchValue(kUiTestActionTimeout);
+ if (command_line.HasSwitch(kUiTestActionTimeout)) {
+ std::wstring act_str = command_line.GetSwitchValue(kUiTestActionTimeout);
int act_timeout = StringToInt(act_str);
action_timeout_ms_ = std::max(kWaitForActionMsec, act_timeout);
}
- if (CommandLine().HasSwitch(kUiTestActionMaxTimeout)) {
+ if (command_line.HasSwitch(kUiTestActionMaxTimeout)) {
std::wstring action_max_str =
- CommandLine().GetSwitchValue(kUiTestActionMaxTimeout);
+ command_line.GetSwitchValue(kUiTestActionMaxTimeout);
int max_timeout = StringToInt(action_max_str);
action_max_timeout_ms_ = std::max(kWaitForActionMaxMsec, max_timeout);
}
- if (CommandLine().HasSwitch(kUiTestSleepTimeout)) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(kUiTestSleepTimeout)) {
std::wstring sleep_timeout_str =
- CommandLine().GetSwitchValue(kUiTestSleepTimeout);
+ CommandLine::ForCurrentProcess()->GetSwitchValue(kUiTestSleepTimeout);
int sleep_timeout = StringToInt(sleep_timeout_str);
sleep_timeout_ms_ = std::max(kWaitForActionMsec, sleep_timeout);
}
@@ -235,23 +237,29 @@ void UITest::CloseBrowserAndServer() {
#endif
}
-void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
- std::wstring command_line(browser_directory_);
- file_util::AppendToPath(&command_line,
+void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
+ std::wstring command = browser_directory_;
+ file_util::AppendToPath(&command,
chrome::kBrowserProcessExecutableName);
+ CommandLine command_line(command);
// Add any explict command line flags passed to the process.
std::wstring extra_chrome_flags =
- CommandLine().GetSwitchValue(kExtraChromeFlagsSwitch);
- if (!extra_chrome_flags.empty())
- command_line.append(L" " + extra_chrome_flags);
+ CommandLine::ForCurrentProcess()->GetSwitchValue(kExtraChromeFlagsSwitch);
+ if (!extra_chrome_flags.empty()) {
+#if defined(OS_WIN)
+ command_line.AppendLooseValue(extra_chrome_flags);
+#else
+ // TODO(port): figure out how to pass through extra flags via a string.
+ NOTIMPLEMENTED();
+#endif
+ }
// We need cookies on file:// for things like the page cycler.
- CommandLine::AppendSwitch(&command_line, switches::kEnableFileCookies);
+ command_line.AppendSwitch(switches::kEnableFileCookies);
if (dom_automation_enabled_)
- CommandLine::AppendSwitch(&command_line,
- switches::kDomAutomationController);
+ command_line.AppendSwitch(switches::kDomAutomationController);
#if defined(OS_WIN)
if (include_testing_id_) {
@@ -261,12 +269,10 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
// this by passing an url (e.g. about:blank) on the command line, but
// I decided to keep using the old switch in the existing use case to
// minimize changes in behavior.
- CommandLine::AppendSwitchWithValue(&command_line,
- switches::kAutomationClientChannelID,
+ command_line.AppendSwitchWithValue(switches::kAutomationClientChannelID,
server_->channel_id());
} else {
- CommandLine::AppendSwitchWithValue(&command_line,
- switches::kTestingChannelID,
+ command_line.AppendSwitchWithValue(switches::kTestingChannelID,
server_->channel_id());
}
}
@@ -276,56 +282,52 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
#endif
if (!show_error_dialogs_)
- CommandLine::AppendSwitch(&command_line, switches::kNoErrorDialogs);
+ command_line.AppendSwitch(switches::kNoErrorDialogs);
if (in_process_renderer_)
- CommandLine::AppendSwitch(&command_line, switches::kSingleProcess);
+ command_line.AppendSwitch(switches::kSingleProcess);
if (in_process_plugins_)
- CommandLine::AppendSwitch(&command_line, switches::kInProcessPlugins);
+ command_line.AppendSwitch(switches::kInProcessPlugins);
if (no_sandbox_)
- CommandLine::AppendSwitch(&command_line, switches::kNoSandbox);
+ command_line.AppendSwitch(switches::kNoSandbox);
if (full_memory_dump_)
- CommandLine::AppendSwitch(&command_line, switches::kFullMemoryCrashReport);
+ command_line.AppendSwitch(switches::kFullMemoryCrashReport);
if (safe_plugins_)
- CommandLine::AppendSwitch(&command_line, switches::kSafePlugins);
+ command_line.AppendSwitch(switches::kSafePlugins);
if (enable_dcheck_)
- CommandLine::AppendSwitch(&command_line, switches::kEnableDCHECK);
+ command_line.AppendSwitch(switches::kEnableDCHECK);
if (silent_dump_on_dcheck_)
- CommandLine::AppendSwitch(&command_line, switches::kSilentDumpOnDCHECK);
+ command_line.AppendSwitch(switches::kSilentDumpOnDCHECK);
if (disable_breakpad_)
- CommandLine::AppendSwitch(&command_line, switches::kDisableBreakpad);
+ command_line.AppendSwitch(switches::kDisableBreakpad);
if (!homepage_.empty())
- CommandLine::AppendSwitchWithValue(&command_line,
- switches::kHomePage,
+ command_line.AppendSwitchWithValue(switches::kHomePage,
homepage_);
PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
if (!user_data_dir_.empty())
- CommandLine::AppendSwitchWithValue(&command_line,
- switches::kUserDataDir,
+ command_line.AppendSwitchWithValue(switches::kUserDataDir,
user_data_dir_);
if (!js_flags_.empty())
- CommandLine::AppendSwitchWithValue(&command_line,
- switches::kJavaScriptFlags,
+ command_line.AppendSwitchWithValue(switches::kJavaScriptFlags,
js_flags_);
- CommandLine::AppendSwitch(&command_line, switches::kMetricsRecordingOnly);
+ command_line.AppendSwitch(switches::kMetricsRecordingOnly);
// We always want to enable chrome logging
- CommandLine::AppendSwitch(&command_line, switches::kEnableLogging);
+ command_line.AppendSwitch(switches::kEnableLogging);
if (dump_histograms_on_exit_)
- CommandLine::AppendSwitch(&command_line, switches::kDumpHistogramsOnExit);
+ command_line.AppendSwitch(switches::kDumpHistogramsOnExit);
#ifdef WAIT_FOR_DEBUGGER_ON_OPEN
- CommandLine::AppendSwitch(&command_line, switches::kDebugOnStart);
+ command_line.AppendSwitch(switches::kDebugOnStart);
#endif
if (!ui_test_name_.empty())
- CommandLine::AppendSwitchWithValue(&command_line,
- switches::kTestName,
+ command_line.AppendSwitchWithValue(switches::kTestName,
ui_test_name_);
DebugFlags::ProcessDebugFlags(&command_line, DebugFlags::UNKNOWN, false);
- command_line.append(L" " + arguments);
+ command_line.AppendArguments(arguments, false);
// Clear user data directory to make sure test environment is consistent
// We balk on really short (absolute) user_data_dir directory names, because
@@ -356,7 +358,7 @@ void UITest::LaunchBrowser(const std::wstring& arguments, bool clear_profile) {
if (use_existing_browser_) {
DWORD pid = 0;
HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass,
- user_data_dir_.c_str());
+ user_data_dir_.c_str());
GetWindowThreadProcessId(hwnd, &pid);
// This mode doesn't work if we wound up launching a new browser ourselves.
ASSERT_NE(pid, base::GetProcId(process_));
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 7f6c906..31ad827 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -24,6 +24,7 @@
#endif
#include <string>
+#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process.h"
@@ -75,8 +76,8 @@ class UITest : public testing::Test {
// Closes the browser and IPC testing server.
void CloseBrowserAndServer();
- // Launches the browser with the given arguments.
- void LaunchBrowser(const std::wstring& arguments, bool clear_profile);
+ // Launches the browser with the given command line.
+ void LaunchBrowser(const CommandLine& cmdline, bool clear_profile);
// Exits out browser instance.
void QuitBrowser();
@@ -389,7 +390,7 @@ class UITest : public testing::Test {
// with no trailing slash
std::wstring test_data_directory_; // Path to the unit test data,
// with no trailing slash
- std::wstring launch_arguments_; // Arguments to the browser on launch.
+ CommandLine launch_arguments_; // Command to launch the browser
size_t expected_errors_; // The number of errors expected during
// the run (generally 0).
int expected_crashes_; // The number of crashes expected during
diff --git a/chrome/test/ui/ui_test_suite.h b/chrome/test/ui/ui_test_suite.h
index b3d609f..07f6c76 100644
--- a/chrome/test/ui/ui_test_suite.h
+++ b/chrome/test/ui/ui_test_suite.h
@@ -18,7 +18,7 @@ class UITestSuite : public ChromeTestSuite {
virtual void Initialize() {
ChromeTestSuite::Initialize();
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
UITest::set_in_process_renderer(
parsed_command_line.HasSwitch(switches::kSingleProcess));
UITest::set_in_process_plugins(
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 8847988..b2c196b 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -41,7 +41,8 @@ protected:
// NOTE: The user data directory will be erased before each UI test that
// uses it, in order to ensure consistency.
std::wstring user_data_dir =
- CommandLine().GetSwitchValue(switches::kUserDataDir);
+ CommandLine::ForCurrentProcess()->GetSwitchValue(
+ switches::kUserDataDir);
if (user_data_dir.empty() &&
PathService::Get(base::DIR_EXE, &user_data_dir))
file_util::AppendToPath(&user_data_dir, L"test_user_data");
diff --git a/chrome/tools/test/image_diff/image_diff.cc b/chrome/tools/test/image_diff/image_diff.cc
index c21003d..044b89c 100644
--- a/chrome/tools/test/image_diff/image_diff.cc
+++ b/chrome/tools/test/image_diff/image_diff.cc
@@ -320,13 +320,8 @@ int DiffImages(const char* file1, const char* file2, const char* out_file) {
int main(int argc, const char* argv[]) {
base::EnableTerminationOnHeapCorruption();
- // TODO(estade): why does using the default constructor (command line
- // singleton) cause an exception when run in debug mode?
-#if defined(OS_WIN)
- CommandLine parsed_command_line(::GetCommandLine());
-#elif defined(OS_POSIX)
- CommandLine parsed_command_line(argc, argv);
-#endif
+ CommandLine::Init(argc, argv);
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kOptionPollStdin)) {
// Watch stdin for filenames.
std::string stdin_buffer;
@@ -353,15 +348,14 @@ int main(int argc, const char* argv[]) {
return 0;
}
+ std::vector<std::wstring> values = parsed_command_line.GetLooseValues();
if (parsed_command_line.HasSwitch(kOptionGenerateDiff)) {
- if (3 == parsed_command_line.GetLooseValueCount()) {
- CommandLine::LooseValueIterator iter =
- parsed_command_line.GetLooseValuesBegin();
- return DiffImages(WideToUTF8(*iter).c_str(),
- WideToUTF8(*(iter + 1)).c_str(),
- WideToUTF8(*(iter + 2)).c_str());
+ if (values.size() == 3) {
+ return DiffImages(WideToUTF8(values[0]).c_str(),
+ WideToUTF8(values[1]).c_str(),
+ WideToUTF8(values[2]).c_str());
}
- } else if (2 == parsed_command_line.GetLooseValueCount()) {
+ } else if (values.size() == 2) {
return CompareImages(argv[1], argv[2]);
}
diff --git a/chrome/views/window.cc b/chrome/views/window.cc
index 1a3ad56..dbc55ed 100644
--- a/chrome/views/window.cc
+++ b/chrome/views/window.cc
@@ -237,7 +237,7 @@ void Window::Observe(NotificationType type,
// This window is closed when the last app window is closed.
DCHECK(type == NOTIFY_ALL_APPWINDOWS_CLOSED);
// Only registered as an observer when we're not an app window.
- DCHECK(!IsAppWindow());
+ // XXX DCHECK(!IsAppWindow());
Close();
}