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 |
29 // Return a list of languages in which the UI can be shown. Each list entry is a | 36 // 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 | 37 // 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|, | 38 // 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 | 39 // 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 | 40 // |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 | 41 // 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. | 42 // entry in the resulting list, that entry will be marked as selected. |
36 scoped_ptr<base::ListValue> GetUILanguageList( | 43 scoped_ptr<base::ListValue> GetUILanguageList( |
37 const std::vector<std::string>* most_relevant_language_codes, | 44 const std::vector<std::string>* most_relevant_language_codes, |
38 const std::string& selected); | 45 const std::string& selected); |
39 | 46 |
| 47 // Must be called on UI thread. Runs GetUILanguageList(), on Blocking Pool, |
| 48 // and calls |callback| on UI thread with result. |
| 49 void ResolveUILanguageList( |
| 50 scoped_ptr<locale_util::LanguageSwitchResult> language_switch_result, |
| 51 UILanguageListResolvedCallback callback); |
| 52 |
| 53 // Returns a minimal list of UI languages, which consists of active language |
| 54 // only. It is used as a placeholder until ResolveUILanguageList() finishes |
| 55 // on BlockingPool. |
| 56 scoped_ptr<base::ListValue> GetMinimalUILanguageList(); |
| 57 |
40 // Returns the most first entry of |most_relevant_language_codes| that is | 58 // Returns the most first entry of |most_relevant_language_codes| that is |
41 // actually available (present in |available_locales|). If none of the entries | 59 // actually available (present in |available_locales|). If none of the entries |
42 // are present in |available_locales|, returns the |fallback_locale|. | 60 // are present in |available_locales|, returns the |fallback_locale|. |
43 std::string FindMostRelevantLocale( | 61 std::string FindMostRelevantLocale( |
44 const std::vector<std::string>& most_relevant_language_codes, | 62 const std::vector<std::string>& most_relevant_language_codes, |
45 const base::ListValue& available_locales, | 63 const base::ListValue& available_locales, |
46 const std::string& fallback_locale); | 64 const std::string& fallback_locale); |
47 | 65 |
48 // Return a list of supported accept languages. The listed languages can be used | 66 // 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: | 67 // in the Accept-Language header. The return value will look like: |
(...skipping 27 matching lines...) Expand all Loading... |
77 const GetKeyboardLayoutsForLocaleCallback& callback, | 95 const GetKeyboardLayoutsForLocaleCallback& callback, |
78 const std::string& locale); | 96 const std::string& locale); |
79 | 97 |
80 // Returns the current keyboard layout, expressed as a dictionary that contains | 98 // Returns the current keyboard layout, expressed as a dictionary that contains |
81 // data such as an ID and a display name. | 99 // data such as an ID and a display name. |
82 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout(); | 100 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout(); |
83 | 101 |
84 } // namespace chromeos | 102 } // namespace chromeos |
85 | 103 |
86 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ | 104 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ |
OLD | NEW |