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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
| 11 #include "base/memory/weak_ptr.h" |
11 #include "chrome/browser/chromeos/input_method/input_method_engine.h" | 12 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
12 #include "chromeos/ime/ibus_bridge.h" | 13 #include "chromeos/ime/ibus_bridge.h" |
13 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 | 17 |
17 class IBusText; | 18 class IBusText; |
18 | 19 |
19 class IBusEngineFactoryService; | |
20 class IBusEngineService; | 20 class IBusEngineService; |
21 | 21 |
22 namespace input_method { | 22 namespace input_method { |
23 class CandidateWindow; | 23 class CandidateWindow; |
24 struct KeyEventHandle; | 24 struct KeyEventHandle; |
25 } // namespace input_method | 25 } // namespace input_method |
26 | 26 |
27 class InputMethodEngineIBus : public InputMethodEngine, | 27 class InputMethodEngineIBus : public InputMethodEngine, |
28 public IBusEngineHandlerInterface { | 28 public IBusEngineHandlerInterface { |
29 public: | 29 public: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 void OnDisconnected(); | 102 void OnDisconnected(); |
103 | 103 |
104 private: | 104 private: |
105 // Converts MenuItem to InputMethodProperty. | 105 // Converts MenuItem to InputMethodProperty. |
106 void MenuItemToProperty(const MenuItem& item, | 106 void MenuItemToProperty(const MenuItem& item, |
107 input_method::InputMethodProperty* property); | 107 input_method::InputMethodProperty* property); |
108 | 108 |
109 // Registers the engine component. | 109 // Registers the engine component. |
110 void RegisterComponent(); | 110 void RegisterComponent(); |
111 | 111 |
112 // Called when the ibus-daemon sends CreateEngine message with corresponding | 112 // Called when the IBusBrige executes CreateEngine with |
113 // engine id. | 113 // corresponding engine id. |
114 void CreateEngineHandler( | 114 void CreateEngineHandler(); |
115 const IBusEngineFactoryService::CreateEngineResponseSender& sender); | |
116 | 115 |
117 // Returns current IBusEngineService, if there is no available service, this | 116 // Returns current IBusEngineService, if there is no available service, this |
118 // function returns NULL. | 117 // function returns NULL. |
119 IBusEngineService* GetCurrentService(); | 118 IBusEngineService* GetCurrentService(); |
120 | 119 |
121 // True if the current context has focus. | 120 // True if the current context has focus. |
122 bool focused_; | 121 bool focused_; |
123 | 122 |
124 // True if this engine is active. | 123 // True if this engine is active. |
125 bool active_; | 124 bool active_; |
126 | 125 |
127 // ID that is used for the current input context. False if there is no focus. | 126 // ID that is used for the current input context. False if there is no focus. |
128 int context_id_; | 127 int context_id_; |
129 | 128 |
130 // Next id that will be assigned to a context. | 129 // Next id that will be assigned to a context. |
131 int next_context_id_; | 130 int next_context_id_; |
132 | 131 |
133 // This IME ID in Chrome Extension. | 132 // This IME ID in Chrome Extension. |
134 std::string engine_id_; | 133 std::string engine_id_; |
135 | 134 |
136 // This IME ID in ibus. | 135 // This IME ID in ibus. |
137 std::string ibus_id_; | 136 std::string ibus_id_; |
138 | 137 |
139 // The current object path. | 138 // Flag whether CreateEngineHandler is called or not. |
140 dbus::ObjectPath object_path_; | 139 bool is_create_engine_handler_called_; |
141 | 140 |
142 // The current auxialy text and it's visiblity. | 141 // The current auxialy text and it's visiblity. |
143 scoped_ptr<IBusText> aux_text_; | 142 scoped_ptr<IBusText> aux_text_; |
144 bool aux_text_visible_; | 143 bool aux_text_visible_; |
145 | 144 |
146 // Pointer to the object recieving events for this IME. | 145 // Pointer to the object recieving events for this IME. |
147 InputMethodEngine::Observer* observer_; | 146 InputMethodEngine::Observer* observer_; |
148 | 147 |
149 // The current preedit text, and it's cursor position. | 148 // The current preedit text, and it's cursor position. |
150 scoped_ptr<IBusText> preedit_text_; | 149 scoped_ptr<IBusText> preedit_text_; |
151 int preedit_cursor_; | 150 int preedit_cursor_; |
152 | 151 |
153 // The current candidate window. | 152 // The current candidate window. |
154 scoped_ptr<input_method::CandidateWindow> candidate_window_; | 153 scoped_ptr<input_method::CandidateWindow> candidate_window_; |
155 | 154 |
156 // The current candidate window property. | 155 // The current candidate window property. |
157 CandidateWindowProperty candidate_window_property_; | 156 CandidateWindowProperty candidate_window_property_; |
158 | 157 |
159 // Indicates whether the candidate window is visible. | 158 // Indicates whether the candidate window is visible. |
160 bool window_visible_; | 159 bool window_visible_; |
161 | 160 |
162 // Mapping of candidate index to candidate id. | 161 // Mapping of candidate index to candidate id. |
163 std::vector<int> candidate_ids_; | 162 std::vector<int> candidate_ids_; |
164 | 163 |
165 // Mapping of candidate id to index. | 164 // Mapping of candidate id to index. |
166 std::map<int, int> candidate_indexes_; | 165 std::map<int, int> candidate_indexes_; |
167 | 166 |
168 scoped_ptr<IBusEngineService> ibus_engine_service_; | 167 scoped_ptr<IBusEngineService> ibus_engine_service_; |
169 scoped_ptr<IBusEngineFactoryService> ibus_engine_factory_service_; | |
170 | 168 |
171 // Used for making callbacks. | 169 // Used for making callbacks. |
172 base::WeakPtrFactory<InputMethodEngineIBus> weak_ptr_factory_; | 170 base::WeakPtrFactory<InputMethodEngineIBus> weak_ptr_factory_; |
173 }; | 171 }; |
174 | 172 |
175 } // namespace chromeos | 173 } // namespace chromeos |
176 | 174 |
177 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ | 175 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_ |
OLD | NEW |