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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gio/gio.h> // GAsyncResult and related types. | 9 #include <gio/gio.h> // GAsyncResult and related types. |
10 #include <glib-object.h> | 10 #include <glib-object.h> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 virtual void SendHandwritingStroke(const HandwritingStroke& stroke) OVERRIDE; | 53 virtual void SendHandwritingStroke(const HandwritingStroke& stroke) OVERRIDE; |
54 virtual void CancelHandwriting(int n_strokes) OVERRIDE; | 54 virtual void CancelHandwriting(int n_strokes) OVERRIDE; |
55 #endif | 55 #endif |
56 | 56 |
57 // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for | 57 // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for |
58 // unit testing. | 58 // unit testing. |
59 static bool FindAndUpdatePropertyForTesting( | 59 static bool FindAndUpdatePropertyForTesting( |
60 const InputMethodProperty& new_prop, | 60 const InputMethodProperty& new_prop, |
61 InputMethodPropertyList* prop_list); | 61 InputMethodPropertyList* prop_list); |
62 | 62 |
63 // Called after the connection to ibus-daemon is established. | |
64 void IBusDaemonInitializationDone(); | |
65 | |
63 private: | 66 private: |
67 enum IBusDaemonStatus{ | |
68 IBUS_DAEMON_INITIALIZING, | |
69 IBUS_DAEMON_RUNNING, | |
70 IBUS_DAEMON_SHUTTING_DOWN, | |
71 IBUS_DAEMON_STOP, | |
72 }; | |
73 | |
64 // Functions that end with Thunk are used to deal with glib callbacks. | 74 // Functions that end with Thunk are used to deal with glib callbacks. |
65 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusConnected, IBusBus*); | 75 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusConnected, IBusBus*); |
66 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusDisconnected, IBusBus*); | 76 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusDisconnected, IBusBus*); |
67 CHROMEG_CALLBACK_3(IBusControllerImpl, void, BusNameOwnerChanged, | 77 CHROMEG_CALLBACK_3(IBusControllerImpl, void, BusNameOwnerChanged, |
68 IBusBus*, const gchar*, const gchar*, const gchar*); | 78 IBusBus*, const gchar*, const gchar*, const gchar*); |
69 CHROMEG_CALLBACK_1(IBusControllerImpl, void, FocusIn, | 79 CHROMEG_CALLBACK_1(IBusControllerImpl, void, FocusIn, |
70 IBusPanelService*, const gchar*); | 80 IBusPanelService*, const gchar*); |
71 CHROMEG_CALLBACK_1(IBusControllerImpl, void, RegisterProperties, | 81 CHROMEG_CALLBACK_1(IBusControllerImpl, void, RegisterProperties, |
72 IBusPanelService*, IBusPropList*); | 82 IBusPanelService*, IBusPropList*); |
73 CHROMEG_CALLBACK_1(IBusControllerImpl, void, UpdateProperty, | 83 CHROMEG_CALLBACK_1(IBusControllerImpl, void, UpdateProperty, |
(...skipping 30 matching lines...) Expand all Loading... | |
104 void SendAllInputMethodConfigs(); | 114 void SendAllInputMethodConfigs(); |
105 | 115 |
106 // Starts listening to the "connected", "disconnected", and | 116 // Starts listening to the "connected", "disconnected", and |
107 // "name-owner-changed" D-Bus signals from ibus-daemon. | 117 // "name-owner-changed" D-Bus signals from ibus-daemon. |
108 void ConnectBusSignals(); | 118 void ConnectBusSignals(); |
109 | 119 |
110 // Starts listening to the "focus-in", "register-properties", and | 120 // Starts listening to the "focus-in", "register-properties", and |
111 // "update-property" D-Bus signals from ibus-daemon. | 121 // "update-property" D-Bus signals from ibus-daemon. |
112 void ConnectPanelServiceSignals(); | 122 void ConnectPanelServiceSignals(); |
113 | 123 |
114 // Starts ibus-daemon if it's not yet started and |should_launch_daemon_| is | 124 // Adds address file watcher in FILE thread and then calls LaunchIBusDaemon. |
115 // true. | 125 bool StartIBusDaemon(); |
116 bool MaybeLaunchIBusDaemon(); | 126 |
127 // Starts ibus-daemon. | |
128 void LaunchIBusDaemon(const std::string& ibus_address); | |
117 | 129 |
118 // Launches an input method procsess specified by the given command | 130 // Launches an input method procsess specified by the given command |
119 // line. On success, returns true and stores the process handle in | 131 // line. On success, returns true and stores the process handle in |
120 // |process_handle|. Otherwise, returns false, and the contents of | 132 // |process_handle|. Otherwise, returns false, and the contents of |
121 // |process_handle| is untouched. |watch_func| will be called when the | 133 // |process_handle| is untouched. |watch_func| will be called when the |
122 // process terminates. | 134 // process terminates. |
123 bool LaunchProcess(const std::string& command_line, | 135 bool LaunchProcess(const std::string& command_line, |
124 base::ProcessHandle* process_handle, | 136 base::ProcessHandle* process_handle, |
125 GChildWatchFunc watch_func); | 137 GChildWatchFunc watch_func); |
126 | 138 |
127 // A callback function that will be called when ibus_config_set_value_async() | 139 // A callback function that will be called when ibus_config_set_value_async() |
128 // request is finished. | 140 // request is finished. |
129 static void SetInputMethodConfigCallback(GObject* source_object, | 141 static void SetInputMethodConfigCallback(GObject* source_object, |
130 GAsyncResult* res, | 142 GAsyncResult* res, |
131 gpointer user_data); | 143 gpointer user_data); |
132 | 144 |
133 // Called when the input method process is shut down. | 145 // Called when the input method process is shut down. |
134 static void OnIBusDaemonExit(GPid pid, | 146 static void OnIBusDaemonExit(GPid pid, |
135 gint status, | 147 gint status, |
136 IBusControllerImpl* controller); | 148 IBusControllerImpl* controller); |
137 | 149 |
138 // Connection to the ibus-daemon via IBus API. These objects are used to | 150 // Connection to the ibus-daemon via IBus API. These objects are used to |
139 // call ibus-daemon's API (e.g. activate input methods, set config, ...) | 151 // call ibus-daemon's API (e.g. activate input methods, set config, ...) |
140 IBusBus* ibus_; | 152 IBusBus* ibus_; |
141 IBusConfig* ibus_config_; | 153 IBusConfig* ibus_config_; |
142 | 154 |
143 // true when ibus-daemon should be running. | |
144 bool should_launch_daemon_; | |
145 | |
146 // The process handle of the IBus daemon. kNullProcessHandle if it's not | 155 // The process handle of the IBus daemon. kNullProcessHandle if it's not |
147 // running. | 156 // running. |
148 base::ProcessHandle process_handle_; | 157 base::ProcessHandle process_handle_; |
149 | 158 |
150 // Current input context path. | 159 // Current input context path. |
151 std::string current_input_context_path_; | 160 std::string current_input_context_path_; |
152 | 161 |
153 // The input method ID which is currently selected. The ID is sent to the | 162 // The input method ID which is currently selected. The ID is sent to the |
154 // daemon when |ibus_| and |ibus_config_| connections are both established. | 163 // daemon when |ibus_| and |ibus_config_| connections are both established. |
155 std::string current_input_method_id_; | 164 std::string current_input_method_id_; |
156 | 165 |
157 // An object which knows all valid input methods and layout IDs. | 166 // An object which knows all valid input methods and layout IDs. |
158 InputMethodWhitelist whitelist_; | 167 InputMethodWhitelist whitelist_; |
159 | 168 |
169 // Represents ibus-daemon's status. | |
170 IBusDaemonStatus ibus_daemon_status_; | |
171 | |
172 // The retry count if the ibus-daemon is crashed in initializing step. | |
173 int ibus_launch_retry_count_; | |
Yusuke Sato
2012/05/01 07:06:55
Wouldn't it be possible not to add this variable f
Seigo Nonaka
2012/05/02 05:12:10
Okay, I removed this variable.
On 2012/05/01 07:06
| |
174 | |
175 // Used for making callbacks for PostTask. | |
176 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_; | |
177 | |
160 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); | 178 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); |
161 }; | 179 }; |
162 | 180 |
163 } // namespace input_method | 181 } // namespace input_method |
164 } // namespace chromeos | 182 } // namespace chromeos |
165 | 183 |
166 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ | 184 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ |
OLD | NEW |