| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/threading/thread_checker.h" |
| 16 #include "chromeos/ime/input_method_descriptor.h" | 17 #include "chromeos/ime/input_method_descriptor.h" |
| 17 | 18 |
| 18 namespace chromeos { | 19 namespace chromeos { |
| 19 namespace input_method { | 20 namespace input_method { |
| 20 | 21 |
| 21 class InputMethodDelegate; | 22 class InputMethodDelegate; |
| 22 | 23 |
| 23 enum InputMethodType { | 24 enum InputMethodType { |
| 24 kKeyboardLayoutsOnly, | 25 kKeyboardLayoutsOnly, |
| 25 kAllInputMethods, | 26 kAllInputMethods, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Gets the language codes associated with the given input method IDs. | 91 // Gets the language codes associated with the given input method IDs. |
| 91 // The returned language codes won't have duplicates. | 92 // The returned language codes won't have duplicates. |
| 92 void GetLanguageCodesFromInputMethodIds( | 93 void GetLanguageCodesFromInputMethodIds( |
| 93 const std::vector<std::string>& input_method_ids, | 94 const std::vector<std::string>& input_method_ids, |
| 94 std::vector<std::string>* out_language_codes) const; | 95 std::vector<std::string>* out_language_codes) const; |
| 95 | 96 |
| 96 // Gets first input method associated with the language. | 97 // Gets first input method associated with the language. |
| 97 // Returns empty string on error. | 98 // Returns empty string on error. |
| 98 std::string GetLanguageDefaultInputMethodId(const std::string& language_code); | 99 std::string GetLanguageDefaultInputMethodId(const std::string& language_code); |
| 99 | 100 |
| 100 // Returns the input method ID of the hardware keyboard. e.g. "xkb:us::eng" | 101 // Updates the internal cache of hardware layouts. |
| 101 // for the US Qwerty keyboard. | 102 void UpdateHardwareLayoutCache(); |
| 102 std::string GetHardwareInputMethodId() const; | 103 |
| 104 // Fills the input method IDs of the hardware keyboard. e.g. "xkb:us::eng" |
| 105 // for the US Qwerty keyboard. |out| must not be NULL. |
| 106 const std::vector<std::string>& GetHardwareInputMethodIds(); |
| 103 | 107 |
| 104 // Returns the login-allowed input method ID of the hardware keyboard. | 108 // Returns the login-allowed input method ID of the hardware keyboard. |
| 105 std::string GetHardwareLoginInputMethodId() const; | 109 const std::vector<std::string>& GetHardwareLoginInputMethodIds(); |
| 106 | 110 |
| 107 // Returns true if given input method can be used to input login data. | 111 // Returns true if given input method can be used to input login data. |
| 108 bool IsLoginKeyboard(const std::string& input_method_id) const; | 112 bool IsLoginKeyboard(const std::string& input_method_id) const; |
| 109 | 113 |
| 110 // Returns true if the given input method id is supported. | 114 // Returns true if the given input method id is supported. |
| 111 bool IsValidInputMethodId(const std::string& input_method_id) const; | 115 bool IsValidInputMethodId(const std::string& input_method_id) const; |
| 112 | 116 |
| 113 // Returns true if the given input method id is for a keyboard layout. | 117 // Returns true if the given input method id is for a keyboard layout. |
| 114 static bool IsKeyboardLayout(const std::string& input_method_id); | 118 static bool IsKeyboardLayout(const std::string& input_method_id); |
| 115 | 119 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 std::map<std::string, std::string> id_to_language_code_; | 170 std::map<std::string, std::string> id_to_language_code_; |
| 167 InputMethodIdToDescriptorMap id_to_descriptor_; | 171 InputMethodIdToDescriptorMap id_to_descriptor_; |
| 168 XkbIdToDescriptorMap xkb_id_to_descriptor_; | 172 XkbIdToDescriptorMap xkb_id_to_descriptor_; |
| 169 ComponentExtIMEMap component_extension_ime_id_to_descriptor_; | 173 ComponentExtIMEMap component_extension_ime_id_to_descriptor_; |
| 170 | 174 |
| 171 typedef base::hash_map<std::string, int> HashType; | 175 typedef base::hash_map<std::string, int> HashType; |
| 172 HashType english_to_resource_id_; | 176 HashType english_to_resource_id_; |
| 173 | 177 |
| 174 InputMethodDelegate* delegate_; | 178 InputMethodDelegate* delegate_; |
| 175 | 179 |
| 180 base::ThreadChecker thread_checker_; |
| 181 std::vector<std::string> hardware_layouts_; |
| 182 std::vector<std::string> hardware_login_layouts_; |
| 183 |
| 176 DISALLOW_COPY_AND_ASSIGN(InputMethodUtil); | 184 DISALLOW_COPY_AND_ASSIGN(InputMethodUtil); |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 } // namespace input_method | 187 } // namespace input_method |
| 180 } // namespace chromeos | 188 } // namespace chromeos |
| 181 | 189 |
| 182 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ | 190 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ |
| OLD | NEW |