| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 bool parse_switches = true; | 74 bool parse_switches = true; |
| 75 for (size_t i = 1; i < argv.size(); ++i) { | 75 for (size_t i = 1; i < argv.size(); ++i) { |
| 76 CommandLine::StringType arg = argv[i]; | 76 CommandLine::StringType arg = argv[i]; |
| 77 base::TrimWhitespace(arg, base::TRIM_ALL, &arg); | 77 base::TrimWhitespace(arg, base::TRIM_ALL, &arg); |
| 78 | 78 |
| 79 CommandLine::StringType switch_string; | 79 CommandLine::StringType switch_string; |
| 80 CommandLine::StringType switch_value; | 80 CommandLine::StringType switch_value; |
| 81 parse_switches &= (arg != kSwitchTerminator); | 81 parse_switches &= (arg != kSwitchTerminator); |
| 82 if (parse_switches && IsSwitch(arg, &switch_string, &switch_value)) { | 82 if (parse_switches && IsSwitch(arg, &switch_string, &switch_value)) { |
| 83 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 84 command_line.AppendSwitchNative(WideToASCII(switch_string), switch_value); | 84 command_line.AppendSwitchNative(base::UTF16ToASCII(switch_string), |
| 85 switch_value); |
| 85 #elif defined(OS_POSIX) | 86 #elif defined(OS_POSIX) |
| 86 command_line.AppendSwitchNative(switch_string, switch_value); | 87 command_line.AppendSwitchNative(switch_string, switch_value); |
| 87 #endif | 88 #endif |
| 88 } else { | 89 } else { |
| 89 command_line.AppendArgNative(arg); | 90 command_line.AppendArgNative(arg); |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 | 94 |
| 94 // Lowercase switches for backwards compatiblity *on Windows*. | 95 // Lowercase switches for backwards compatiblity *on Windows*. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 302 } |
| 302 | 303 |
| 303 std::string CommandLine::GetSwitchValueASCII( | 304 std::string CommandLine::GetSwitchValueASCII( |
| 304 const std::string& switch_string) const { | 305 const std::string& switch_string) const { |
| 305 StringType value = GetSwitchValueNative(switch_string); | 306 StringType value = GetSwitchValueNative(switch_string); |
| 306 if (!IsStringASCII(value)) { | 307 if (!IsStringASCII(value)) { |
| 307 DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII."; | 308 DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII."; |
| 308 return std::string(); | 309 return std::string(); |
| 309 } | 310 } |
| 310 #if defined(OS_WIN) | 311 #if defined(OS_WIN) |
| 311 return WideToASCII(value); | 312 return base::UTF16ToASCII(value); |
| 312 #else | 313 #else |
| 313 return value; | 314 return value; |
| 314 #endif | 315 #endif |
| 315 } | 316 } |
| 316 | 317 |
| 317 FilePath CommandLine::GetSwitchValuePath( | 318 FilePath CommandLine::GetSwitchValuePath( |
| 318 const std::string& switch_string) const { | 319 const std::string& switch_string) const { |
| 319 return FilePath(GetSwitchValueNative(switch_string)); | 320 return FilePath(GetSwitchValueNative(switch_string)); |
| 320 } | 321 } |
| 321 | 322 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 int num_args = 0; | 430 int num_args = 0; |
| 430 wchar_t** args = NULL; | 431 wchar_t** args = NULL; |
| 431 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); | 432 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); |
| 432 | 433 |
| 433 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " | 434 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " |
| 434 << command_line; | 435 << command_line; |
| 435 InitFromArgv(num_args, args); | 436 InitFromArgv(num_args, args); |
| 436 LocalFree(args); | 437 LocalFree(args); |
| 437 } | 438 } |
| 438 #endif | 439 #endif |
| OLD | NEW |