summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 01:00:22 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-21 01:00:22 +0000
commitbb97536b768ac68fcbc4605c35461a798ef6e5ff (patch)
tree479bde96cd05a9e1f9d2746dd82313e2eb715e8e /chrome/browser
parent8731a63268015f4e5d684833c11a1b44bd9ae468 (diff)
downloadchromium_src-bb97536b768ac68fcbc4605c35461a798ef6e5ff.zip
chromium_src-bb97536b768ac68fcbc4605c35461a798ef6e5ff.tar.gz
chromium_src-bb97536b768ac68fcbc4605c35461a798ef6e5ff.tar.bz2
Make CommandLine into a normal object, with some statics for getting at the current process's command line.
One explicit goal of this change is to *not* deal with the string/wstring issues at the API on POSIX; the functions are the same as before, which means they remain as broken as before. (I did try to fix the internals, though, so migrating the callers is now possible by adding platform-appropriate hooks.) Review URL: http://codereview.chromium.org/18248 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-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
28 files changed, 130 insertions, 132 deletions
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));