OLD | NEW |
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 "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // Concatenate most_relevant_locales_display_names and display_names. | 226 // Concatenate most_relevant_locales_display_names and display_names. |
227 // Insert special divider in between. | 227 // Insert special divider in between. |
228 std::vector<base::string16> out_display_names; | 228 std::vector<base::string16> out_display_names; |
229 for (size_t i = 0; i < most_relevant_locales_display_names.size(); ++i) { | 229 for (size_t i = 0; i < most_relevant_locales_display_names.size(); ++i) { |
230 if (most_relevant_locales_display_names[i].size() == 0) | 230 if (most_relevant_locales_display_names[i].size() == 0) |
231 continue; | 231 continue; |
232 out_display_names.push_back(most_relevant_locales_display_names[i]); | 232 out_display_names.push_back(most_relevant_locales_display_names[i]); |
233 } | 233 } |
234 | 234 |
235 base::string16 divider16; | 235 base::string16 divider16; |
236 if (insert_divider) { | 236 if (insert_divider && !out_display_names.empty()) { |
| 237 // Insert a divider if requested, but only if |
| 238 // |most_relevant_locales_display_names| is not empty. |
237 divider16 = base::ASCIIToUTF16(kMostRelevantLanguagesDivider); | 239 divider16 = base::ASCIIToUTF16(kMostRelevantLanguagesDivider); |
238 out_display_names.push_back(divider16); | 240 out_display_names.push_back(divider16); |
239 } | 241 } |
240 | 242 |
241 std::copy(display_names.begin(), | 243 std::copy(display_names.begin(), |
242 display_names.end(), | 244 display_names.end(), |
243 std::back_inserter(out_display_names)); | 245 std::back_inserter(out_display_names)); |
244 | 246 |
245 // Build the language list from the language map. | 247 // Build the language list from the language map. |
246 scoped_ptr<base::ListValue> language_list(new base::ListValue()); | 248 scoped_ptr<base::ListValue> language_list(new base::ListValue()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 } | 453 } |
452 | 454 |
453 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 455 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
454 const input_method::InputMethodDescriptor current_input_method = | 456 const input_method::InputMethodDescriptor current_input_method = |
455 input_method::InputMethodManager::Get()->GetCurrentInputMethod(); | 457 input_method::InputMethodManager::Get()->GetCurrentInputMethod(); |
456 return CreateInputMethodsEntry(current_input_method, | 458 return CreateInputMethodsEntry(current_input_method, |
457 current_input_method.id()); | 459 current_input_method.id()); |
458 } | 460 } |
459 | 461 |
460 } // namespace chromeos | 462 } // namespace chromeos |
OLD | NEW |