| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chromeos/dbus/ibus/ibus_input_context_client.h" | 15 #include "chromeos/dbus/ibus/ibus_input_context_client.h" |
| 16 #include "ui/base/ime/character_composer.h" | 16 #include "ui/base/ime/character_composer.h" |
| 17 #include "ui/base/ime/composition_text.h" | 17 #include "ui/base/ime/composition_text.h" |
| 18 #include "ui/base/ime/ibus_client.h" | |
| 19 #include "ui/base/ime/input_method_base.h" | 18 #include "ui/base/ime/input_method_base.h" |
| 20 | 19 |
| 21 namespace dbus { | 20 namespace dbus { |
| 22 class ObjectPath; | 21 class ObjectPath; |
| 23 } | 22 } |
| 24 namespace chromeos { | 23 namespace chromeos { |
| 25 namespace ibus { | 24 namespace ibus { |
| 26 class IBusText; | 25 class IBusText; |
| 27 } // namespace ibus | 26 } // namespace ibus |
| 28 } // namespace chromeos | 27 } // namespace chromeos |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 virtual std::string GetInputLocale() OVERRIDE; | 49 virtual std::string GetInputLocale() OVERRIDE; |
| 51 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; | 50 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; |
| 52 virtual bool IsActive() OVERRIDE; | 51 virtual bool IsActive() OVERRIDE; |
| 53 | 52 |
| 54 // Called when the connection with ibus-daemon is established. | 53 // Called when the connection with ibus-daemon is established. |
| 55 virtual void OnConnected(); | 54 virtual void OnConnected(); |
| 56 | 55 |
| 57 // Called when the connection with ibus-daemon is shutdowned. | 56 // Called when the connection with ibus-daemon is shutdowned. |
| 58 virtual void OnDisconnected(); | 57 virtual void OnDisconnected(); |
| 59 | 58 |
| 60 // Sets |new_client| as a new IBusClient. InputMethodIBus owns the object. | |
| 61 // A client has to be set before InputMethodIBus::Init() is called. | |
| 62 void set_ibus_client(scoped_ptr<internal::IBusClient> new_client); | |
| 63 | |
| 64 // The caller is not allowed to delete the object. | |
| 65 internal::IBusClient* ibus_client() const; | |
| 66 | |
| 67 protected: | 59 protected: |
| 68 // Converts |text| into CompositionText. | 60 // Converts |text| into CompositionText. |
| 69 void ExtractCompositionText(const chromeos::ibus::IBusText& text, | 61 void ExtractCompositionText(const chromeos::ibus::IBusText& text, |
| 70 uint32 cursor_position, | 62 uint32 cursor_position, |
| 71 CompositionText* out_composition) const; | 63 CompositionText* out_composition) const; |
| 72 | 64 |
| 73 // Process a key returned from the input method. | 65 // Process a key returned from the input method. |
| 74 virtual void ProcessKeyEventPostIME(const base::NativeEvent& native_key_event, | 66 virtual void ProcessKeyEventPostIME(const base::NativeEvent& native_key_event, |
| 75 uint32 ibus_keycode, | 67 uint32 ibus_keycode, |
| 76 bool handled); | 68 bool handled); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 virtual void HidePreeditText() OVERRIDE; | 167 virtual void HidePreeditText() OVERRIDE; |
| 176 virtual void UpdatePreeditText(const chromeos::ibus::IBusText& text, | 168 virtual void UpdatePreeditText(const chromeos::ibus::IBusText& text, |
| 177 uint32 cursor_pos, | 169 uint32 cursor_pos, |
| 178 bool visible) OVERRIDE; | 170 bool visible) OVERRIDE; |
| 179 | 171 |
| 180 void CreateInputContextDone(const dbus::ObjectPath& object_path); | 172 void CreateInputContextDone(const dbus::ObjectPath& object_path); |
| 181 void CreateInputContextFail(); | 173 void CreateInputContextFail(); |
| 182 void ProcessKeyEventDone(uint32 id, XEvent* xevent, uint32 keyval, | 174 void ProcessKeyEventDone(uint32 id, XEvent* xevent, uint32 keyval, |
| 183 bool is_handled); | 175 bool is_handled); |
| 184 | 176 |
| 185 scoped_ptr<internal::IBusClient> ibus_client_; | |
| 186 | |
| 187 // All pending key events. Note: we do not own these object, we just save | 177 // All pending key events. Note: we do not own these object, we just save |
| 188 // pointers to these object so that we can abandon them when necessary. | 178 // pointers to these object so that we can abandon them when necessary. |
| 189 // They will be deleted in ProcessKeyEventDone(). | 179 // They will be deleted in ProcessKeyEventDone(). |
| 190 std::set<uint32> pending_key_events_; | 180 std::set<uint32> pending_key_events_; |
| 191 | 181 |
| 192 // Represents input context's state. | 182 // Represents input context's state. |
| 193 InputContextState input_context_state_; | 183 InputContextState input_context_state_; |
| 194 | 184 |
| 195 // The count of CreateInputContext message failure. | 185 // The count of CreateInputContext message failure. |
| 196 int create_input_context_fail_count_; | 186 int create_input_context_fail_count_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 220 |
| 231 // Used for making callbacks. | 221 // Used for making callbacks. |
| 232 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; | 222 base::WeakPtrFactory<InputMethodIBus> weak_ptr_factory_; |
| 233 | 223 |
| 234 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); | 224 DISALLOW_COPY_AND_ASSIGN(InputMethodIBus); |
| 235 }; | 225 }; |
| 236 | 226 |
| 237 } // namespace ui | 227 } // namespace ui |
| 238 | 228 |
| 239 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ | 229 #endif // UI_BASE_IME_INPUT_METHOD_IBUS_H_ |
| OLD | NEW |