| Index: base/command_line.cc
|
| diff --git a/base/command_line.cc b/base/command_line.cc
|
| index 873da813483651bc9e74b0510e17fa925225b5bd..56a7aa863455ea5abf14044ee5a310e15f6df849 100644
|
| --- a/base/command_line.cc
|
| +++ b/base/command_line.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/files/file_path.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| +#include "base/stl_util.h"
|
| #include "base/strings/string_split.h"
|
| #include "base/strings/string_tokenizer.h"
|
| #include "base/strings/string_util.h"
|
| @@ -148,6 +149,22 @@ string16 QuoteForCommandLineToArgvW(const string16& arg,
|
| }
|
| #endif
|
|
|
| +std::string GetSwitchKey(const std::string& switch_string) {
|
| +#if defined(OS_WIN)
|
| + return ToLowerASCII(switch_string);
|
| +#elif defined(OS_POSIX)
|
| + return switch_string;
|
| +#endif
|
| +}
|
| +
|
| +CommandLine::StringType GetCombinedSwitchString(const std::string switch_key) {
|
| +#if defined(OS_WIN)
|
| + return ASCIIToUTF16(switch_key);
|
| +#elif defined(OS_POSIX)
|
| + return switch_key;
|
| +#endif
|
| +}
|
| +
|
| } // namespace
|
|
|
| CommandLine::CommandLine(NoProgram no_program)
|
| @@ -334,13 +351,8 @@ void CommandLine::AppendSwitchPath(const std::string& switch_string,
|
|
|
| void CommandLine::AppendSwitchNative(const std::string& switch_string,
|
| const CommandLine::StringType& value) {
|
| -#if defined(OS_WIN)
|
| - const std::string switch_key = ToLowerASCII(switch_string);
|
| - StringType combined_switch_string(ASCIIToUTF16(switch_key));
|
| -#elif defined(OS_POSIX)
|
| - const std::string& switch_key = switch_string;
|
| - StringType combined_switch_string(switch_key);
|
| -#endif
|
| + const std::string switch_key = GetSwitchKey(switch_string);
|
| + StringType combined_switch_string = GetCombinedSwitchString(switch_key);
|
| size_t prefix_length = GetSwitchPrefixLength(combined_switch_string);
|
| auto insertion =
|
| switches_.insert(make_pair(switch_key.substr(prefix_length), value));
|
| @@ -365,6 +377,20 @@ void CommandLine::AppendSwitchASCII(const std::string& switch_string,
|
| #endif
|
| }
|
|
|
| +void CommandLine::RemoveSwitchForTesting(const std::string& switch_string) {
|
| + const std::string switch_key = GetSwitchKey(switch_string);
|
| + StringType combined_switch_string = GetCombinedSwitchString(switch_key);
|
| + size_t prefix_length = GetSwitchPrefixLength(combined_switch_string);
|
| + switches_by_stringpiece_.erase(switch_key.substr(prefix_length));
|
| + switches_.erase(switch_string.substr(prefix_length));
|
| +
|
| + auto find_switch = [&combined_switch_string](const std::string& argv_entry) {
|
| + return argv_entry.find(combined_switch_string) != std::string::npos;
|
| + };
|
| +
|
| + base::EraseIf(argv_, find_switch);
|
| +}
|
| +
|
| void CommandLine::CopySwitchesFrom(const CommandLine& source,
|
| const char* const switches[],
|
| size_t count) {
|
|
|