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

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

Issue 1200053004: Move more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « components/search_engines/template_url_parser.cc ('k') | components/url_fixer/url_fixer.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/core/language_detection/language_detection_util.h " 5 #include "components/translate/core/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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (chunks.size() < 1 || 2 < chunks.size()) 317 if (chunks.size() < 1 || 2 < chunks.size())
318 return false; 318 return false;
319 319
320 const std::string& main_code = chunks[0]; 320 const std::string& main_code = chunks[0];
321 321
322 if (main_code.size() < 1 || 3 < main_code.size()) 322 if (main_code.size() < 1 || 3 < main_code.size())
323 return false; 323 return false;
324 324
325 for (std::string::const_iterator it = main_code.begin(); 325 for (std::string::const_iterator it = main_code.begin();
326 it != main_code.end(); ++it) { 326 it != main_code.end(); ++it) {
327 if (!IsAsciiAlpha(*it)) 327 if (!base::IsAsciiAlpha(*it))
328 return false; 328 return false;
329 } 329 }
330 330
331 if (chunks.size() == 1) 331 if (chunks.size() == 1)
332 return true; 332 return true;
333 333
334 const std::string& sub_code = chunks[1]; 334 const std::string& sub_code = chunks[1];
335 335
336 if (sub_code.size() != 2) 336 if (sub_code.size() != 2)
337 return false; 337 return false;
338 338
339 for (std::string::const_iterator it = sub_code.begin(); 339 for (std::string::const_iterator it = sub_code.begin();
340 it != sub_code.end(); ++it) { 340 it != sub_code.end(); ++it) {
341 if (!IsAsciiAlpha(*it)) 341 if (!base::IsAsciiAlpha(*it))
342 return false; 342 return false;
343 } 343 }
344 344
345 return true; 345 return true;
346 } 346 }
347 347
348 bool IsSameOrSimilarLanguages(const std::string& page_language, 348 bool IsSameOrSimilarLanguages(const std::string& page_language,
349 const std::string& cld_language) { 349 const std::string& cld_language) {
350 std::vector<std::string> chunks; 350 std::vector<std::string> chunks;
351 351
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // distinguish from English, and the language is one of well-known languages 390 // distinguish from English, and the language is one of well-known languages
391 // which often provide "en-*" meta information mistakenly. 391 // which often provide "en-*" meta information mistakenly.
392 for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) { 392 for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) {
393 if (cld_language == kWellKnownCodesOnWrongConfiguration[i]) 393 if (cld_language == kWellKnownCodesOnWrongConfiguration[i])
394 return true; 394 return true;
395 } 395 }
396 return false; 396 return false;
397 } 397 }
398 398
399 } // namespace translate 399 } // namespace translate
OLDNEW
« no previous file with comments | « components/search_engines/template_url_parser.cc ('k') | components/url_fixer/url_fixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698