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

Side by Side Diff: components/translate/language_detection/language_detection_util.cc

Issue 183853011: Move TrimWhitespace to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/translate/language_detection/language_detection_util.h" 5 #include "components/translate/language_detection/language_detection_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 void CorrectLanguageCodeTypo(std::string* code) { 273 void CorrectLanguageCodeTypo(std::string* code) {
274 DCHECK(code); 274 DCHECK(code);
275 275
276 size_t coma_index = code->find(','); 276 size_t coma_index = code->find(',');
277 if (coma_index != std::string::npos) { 277 if (coma_index != std::string::npos) {
278 // There are more than 1 language specified, just keep the first one. 278 // There are more than 1 language specified, just keep the first one.
279 *code = code->substr(0, coma_index); 279 *code = code->substr(0, coma_index);
280 } 280 }
281 TrimWhitespaceASCII(*code, TRIM_ALL, code); 281 base::TrimWhitespaceASCII(*code, base::TRIM_ALL, code);
282 282
283 // An underscore instead of a dash is a frequent mistake. 283 // An underscore instead of a dash is a frequent mistake.
284 size_t underscore_index = code->find('_'); 284 size_t underscore_index = code->find('_');
285 if (underscore_index != std::string::npos) 285 if (underscore_index != std::string::npos)
286 (*code)[underscore_index] = '-'; 286 (*code)[underscore_index] = '-';
287 287
288 // Change everything up to a dash to lower-case and everything after to upper. 288 // Change everything up to a dash to lower-case and everything after to upper.
289 size_t dash_index = code->find('-'); 289 size_t dash_index = code->find('-');
290 if (dash_index != std::string::npos) { 290 if (dash_index != std::string::npos) {
291 *code = StringToLowerASCII(code->substr(0, dash_index)) + 291 *code = StringToLowerASCII(code->substr(0, dash_index)) +
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // distinguish from English, and the language is one of well-known languages 377 // distinguish from English, and the language is one of well-known languages
378 // which often provide "en-*" meta information mistakenly. 378 // which often provide "en-*" meta information mistakenly.
379 for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) { 379 for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) {
380 if (cld_language == kWellKnownCodesOnWrongConfiguration[i]) 380 if (cld_language == kWellKnownCodesOnWrongConfiguration[i])
381 return true; 381 return true;
382 } 382 }
383 return false; 383 return false;
384 } 384 }
385 385
386 } // namespace translate 386 } // namespace translate
OLDNEW
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698