summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 19:55:16 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 19:55:16 +0000
commitc4e52f0d8fa148f543d3e7b2562164e9bf5605aa (patch)
tree86a455dd54d4542026ff3059ac939dc809a09b26 /chrome
parent2fd94bbeefa87a83a96c65ff998add7d7fb0f908 (diff)
downloadchromium_src-c4e52f0d8fa148f543d3e7b2562164e9bf5605aa.zip
chromium_src-c4e52f0d8fa148f543d3e7b2562164e9bf5605aa.tar.gz
chromium_src-c4e52f0d8fa148f543d3e7b2562164e9bf5605aa.tar.bz2
Use GetSwitchValueASCII.
BUG=24672 TEST=None Original patch by Thiago Farina <thiago.farina@gmail.com> at http://codereview.chromium.org/296004 Review URL: http://codereview.chromium.org/373013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_init.cc49
-rw-r--r--chrome/browser/chromeos/external_cookie_handler.cc2
-rw-r--r--chrome/browser/extensions/extensions_service.cc4
-rw-r--r--chrome/browser/first_run_win.cc6
-rw-r--r--chrome/browser/nacl_process_host.cc2
-rw-r--r--chrome/browser/plugin_process_host.cc2
-rw-r--r--chrome/browser/plugin_service.cc5
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc8
-rw-r--r--chrome/browser/sessions/session_restore.cc6
-rw-r--r--chrome/browser/sync/profile_sync_service.cc5
-rw-r--r--chrome/browser/zygote_host_linux.cc4
-rw-r--r--chrome/common/child_thread.cc11
-rw-r--r--chrome/common/chrome_paths.cc9
-rw-r--r--chrome/common/logging_chrome.cc13
-rw-r--r--chrome/test/unit/chrome_test_suite.h6
15 files changed, 65 insertions, 67 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 8d74710..a0ee959 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -407,9 +407,9 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
if (command_line_.HasSwitch(switches::kRemoteShellPort)) {
if (!RenderProcessHost::run_renderer_in_process()) {
- std::wstring port_str =
- command_line_.GetSwitchValue(switches::kRemoteShellPort);
- int64 port = StringToInt64(WideToUTF16Hack(port_str));
+ std::string port_str =
+ command_line_.GetSwitchValueASCII(switches::kRemoteShellPort);
+ int64 port = StringToInt64(port_str);
if (port > 0 && port < 65535) {
g_browser_process->InitDebuggerWrapper(static_cast<int>(port));
} else {
@@ -419,8 +419,8 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
}
if (command_line_.HasSwitch(switches::kUserAgent)) {
- webkit_glue::SetUserAgent(WideToUTF8(
- command_line_.GetSwitchValue(switches::kUserAgent)));
+ webkit_glue::SetUserAgent(command_line_.GetSwitchValueASCII(
+ switches::kUserAgent));
}
// Open the required browser windows and tabs.
@@ -479,7 +479,7 @@ bool BrowserInit::LaunchWithProfile::OpenApplicationURL(Profile* profile) {
if (!command_line_.HasSwitch(switches::kApp))
return false;
- GURL url(WideToUTF8(command_line_.GetSwitchValue(switches::kApp)));
+ GURL url(command_line_.GetSwitchValueASCII(switches::kApp));
if (!url.is_empty() && url.is_valid()) {
Browser::OpenApplicationWindow(profile, url);
return true;
@@ -551,10 +551,10 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
int pin_count = 0;
if (!browser) {
- std::wstring pin_count_string =
- command_line_.GetSwitchValue(switches::kPinnedTabCount);
+ std::string pin_count_string =
+ command_line_.GetSwitchValueASCII(switches::kPinnedTabCount);
if (!pin_count_string.empty())
- pin_count = StringToInt(WideToUTF16Hack(pin_count_string));
+ pin_count = StringToInt(pin_count_string);
}
if (!browser || browser->type() != Browser::TYPE_NORMAL)
browser = Browser::Create(profile_);
@@ -687,11 +687,11 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
BrowserInit* browser_init) {
DCHECK(profile);
if (process_startup) {
- const std::wstring popup_count_string =
- command_line.GetSwitchValue(switches::kOmniBoxPopupCount);
+ const std::string popup_count_string =
+ command_line.GetSwitchValueASCII(switches::kOmniBoxPopupCount);
if (!popup_count_string.empty()) {
int count = 0;
- if (StringToInt(WideToUTF16Hack(popup_count_string), &count)) {
+ if (StringToInt(popup_count_string, &count)) {
const int popup_count = std::max(0, count);
AutocompleteResult::set_max_matches(popup_count);
AutocompleteProvider::set_max_matches(popup_count / 2);
@@ -701,11 +701,11 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
if (command_line.HasSwitch(switches::kDisablePromptOnRepost))
NavigationController::DisablePromptOnRepost();
- const std::wstring tab_count_string =
- command_line.GetSwitchValue(switches::kTabCountToLoadOnSessionRestore);
+ const std::string tab_count_string = command_line.GetSwitchValueASCII(
+ switches::kTabCountToLoadOnSessionRestore);
if (!tab_count_string.empty()) {
int count = 0;
- if (StringToInt(WideToUTF16Hack(tab_count_string), &count)) {
+ if (StringToInt(tab_count_string, &count)) {
const int tab_count = std::max(0, count);
SessionRestore::num_tabs_to_load_ = static_cast<size_t>(tab_count);
}
@@ -713,18 +713,17 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
// Look for the testing channel ID ONLY during process startup
if (command_line.HasSwitch(switches::kTestingChannelID)) {
- std::string testing_channel_id = WideToASCII(
- command_line.GetSwitchValue(switches::kTestingChannelID));
+ std::string testing_channel_id = command_line.GetSwitchValueASCII(
+ switches::kTestingChannelID);
// TODO(sanjeevr) Check if we need to make this a singleton for
// compatibility with the old testing code
// If there are any loose parameters, we expect each one to generate a
// new tab; if there are none then we get one homepage tab.
int expected_tab_count = 1;
if (command_line.HasSwitch(switches::kRestoreLastSession)) {
- std::wstring restore_session_value(
- command_line.GetSwitchValue(switches::kRestoreLastSession));
- StringToInt(WideToUTF16Hack(restore_session_value),
- &expected_tab_count);
+ std::string restore_session_value(
+ command_line.GetSwitchValueASCII(switches::kRestoreLastSession));
+ StringToInt(restore_session_value, &expected_tab_count);
} else {
expected_tab_count =
std::max(1, static_cast<int>(command_line.GetLooseValues().size()));
@@ -741,8 +740,8 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
switches::kPackExtension));
FilePath private_key_path;
if (command_line.HasSwitch(switches::kPackExtensionKey)) {
- private_key_path = FilePath::FromWStringHack(
- command_line.GetSwitchValue(switches::kPackExtensionKey));
+ private_key_path = command_line.GetSwitchValuePath(
+ switches::kPackExtensionKey);
}
// Output Paths.
@@ -792,8 +791,8 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
bool silent_launch = false;
if (command_line.HasSwitch(switches::kAutomationClientChannelID)) {
- std::string automation_channel_id = WideToASCII(
- command_line.GetSwitchValue(switches::kAutomationClientChannelID));
+ std::string automation_channel_id = command_line.GetSwitchValueASCII(
+ switches::kAutomationClientChannelID);
// 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 =
diff --git a/chrome/browser/chromeos/external_cookie_handler.cc b/chrome/browser/chromeos/external_cookie_handler.cc
index 34853a9..a3cf9d5 100644
--- a/chrome/browser/chromeos/external_cookie_handler.cc
+++ b/chrome/browser/chromeos/external_cookie_handler.cc
@@ -20,7 +20,7 @@ void ExternalCookieHandler::GetCookies(const CommandLine& parsed_command_line,
// If there are Google External SSO cookies, add them to the cookie store.
if (parsed_command_line.HasSwitch(switches::kCookiePipe)) {
std::string pipe_name =
- WideToASCII(parsed_command_line.GetSwitchValue(switches::kCookiePipe));
+ parsed_command_line.GetSwitchValueASCII(switches::kCookiePipe);
ExternalCookieHandler cookie_handler(new PipeReader(pipe_name));
cookie_handler.HandleCookies(
profile->GetRequestContext()->GetCookieStore());
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index accb9cb..a2193ef 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -103,8 +103,8 @@ ExtensionsService::ExtensionsService(Profile* profile,
if (autoupdate_enabled) {
int update_frequency = kDefaultUpdateFrequencySeconds;
if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) {
- update_frequency = StringToInt(WideToASCII(command_line->GetSwitchValue(
- switches::kExtensionsUpdateFrequency)));
+ update_frequency = StringToInt(command_line->GetSwitchValueASCII(
+ switches::kExtensionsUpdateFrequency));
}
updater_ = new ExtensionUpdater(this, prefs, update_frequency);
}
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc
index f2ea99e8..fc2d8eb 100644
--- a/chrome/browser/first_run_win.cc
+++ b/chrome/browser/first_run_win.cc
@@ -504,7 +504,7 @@ class HungImporterMonitor : public WorkerThreadTicker::Callback {
HWND owner_window_;
base::ProcessHandle import_process_;
WorkerThreadTicker ticker_;
- DISALLOW_EVIL_CONSTRUCTORS(HungImporterMonitor);
+ DISALLOW_COPY_AND_ASSIGN(HungImporterMonitor);
};
// This class is used by FirstRun::ImportNow to get notified of the outcome of
@@ -541,7 +541,7 @@ class FirstRunImportObserver : public ImportObserver {
bool loop_running_;
int import_result_;
- DISALLOW_EVIL_CONSTRUCTORS(FirstRunImportObserver);
+ DISALLOW_COPY_AND_ASSIGN(FirstRunImportObserver);
};
std::wstring EncodeImportParams(int browser_type, int options, HWND window) {
@@ -575,7 +575,7 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type,
if (cmdline.HasSwitch(switches::kUserDataDir)) {
import_cmd.AppendSwitchWithValue(
switches::kUserDataDir,
- cmdline.GetSwitchValue(switches::kUserDataDir));
+ cmdline.GetSwitchValueASCII(switches::kUserDataDir));
}
// Since ImportSettings is called before the local state is stored on disk
diff --git a/chrome/browser/nacl_process_host.cc b/chrome/browser/nacl_process_host.cc
index dcd3401..dbdcb2a 100644
--- a/chrome/browser/nacl_process_host.cc
+++ b/chrome/browser/nacl_process_host.cc
@@ -146,7 +146,7 @@ bool NaClProcessHost::LaunchSelLdr(ResourceMessageFilter* renderer_msg_filter,
if (browser_command_line.HasSwitch(switch_names[i])) {
cmd_line.AppendSwitchWithValue(
switch_names[i],
- browser_command_line.GetSwitchValue(switch_names[i]));
+ browser_command_line.GetSwitchValueASCII(switch_names[i]));
}
}
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index 96bf5a2..681ca2f 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -402,7 +402,7 @@ bool PluginProcessHost::Init(const WebPluginInfo& info,
if (browser_command_line.HasSwitch(switch_names[i])) {
cmd_line.AppendSwitchWithValue(
switch_names[i],
- browser_command_line.GetSwitchValue(switch_names[i]));
+ browser_command_line.GetSwitchValueASCII(switch_names[i]));
}
}
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index f9153c6..5f66be9 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -54,10 +54,9 @@ PluginService::PluginService()
ChromePluginLib::RegisterPluginsWithNPAPI();
// Load the one specified on the command line as well.
const CommandLine* command_line = CommandLine::ForCurrentProcess();
- std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin);
+ FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin);
if (!path.empty()) {
- NPAPI::PluginList::Singleton()->AddExtraPluginPath(
- FilePath::FromWStringHack(path));
+ NPAPI::PluginList::Singleton()->AddExtraPluginPath(path);
}
#ifndef DISABLE_NACL
if (command_line->HasSwitch(switches::kInternalNaCl))
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 91c692f..f3484a1 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -479,7 +479,7 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
FieldTrialList::StatesToString(&field_trial_states);
if (!field_trial_states.empty()) {
command_line->AppendSwitchWithValue(switches::kForceFieldTestNameAndValue,
- ASCIIToWide(field_trial_states));
+ field_trial_states);
}
// A command prefix is something prepended to the command line of the spawned
@@ -499,8 +499,8 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
ChildProcessHost::SetCrashReporterCommandLine(command_line);
- const std::wstring& profile_path =
- browser_command_line.GetSwitchValue(switches::kUserDataDir);
+ const std::string& profile_path =
+ browser_command_line.GetSwitchValueASCII(switches::kUserDataDir);
if (!profile_path.empty())
command_line->AppendSwitchWithValue(switches::kUserDataDir, profile_path);
}
@@ -566,7 +566,7 @@ void BrowserRenderProcessHost::PropogateBrowserCommandLineToRenderer(
for (size_t i = 0; i < arraysize(switch_names); ++i) {
if (browser_cmd.HasSwitch(switch_names[i])) {
renderer_cmd->AppendSwitchWithValue(switch_names[i],
- browser_cmd.GetSwitchValue(switch_names[i]));
+ browser_cmd.GetSwitchValueASCII(switch_names[i]));
}
}
}
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc
index 6db8516..36bc224 100644
--- a/chrome/browser/sessions/session_restore.cc
+++ b/chrome/browser/sessions/session_restore.cc
@@ -365,11 +365,11 @@ class SessionRestoreImpl : public NotificationObserver {
bool pin_tabs) {
int pin_count = 0;
if (pin_tabs) {
- std::wstring pin_count_string =
- CommandLine::ForCurrentProcess()->GetSwitchValue(
+ std::string pin_count_string =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kPinnedTabCount);
if (!pin_count_string.empty())
- pin_count = StringToInt(WideToUTF16Hack(pin_count_string));
+ pin_count = StringToInt(pin_count_string);
}
for (size_t i = 0; i < urls.size(); ++i) {
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 0a0e9f9..f35939d 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -74,9 +74,10 @@ void ProfileSyncService::InitSettings() {
// Override the sync server URL from the command-line, if sync server
// command-line argument exists.
if (command_line.HasSwitch(switches::kSyncServiceURL)) {
- std::wstring value(command_line.GetSwitchValue(switches::kSyncServiceURL));
+ std::string value(command_line.GetSwitchValueASCII(
+ switches::kSyncServiceURL));
if (!value.empty()) {
- GURL custom_sync_url(WideToUTF8(value));
+ GURL custom_sync_url(value);
if (custom_sync_url.is_valid()) {
sync_service_url_ = custom_sync_url;
} else {
diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc
index 00d082c..7e78bab 100644
--- a/chrome/browser/zygote_host_linux.cc
+++ b/chrome/browser/zygote_host_linux.cc
@@ -87,13 +87,13 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
}
if (browser_command_line.HasSwitch(switches::kLoggingLevel)) {
cmd_line.AppendSwitchWithValue(switches::kLoggingLevel,
- browser_command_line.GetSwitchValue(
+ browser_command_line.GetSwitchValueASCII(
switches::kLoggingLevel));
}
if (browser_command_line.HasSwitch(switches::kEnableLogging)) {
// Append with value to support --enable-logging=stderr.
cmd_line.AppendSwitchWithValue(switches::kEnableLogging,
- browser_command_line.GetSwitchValue(
+ browser_command_line.GetSwitchValueASCII(
switches::kEnableLogging));
}
if (browser_command_line.HasSwitch(switches::kEnableSeccompSandbox)) {
diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc
index 43da09a..48358f1 100644
--- a/chrome/common/child_thread.cc
+++ b/chrome/common/child_thread.cc
@@ -17,9 +17,8 @@
ChildThread::ChildThread() {
- channel_name_ = WideToASCII(
- CommandLine::ForCurrentProcess()->GetSwitchValue(
- switches::kProcessChannelID));
+ channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessChannelID);
Init();
}
@@ -32,9 +31,9 @@ void ChildThread::Init() {
check_with_browser_before_shutdown_ = false;
message_loop_ = MessageLoop::current();
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) {
- webkit_glue::SetUserAgent(WideToUTF8(
- CommandLine::ForCurrentProcess()->GetSwitchValue(
- switches::kUserAgent)));
+ webkit_glue::SetUserAgent(
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kUserAgent));
}
channel_.reset(new IPC::SyncChannel(channel_name_,
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index aa9ae8d..4382793 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -23,11 +23,10 @@ namespace chrome {
bool GetGearsPluginPathFromCommandLine(FilePath* path) {
#ifndef NDEBUG
// for debugging, support a cmd line based override
- std::wstring plugin_path = CommandLine::ForCurrentProcess()->GetSwitchValue(
- switches::kGearsPluginPathOverride);
- // TODO(tc): After GetSwitchNativeValue lands, we don't need to use
- // FromWStringHack.
- *path = FilePath::FromWStringHack(plugin_path);
+ FilePath plugin_path =
+ CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kGearsPluginPathOverride);
+ *path = plugin_path;
return !plugin_path.empty();
#else
return false;
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index 3236468..6af2128 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -117,7 +117,7 @@ void InitChromeLogging(const CommandLine& command_line,
if (enable_logging) {
// Let --enable-logging=stderr force only stderr, particularly useful for
// non-debug builds where otherwise you can't get logs to stderr at all.
- if (command_line.GetSwitchValue(switches::kEnableLogging) == L"stderr")
+ if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr")
log_mode = logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG;
else
log_mode = kDefaultLoggingMode;
@@ -141,15 +141,16 @@ void InitChromeLogging(const CommandLine& command_line,
command_line.HasSwitch(switches::kNoErrorDialogs))
SuppressDialogs();
- std::wstring log_filter_prefix =
- command_line.GetSwitchValue(switches::kLogFilterPrefix);
- logging::SetLogFilterPrefix(WideToUTF8(log_filter_prefix).c_str());
+ std::string log_filter_prefix =
+ command_line.GetSwitchValueASCII(switches::kLogFilterPrefix);
+ logging::SetLogFilterPrefix(log_filter_prefix.c_str());
// Use a minimum log level if the command line has one, otherwise set the
// default to LOG_WARNING.
- std::wstring log_level = command_line.GetSwitchValue(switches::kLoggingLevel);
+ std::string log_level = command_line.GetSwitchValueASCII(
+ switches::kLoggingLevel);
int level = 0;
- if (StringToInt(WideToUTF16Hack(log_level), &level)) {
+ if (StringToInt(log_level, &level)) {
if ((level >= 0) && (level < LOG_NUM_SEVERITIES))
logging::SetMinLogLevel(level);
} else {
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 178b62a..bd05e0d 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -86,9 +86,9 @@ class ChromeTestSuite : public TestSuite {
// user data directory that lives alongside the current app.
// NOTE: The user data directory will be erased before each UI test that
// uses it, in order to ensure consistency.
- FilePath user_data_dir = FilePath::FromWStringHack(
- CommandLine::ForCurrentProcess()->GetSwitchValue(
- switches::kUserDataDir));
+ FilePath user_data_dir =
+ CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kUserDataDir);
if (user_data_dir.empty() &&
file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("chrome_test_"),
&user_data_dir)) {