OLD | NEW |
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_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 <cstddef> | 8 #include <cstddef> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 21 matching lines...) Expand all Loading... |
32 // including ones not active. The list is used to initialize member variables | 32 // including ones not active. The list is used to initialize member variables |
33 // in this class. | 33 // in this class. |
34 InputMethodUtil(InputMethodDelegate* delegate, | 34 InputMethodUtil(InputMethodDelegate* delegate, |
35 scoped_ptr<InputMethodDescriptors> supported_input_methods); | 35 scoped_ptr<InputMethodDescriptors> supported_input_methods); |
36 ~InputMethodUtil(); | 36 ~InputMethodUtil(); |
37 | 37 |
38 // Converts a string sent from IBus IME engines, which is written in English, | 38 // Converts a string sent from IBus IME engines, which is written in English, |
39 // into Chrome's string ID, then pulls internationalized resource string from | 39 // into Chrome's string ID, then pulls internationalized resource string from |
40 // the resource bundle and returns it. These functions are not thread-safe. | 40 // the resource bundle and returns it. These functions are not thread-safe. |
41 // Non-UI threads are not allowed to call them. | 41 // Non-UI threads are not allowed to call them. |
42 string16 TranslateString(const std::string& english_string) const; | 42 base::string16 TranslateString(const std::string& english_string) const; |
43 | 43 |
44 // Converts an input method ID to a language code of the IME. Returns "Eng" | 44 // Converts an input method ID to a language code of the IME. Returns "Eng" |
45 // when |input_method_id| is unknown. | 45 // when |input_method_id| is unknown. |
46 // Example: "hangul" => "ko" | 46 // Example: "hangul" => "ko" |
47 std::string GetLanguageCodeFromInputMethodId( | 47 std::string GetLanguageCodeFromInputMethodId( |
48 const std::string& input_method_id) const; | 48 const std::string& input_method_id) const; |
49 | 49 |
50 // Converts an input method ID to a display name of the IME. Returns | 50 // Converts an input method ID to a display name of the IME. Returns |
51 // an empty strng when |input_method_id| is unknown. | 51 // an empty strng when |input_method_id| is unknown. |
52 // Examples: "pinyin" => "Pinyin" | 52 // Examples: "pinyin" => "Pinyin" |
53 std::string GetInputMethodDisplayNameFromId( | 53 std::string GetInputMethodDisplayNameFromId( |
54 const std::string& input_method_id) const; | 54 const std::string& input_method_id) const; |
55 | 55 |
56 string16 GetInputMethodShortName( | 56 base::string16 GetInputMethodShortName( |
57 const InputMethodDescriptor& input_method) const; | 57 const InputMethodDescriptor& input_method) const; |
58 string16 GetInputMethodMediumName( | 58 base::string16 GetInputMethodMediumName( |
59 const InputMethodDescriptor& input_method) const; | 59 const InputMethodDescriptor& input_method) const; |
60 string16 GetInputMethodLongName( | 60 base::string16 GetInputMethodLongName( |
61 const InputMethodDescriptor& input_method) const; | 61 const InputMethodDescriptor& input_method) const; |
62 | 62 |
63 // Converts an input method ID to an input method descriptor. Returns NULL | 63 // Converts an input method ID to an input method descriptor. Returns NULL |
64 // when |input_method_id| is unknown. | 64 // when |input_method_id| is unknown. |
65 // Example: "pinyin" => { id: "pinyin", display_name: "Pinyin", | 65 // Example: "pinyin" => { id: "pinyin", display_name: "Pinyin", |
66 // keyboard_layout: "us", language_code: "zh" } | 66 // keyboard_layout: "us", language_code: "zh" } |
67 const InputMethodDescriptor* GetInputMethodDescriptorFromId( | 67 const InputMethodDescriptor* GetInputMethodDescriptorFromId( |
68 const std::string& input_method_id) const; | 68 const std::string& input_method_id) const; |
69 | 69 |
70 // Gets input method IDs that belong to |language_code|. | 70 // Gets input method IDs that belong to |language_code|. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Examples: | 133 // Examples: |
134 // | 134 // |
135 // "xkb:us::eng" => "us" | 135 // "xkb:us::eng" => "us" |
136 // "xkb:us:dvorak:eng" => "us(dvorak)" | 136 // "xkb:us:dvorak:eng" => "us(dvorak)" |
137 // "xkb:gb::eng" => "gb" | 137 // "xkb:gb::eng" => "gb" |
138 // "pinyin" => "us" (because Pinyin uses US keyboard layout) | 138 // "pinyin" => "us" (because Pinyin uses US keyboard layout) |
139 std::string GetKeyboardLayoutName(const std::string& input_method_id) const; | 139 std::string GetKeyboardLayoutName(const std::string& input_method_id) const; |
140 | 140 |
141 private: | 141 private: |
142 bool TranslateStringInternal(const std::string& english_string, | 142 bool TranslateStringInternal(const std::string& english_string, |
143 string16 *out_string) const; | 143 base::string16 *out_string) const; |
144 | 144 |
145 // Map from language code to associated input method IDs, etc. | 145 // Map from language code to associated input method IDs, etc. |
146 typedef std::multimap<std::string, std::string> LanguageCodeToIdsMap; | 146 typedef std::multimap<std::string, std::string> LanguageCodeToIdsMap; |
147 // Map from input method ID to associated input method descriptor. | 147 // Map from input method ID to associated input method descriptor. |
148 typedef std::map< | 148 typedef std::map< |
149 std::string, InputMethodDescriptor> InputMethodIdToDescriptorMap; | 149 std::string, InputMethodDescriptor> InputMethodIdToDescriptorMap; |
150 // Map from XKB layout ID to associated input method descriptor. | 150 // Map from XKB layout ID to associated input method descriptor. |
151 typedef std::map<std::string, InputMethodDescriptor> XkbIdToDescriptorMap; | 151 typedef std::map<std::string, InputMethodDescriptor> XkbIdToDescriptorMap; |
152 // Map from component extention IME id to associated input method descriptor. | 152 // Map from component extention IME id to associated input method descriptor. |
153 typedef std::map<std::string, InputMethodDescriptor> ComponentExtIMEMap; | 153 typedef std::map<std::string, InputMethodDescriptor> ComponentExtIMEMap; |
154 | 154 |
155 LanguageCodeToIdsMap language_code_to_ids_; | 155 LanguageCodeToIdsMap language_code_to_ids_; |
156 std::map<std::string, std::string> id_to_language_code_; | 156 std::map<std::string, std::string> id_to_language_code_; |
157 InputMethodIdToDescriptorMap id_to_descriptor_; | 157 InputMethodIdToDescriptorMap id_to_descriptor_; |
158 XkbIdToDescriptorMap xkb_id_to_descriptor_; | 158 XkbIdToDescriptorMap xkb_id_to_descriptor_; |
159 ComponentExtIMEMap component_extension_ime_id_to_descriptor_; | 159 ComponentExtIMEMap component_extension_ime_id_to_descriptor_; |
160 | 160 |
161 typedef base::hash_map<std::string, int> HashType; | 161 typedef base::hash_map<std::string, int> HashType; |
162 HashType english_to_resource_id_; | 162 HashType english_to_resource_id_; |
163 | 163 |
164 InputMethodDelegate* delegate_; | 164 InputMethodDelegate* delegate_; |
165 | 165 |
166 DISALLOW_COPY_AND_ASSIGN(InputMethodUtil); | 166 DISALLOW_COPY_AND_ASSIGN(InputMethodUtil); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace input_method | 169 } // namespace input_method |
170 } // namespace chromeos | 170 } // namespace chromeos |
171 | 171 |
172 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ | 172 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ |
OLD | NEW |