OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |