Chromium Code Reviews| 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 // Set hardware keyboard layout for testing purpose. To use this function, | |
| 105 // need to set FakeInputMethodDelegate to constructor instead of real | |
| 106 // implementation. | |
| 107 void SetHardwareKeyboardLayoutForTesting(const std::string& layout); | |
| 108 | |
|
Alexander Alekseev
2014/02/13 12:47:04
nit: add TODO: this is a temporary restriction unt
Seigo Nonaka
2014/02/14 03:51:45
Done.
| |
| 109 // Fills the input method IDs of the hardware keyboard. e.g. "xkb:us::eng" | |
| 110 // for the US Qwerty keyboard. |out| must not be NULL. | |
| 111 const std::vector<std::string>& GetHardwareInputMethodIds(); | |
| 103 | 112 |
| 104 // Returns the login-allowed input method ID of the hardware keyboard. | 113 // Returns the login-allowed input method ID of the hardware keyboard. |
| 105 std::string GetHardwareLoginInputMethodId() const; | 114 const std::vector<std::string>& GetHardwareLoginInputMethodIds(); |
| 106 | 115 |
| 107 // Returns true if given input method can be used to input login data. | 116 // Returns true if given input method can be used to input login data. |
| 108 bool IsLoginKeyboard(const std::string& input_method_id) const; | 117 bool IsLoginKeyboard(const std::string& input_method_id) const; |
| 109 | 118 |
| 110 // Returns true if the given input method id is supported. | 119 // Returns true if the given input method id is supported. |
| 111 bool IsValidInputMethodId(const std::string& input_method_id) const; | 120 bool IsValidInputMethodId(const std::string& input_method_id) const; |
| 112 | 121 |
| 113 // Returns true if the given input method id is for a keyboard layout. | 122 // Returns true if the given input method id is for a keyboard layout. |
| 114 static bool IsKeyboardLayout(const std::string& input_method_id); | 123 static bool IsKeyboardLayout(const std::string& input_method_id); |
| 115 | 124 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 std::map<std::string, std::string> id_to_language_code_; | 175 std::map<std::string, std::string> id_to_language_code_; |
| 167 InputMethodIdToDescriptorMap id_to_descriptor_; | 176 InputMethodIdToDescriptorMap id_to_descriptor_; |
| 168 XkbIdToDescriptorMap xkb_id_to_descriptor_; | 177 XkbIdToDescriptorMap xkb_id_to_descriptor_; |
| 169 ComponentExtIMEMap component_extension_ime_id_to_descriptor_; | 178 ComponentExtIMEMap component_extension_ime_id_to_descriptor_; |
| 170 | 179 |
| 171 typedef base::hash_map<std::string, int> HashType; | 180 typedef base::hash_map<std::string, int> HashType; |
| 172 HashType english_to_resource_id_; | 181 HashType english_to_resource_id_; |
| 173 | 182 |
| 174 InputMethodDelegate* delegate_; | 183 InputMethodDelegate* delegate_; |
| 175 | 184 |
| 185 base::ThreadChecker thread_checker_; | |
| 186 std::vector<std::string> hardware_layouts_; | |
| 187 std::vector<std::string> hardware_login_layouts_; | |
| 188 | |
| 176 DISALLOW_COPY_AND_ASSIGN(InputMethodUtil); | 189 DISALLOW_COPY_AND_ASSIGN(InputMethodUtil); |
| 177 }; | 190 }; |
| 178 | 191 |
| 179 } // namespace input_method | 192 } // namespace input_method |
| 180 } // namespace chromeos | 193 } // namespace chromeos |
| 181 | 194 |
| 182 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ | 195 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_UTIL_H_ |
| OLD | NEW |