• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 
14 namespace base {
15 class DictionaryValue;
16 class ListValue;
17 }
18 
19 namespace chromeos {
20 
21 // GetUILanguageList() returns a concatenated list of the most relevant
22 // languages followed by all others. An entry with its "code" attribute set to
23 // this value is inserted in between.
24 extern const char kMostRelevantLanguagesDivider[];
25 
26 // Utility methods for retrieving lists of supported locales and input methods /
27 // keyboard layouts during OOBE and on the login screen.
28 
29 // 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
31 // 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
33 // |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
35 // entry in the resulting list, that entry will be marked as selected.
36 scoped_ptr<base::ListValue> GetUILanguageList(
37     const std::vector<std::string>* most_relevant_language_codes,
38     const std::string& selected);
39 
40 // Returns the most first entry of |most_relevant_language_codes| that is
41 // actually available (present in |available_locales|). If none of the entries
42 // are present in |available_locales|, returns the |fallback_locale|.
43 std::string FindMostRelevantLocale(
44     const std::vector<std::string>& most_relevant_language_codes,
45     const base::ListValue& available_locales,
46     const std::string& fallback_locale);
47 
48 // 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:
50 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, ...]
51 // The most relevant languages, read from initial_locale in VPD, will be first
52 // in the list.
53 scoped_ptr<base::ListValue> GetAcceptLanguageList();
54 
55 // 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
57 // 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
59 // 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.
61 // 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
63 // through keyboard layouts via keyboard shortcuts).
64 scoped_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts(
65     const std::string& locale,
66     const std::string& selected);
67 
68 // 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
70 // 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
72 // layouts supported for |locale| are returned, including those that produce
73 // non-Latin characters by default.
74 typedef base::Callback<void(scoped_ptr<base::ListValue>)>
75     GetKeyboardLayoutsForLocaleCallback;
76 void GetKeyboardLayoutsForLocale(
77     const GetKeyboardLayoutsForLocaleCallback& callback,
78     const std::string& locale);
79 
80 // Returns the current keyboard layout, expressed as a dictionary that contains
81 // data such as an ID and a display name.
82 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout();
83 
84 }  // namespace chromeos
85 
86 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_L10N_UTIL_H_
87