| 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 <stddef.h> |    7 #include <stddef.h> | 
|    8  |    8  | 
|    9 #include <algorithm> |  | 
|   10 #include <iterator> |    9 #include <iterator> | 
|   11 #include <map> |   10 #include <map> | 
|   12 #include <set> |   11 #include <set> | 
|   13 #include <utility> |   12 #include <utility> | 
|   14  |   13  | 
|   15 #include "base/bind.h" |   14 #include "base/bind.h" | 
|   16 #include "base/i18n/rtl.h" |   15 #include "base/i18n/rtl.h" | 
|   17 #include "base/location.h" |   16 #include "base/location.h" | 
|   18 #include "base/logging.h" |   17 #include "base/logging.h" | 
|   19 #include "base/memory/ref_counted.h" |   18 #include "base/memory/ref_counted.h" | 
|   20 #include "base/sequenced_task_runner.h" |   19 #include "base/sequenced_task_runner.h" | 
 |   20 #include "base/stl_util.h" | 
|   21 #include "base/strings/string16.h" |   21 #include "base/strings/string16.h" | 
|   22 #include "base/strings/stringprintf.h" |   22 #include "base/strings/stringprintf.h" | 
|   23 #include "base/strings/utf_string_conversions.h" |   23 #include "base/strings/utf_string_conversions.h" | 
|   24 #include "base/task_runner_util.h" |   24 #include "base/task_runner_util.h" | 
|   25 #include "base/threading/sequenced_worker_pool.h" |   25 #include "base/threading/sequenced_worker_pool.h" | 
|   26 #include "base/values.h" |   26 #include "base/values.h" | 
|   27 #include "chrome/browser/browser_process.h" |   27 #include "chrome/browser/browser_process.h" | 
|   28 #include "chrome/browser/chromeos/customization/customization_document.h" |   28 #include "chrome/browser/chromeos/customization/customization_document.h" | 
|   29 #include "chrome/browser/chromeos/input_method/input_method_util.h" |   29 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 
|   30 #include "chrome/browser/chromeos/profiles/profile_helper.h" |   30 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  146   for (std::map<std::string, int>::const_iterator it = language_index.begin(); |  146   for (std::map<std::string, int>::const_iterator it = language_index.begin(); | 
|  147        it != language_index.end(); ++it) { |  147        it != language_index.end(); ++it) { | 
|  148     const std::string& language_id = it->first; |  148     const std::string& language_id = it->first; | 
|  149  |  149  | 
|  150     const std::string lang = l10n_util::GetLanguage(language_id); |  150     const std::string lang = l10n_util::GetLanguage(language_id); | 
|  151  |  151  | 
|  152     // Ignore non-specific codes. |  152     // Ignore non-specific codes. | 
|  153     if (lang.empty() || lang == language_id) |  153     if (lang.empty() || lang == language_id) | 
|  154       continue; |  154       continue; | 
|  155  |  155  | 
|  156     if (std::find(base_language_codes.begin(), |  156     if (ContainsValue(base_language_codes, language_id)) { | 
|  157                   base_language_codes.end(), |  | 
|  158                   language_id) != base_language_codes.end()) { |  | 
|  159       // Language is supported. No need to replace |  157       // Language is supported. No need to replace | 
|  160       continue; |  158       continue; | 
|  161     } |  159     } | 
|  162     std::string resolved_locale; |  160     std::string resolved_locale; | 
|  163     if (!l10n_util::CheckAndResolveLocale(language_id, &resolved_locale)) |  161     if (!l10n_util::CheckAndResolveLocale(language_id, &resolved_locale)) | 
|  164       continue; |  162       continue; | 
|  165  |  163  | 
|  166     if (std::find(base_language_codes.begin(), |  164     if (!ContainsValue(base_language_codes, resolved_locale)) { | 
|  167                   base_language_codes.end(), |  | 
|  168                   resolved_locale) == base_language_codes.end()) { |  | 
|  169       // Resolved locale is not supported. |  165       // Resolved locale is not supported. | 
|  170       continue; |  166       continue; | 
|  171     } |  167     } | 
|  172  |  168  | 
|  173     const base::string16 display_name = |  169     const base::string16 display_name = | 
|  174         l10n_util::GetDisplayNameForLocale(language_id, app_locale, true); |  170         l10n_util::GetDisplayNameForLocale(language_id, app_locale, true); | 
|  175     const base::string16 native_display_name = |  171     const base::string16 native_display_name = | 
|  176         l10n_util::GetDisplayNameForLocale( |  172         l10n_util::GetDisplayNameForLocale( | 
|  177             language_id, language_id, true); |  173             language_id, language_id, true); | 
|  178  |  174  | 
|  179     language_map[display_name] = |  175     language_map[display_name] = | 
|  180         std::make_pair(language_id, native_display_name); |  176         std::make_pair(language_id, native_display_name); | 
|  181  |  177  | 
|  182     most_relevant_locales_display_names[it->second] = display_name; |  178     most_relevant_locales_display_names[it->second] = display_name; | 
|  183     ++most_relevant_locales_count; |  179     ++most_relevant_locales_count; | 
|  184   } |  180   } | 
|  185  |  181  | 
|  186   // Translate language codes, generated from input methods. |  182   // Translate language codes, generated from input methods. | 
|  187   for (std::set<std::string>::const_iterator it = language_codes.begin(); |  183   for (std::set<std::string>::const_iterator it = language_codes.begin(); | 
|  188        it != language_codes.end(); ++it) { |  184        it != language_codes.end(); ++it) { | 
|  189      // Exclude the language which is not in |base_langauge_codes| even it has |  185      // Exclude the language which is not in |base_langauge_codes| even it has | 
|  190      // input methods. |  186      // input methods. | 
|  191     if (std::find(base_language_codes.begin(), |  187     if (!ContainsValue(base_language_codes, *it)) | 
|  192                   base_language_codes.end(), |  | 
|  193                   *it) == base_language_codes.end()) { |  | 
|  194       continue; |  188       continue; | 
|  195     } |  | 
|  196  |  189  | 
|  197     const base::string16 display_name = |  190     const base::string16 display_name = | 
|  198         l10n_util::GetDisplayNameForLocale(*it, app_locale, true); |  191         l10n_util::GetDisplayNameForLocale(*it, app_locale, true); | 
|  199     const base::string16 native_display_name = |  192     const base::string16 native_display_name = | 
|  200         l10n_util::GetDisplayNameForLocale(*it, *it, true); |  193         l10n_util::GetDisplayNameForLocale(*it, *it, true); | 
|  201  |  194  | 
|  202     language_map[display_name] = |  195     language_map[display_name] = | 
|  203         std::make_pair(*it, native_display_name); |  196         std::make_pair(*it, native_display_name); | 
|  204  |  197  | 
|  205     const std::map<std::string, int>::const_iterator index_pos = |  198     const std::map<std::string, int>::const_iterator index_pos = | 
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  594 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |  587 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 
|  595   const input_method::InputMethodDescriptor current_input_method = |  588   const input_method::InputMethodDescriptor current_input_method = | 
|  596       input_method::InputMethodManager::Get() |  589       input_method::InputMethodManager::Get() | 
|  597           ->GetActiveIMEState() |  590           ->GetActiveIMEState() | 
|  598           ->GetCurrentInputMethod(); |  591           ->GetCurrentInputMethod(); | 
|  599   return CreateInputMethodsEntry(current_input_method, |  592   return CreateInputMethodsEntry(current_input_method, | 
|  600                                  current_input_method.id()); |  593                                  current_input_method.id()); | 
|  601 } |  594 } | 
|  602  |  595  | 
|  603 }  // namespace chromeos |  596 }  // namespace chromeos | 
| OLD | NEW |