Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/l10n_util.h

Issue 686863002: Revert "Revert of Revert of Revert of ChromeOS NetworkScreenHandler should not call CheckAndResolve… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // If |language_switch_result| is null, assume current browser locale is already
50 // correct and has been successfully loaded.
51 void ResolveUILanguageList(
52 scoped_ptr<locale_util::LanguageSwitchResult> language_switch_result,
53 UILanguageListResolvedCallback callback);
54
55 // Returns a minimal list of UI languages, which consists of active language
56 // only. It is used as a placeholder until ResolveUILanguageList() finishes
57 // on BlockingPool.
58 scoped_ptr<base::ListValue> GetMinimalUILanguageList();
59
40 // Returns the most first entry of |most_relevant_language_codes| that is 60 // Returns the most first entry of |most_relevant_language_codes| that is
41 // actually available (present in |available_locales|). If none of the entries 61 // actually available (present in |available_locales|). If none of the entries
42 // are present in |available_locales|, returns the |fallback_locale|. 62 // are present in |available_locales|, returns the |fallback_locale|.
43 std::string FindMostRelevantLocale( 63 std::string FindMostRelevantLocale(
44 const std::vector<std::string>& most_relevant_language_codes, 64 const std::vector<std::string>& most_relevant_language_codes,
45 const base::ListValue& available_locales, 65 const base::ListValue& available_locales,
46 const std::string& fallback_locale); 66 const std::string& fallback_locale);
47 67
48 // Return a list of supported accept languages. The listed languages can be used 68 // 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: 69 // in the Accept-Language header. The return value will look like:
50 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, ...] 70 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, ...]
51 // The most relevant languages, read from initial_locale in VPD, will be first 71 // The most relevant languages, read from initial_locale in VPD, will be first
52 // in the list. 72 // in the list.
53 scoped_ptr<base::ListValue> GetAcceptLanguageList(); 73 scoped_ptr<base::ListValue> GetAcceptLanguageList();
54 74
55 // Return a list of keyboard layouts that can be used for |locale| on the login 75 // Return a list of keyboard layouts that can be used for |locale| on the login
56 // screen. Each list entry is a dictionary that contains data such as an ID and 76 // screen. Each list entry is a dictionary that contains data such as an ID and
57 // a display name. The list will consist of the device's hardware layouts, 77 // a display name. The list will consist of the device's hardware layouts,
58 // followed by a divider and locale-specific keyboard layouts, if any. The list 78 // followed by a divider and locale-specific keyboard layouts, if any. The list
59 // will also always contain the US keyboard layout. If |selected| matches the ID 79 // will also always contain the US keyboard layout. If |selected| matches the ID
60 // of any entry in the resulting list, that entry will be marked as selected. 80 // of any entry in the resulting list, that entry will be marked as selected.
61 // In addition to returning the list of keyboard layouts, this function also 81 // In addition to returning the list of keyboard layouts, this function also
62 // activates them so that they can be selected by the user (e.g. by cycling 82 // activates them if |activate_keyboards| is true, so that they can be selected
63 // through keyboard layouts via keyboard shortcuts). 83 // by the user (e.g. by cycling through keyboard layouts via keyboard
84 // shortcuts).
64 scoped_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts( 85 scoped_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts(
65 const std::string& locale, 86 const std::string& locale,
66 const std::string& selected); 87 const std::string& selected,
88 bool activate_keyboards);
67 89
68 // Invokes |callback| with a list of keyboard layouts that can be used for 90 // Invokes |callback| with a list of keyboard layouts that can be used for
69 // |locale|. Each list entry is a dictionary that contains data such as an ID 91 // |locale|. Each list entry is a dictionary that contains data such as an ID
70 // and a display name. The list will consist of the device's hardware layouts, 92 // and a display name. The list will consist of the device's hardware layouts,
71 // followed by a divider and locale-specific keyboard layouts, if any. All 93 // followed by a divider and locale-specific keyboard layouts, if any. All
72 // layouts supported for |locale| are returned, including those that produce 94 // layouts supported for |locale| are returned, including those that produce
73 // non-Latin characters by default. 95 // non-Latin characters by default.
74 typedef base::Callback<void(scoped_ptr<base::ListValue>)> 96 typedef base::Callback<void(scoped_ptr<base::ListValue>)>
75 GetKeyboardLayoutsForLocaleCallback; 97 GetKeyboardLayoutsForLocaleCallback;
76 void GetKeyboardLayoutsForLocale( 98 void GetKeyboardLayoutsForLocale(
77 const GetKeyboardLayoutsForLocaleCallback& callback, 99 const GetKeyboardLayoutsForLocaleCallback& callback,
78 const std::string& locale); 100 const std::string& locale);
79 101
80 // Returns the current keyboard layout, expressed as a dictionary that contains 102 // Returns the current keyboard layout, expressed as a dictionary that contains
81 // data such as an ID and a display name. 103 // data such as an ID and a display name.
82 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout(); 104 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout();
83 105
84 } // namespace chromeos 106 } // namespace chromeos
85 107
86 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_ 108 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698