Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_engine_ibus.h

Issue 10834108: Replace InputMethodEngineIBus. (Closed) Base URL: http://git.chromium.org/chromium/src.git@input_method_engine_ibus
Patch Set: Address comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_
7
8 #include <string>
9 #include <vector>
10 #include <map>
11 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
12 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h"
13 #include "chromeos/dbus/ibus/ibus_engine_service.h"
14 #include "dbus/object_path.h"
15
16 namespace chromeos {
17
18 namespace ibus {
19 class IBusComponent;
20 class IBusLookupTable;
21 class IBusText;
22 }
23
24 class IBusEngineService;
25 namespace input_method {
26 struct KeyEventHandle;
27 } // namespace input_method
28
29 class InputMethodEngineIBus : public InputMethodEngine,
30 public IBusEngineHandlerInterface {
31 public:
32 InputMethodEngineIBus();
33
34 virtual ~InputMethodEngineIBus();
35
36 void Initialize(
37 InputMethodEngine::Observer* observer,
38 const char* engine_name,
39 const char* extension_id,
40 const char* engine_id,
41 const char* description,
42 const char* language,
43 const std::vector<std::string>& layouts,
44 std::string* error);
45
46 // InputMethodEngine overrides.
47 virtual bool SetComposition(int context_id,
48 const char* text,
49 int selection_start,
50 int selection_end,
51 int cursor,
52 const std::vector<SegmentInfo>& segments,
53 std::string* error) OVERRIDE;
54 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE;
55 virtual bool CommitText(int context_id, const char* text,
56 std::string* error) OVERRIDE;
57 virtual bool SetCandidateWindowVisible(bool visible,
58 std::string* error) OVERRIDE;
59 virtual void SetCandidateWindowCursorVisible(bool visible) OVERRIDE;
60 virtual void SetCandidateWindowVertical(bool vertical) OVERRIDE;
61 virtual void SetCandidateWindowPageSize(int size) OVERRIDE;
62 virtual void SetCandidateWindowAuxText(const char* text) OVERRIDE;
63 virtual void SetCandidateWindowAuxTextVisible(bool visible) OVERRIDE;
64 virtual bool SetCandidates(int context_id,
65 const std::vector<Candidate>& candidates,
66 std::string* error) OVERRIDE;
67 virtual bool SetCursorPosition(int context_id, int candidate_id,
68 std::string* error) OVERRIDE;
69 virtual bool SetMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
70 virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
71 virtual bool IsActive() const OVERRIDE;
72 virtual void KeyEventDone(input_method::KeyEventHandle* key_data,
73 bool handled) OVERRIDE;
74
75 // IBusEngineHandlerInterface overrides.
76 virtual void FocusIn() OVERRIDE;
77 virtual void FocusOut() OVERRIDE;
78 virtual void Enable() OVERRIDE;
79 virtual void Disable() OVERRIDE;
80 virtual void PropertyActivate(const std::string& property_name,
81 IBusPropertyState property_state) OVERRIDE;
82 virtual void PropertyShow(const std::string& property_name) OVERRIDE;
83 virtual void PropertyHide(const std::string& property_name) OVERRIDE;
84 virtual void SetCapability(IBusCapability capability) OVERRIDE;
85 virtual void Reset() OVERRIDE;
86 virtual void ProcessKeyEvent(uint32 keysym, uint32 keycode, uint32 state,
87 const KeyEventDoneCallback& callback) OVERRIDE;
88 virtual void CandidateClicked(uint32 index, IBusMouseButton button,
89 uint32 state) OVERRIDE;
90 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos,
91 uint32 anchor_pos) OVERRIDE;
92
93 // Called when the connection with ibus-daemon is connected.
94 void OnConnected();
95
96 // Called whtn the connection with ibus-daemon is disconnected.
97 void OnDisconnected();
98
99 private:
100 // Returns true if the connection to ibus-daemon is avaiable.
101 bool IsConnected();
102
103 // Converts MenuItem to IBusProperty.
104 bool MenuItemToProperty(const MenuItem& item, ibus::IBusProperty* property);
105
106 // Registers the engine component.
107 void RegisterComponent();
108
109 // Called when the RegisterComponent is failed.
110 void OnComponentRegistrationFailed();
111
112 // Called when the RegisterComponent is succeeded.
113 void OnComponentRegistered();
114
115 // Called when the ibus-daemon sends CreateEngine message with corresponding
116 // engine id.
117 void CreateEngineHandler(
118 const IBusEngineFactoryService::CreateEngineResponseSender& sender);
119
120 // Returns current IBusEngineService, if there is no available service, this
121 // function returns NULL.
122 IBusEngineService* GetCurrentService();
123
124 // True if the current context has focus.
125 bool focused_;
126
127 // True if this engine is active.
128 bool active_;
129
130 // ID that is used for the current input context. False if there is no focus.
131 int context_id_;
132
133 // Next id that will be assigned to a context.
134 int next_context_id_;
135
136 // This IME ID in Chrome Extension.
137 std::string engine_id_;
138
139 // This IME ID in ibus.
140 std::string ibus_id_;
141
142 // The current object path and it's numerical id.
143 dbus::ObjectPath object_path_;
144 int current_object_path_;
145
146 // The current auxialy text and it's visiblity.
147 scoped_ptr<ibus::IBusText> aux_text_;
148 bool aux_text_visible_;
149
150 // Pointer to the object recieving events for this IME.
151 InputMethodEngine::Observer* observer_;
152
153 // The current preedit text, and it's cursor position.
154 scoped_ptr<ibus::IBusText> preedit_text_;
155 int preedit_cursor_;
156
157 // The current engine component.
158 scoped_ptr<ibus::IBusComponent> component_;
159
160 // The current lookup table and it's visiblity.
161 scoped_ptr<ibus::IBusLookupTable> table_;
162 bool table_visible_;
163
164 // Mapping of candidate index to candidate id.
165 std::vector<int> candidate_ids_;
166
167 // Mapping of candidate id to index.
168 std::map<int, int> candidate_indexes_;
169
170 // Used for making callbacks.
171 base::WeakPtrFactory<InputMethodEngineIBus> weak_ptr_factory_;
172 };
173
174 } // namespace chromeos
175
176 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_IBUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698