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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_util.h

Issue 2861022: Add EnableInputMethodsAndKeyboardLayouts function (Closed)
Patch Set: fix Created 10 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/input_method_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 std::wstring GetLanguageDisplayNameFromCode(const std::string& language_code); 100 std::wstring GetLanguageDisplayNameFromCode(const std::string& language_code);
101 101
102 // Sorts the given language codes by their corresponding language names, 102 // Sorts the given language codes by their corresponding language names,
103 // using the unicode string comparator. Uses unstable sorting. 103 // using the unicode string comparator. Uses unstable sorting.
104 void SortLanguageCodesByNames(std::vector<std::string>* language_codes); 104 void SortLanguageCodesByNames(std::vector<std::string>* language_codes);
105 105
106 // Sorts the given input method ids by their corresponding language names, 106 // Sorts the given input method ids by their corresponding language names,
107 // using the unicode string comparator. Uses stable sorting. 107 // using the unicode string comparator. Uses stable sorting.
108 void SortInputMethodIdsByNames(std::vector<std::string>* input_method_ids); 108 void SortInputMethodIdsByNames(std::vector<std::string>* input_method_ids);
109 109
110 // This function is only for unit tests. Do not use this.
111 void SortInputMethodIdsByNamesInternal(
112 const std::map<std::string, std::string>& id_to_language_code_map,
113 std::vector<std::string>* input_method_ids);
114
115 // Reorders the given input method ids for the language code. For 110 // Reorders the given input method ids for the language code. For
116 // example, if |language_codes| is "fr" and |input_method_ids| contains 111 // example, if |language_codes| is "fr" and |input_method_ids| contains
117 // ["xkb:be::fra", and "xkb:fr::fra"], the list is reordered to 112 // ["xkb:be::fra", and "xkb:fr::fra"], the list is reordered to
118 // ["xkb:fr::fra", and "xkb:be::fra"], so that French keyboard layout 113 // ["xkb:fr::fra", and "xkb:be::fra"], so that French keyboard layout
119 // comes before Belgian keyboard layout. 114 // comes before Belgian keyboard layout.
120 void ReorderInputMethodIdsForLanguageCode( 115 void ReorderInputMethodIdsForLanguageCode(
121 const std::string& language_code, 116 const std::string& language_code,
122 std::vector<std::string>* input_method_ids); 117 std::vector<std::string>* input_method_ids);
123 118
119 enum InputMethodType {
120 kKeyboardLayoutsOnly,
121 kAllInputMethods,
122 };
123
124 // Gets input method ids that belong to |language_code|. 124 // Gets input method ids that belong to |language_code|.
125 // If |keyboard_layout_only| is true, the function does not return input methods 125 // If |type| is |kKeyboardLayoutsOnly|, the function does not return input
126 // that are not for keybord layout switching. Returns true on success. Note that 126 // methods that are not for keybord layout switching. Returns true on success.
127 // the function might return false if ibus-daemon is not running, or 127 // Note that the function might return false if ibus-daemon is not running, or
128 // |language_code| is unknown. 128 // |language_code| is unknown.
129 bool GetInputMethodIdsFromLanguageCode( 129 bool GetInputMethodIdsFromLanguageCode(
130 const std::string& language_code, 130 const std::string& language_code,
131 bool keyboard_layout_only, 131 InputMethodType type,
132 std::vector<std::string>* out_input_method_ids);
133
134 // Enables input methods (e.g. Chinese, Japanese) and keyboard layouts (e.g.
135 // US qwerty, US dvorak, French azerty) that are necessary for the language code
136 // and then switches to |initial_input_method_id| if the string is not empty.
137 // For example, if |language_code| is "en-US", US qwerty and US dvorak layouts
138 // would be enabled. Likewise, for Germany locale, US qwerty layout and several
139 // keyboard layouts for Germany would be enabled.
140 // If |type| is kAllInputMethods, all keyboard layouts and all input methods
141 // are enabled. If it's kKeyboardLayoutsOnly, only keyboard layouts are enabled.
142 // For example, for Japanese, xkb:jp::jpn is enabled when kKeyboardLayoutsOnly,
143 // and xkb:jp::jpn, mozc, mozc-jp, mozc-dv are enabled when kAllInputMethods.
144 void EnableInputMethods(const std::string& language_code, InputMethodType type,
145 const std::string& initial_input_method_id);
146
147
148 // DO NOT USE Functions below. These are only exported for unit tests.
149 void SortInputMethodIdsByNamesInternal(
150 const std::map<std::string, std::string>& id_to_language_code_map,
151 std::vector<std::string>* input_method_ids);
152
153 bool GetInputMethodIdsFromLanguageCodeInternal(
154 const std::multimap<std::string, std::string>& language_code_to_ids,
155 const std::string& normalized_language_code,
156 InputMethodType type,
132 std::vector<std::string>* out_input_method_ids); 157 std::vector<std::string>* out_input_method_ids);
133 158
134 } // namespace input_method 159 } // namespace input_method
135 } // namespace chromeos 160 } // namespace chromeos
136 161
137 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ 162 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/input_method_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698