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 UI_BASE_IME_IBUS_CLIENT_H_ | 5 #ifndef UI_BASE_IME_IBUS_CLIENT_H_ |
| 6 #define UI_BASE_IME_IBUS_CLIENT_H_ | 6 #define UI_BASE_IME_IBUS_CLIENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/event_types.h" | |
| 11 #include "base/string16.h" | |
| 12 #include "chromeos/dbus/ibus/ibus_client.h" | |
| 13 #include "chromeos/dbus/ibus/ibus_input_context_client.h" | |
| 14 #include "chromeos/dbus/ibus/ibus_text.h" | |
| 15 #include "ui/base/events.h" | |
| 16 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
| 17 #include "ui/gfx/rect.h" | |
| 18 | 11 |
| 19 namespace gfx { | 12 namespace gfx { |
| 20 class Rect; | 13 class Rect; |
| 21 } // namespace gfx | 14 } // namespace gfx |
| 22 namespace ui { | 15 namespace ui { |
| 23 | 16 |
| 24 struct CompositionText; | |
| 25 | |
| 26 namespace internal { | 17 namespace internal { |
| 27 | 18 |
| 28 // An interface implemented by the object that sends and receives an event to | 19 // An interface implemented by the object that sends and receives an event to |
|
Yusuke Sato
2012/06/25 13:41:33
not an interface anymore.
Seigo Nonaka
2012/06/28 03:43:03
Done.
| |
| 29 // and from ibus-daemon. | 20 // and from ibus-daemon. |
| 30 // TODO(nona): Remove all methods except GetInputMethodType and | |
| 31 // SetCursorLocation. | |
| 32 class UI_EXPORT IBusClient { | 21 class UI_EXPORT IBusClient { |
| 33 public: | 22 public: |
| 34 // A class to hold all data related to a key event being processed by the | 23 IBusClient(); |
| 35 // input method but still has no result back yet. | 24 virtual ~IBusClient(); |
| 36 class PendingKeyEvent { | |
| 37 public: | |
| 38 virtual ~PendingKeyEvent() {} | |
| 39 // Process this pending key event after we receive its result from the input | |
| 40 // method. It just call through InputMethodIBus::ProcessKeyEventPostIME(). | |
| 41 virtual void ProcessPostIME(bool handled) = 0; | |
| 42 }; | |
| 43 | |
| 44 // A class to hold information of a pending request for creating an ibus input | |
| 45 // context. | |
| 46 class PendingCreateICRequest { | |
| 47 public: | |
| 48 virtual ~PendingCreateICRequest() {} | |
| 49 // Set up signal handlers, or destroy object proxy if the input context is | |
| 50 // already abandoned. | |
| 51 virtual void InitOrAbandonInputContext() = 0; | |
| 52 | |
| 53 // Called if the create input context method call is failed. | |
| 54 virtual void OnCreateInputContextFailed() = 0; | |
| 55 }; | |
| 56 | |
| 57 enum InlineCompositionCapability { | |
| 58 OFF_THE_SPOT_COMPOSITION = 0, | |
| 59 INLINE_COMPOSITION = 1, | |
| 60 }; | |
| 61 | 25 |
| 62 // The type of IME which is currently selected. Implementations should return | 26 // The type of IME which is currently selected. Implementations should return |
| 63 // the former when no IME is selected or the type of the current IME is | 27 // the former when no IME is selected or the type of the current IME is |
| 64 // unknown. | 28 // unknown. |
| 65 enum InputMethodType { | 29 enum InputMethodType { |
| 66 INPUT_METHOD_NORMAL = 0, | 30 INPUT_METHOD_NORMAL = 0, |
| 67 INPUT_METHOD_XKB_LAYOUT, | 31 INPUT_METHOD_XKB_LAYOUT, |
| 68 }; | 32 }; |
| 69 | 33 |
| 70 virtual ~IBusClient() {} | |
| 71 | |
| 72 // Returns true if the connection to ibus-daemon is established. | |
| 73 virtual bool IsConnected() = 0; | |
| 74 | |
| 75 // Returns true if the input context is ready to use. | |
| 76 virtual bool IsContextReady() = 0; | |
| 77 | |
| 78 // Creates a new input context asynchronously. An implementation has to call | |
| 79 // PendingCreateICRequest::StoreOrAbandonInputContext() with the newly created | |
| 80 // context when the asynchronous request succeeds. | |
| 81 // TODO(nona): We can omit the first argument(need unittests fix). | |
| 82 virtual void CreateContext(PendingCreateICRequest* request) = 0; | |
| 83 | |
| 84 // Destroys the proxy object in input context client. | |
| 85 virtual void DestroyProxy() = 0; | |
| 86 | |
| 87 // Updates the set of capabilities. | |
| 88 virtual void SetCapabilities(InlineCompositionCapability inline_type) = 0; | |
| 89 | |
| 90 // Focuses the context asynchronously. | |
| 91 virtual void FocusIn() = 0; | |
| 92 // Blurs the context asynchronously. | |
| 93 virtual void FocusOut() = 0; | |
| 94 // Resets the context asynchronously. | |
| 95 virtual void Reset() = 0; | |
| 96 | |
| 97 // Returns the current input method type. | 34 // Returns the current input method type. |
| 98 virtual InputMethodType GetInputMethodType() = 0; | 35 virtual InputMethodType GetInputMethodType(); |
| 99 | 36 |
| 100 // Resets the cursor location asynchronously. | 37 // Resets the cursor location asynchronously. |
| 101 virtual void SetCursorLocation(const gfx::Rect& cursor_location, | 38 virtual void SetCursorLocation(const gfx::Rect& cursor_location, |
| 102 const gfx::Rect& composition_head) = 0; | 39 const gfx::Rect& composition_head); |
| 103 | 40 |
| 104 // Sends the key to ibus-daemon asynchronously. | 41 private: |
| 105 virtual void SendKeyEvent( | 42 DISALLOW_COPY_AND_ASSIGN(IBusClient); |
| 106 uint32 keyval, | |
| 107 uint32 keycode, | |
| 108 uint32 state, | |
| 109 const chromeos::IBusInputContextClient::ProcessKeyEventCallback& cb) = 0; | |
| 110 }; | 43 }; |
| 111 | 44 |
| 112 } // namespace internal | 45 } // namespace internal |
| 113 } // namespace ui | 46 } // namespace ui |
| 114 | 47 |
| 115 #endif // UI_BASE_IME_IBUS_CLIENT_H_ | 48 #endif // UI_BASE_IME_IBUS_CLIENT_H_ |
| OLD | NEW |