Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: base/command_line.cc

Issue 6538059: Revert 75405 - Register Application Restart with Windows Restart Manager on b... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line.h ('k') | chrome/browser/browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line.cc
===================================================================
--- base/command_line.cc (revision 75409)
+++ base/command_line.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -41,59 +41,13 @@
#endif
#if defined(OS_WIN)
-namespace {
// Lowercase a string. This is used to lowercase switch names.
// Is this what we really want? It seems crazy to me. I've left it in
// for backwards compatibility on Windows.
-void Lowercase(std::string* parameter) {
+static void Lowercase(std::string* parameter) {
transform(parameter->begin(), parameter->end(), parameter->begin(),
tolower);
}
-
-// Quote a string if necessary, such that CommandLineToArgvW() will
-// always process it as a single argument.
-std::wstring WindowsStyleQuote(const std::wstring& arg) {
- // We follow the quoting rules of CommandLineToArgvW.
- // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
- if (arg.find_first_of(L" \\\"") == std::wstring::npos) {
- // No quoting necessary.
- return arg;
- }
-
- std::wstring out;
- out.push_back(L'"');
- for (size_t i = 0; i < arg.size(); ++i) {
- if (arg[i] == '\\') {
- // Find the extent of this run of backslashes.
- size_t start = i, end = start + 1;
- for (; end < arg.size() && arg[end] == '\\'; ++end)
- /* empty */;
- size_t backslash_count = end - start;
-
- // Backslashes are escapes only if the run is followed by a double quote.
- // Since we also will end the string with a double quote, we escape for
- // either a double quote or the end of the string.
- if (end == arg.size() || arg[end] == '"') {
- // To quote, we need to output 2x as many backslashes.
- backslash_count *= 2;
- }
- for (size_t j = 0; j < backslash_count; ++j)
- out.push_back('\\');
-
- // Advance i to one before the end to balance i++ in loop.
- i = end - 1;
- } else if (arg[i] == '"') {
- out.push_back('\\');
- out.push_back('"');
- } else {
- out.push_back(arg[i]);
- }
- }
- out.push_back('"');
-
- return out;
-}
-} // namespace
#endif
CommandLine::~CommandLine() {
@@ -337,6 +291,55 @@
switches_[switch_string] = L"";
}
+void CommandLine::AppendSwitchASCII(const std::string& switch_string,
+ const std::string& value_string) {
+ AppendSwitchNative(switch_string, ASCIIToWide(value_string));
+}
+
+// Quote a string if necessary, such that CommandLineToArgvW() will
+// always process it as a single argument.
+static std::wstring WindowsStyleQuote(const std::wstring& arg) {
+ // We follow the quoting rules of CommandLineToArgvW.
+ // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
+ if (arg.find_first_of(L" \\\"") == std::wstring::npos) {
+ // No quoting necessary.
+ return arg;
+ }
+
+ std::wstring out;
+ out.push_back(L'"');
+ for (size_t i = 0; i < arg.size(); ++i) {
+ if (arg[i] == '\\') {
+ // Find the extent of this run of backslashes.
+ size_t start = i, end = start + 1;
+ for (; end < arg.size() && arg[end] == '\\'; ++end)
+ /* empty */;
+ size_t backslash_count = end - start;
+
+ // Backslashes are escapes only if the run is followed by a double quote.
+ // Since we also will end the string with a double quote, we escape for
+ // either a double quote or the end of the string.
+ if (end == arg.size() || arg[end] == '"') {
+ // To quote, we need to output 2x as many backslashes.
+ backslash_count *= 2;
+ }
+ for (size_t j = 0; j < backslash_count; ++j)
+ out.push_back('\\');
+
+ // Advance i to one before the end to balance i++ in loop.
+ i = end - 1;
+ } else if (arg[i] == '"') {
+ out.push_back('\\');
+ out.push_back('"');
+ } else {
+ out.push_back(arg[i]);
+ }
+ }
+ out.push_back('"');
+
+ return out;
+}
+
void CommandLine::AppendSwitchNative(const std::string& switch_string,
const std::wstring& value) {
std::wstring combined_switch_string =
@@ -350,11 +353,6 @@
switches_[switch_string] = value;
}
-void CommandLine::AppendSwitchASCII(const std::string& switch_string,
- const std::string& value_string) {
- AppendSwitchNative(switch_string, ASCIIToWide(value_string));
-}
-
void CommandLine::AppendArg(const std::string& value) {
DCHECK(IsStringUTF8(value));
AppendArgNative(UTF8ToWide(value));
@@ -369,7 +367,8 @@
void CommandLine::AppendArguments(const CommandLine& other,
bool include_program) {
// Verify include_program is used correctly.
- DCHECK(!include_program || !other.GetProgram().empty());
+ // Logic could be shorter but this is clearer.
+ DCHECK_EQ(include_program, !other.GetProgram().empty());
if (include_program)
program_ = other.program_;
@@ -452,31 +451,13 @@
#endif
-void CommandLine::AppendSwitchPath(const std::string& switch_string,
- const FilePath& path) {
- AppendSwitchNative(switch_string, path.value());
-}
-
-void CommandLine::AppendSwitches(const CommandLine& other) {
- std::map<std::string, StringType>::const_iterator i;
- for (i = other.switches_.begin(); i != other.switches_.end(); ++i)
- AppendSwitchNative(i->first, i->second);
-}
-
void CommandLine::AppendArgPath(const FilePath& path) {
AppendArgNative(path.value());
}
-void CommandLine::AppendArgs(const CommandLine& other) {
- if(other.args_.size() <= 0)
- return;
-
-#if defined(OS_WIN)
- command_line_string_.append(L" --");
-#endif // OS_WIN
- std::vector<StringType>::const_iterator i;
- for (i = other.args_.begin(); i != other.args_.end(); ++i)
- AppendArgNative(*i);
+void CommandLine::AppendSwitchPath(const std::string& switch_string,
+ const FilePath& path) {
+ AppendSwitchNative(switch_string, path.value());
}
void CommandLine::CopySwitchesFrom(const CommandLine& source,
« no previous file with comments | « base/command_line.h ('k') | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698