| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // Build the list of display names, and build the language map. | 119 // Build the list of display names, and build the language map. |
| 120 | 120 |
| 121 // The list of configured locales might have entries not in | 121 // The list of configured locales might have entries not in |
| 122 // base_language_codes. If there are unsupported language variants, | 122 // base_language_codes. If there are unsupported language variants, |
| 123 // but they resolve to backup locale within base_language_codes, also | 123 // but they resolve to backup locale within base_language_codes, also |
| 124 // add them to the list. | 124 // add them to the list. |
| 125 for (std::map<std::string, int>::const_iterator it = language_index.begin(); | 125 for (std::map<std::string, int>::const_iterator it = language_index.begin(); |
| 126 it != language_index.end(); ++it) { | 126 it != language_index.end(); ++it) { |
| 127 const std::string& language_id = it->first; | 127 const std::string& language_id = it->first; |
| 128 | 128 |
| 129 const std::string lang = l10n_util::GetLanguage(language_id); | 129 const size_t dash_pos = language_id.find_first_of('-'); |
| 130 | 130 |
| 131 // Ignore non-specific codes. | 131 // Ignore non-specific codes. |
| 132 if (lang.empty() || lang == language_id) | 132 if (dash_pos == std::string::npos || dash_pos == 0) |
| 133 continue; | 133 continue; |
| 134 | 134 |
| 135 if (std::find(base_language_codes.begin(), | 135 if (std::find(base_language_codes.begin(), |
| 136 base_language_codes.end(), | 136 base_language_codes.end(), |
| 137 language_id) != base_language_codes.end()) { | 137 language_id) != base_language_codes.end()) { |
| 138 // Language is supported. No need to replace | 138 // Language is supported. No need to replace |
| 139 continue; | 139 continue; |
| 140 } | 140 } |
| 141 std::string resolved_locale; | 141 std::string resolved_locale; |
| 142 if (!l10n_util::CheckAndResolveLocale(language_id, &resolved_locale)) | 142 if (!l10n_util::CheckAndResolveLocale(language_id, &resolved_locale)) |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 } | 467 } |
| 468 | 468 |
| 469 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 469 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
| 470 const input_method::InputMethodDescriptor current_input_method = | 470 const input_method::InputMethodDescriptor current_input_method = |
| 471 input_method::InputMethodManager::Get()->GetCurrentInputMethod(); | 471 input_method::InputMethodManager::Get()->GetCurrentInputMethod(); |
| 472 return CreateInputMethodsEntry(current_input_method, | 472 return CreateInputMethodsEntry(current_input_method, |
| 473 current_input_method.id()); | 473 current_input_method.id()); |
| 474 } | 474 } |
| 475 | 475 |
| 476 } // namespace chromeos | 476 } // namespace chromeos |
| OLD | NEW |