summaryrefslogtreecommitdiffstats
path: root/webkit
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 /webkit
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 'webkit')
-rw-r--r--webkit/activex_shim/activex_shared.cc4
-rw-r--r--webkit/glue/plugins/plugin_list_win.cc2
-rw-r--r--webkit/tools/test_shell/mac/main.mm16
-rw-r--r--webkit/tools/test_shell/node_leak_test.cc12
-rw-r--r--webkit/tools/test_shell/run_all_tests.cc6
-rwxr-xr-xwebkit/tools/test_shell/test_shell.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc19
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc2
8 files changed, 29 insertions, 34 deletions
diff --git a/webkit/activex_shim/activex_shared.cc b/webkit/activex_shim/activex_shared.cc
index 0b12b57..ee146b9 100644
--- a/webkit/activex_shim/activex_shared.cc
+++ b/webkit/activex_shim/activex_shared.cc
@@ -88,8 +88,8 @@ static bool IsAllowAllActiveX() {
static bool parsed_flag = false;
static bool allow_all_activex = false;
if (!parsed_flag) {
- CommandLine command_line;
- allow_all_activex = command_line.HasSwitch(kAllowAllActiveX);
+ allow_all_activex =
+ CommandLine::ForCurrentProcess()->HasSwitch(kAllowAllActiveX);
parsed_flag = true;
}
return allow_all_activex;
diff --git a/webkit/glue/plugins/plugin_list_win.cc b/webkit/glue/plugins/plugin_list_win.cc
index d15584c..2aaf983 100644
--- a/webkit/glue/plugins/plugin_list_win.cc
+++ b/webkit/glue/plugins/plugin_list_win.cc
@@ -195,7 +195,7 @@ namespace NPAPI
{
void PluginList::PlatformInit() {
- CommandLine command_line;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
dont_load_new_wmp_ = command_line.HasSwitch(kUseOldWMPPluginSwitch);
use_internal_activex_shim_ =
!command_line.HasSwitch(kNoNativeActiveXShimSwitch);
diff --git a/webkit/tools/test_shell/mac/main.mm b/webkit/tools/test_shell/mac/main.mm
index 19c3507..535ac24 100644
--- a/webkit/tools/test_shell/mac/main.mm
+++ b/webkit/tools/test_shell/mac/main.mm
@@ -115,8 +115,8 @@ int main(const int argc, const char *argv[]) {
// the windows version, so that we can run the same test scripts. stop
// if we hit something that's not a switch (like, oh, a URL).
- CommandLine::SetArgcArgv(argc, argv);
- CommandLine parsed_command_line(argc, argv);
+ CommandLine::Init(argc, argv);
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(test_shell::kCheckLayoutTestSystemDeps)) {
// Always succeed the deps check, currently just used by windows port.
@@ -167,7 +167,7 @@ int main(const int argc, const char *argv[]) {
std::wstring javascript_flags =
parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags);
// Test shell always exposes the GC.
- CommandLine::AppendSwitch(&javascript_flags, L"expose-gc");
+ javascript_flags += L" --expose-gc";
webkit_glue::SetJavaScriptFlags(javascript_flags);
// Load and initialize the stats table (one per process, so that multiple
@@ -235,12 +235,10 @@ int main(const int argc, const char *argv[]) {
uri = UTF8ToWide([testShellURL UTF8String]);
}
- if (parsed_command_line.GetLooseValueCount() > 0) {
- CommandLine::LooseValueIterator iter =
- parsed_command_line.GetLooseValuesBegin();
- uri = *iter;
- }
-
+ std::vector<std::wstring> values = parsed_command_line.GetLooseValues();
+ if (values.size() > 0)
+ uri = values[0];
+
TestShell* shell;
if (TestShell::CreateNewWindow(uri, &shell)) {
#ifdef NOTYET
diff --git a/webkit/tools/test_shell/node_leak_test.cc b/webkit/tools/test_shell/node_leak_test.cc
index 97549c6..f24172a 100644
--- a/webkit/tools/test_shell/node_leak_test.cc
+++ b/webkit/tools/test_shell/node_leak_test.cc
@@ -30,11 +30,11 @@ const wchar_t kTestUrlSwitch[] = L"test-url";
class NodeLeakTest : public TestShellTest {
public:
virtual void SetUp() {
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
- std::wstring js_flags =
- parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags);
- CommandLine::AppendSwitch(&js_flags, L"expose-gc");
+ std::wstring js_flags =
+ parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags);
+ js_flags += L" --expose-gc";
webkit_glue::SetJavaScriptFlags(js_flags);
// Expose GCController to JavaScript as well.
webkit_glue::SetShouldExposeGCController(true);
@@ -66,7 +66,7 @@ class NodeLeakTest : public TestShellTest {
virtual void TearDown() {
TestShellTest::TearDown();
-
+
SimpleResourceLoaderBridge::Shutdown();
}
@@ -80,7 +80,7 @@ class NodeLeakTest : public TestShellTest {
};
TEST_F(NodeLeakTest, TestURL) {
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(kTestUrlSwitch)) {
NavigateToURL(parsed_command_line.GetSwitchValue(kTestUrlSwitch).c_str());
}
diff --git a/webkit/tools/test_shell/run_all_tests.cc b/webkit/tools/test_shell/run_all_tests.cc
index d7ff3d0..9d5cfb7 100644
--- a/webkit/tools/test_shell/run_all_tests.cc
+++ b/webkit/tools/test_shell/run_all_tests.cc
@@ -48,15 +48,13 @@ int main(int argc, char* argv[]) {
base::EnableTerminationOnHeapCorruption();
// Some unittests may use base::Singleton<>, thus we need to instanciate
// the AtExitManager or else we will leak objects.
- base::AtExitManager at_exit_manager;
+ base::AtExitManager at_exit_manager;
#if defined(OS_LINUX)
gtk_init(&argc, &argv);
#endif
-#if defined(OS_POSIX)
- CommandLine::SetArgcArgv(argc, argv);
-#endif
+ CommandLine::Init(argc, argv);
// Suppress error dialogs and do not show GP fault error box on Windows.
TestShell::InitLogging(true, false, false);
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 3247022..ced93a5 100755
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -501,7 +501,7 @@ void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
namespace webkit_glue {
bool IsMediaPlayerAvailable() {
- return CommandLine().HasSwitch(test_shell::kEnableVideo);
+ return CommandLine::ForCurrentProcess()->HasSwitch(test_shell::kEnableVideo);
}
void PrefetchDns(const std::string& hostname) {}
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index d24c42d..3e4ecf3 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -134,11 +134,12 @@ int main(int argc, char* argv[]) {
#if defined(OS_LINUX)
gtk_init(&argc, &argv);
- // Only parse the command line after GTK's had a crack at it.
- CommandLine::SetArgcArgv(argc, argv);
#endif
- CommandLine parsed_command_line;
+ // Only parse the command line after GTK's had a crack at it.
+ CommandLine::Init(argc, argv);
+
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(test_shell::kStartupDialog))
TestShell::ShowStartupDebuggingDialog();
@@ -265,16 +266,14 @@ int main(int argc, char* argv[]) {
file_util::AppendToPath(&uri, L"index.html");
}
- if (parsed_command_line.GetLooseValueCount() > 0) {
- CommandLine::LooseValueIterator iter(
- parsed_command_line.GetLooseValuesBegin());
- uri = *iter;
- }
+ std::vector<std::wstring> loose_values = parsed_command_line.GetLooseValues();
+ if (loose_values.size() > 0)
+ uri = loose_values[0];
- std::wstring js_flags =
+ std::wstring js_flags =
parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags);
// Test shell always exposes the GC.
- CommandLine::AppendSwitch(&js_flags, L"expose-gc");
+ js_flags += L" --expose-gc";
webkit_glue::SetJavaScriptFlags(js_flags);
// Also expose GCController to JavaScript.
webkit_glue::SetShouldExposeGCController(true);
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index a6ba571..81baf04 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -151,7 +151,7 @@ void TestShell::InitializeTestShell(bool layout_test_mode) {
DCHECK(rc != 0);
}
- CommandLine parsed_command_line;
+ const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
if (parsed_command_line.HasSwitch(test_shell::kCrashDumps)) {
std::wstring dir(
parsed_command_line.GetSwitchValue(test_shell::kCrashDumps));