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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h

Issue 397723002: Extract l10n-related parts of NetworkScreenHandler to a helper file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Derive list of input methods from actual locale, not requested locale. This is how it used to work … Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H _ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H _
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H _ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLER_H _
7 7
8 #include <string>
9
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
9 #include "chrome/browser/ui/webui/options/language_options_handler.h" 12 #include "chrome/browser/ui/webui/options/language_options_handler.h"
10 #include "chromeos/ime/component_extension_ime_manager.h" 13 #include "chromeos/ime/component_extension_ime_manager.h"
11 #include "chromeos/ime/input_method_descriptor.h" 14 #include "chromeos/ime/input_method_descriptor.h"
12 15
13 namespace chromeos { 16 namespace chromeos {
14 namespace options { 17 namespace options {
15 18
16 // GetUILanguageList() returns concatenated list of list of vendor languages
17 // followed by other languages. An entry with "code" attribute set to this value
18 // is inserted in between.
19 extern const char kVendorOtherLanguagesListDivider[];
20
21 // Language options page UI handler for Chrome OS. For non-Chrome OS, 19 // Language options page UI handler for Chrome OS. For non-Chrome OS,
22 // see LanguageOptionsHnadler. 20 // see LanguageOptionsHnadler.
23 class CrosLanguageOptionsHandler 21 class CrosLanguageOptionsHandler
24 : public ::options::LanguageOptionsHandlerCommon, 22 : public ::options::LanguageOptionsHandlerCommon,
25 public ComponentExtensionIMEManager::Observer { 23 public ComponentExtensionIMEManager::Observer {
26 public: 24 public:
27 CrosLanguageOptionsHandler(); 25 CrosLanguageOptionsHandler();
28 virtual ~CrosLanguageOptionsHandler(); 26 virtual ~CrosLanguageOptionsHandler();
29 27
30 // OptionsPageUIHandler implementation. 28 // OptionsPageUIHandler implementation.
31 virtual void GetLocalizedValues( 29 virtual void GetLocalizedValues(
32 base::DictionaryValue* localized_strings) OVERRIDE; 30 base::DictionaryValue* localized_strings) OVERRIDE;
33 31
34 // DOMMessageHandler implementation. 32 // DOMMessageHandler implementation.
35 virtual void RegisterMessages() OVERRIDE; 33 virtual void RegisterMessages() OVERRIDE;
36 34
37 // The following static methods are public for ease of testing. 35 // The following static methods are public for ease of testing.
38 36
39 // Gets the list of input methods from the given input descriptors. 37 // Gets the list of supported input methods.
40 // The return value will look like: 38 // The return value will look like:
41 // [{'id': 'pinyin', 'displayName': 'Pinyin', 39 // [{'id': 'pinyin', 'displayName': 'Pinyin',
42 // 'languageCodeSet': {'zh-CW': true}}, ...] 40 // 'languageCodeSet': {'zh-CW': true}}, ...]
43 // 41 //
44 // Note that true in languageCodeSet does not mean anything. We just use 42 // Note that true in languageCodeSet does not mean anything. We just use
45 // the dictionary as a set. 43 // the dictionary as a set.
46 static base::ListValue* GetInputMethodList( 44 static base::ListValue* GetInputMethodList();
47 const input_method::InputMethodDescriptors& descriptors);
48
49 // Gets the list of accept languages with the given input descriptors.
50 // Listed languages will be used as Accept-Language header.
51 // The return value will look like:
52 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'},
53 // ...]
54 // "most relevant" languages, as set in initial_locale in VPD, will be first
55 // in the list.
56 static base::ListValue* GetAcceptLanguageList(
57 const input_method::InputMethodDescriptors& descriptors);
58
59 // Gets the list of UI languages with the given input descriptors.
60 // The return value will look like:
61 // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'},
62 // ...]
63 // "most relevant" languages, as set in initial_locale in VPD, will be first
64 // in the list.
65 // An entry with "code" attribute set to kVendorOtherLanguagesListDivider is
66 // used as a divider to separate "most relevant" languages against other.
67 static base::ListValue* GetUILanguageList(
68 const input_method::InputMethodDescriptors& descriptors);
69 45
70 // Converts input method descriptors to the list of input methods. 46 // Converts input method descriptors to the list of input methods.
71 // The return value will look like: 47 // The return value will look like:
72 // [{'id': '_ext_ime_nejguenhnsnjnwychcnsdsdjketest', 48 // [{'id': '_ext_ime_nejguenhnsnjnwychcnsdsdjketest',
73 // 'displayName': 'Sample IME'}, ...] 49 // 'displayName': 'Sample IME'}, ...]
74 static base::ListValue* ConvertInputMethodDescriptorsToIMEList( 50 static base::ListValue* ConvertInputMethodDescriptorsToIMEList(
75 const input_method::InputMethodDescriptors& descriptors); 51 const input_method::InputMethodDescriptors& descriptors);
76 52
77 private: 53 private:
78 // LanguageOptionsHandlerCommon implementation. 54 // LanguageOptionsHandlerCommon implementation.
(...skipping 11 matching lines...) Expand all
90 // |args| will contain the input method ID as string (ex. "mozc"). 66 // |args| will contain the input method ID as string (ex. "mozc").
91 void InputMethodEnableCallback(const base::ListValue* args); 67 void InputMethodEnableCallback(const base::ListValue* args);
92 68
93 // Called when the input method options page is opened. 69 // Called when the input method options page is opened.
94 // |args| will contain the input method ID as string (ex. "mozc"). 70 // |args| will contain the input method ID as string (ex. "mozc").
95 void InputMethodOptionsOpenCallback(const base::ListValue* args); 71 void InputMethodOptionsOpenCallback(const base::ListValue* args);
96 72
97 // ComponentExtensionIMEManager::Observer override. 73 // ComponentExtensionIMEManager::Observer override.
98 virtual void OnImeComponentExtensionInitialized() OVERRIDE; 74 virtual void OnImeComponentExtensionInitialized() OVERRIDE;
99 75
100 // Gets the list of languages with |descriptors| based on
101 // |base_language_codes|.
102 // |insert_divider| means to insert entry with "code" attribute set to
103 // kVendorOtherLanguagesListDivider between "most relevant" languages and
104 // other.
105 static base::ListValue* GetLanguageListInternal(
106 const input_method::InputMethodDescriptors& descriptors,
107 const std::vector<std::string>& base_language_codes,
108 bool insert_divider);
109
110 // OptionsPageUIHandler implementation. 76 // OptionsPageUIHandler implementation.
111 virtual void InitializePage() OVERRIDE; 77 virtual void InitializePage() OVERRIDE;
112 78
113 // Adds the name of the extension that provides the IME to each entry in the 79 // Adds the name of the extension that provides the IME to each entry in the
114 // |list| of extension IMEs. 80 // |list| of extension IMEs.
115 void AddImeProvider(base::ListValue* list); 81 void AddImeProvider(base::ListValue* list);
116 82
117 // True if the component extension list was appended into input method list. 83 // True if the component extension list was appended into input method list.
118 bool composition_extension_appended_; 84 bool composition_extension_appended_;
119 85
120 // True if this page was initialized. 86 // True if this page was initialized.
121 bool is_page_initialized_; 87 bool is_page_initialized_;
122 88
123 DISALLOW_COPY_AND_ASSIGN(CrosLanguageOptionsHandler); 89 DISALLOW_COPY_AND_ASSIGN(CrosLanguageOptionsHandler);
124 }; 90 };
125 91
126 } // namespace options 92 } // namespace options
127 } // namespace chromeos 93 } // namespace chromeos
128 94
129 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLE R_H_ 95 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CROS_LANGUAGE_OPTIONS_HANDLE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698