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 | 7 |
8 #include <gio/gio.h> // GAsyncResult and related types. | 8 #include <gio/gio.h> // GAsyncResult and related types. |
9 #include <glib-object.h> | 9 #include <glib-object.h> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 private: | 65 private: |
66 enum IBusDaemonStatus{ | 66 enum IBusDaemonStatus{ |
67 IBUS_DAEMON_INITIALIZING, | 67 IBUS_DAEMON_INITIALIZING, |
68 IBUS_DAEMON_RUNNING, | 68 IBUS_DAEMON_RUNNING, |
69 IBUS_DAEMON_SHUTTING_DOWN, | 69 IBUS_DAEMON_SHUTTING_DOWN, |
70 IBUS_DAEMON_STOP, | 70 IBUS_DAEMON_STOP, |
71 }; | 71 }; |
72 | 72 |
73 // Functions that end with Thunk are used to deal with glib callbacks. | 73 // Functions that end with Thunk are used to deal with glib callbacks. |
74 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusConnected, IBusBus*); | 74 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusConnected, IBusBus*); |
75 CHROMEG_CALLBACK_0(IBusControllerImpl, void, BusDisconnected, IBusBus*); | |
76 CHROMEG_CALLBACK_3(IBusControllerImpl, void, BusNameOwnerChanged, | |
77 IBusBus*, const gchar*, const gchar*, const gchar*); | |
78 CHROMEG_CALLBACK_1(IBusControllerImpl, void, RegisterProperties, | 75 CHROMEG_CALLBACK_1(IBusControllerImpl, void, RegisterProperties, |
79 IBusPanelService*, IBusPropList*); | 76 IBusPanelService*, IBusPropList*); |
80 CHROMEG_CALLBACK_1(IBusControllerImpl, void, UpdateProperty, | 77 CHROMEG_CALLBACK_1(IBusControllerImpl, void, UpdateProperty, |
81 IBusPanelService*, IBusProperty*); | 78 IBusPanelService*, IBusProperty*); |
82 | 79 |
83 // IBusControllerBase overrides: | 80 // IBusControllerBase overrides: |
84 virtual bool SetInputMethodConfigInternal( | 81 virtual bool SetInputMethodConfigInternal( |
85 const ConfigKeyType& key, | 82 const ConfigKeyType& key, |
86 const InputMethodConfigValue& value) OVERRIDE; | 83 const InputMethodConfigValue& value) OVERRIDE; |
87 | 84 |
(...skipping 12 matching lines...) Expand all Loading... |
100 | 97 |
101 // Destroys IBusConfig object if |ibus_| connection is not ready. This | 98 // Destroys IBusConfig object if |ibus_| connection is not ready. This |
102 // function does nothing if |ibus_config_| is NULL or |ibus_| connection is | 99 // function does nothing if |ibus_config_| is NULL or |ibus_| connection is |
103 // still alive. Note that the IBusConfig object can't be used when |ibus_| | 100 // still alive. Note that the IBusConfig object can't be used when |ibus_| |
104 // connection is not ready. | 101 // connection is not ready. |
105 void MaybeDestroyIBusConfig(); | 102 void MaybeDestroyIBusConfig(); |
106 | 103 |
107 // Just calls ibus_bus_set_global_engine_async() with the |id|. | 104 // Just calls ibus_bus_set_global_engine_async() with the |id|. |
108 void SendChangeInputMethodRequest(const std::string& id); | 105 void SendChangeInputMethodRequest(const std::string& id); |
109 | 106 |
110 // Calls SetInputMethodConfigInternal() for each |current_config_values_|. | |
111 void SendAllInputMethodConfigs(); | |
112 | |
113 // Starts listening to the "connected", "disconnected", and | 107 // Starts listening to the "connected", "disconnected", and |
114 // "name-owner-changed" D-Bus signals from ibus-daemon. | 108 // "name-owner-changed" D-Bus signals from ibus-daemon. |
115 void ConnectBusSignals(); | 109 void ConnectBusSignals(); |
116 | 110 |
117 // Starts listening to the "focus-in", "register-properties", and | 111 // Starts listening to the "focus-in", "register-properties", and |
118 // "update-property" D-Bus signals from ibus-daemon. | 112 // "update-property" D-Bus signals from ibus-daemon. |
119 void ConnectPanelServiceSignals(); | 113 void ConnectPanelServiceSignals(); |
120 | 114 |
121 // Adds address file watcher in FILE thread and then calls LaunchIBusDaemon. | 115 // Adds address file watcher in FILE thread and then calls LaunchIBusDaemon. |
122 bool StartIBusDaemon(); | 116 bool StartIBusDaemon(); |
(...skipping 10 matching lines...) Expand all Loading... |
133 base::ProcessHandle* process_handle, | 127 base::ProcessHandle* process_handle, |
134 GChildWatchFunc watch_func); | 128 GChildWatchFunc watch_func); |
135 | 129 |
136 // Returns pointer to InputMethod object. | 130 // Returns pointer to InputMethod object. |
137 ui::InputMethodIBus* GetInputMethod(); | 131 ui::InputMethodIBus* GetInputMethod(); |
138 | 132 |
139 // Injects an alternative ui::InputMethod for testing. | 133 // Injects an alternative ui::InputMethod for testing. |
140 // The injected object must be released by caller. | 134 // The injected object must be released by caller. |
141 void set_input_method_for_testing(ui::InputMethodIBus* input_method); | 135 void set_input_method_for_testing(ui::InputMethodIBus* input_method); |
142 | 136 |
143 // A callback function that will be called when ibus_config_set_value_async() | 137 // Called when the IBusConfigClient is initialized. |
144 // request is finished. | 138 void OnIBusConfigClientInitialized(); |
145 static void SetInputMethodConfigCallback(GObject* source_object, | |
146 GAsyncResult* res, | |
147 gpointer user_data); | |
148 | 139 |
149 // Called when the input method process is shut down. | 140 // Called when the input method process is shut down. |
150 static void OnIBusDaemonExit(GPid pid, | 141 static void OnIBusDaemonExit(GPid pid, |
151 gint status, | 142 gint status, |
152 IBusControllerImpl* controller); | 143 IBusControllerImpl* controller); |
153 | 144 |
154 // Connection to the ibus-daemon via IBus API. These objects are used to | 145 // Connection to the ibus-daemon via IBus API. These objects are used to |
155 // call ibus-daemon's API (e.g. activate input methods, set config, ...) | 146 // call ibus-daemon's API (e.g. activate input methods, set config, ...) |
156 IBusBus* ibus_; | 147 IBusBus* ibus_; |
157 IBusConfig* ibus_config_; | 148 IBusConfig* ibus_config_; |
(...skipping 25 matching lines...) Expand all Loading... |
183 // Used for making callbacks for PostTask. | 174 // Used for making callbacks for PostTask. |
184 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_; | 175 base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_; |
185 | 176 |
186 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); | 177 DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl); |
187 }; | 178 }; |
188 | 179 |
189 } // namespace input_method | 180 } // namespace input_method |
190 } // namespace chromeos | 181 } // namespace chromeos |
191 | 182 |
192 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ | 183 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_ |
OLD | NEW |