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

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

Issue 10159004: Extends DBusThreadManager to connect ibus-bus. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix 32bit build failure. Created 8 years, 7 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
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
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 static void IBusDaemonInitializationDone(IBusControllerImpl* controller,
64 const std::string& ibus_address);
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
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. 155 // The current ibus_daemon address. This value is assigned at the launching
144 bool should_launch_daemon_; 156 // ibus-daemon and used in bus connection initialization.
157 std::string ibus_daemon_address_;
145 158
146 // The process handle of the IBus daemon. kNullProcessHandle if it's not 159 // The process handle of the IBus daemon. kNullProcessHandle if it's not
147 // running. 160 // running.
148 base::ProcessHandle process_handle_; 161 base::ProcessHandle process_handle_;
149 162
150 // Current input context path. 163 // Current input context path.
151 std::string current_input_context_path_; 164 std::string current_input_context_path_;
152 165
153 // The input method ID which is currently selected. The ID is sent to the 166 // 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. 167 // daemon when |ibus_| and |ibus_config_| connections are both established.
155 std::string current_input_method_id_; 168 std::string current_input_method_id_;
156 169
157 // An object which knows all valid input methods and layout IDs. 170 // An object which knows all valid input methods and layout IDs.
158 InputMethodWhitelist whitelist_; 171 InputMethodWhitelist whitelist_;
159 172
173 // Represents ibus-daemon's status.
174 IBusDaemonStatus ibus_daemon_status_;
175
176 // Used for making callbacks for PostTask.
177 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_;
178
160 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); 179 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl);
161 }; 180 };
162 181
163 } // namespace input_method 182 } // namespace input_method
164 } // namespace chromeos 183 } // namespace chromeos
165 184
166 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ 185 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698