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

Side by Side Diff: trunk/src/base/command_line.cc

Issue 198163004: Revert 257524 "Move IsStringASCII/UTF8 to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/src/base/i18n/streaming_utf8_validator_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]); 298 TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
299 } 299 }
300 300
301 bool CommandLine::HasSwitch(const std::string& switch_string) const { 301 bool CommandLine::HasSwitch(const std::string& switch_string) const {
302 return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end(); 302 return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end();
303 } 303 }
304 304
305 std::string CommandLine::GetSwitchValueASCII( 305 std::string CommandLine::GetSwitchValueASCII(
306 const std::string& switch_string) const { 306 const std::string& switch_string) const {
307 StringType value = GetSwitchValueNative(switch_string); 307 StringType value = GetSwitchValueNative(switch_string);
308 if (!base::IsStringASCII(value)) { 308 if (!IsStringASCII(value)) {
309 DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII."; 309 DLOG(WARNING) << "Value of switch (" << switch_string << ") must be ASCII.";
310 return std::string(); 310 return std::string();
311 } 311 }
312 #if defined(OS_WIN) 312 #if defined(OS_WIN)
313 return UTF16ToASCII(value); 313 return UTF16ToASCII(value);
314 #else 314 #else
315 return value; 315 return value;
316 #endif 316 #endif
317 } 317 }
318 318
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Erase only the first kSwitchTerminator (maybe "--" is a legitimate page?) 380 // Erase only the first kSwitchTerminator (maybe "--" is a legitimate page?)
381 StringVector::iterator switch_terminator = 381 StringVector::iterator switch_terminator =
382 std::find(args.begin(), args.end(), kSwitchTerminator); 382 std::find(args.begin(), args.end(), kSwitchTerminator);
383 if (switch_terminator != args.end()) 383 if (switch_terminator != args.end())
384 args.erase(switch_terminator); 384 args.erase(switch_terminator);
385 return args; 385 return args;
386 } 386 }
387 387
388 void CommandLine::AppendArg(const std::string& value) { 388 void CommandLine::AppendArg(const std::string& value) {
389 #if defined(OS_WIN) 389 #if defined(OS_WIN)
390 DCHECK(base::IsStringUTF8(value)); 390 DCHECK(IsStringUTF8(value));
391 AppendArgNative(base::UTF8ToWide(value)); 391 AppendArgNative(UTF8ToWide(value));
392 #elif defined(OS_POSIX) 392 #elif defined(OS_POSIX)
393 AppendArgNative(value); 393 AppendArgNative(value);
394 #endif 394 #endif
395 } 395 }
396 396
397 void CommandLine::AppendArgPath(const FilePath& path) { 397 void CommandLine::AppendArgPath(const FilePath& path) {
398 AppendArgNative(path.value()); 398 AppendArgNative(path.value());
399 } 399 }
400 400
401 void CommandLine::AppendArgNative(const CommandLine::StringType& value) { 401 void CommandLine::AppendArgNative(const CommandLine::StringType& value) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); 433 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args);
434 434
435 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " 435 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: "
436 << UTF16ToUTF8(command_line); 436 << UTF16ToUTF8(command_line);
437 InitFromArgv(num_args, args); 437 InitFromArgv(num_args, args);
438 LocalFree(args); 438 LocalFree(args);
439 } 439 }
440 #endif 440 #endif
441 441
442 } // namespace base 442 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | trunk/src/base/i18n/streaming_utf8_validator_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698