Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string16.h" | |
| 14 #include "chrome/browser/chromeos/base/locale_util.h" | |
| 13 | 15 |
| 14 namespace base { | 16 namespace base { |
| 15 class DictionaryValue; | 17 class DictionaryValue; |
| 16 class ListValue; | 18 class ListValue; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace chromeos { | 21 namespace chromeos { |
| 20 | 22 |
| 23 typedef base::Callback<void(scoped_ptr<base::ListValue> /* new_language_list */, | |
| 24 std::string /* new_language_list_locale */, | |
| 25 std::string /* new_selected_language */)> | |
| 26 UILanguageListResolvedCallback; | |
| 27 | |
| 21 // GetUILanguageList() returns a concatenated list of the most relevant | 28 // GetUILanguageList() returns a concatenated list of the most relevant |
| 22 // languages followed by all others. An entry with its "code" attribute set to | 29 // languages followed by all others. An entry with its "code" attribute set to |
| 23 // this value is inserted in between. | 30 // this value is inserted in between. |
| 24 extern const char kMostRelevantLanguagesDivider[]; | 31 extern const char kMostRelevantLanguagesDivider[]; |
| 25 | 32 |
| 26 // Utility methods for retrieving lists of supported locales and input methods / | 33 // Utility methods for retrieving lists of supported locales and input methods / |
| 27 // keyboard layouts during OOBE and on the login screen. | 34 // keyboard layouts during OOBE and on the login screen. |
| 28 | 35 |
| 36 // Helper function for GetUILanguageList. | |
| 37 // Requires |language_display_name| after | |
| 38 // base::i18n::UnadjustStringForLocaleDirection. | |
| 39 const std::string GetLanguageDirectionality( | |
| 40 const base::string16& language_display_name); | |
| 41 | |
| 29 // Return a list of languages in which the UI can be shown. Each list entry is a | 42 // Return a list of languages in which the UI can be shown. Each list entry is a |
| 30 // dictionary that contains data such as the language's locale code and a | 43 // dictionary that contains data such as the language's locale code and a |
| 31 // display name. The list will consist of the |most_relevant_language_codes|, | 44 // display name. The list will consist of the |most_relevant_language_codes|, |
| 32 // followed by a divider and all other supported languages after that. If | 45 // followed by a divider and all other supported languages after that. If |
| 33 // |most_relevant_language_codes| is NULL, the most relevant languages are read | 46 // |most_relevant_language_codes| is NULL, the most relevant languages are read |
| 34 // from initial_locale in VPD. If |selected| matches the locale code of any | 47 // from initial_locale in VPD. If |selected| matches the locale code of any |
| 35 // entry in the resulting list, that entry will be marked as selected. | 48 // entry in the resulting list, that entry will be marked as selected. |
| 36 scoped_ptr<base::ListValue> GetUILanguageList( | 49 scoped_ptr<base::ListValue> GetUILanguageList( |
| 37 const std::vector<std::string>* most_relevant_language_codes, | 50 const std::vector<std::string>* most_relevant_language_codes, |
| 38 const std::string& selected); | 51 const std::string& selected); |
| 39 | 52 |
| 53 // Must be called on UI thread. Runs GetUILanguageList(), on Blocking Pool, | |
| 54 // and calls |callback| on UI thread with result. | |
| 55 void ResolveUILanguageList( | |
| 56 scoped_ptr<locale_util::LanguageSwitchResult> language_switch_result, | |
|
dzhioev (left Google)
2014/10/02 14:12:10
Please, describe in a comment what's happening whe
Alexander Alekseev
2014/10/02 19:05:03
Done.
| |
| 57 UILanguageListResolvedCallback callback); | |
| 58 | |
| 59 // Returns a minimal list of UI languages, which consists of active language | |
| 60 // only. It is used as a placeholder until ResolveUILanguageList() finishes | |
| 61 // on BlockingPool. | |
| 62 scoped_ptr<base::ListValue> GetMinimalUILanguageList(); | |
| 63 | |
| 40 // Returns the most first entry of |most_relevant_language_codes| that is | 64 // Returns the most first entry of |most_relevant_language_codes| that is |
| 41 // actually available (present in |available_locales|). If none of the entries | 65 // actually available (present in |available_locales|). If none of the entries |
| 42 // are present in |available_locales|, returns the |fallback_locale|. | 66 // are present in |available_locales|, returns the |fallback_locale|. |
| 43 std::string FindMostRelevantLocale( | 67 std::string FindMostRelevantLocale( |
| 44 const std::vector<std::string>& most_relevant_language_codes, | 68 const std::vector<std::string>& most_relevant_language_codes, |
| 45 const base::ListValue& available_locales, | 69 const base::ListValue& available_locales, |
| 46 const std::string& fallback_locale); | 70 const std::string& fallback_locale); |
| 47 | 71 |
| 48 // Return a list of supported accept languages. The listed languages can be used | 72 // Return a list of supported accept languages. The listed languages can be used |
| 49 // in the Accept-Language header. The return value will look like: | 73 // in the Accept-Language header. The return value will look like: |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 77 const GetKeyboardLayoutsForLocaleCallback& callback, | 101 const GetKeyboardLayoutsForLocaleCallback& callback, |
| 78 const std::string& locale); | 102 const std::string& locale); |
| 79 | 103 |
| 80 // Returns the current keyboard layout, expressed as a dictionary that contains | 104 // Returns the current keyboard layout, expressed as a dictionary that contains |
| 81 // data such as an ID and a display name. | 105 // data such as an ID and a display name. |
| 82 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout(); | 106 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout(); |
| 83 | 107 |
| 84 } // namespace chromeos | 108 } // namespace chromeos |
| 85 | 109 |
| 86 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ | 110 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ |
| OLD | NEW |