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

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

Issue 11280159: Remove ibus dependency from PanelService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 8 years 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 | Annotate | Revision Log
OLDNEW
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 // The header files provides APIs for monitoring and controlling input 5 // The header files provides APIs for monitoring and controlling input
6 // method UI status. The APIs encapsulate the APIs of IBus, the underlying 6 // method UI status. The APIs encapsulate the APIs of IBus, the underlying
7 // input method framework. 7 // input method framework.
8 // TODO(nona): Remove InputMethodLookupTable and IBusUiController.
8 9
9 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ 10 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_
10 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ 11 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_
11 12
12 #include <string> 13 #include <string>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/basictypes.h" 16 #include "base/basictypes.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "chromeos/dbus/ibus/ibus_panel_service.h"
17 19
18 namespace gfx { 20 namespace gfx {
19 class Rect; 21 class Rect;
20 } // namespace gfx 22 } // namespace gfx
21 23
22 namespace chromeos { 24 namespace chromeos {
23 namespace input_method { 25 namespace input_method {
24 26
25 // A key for attaching the |ibus_service_panel_| object to |ibus_|. 27 // A key for attaching the |ibus_service_panel_| object to |ibus_|.
26 const char kPanelObjectKey[] = "panel-object"; 28 const char kPanelObjectKey[] = "panel-object";
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 std::vector<std::string> labels; 77 std::vector<std::string> labels;
76 78
77 // Annotation strings in UTF-8 (ex. "Hankaku Katakana"). 79 // Annotation strings in UTF-8 (ex. "Hankaku Katakana").
78 std::vector<std::string> annotations; 80 std::vector<std::string> annotations;
79 81
80 // Description entries. This text is shown in Infolist window. 82 // Description entries. This text is shown in Infolist window.
81 std::vector<Description> descriptions; 83 std::vector<Description> descriptions;
82 }; 84 };
83 85
84 // IBusUiController is used to interact with the IBus daemon. 86 // IBusUiController is used to interact with the IBus daemon.
85 class IBusUiController { 87 class IBusUiController : public ibus::IBusPanelCandidateWindowHandlerInterface {
86 public: 88 public:
87 class Observer { 89 class Observer {
88 public: 90 public:
89 // Called when the auxiliary text becomes hidden. 91 // Called when the auxiliary text becomes hidden.
90 virtual void OnHideAuxiliaryText() = 0; 92 virtual void OnHideAuxiliaryText() = 0;
91 93
92 // Called when the lookup table becomes hidden. 94 // Called when the lookup table becomes hidden.
93 virtual void OnHideLookupTable() = 0; 95 virtual void OnHideLookupTable() = 0;
94 96
95 // Called when the preedit text becomes hidden. 97 // Called when the preedit text becomes hidden.
96 virtual void OnHidePreeditText() = 0; 98 virtual void OnHidePreeditText() = 0;
97 99
98 // Called when the cursor location is set. 100 // Called when the cursor location is set.
99 virtual void OnSetCursorLocation(const gfx::Rect& cusor_location, 101 virtual void OnSetCursorLocation(const gfx::Rect& cusor_location,
100 const gfx::Rect& composition_head) = 0; 102 const gfx::Rect& composition_head) = 0;
101 103
102 // Called when the auxiliary text is updated. 104 // Called when the auxiliary text is updated.
103 virtual void OnUpdateAuxiliaryText(const std::string& text, 105 virtual void OnUpdateAuxiliaryText(const std::string& text,
104 bool visible) = 0; 106 bool visible) = 0;
105 107
106 // Called when the lookup table is updated. 108 // Called when the lookup table is updated.
107 virtual void OnUpdateLookupTable(const InputMethodLookupTable& table) = 0; 109 virtual void OnUpdateLookupTable(const InputMethodLookupTable& table) = 0;
108 110
109 // Called when the preedit text is updated. 111 // Called when the preedit text is updated.
110 virtual void OnUpdatePreeditText(const std::string& utf8_text, 112 virtual void OnUpdatePreeditText(const std::string& utf8_text,
111 unsigned int cursor, bool visible) = 0; 113 unsigned int cursor, bool visible) = 0;
114 };
112 115
113 // Called when the connection is changed. |connected| is true if the 116 IBusUiController();
114 // connection is established, and false if the connection is closed. 117 virtual ~IBusUiController();
115 virtual void OnConnectionChange(bool connected) = 0;
116 };
117 118
118 // Creates an instance of the class. The constructor is unused. 119 // Creates an instance of the class. The constructor is unused.
119 static IBusUiController* Create(); 120 static IBusUiController* Create();
120 121
121 virtual ~IBusUiController();
122
123 // Connects to the IBus daemon.
124 virtual void Connect() = 0;
125
126 // Adds and removes observers for IBus UI notifications. Clients must be 122 // Adds and removes observers for IBus UI notifications. Clients must be
127 // sure to remove the observer before they go away. To capture the 123 // sure to remove the observer before they go away. To capture the
128 // initial connection change, you should add an observer before calling 124 // initial connection change, you should add an observer before calling
129 // Connect(). 125 // Connect().
130 virtual void AddObserver(Observer* observer) = 0; 126 void AddObserver(Observer* observer);
131 virtual void RemoveObserver(Observer* observer) = 0; 127 void RemoveObserver(Observer* observer);
132 128
133 // Notifies that a candidate is clicked. |CandidateClicked| signal will be 129 // Notifies that a candidate is clicked. |CandidateClicked| signal will be
134 // sent to the ibus-daemon. 130 // sent to the ibus-daemon.
135 // 131 //
136 // - |index| Index in the Lookup table. The semantics is same with 132 // - |index| Index in the Lookup table. The semantics is same with
137 // |cursor_absolute_index|. 133 // |cursor_absolute_index|.
138 // - |button| GdkEventButton::button (1: left button, etc.) 134 // - |button| GdkEventButton::button (1: left button, etc.)
139 // - |state| GdkEventButton::state (key modifier flags) 135 // - |state| GdkEventButton::state (key modifier flags)
140 virtual void NotifyCandidateClicked(int index, int button, int flags) = 0; 136 void NotifyCandidateClicked(int index, int button, int flags);
141 137
142 // Notifies that the cursor up button is clicked. |CursorUp| signal will be 138 // Notifies that the cursor up button is clicked. |CursorUp| signal will be
143 // sent to the ibus-daemon 139 // sent to the ibus-daemon
144 virtual void NotifyCursorUp() = 0; 140 void NotifyCursorUp();
145 141
146 // Notifies that the cursor down button is clicked. |CursorDown| signal 142 // Notifies that the cursor down button is clicked. |CursorDown| signal
147 // will be sent to the ibus-daemon 143 // will be sent to the ibus-daemon
148 virtual void NotifyCursorDown() = 0; 144 void NotifyCursorDown();
149 145
150 // Notifies that the page up button is clicked. |PageUp| signal will be 146 // Notifies that the page up button is clicked. |PageUp| signal will be
151 // sent to the ibus-daemon 147 // sent to the ibus-daemon
152 virtual void NotifyPageUp() = 0; 148 void NotifyPageUp();
153 149
154 // Notifies that the page down button is clicked. |PageDown| signal will be 150 // Notifies that the page down button is clicked. |PageDown| signal will be
155 // sent to the ibus-daemon 151 // sent to the ibus-daemon
156 virtual void NotifyPageDown() = 0; 152 void NotifyPageDown();
153
154 // Handles cursor location update event. This if originate from
satorux1 2012/12/02 23:14:24 if -> is
Seigo Nonaka 2012/12/03 09:53:49 Done.
155 // SetCursorLocation method call, but we can bypass it on Chrome OS because
156 // candidate window is integrated with Chrome.
157 void SetCursorLocation(const gfx::Rect& cursor_location,
158 const gfx::Rect& composition_head);
159
160 private:
161 // IBusPanelHandlerInterface overrides.
162 virtual void UpdateLookupTable(const ibus::IBusLookupTable& table,
163 bool visible) OVERRIDE;
164 virtual void HideLookupTable() OVERRIDE;
165 virtual void UpdateAuxiliaryText(const std::string& text,
166 bool visible) OVERRIDE;
167 virtual void HideAuxiliaryText() OVERRIDE;
168 virtual void UpdatePreeditText(const std::string& text, uint32 cursor_pos,
169 bool visible) OVERRIDE;
170 virtual void HidePreeditText() OVERRIDE;
171
172 ObserverList<Observer> observers_;
173
174 DISALLOW_COPY_AND_ASSIGN(IBusUiController);
157 }; 175 };
158 176
159 bool IsActiveForTesting(const std::string& input_method_id,
160 const InputMethodDescriptors* descriptors);
161
162 } // namespace input_method 177 } // namespace input_method
163 } // namespace chromeos 178 } // namespace chromeos
164 179
165 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ 180 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698