| 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 UI_BASE_IME_INPUT_METHOD_IBUS_H_ | 5 #ifndef UI_BASE_IME_INPUT_METHOD_IBUS_H_ |
| 6 #define UI_BASE_IME_INPUT_METHOD_IBUS_H_ | 6 #define UI_BASE_IME_INPUT_METHOD_IBUS_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // The caller is not allowed to delete the object. | 60 // The caller is not allowed to delete the object. |
| 61 internal::IBusClient* ibus_client() const; | 61 internal::IBusClient* ibus_client() const; |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 // Converts |text| into CompositionText. | 64 // Converts |text| into CompositionText. |
| 65 void ExtractCompositionText(const chromeos::ibus::IBusText& text, | 65 void ExtractCompositionText(const chromeos::ibus::IBusText& text, |
| 66 uint32 cursor_position, | 66 uint32 cursor_position, |
| 67 CompositionText* out_composition) const; | 67 CompositionText* out_composition) const; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 enum InputContextState { |
| 71 // The input context is not working. |
| 72 INPUT_CONTEXT_STOP, |
| 73 // The input context is waiting for CreateInputContext reply from |
| 74 // ibus-daemon. |
| 75 INPUT_CONTEXT_WAIT_CREATE_INPUT_CONTEXT_RESPONSE, |
| 76 // The input context is working and ready to communicate with ibus-daemon. |
| 77 INPUT_CONTEXT_RUNNING, |
| 78 }; |
| 70 class PendingKeyEvent; | 79 class PendingKeyEvent; |
| 71 class PendingCreateICRequest; | |
| 72 | 80 |
| 73 // Overridden from InputMethodBase: | 81 // Overridden from InputMethodBase: |
| 74 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, | 82 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, |
| 75 TextInputClient* focused) OVERRIDE; | 83 TextInputClient* focused) OVERRIDE; |
| 76 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, | 84 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, |
| 77 TextInputClient* focused) OVERRIDE; | 85 TextInputClient* focused) OVERRIDE; |
| 78 | 86 |
| 79 // Creates context asynchronously. | 87 // Creates context asynchronously. |
| 80 void CreateContext(); | 88 void CreateContext(); |
| 81 | 89 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 161 |
| 154 // Event handlers for IBusInputContext: | 162 // Event handlers for IBusInputContext: |
| 155 void OnCommitText(const chromeos::ibus::IBusText& text); | 163 void OnCommitText(const chromeos::ibus::IBusText& text); |
| 156 void OnForwardKeyEvent(uint32 keyval, uint32 keycode, uint32 status); | 164 void OnForwardKeyEvent(uint32 keyval, uint32 keycode, uint32 status); |
| 157 void OnShowPreeditText(); | 165 void OnShowPreeditText(); |
| 158 void OnUpdatePreeditText(const chromeos::ibus::IBusText& text, | 166 void OnUpdatePreeditText(const chromeos::ibus::IBusText& text, |
| 159 uint32 cursor_pos, | 167 uint32 cursor_pos, |
| 160 bool visible); | 168 bool visible); |
| 161 void OnHidePreeditText(); | 169 void OnHidePreeditText(); |
| 162 | 170 |
| 163 void CreateInputContextDone(PendingCreateICRequest* ic_request, | 171 void CreateInputContextDone(const dbus::ObjectPath& object_path); |
| 164 const dbus::ObjectPath& object_path); | 172 void CreateInputContextFail(); |
| 165 void CreateInputContextFail(PendingCreateICRequest* ic_request); | |
| 166 static void ProcessKeyEventDone(PendingKeyEvent* pending_key_event, | 173 static void ProcessKeyEventDone(PendingKeyEvent* pending_key_event, |
| 167 bool is_handled); | 174 bool is_handled); |
| 168 static void ProcessKeyEventFail(PendingKeyEvent* pending_key_event); | 175 static void ProcessKeyEventFail(PendingKeyEvent* pending_key_event); |
| 169 | 176 |
| 170 scoped_ptr<internal::IBusClient> ibus_client_; | 177 scoped_ptr<internal::IBusClient> ibus_client_; |
| 171 | 178 |
| 172 // All pending key events. Note: we do not own these object, we just save | 179 // All pending key events. Note: we do not own these object, we just save |
| 173 // pointers to these object so that we can abandon them when necessary. | 180 // pointers to these object so that we can abandon them when necessary. |
| 174 // They will be deleted in ProcessKeyEventDone(). | 181 // They will be deleted in ProcessKeyEventDone(). |
| 175 std::set<PendingKeyEvent*> pending_key_events_; | 182 std::set<PendingKeyEvent*> pending_key_events_; |
| 176 | 183 |
| 177 // The pending request for creating the input context. We need to keep this | 184 // Represents input context's state. |
| 178 // pointer so that we can receive or abandon the result. | 185 InputContextState input_context_state_; |
| 179 PendingCreateICRequest* pending_create_ic_request_; | 186 |
| 187 // The count of CreateInputContext message failure. |
| 188 int create_input_context_fail_count_; |
| 180 | 189 |
| 181 // Pending composition text generated by the current pending key event. | 190 // Pending composition text generated by the current pending key event. |
| 182 // It'll be sent to the focused text input client as soon as we receive the | 191 // It'll be sent to the focused text input client as soon as we receive the |
| 183 // processing result of the pending key event. | 192 // processing result of the pending key event. |
| 184 CompositionText composition_; | 193 CompositionText composition_; |
| 185 | 194 |
| 186 // Pending result text generated by the current pending key event. | 195 // Pending result text generated by the current pending key event. |
| 187 // It'll be sent to the focused text input client as soon as we receive the | 196 // It'll be sent to the focused text input client as soon as we receive the |
| 188 // processing result of the pending key event. | 197 // processing result of the pending key event. |
| 189 string16 result_text_; | 198 string16 result_text_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 209 | 218 |
| 210 // Used for making callbacks. | 219 // Used for making callbacks. |
| 211 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; | 220 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; |
| 212 | 221 |
| 213 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); | 222 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); |
| 214 }; | 223 }; |
| 215 | 224 |
| 216 } // namespace ui | 225 } // namespace ui |
| 217 | 226 |
| 218 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ | 227 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ |
| OLD | NEW |