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_ENGINE_IBUS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <map> | 10 #include <map> |
11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
12 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h" | 12 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h" |
13 #include "chromeos/dbus/ibus/ibus_engine_service.h" | 13 #include "chromeos/dbus/ibus/ibus_engine_service.h" |
14 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 namespace ibus { | |
19 class IBusComponent; | 18 class IBusComponent; |
20 class IBusLookupTable; | 19 class IBusLookupTable; |
21 class IBusText; | 20 class IBusText; |
22 } | |
23 | 21 |
24 class IBusEngineService; | 22 class IBusEngineService; |
25 namespace input_method { | 23 namespace input_method { |
26 struct KeyEventHandle; | 24 struct KeyEventHandle; |
27 } // namespace input_method | 25 } // namespace input_method |
28 | 26 |
29 class InputMethodEngineIBus : public InputMethodEngine, | 27 class InputMethodEngineIBus : public InputMethodEngine, |
30 public IBusEngineHandlerInterface { | 28 public IBusEngineHandlerInterface { |
31 public: | 29 public: |
32 InputMethodEngineIBus(); | 30 InputMethodEngineIBus(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) OVERRIDE; | 68 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) OVERRIDE; |
71 virtual bool IsActive() const OVERRIDE; | 69 virtual bool IsActive() const OVERRIDE; |
72 virtual void KeyEventDone(input_method::KeyEventHandle* key_data, | 70 virtual void KeyEventDone(input_method::KeyEventHandle* key_data, |
73 bool handled) OVERRIDE; | 71 bool handled) OVERRIDE; |
74 | 72 |
75 // IBusEngineHandlerInterface overrides. | 73 // IBusEngineHandlerInterface overrides. |
76 virtual void FocusIn() OVERRIDE; | 74 virtual void FocusIn() OVERRIDE; |
77 virtual void FocusOut() OVERRIDE; | 75 virtual void FocusOut() OVERRIDE; |
78 virtual void Enable() OVERRIDE; | 76 virtual void Enable() OVERRIDE; |
79 virtual void Disable() OVERRIDE; | 77 virtual void Disable() OVERRIDE; |
80 virtual void PropertyActivate(const std::string& property_name, | 78 virtual void PropertyActivate( |
81 IBusPropertyState property_state) OVERRIDE; | 79 const std::string& property_name, |
| 80 ibus::IBusPropertyState property_state) OVERRIDE; |
82 virtual void PropertyShow(const std::string& property_name) OVERRIDE; | 81 virtual void PropertyShow(const std::string& property_name) OVERRIDE; |
83 virtual void PropertyHide(const std::string& property_name) OVERRIDE; | 82 virtual void PropertyHide(const std::string& property_name) OVERRIDE; |
84 virtual void SetCapability(IBusCapability capability) OVERRIDE; | 83 virtual void SetCapability(IBusCapability capability) OVERRIDE; |
85 virtual void Reset() OVERRIDE; | 84 virtual void Reset() OVERRIDE; |
86 virtual void ProcessKeyEvent(uint32 keysym, uint32 keycode, uint32 state, | 85 virtual void ProcessKeyEvent(uint32 keysym, uint32 keycode, uint32 state, |
87 const KeyEventDoneCallback& callback) OVERRIDE; | 86 const KeyEventDoneCallback& callback) OVERRIDE; |
88 virtual void CandidateClicked(uint32 index, ibus::IBusMouseButton button, | 87 virtual void CandidateClicked(uint32 index, ibus::IBusMouseButton button, |
89 uint32 state) OVERRIDE; | 88 uint32 state) OVERRIDE; |
90 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, | 89 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, |
91 uint32 anchor_pos) OVERRIDE; | 90 uint32 anchor_pos) OVERRIDE; |
92 | 91 |
93 // Called when the connection with ibus-daemon is connected. | 92 // Called when the connection with ibus-daemon is connected. |
94 void OnConnected(); | 93 void OnConnected(); |
95 | 94 |
96 // Called whtn the connection with ibus-daemon is disconnected. | 95 // Called whtn the connection with ibus-daemon is disconnected. |
97 void OnDisconnected(); | 96 void OnDisconnected(); |
98 | 97 |
99 private: | 98 private: |
100 // Returns true if the connection to ibus-daemon is avaiable. | 99 // Returns true if the connection to ibus-daemon is avaiable. |
101 bool IsConnected(); | 100 bool IsConnected(); |
102 | 101 |
103 // Converts MenuItem to IBusProperty. | 102 // Converts MenuItem to IBusProperty. |
104 bool MenuItemToProperty(const MenuItem& item, ibus::IBusProperty* property); | 103 bool MenuItemToProperty(const MenuItem& item, IBusProperty* property); |
105 | 104 |
106 // Registers the engine component. | 105 // Registers the engine component. |
107 void RegisterComponent(); | 106 void RegisterComponent(); |
108 | 107 |
109 // Called when the RegisterComponent is failed. | 108 // Called when the RegisterComponent is failed. |
110 void OnComponentRegistrationFailed(); | 109 void OnComponentRegistrationFailed(); |
111 | 110 |
112 // Called when the RegisterComponent is succeeded. | 111 // Called when the RegisterComponent is succeeded. |
113 void OnComponentRegistered(); | 112 void OnComponentRegistered(); |
114 | 113 |
(...skipping 22 matching lines...) Expand all Loading... |
137 std::string engine_id_; | 136 std::string engine_id_; |
138 | 137 |
139 // This IME ID in ibus. | 138 // This IME ID in ibus. |
140 std::string ibus_id_; | 139 std::string ibus_id_; |
141 | 140 |
142 // The current object path and it's numerical id. | 141 // The current object path and it's numerical id. |
143 dbus::ObjectPath object_path_; | 142 dbus::ObjectPath object_path_; |
144 int current_object_path_; | 143 int current_object_path_; |
145 | 144 |
146 // The current auxialy text and it's visiblity. | 145 // The current auxialy text and it's visiblity. |
147 scoped_ptr<ibus::IBusText> aux_text_; | 146 scoped_ptr<IBusText> aux_text_; |
148 bool aux_text_visible_; | 147 bool aux_text_visible_; |
149 | 148 |
150 // Pointer to the object recieving events for this IME. | 149 // Pointer to the object recieving events for this IME. |
151 InputMethodEngine::Observer* observer_; | 150 InputMethodEngine::Observer* observer_; |
152 | 151 |
153 // The current preedit text, and it's cursor position. | 152 // The current preedit text, and it's cursor position. |
154 scoped_ptr<ibus::IBusText> preedit_text_; | 153 scoped_ptr<IBusText> preedit_text_; |
155 int preedit_cursor_; | 154 int preedit_cursor_; |
156 | 155 |
157 // The current engine component. | 156 // The current engine component. |
158 scoped_ptr<ibus::IBusComponent> component_; | 157 scoped_ptr<IBusComponent> component_; |
159 | 158 |
160 // The current lookup table. | 159 // The current lookup table. |
161 scoped_ptr<ibus::IBusLookupTable> table_; | 160 scoped_ptr<IBusLookupTable> table_; |
162 | 161 |
163 // Indicates whether the candidate window is visible. | 162 // Indicates whether the candidate window is visible. |
164 bool window_visible_; | 163 bool window_visible_; |
165 | 164 |
166 // Mapping of candidate index to candidate id. | 165 // Mapping of candidate index to candidate id. |
167 std::vector<int> candidate_ids_; | 166 std::vector<int> candidate_ids_; |
168 | 167 |
169 // Mapping of candidate id to index. | 168 // Mapping of candidate id to index. |
170 std::map<int, int> candidate_indexes_; | 169 std::map<int, int> candidate_indexes_; |
171 | 170 |
172 // Used for making callbacks. | 171 // Used for making callbacks. |
173 base::WeakPtrFactory<InputMethodEngineIBus> weak_ptr_factory_; | 172 base::WeakPtrFactory<InputMethodEngineIBus> weak_ptr_factory_; |
174 }; | 173 }; |
175 | 174 |
176 } // namespace chromeos | 175 } // namespace chromeos |
177 | 176 |
178 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ | 177 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ |
OLD | NEW |