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

Side by Side Diff: chrome/browser/chromeos/login/language_list.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/login/language_list.h" 5 #include "chrome/browser/chromeos/login/language_list.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 native_names_.find(locale_names_[i]); 71 native_names_.find(locale_names_[i]);
72 DCHECK(locale_data != native_names_.end()); 72 DCHECK(locale_data != native_names_.end());
73 if (locale_data->second.locale_code == locale) 73 if (locale_data->second.locale_code == locale)
74 return static_cast<int>(i); 74 return static_cast<int>(i);
75 } 75 }
76 return -1; 76 return -1;
77 } 77 }
78 78
79 void LanguageList::CopySpecifiedLanguagesUp(const std::string& locale_codes) { 79 void LanguageList::CopySpecifiedLanguagesUp(const std::string& locale_codes) {
80 DCHECK(!locale_names_.empty()); 80 DCHECK(!locale_names_.empty());
81 std::vector<std::string> locale_codes_vector; 81 for (const std::string& code : base::SplitString(
82 base::SplitString(locale_codes, ',', &locale_codes_vector); 82 locale_codes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
83 for (size_t i = 0; i != locale_codes_vector.size(); ++i) { 83 const int locale_index = GetIndexFromLocale(code);
84 const int locale_index = GetIndexFromLocale(locale_codes_vector[i]);
85 CHECK_NE(locale_index, -1); 84 CHECK_NE(locale_index, -1);
86 locale_names_.insert(locale_names_.begin(), locale_names_[locale_index]); 85 locale_names_.insert(locale_names_.begin(), locale_names_[locale_index]);
87 } 86 }
88 } 87 }
89 88
90 void LanguageList::InitNativeNames( 89 void LanguageList::InitNativeNames(
91 const std::vector<std::string>& locale_codes) { 90 const std::vector<std::string>& locale_codes) {
92 const std::string app_locale = g_browser_process->GetApplicationLocale(); 91 const std::string app_locale = g_browser_process->GetApplicationLocale();
93 for (size_t i = 0; i < locale_codes.size(); ++i) { 92 for (size_t i = 0; i < locale_codes.size(); ++i) {
94 const char* locale_code = locale_codes[i].c_str(); 93 const char* locale_code = locale_codes[i].c_str();
(...skipping 10 matching lines...) Expand all
105 native_names_[name_in_current_ui] = 104 native_names_[name_in_current_ui] =
106 LocaleData(name_native, locale_codes[i]); 105 LocaleData(name_native, locale_codes[i]);
107 } 106 }
108 107
109 // Sort using locale specific sorter. 108 // Sort using locale specific sorter.
110 l10n_util::SortStrings16(g_browser_process->GetApplicationLocale(), 109 l10n_util::SortStrings16(g_browser_process->GetApplicationLocale(),
111 &locale_names_); 110 &locale_names_);
112 } 111 }
113 112
114 } // namespace chromeos 113 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/chrome_restart_request.cc ('k') | chrome/browser/chromeos/power/cpu_data_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698