| 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 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include <glib.h> | 9 #include <glib.h> |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 public CandidateWindowController::Observer, | 72 public CandidateWindowController::Observer, |
| 73 #endif | 73 #endif |
| 74 public IBusController::Observer { | 74 public IBusController::Observer { |
| 75 public: | 75 public: |
| 76 InputMethodManagerImpl() | 76 InputMethodManagerImpl() |
| 77 : ibus_controller_(IBusController::Create()), | 77 : ibus_controller_(IBusController::Create()), |
| 78 should_hide_properties_(true), | 78 should_hide_properties_(true), |
| 79 should_launch_ime_(false), | 79 should_launch_ime_(false), |
| 80 ime_connected_(false), | 80 ime_connected_(false), |
| 81 enable_auto_ime_shutdown_(false), // workaround for crosbug.com/27051. | 81 enable_auto_ime_shutdown_(false), // workaround for crosbug.com/27051. |
| 82 enable_extension_imes_(true), |
| 82 shutting_down_(false), | 83 shutting_down_(false), |
| 83 ibus_daemon_process_handle_(base::kNullProcessHandle), | 84 ibus_daemon_process_handle_(base::kNullProcessHandle), |
| 84 util_(whitelist_.GetSupportedInputMethods()), | 85 util_(whitelist_.GetSupportedInputMethods()), |
| 85 xkeyboard_(XKeyboard::Create(util_)), | 86 xkeyboard_(XKeyboard::Create(util_)), |
| 86 ignore_hotkeys_(false) { | 87 ignore_hotkeys_(false) { |
| 87 // Observe APP_TERMINATING to stop input method daemon gracefully. | 88 // Observe APP_TERMINATING to stop input method daemon gracefully. |
| 88 // We should not use APP_EXITING here since logout might be canceled by | 89 // We should not use APP_EXITING here since logout might be canceled by |
| 89 // JavaScript after APP_EXITING is sent (crosbug.com/11055). | 90 // JavaScript after APP_EXITING is sent (crosbug.com/11055). |
| 90 // Note that even if we fail to stop input method daemon from | 91 // Note that even if we fail to stop input method daemon from |
| 91 // Chrome in case of a sudden crash, we have a way to do it from an | 92 // Chrome in case of a sudden crash, we have a way to do it from an |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // update the cache before actually flushing the config. since we need | 300 // update the cache before actually flushing the config. since we need |
| 300 // to return active input methods from GetActiveInputMethods() before | 301 // to return active input methods from GetActiveInputMethods() before |
| 301 // the input method daemon starts. For instance, we need to show the | 302 // the input method daemon starts. For instance, we need to show the |
| 302 // list of available input methods (keyboard layouts) on the login | 303 // list of available input methods (keyboard layouts) on the login |
| 303 // screen before the input method starts. | 304 // screen before the input method starts. |
| 304 if (section == language_prefs::kGeneralSectionName && | 305 if (section == language_prefs::kGeneralSectionName && |
| 305 config_name == language_prefs::kPreloadEnginesConfigName && | 306 config_name == language_prefs::kPreloadEnginesConfigName && |
| 306 value.type == InputMethodConfigValue::kValueTypeStringList) { | 307 value.type == InputMethodConfigValue::kValueTypeStringList) { |
| 307 active_input_method_ids_ = value.string_list_value; | 308 active_input_method_ids_ = value.string_list_value; |
| 308 | 309 |
| 309 std::map<std::string, InputMethodDescriptor>::const_iterator ix; | 310 if (enable_extension_imes_) { |
| 310 for (ix = extra_input_method_ids_.begin(); | 311 std::map<std::string, InputMethodDescriptor>::const_iterator ix; |
| 311 ix != extra_input_method_ids_.end(); ++ix) { | 312 for (ix = extra_input_method_ids_.begin(); |
| 312 active_input_method_ids_.push_back(ix->first); | 313 ix != extra_input_method_ids_.end(); ++ix) { |
| 314 active_input_method_ids_.push_back(ix->first); |
| 315 } |
| 313 } | 316 } |
| 314 } | 317 } |
| 315 | 318 |
| 316 // Before calling FlushImeConfig(), start input method process if necessary. | 319 // Before calling FlushImeConfig(), start input method process if necessary. |
| 317 MaybeStartInputMethodDaemon(section, config_name, value); | 320 MaybeStartInputMethodDaemon(section, config_name, value); |
| 318 | 321 |
| 319 const ConfigKeyType key = std::make_pair(section, config_name); | 322 const ConfigKeyType key = std::make_pair(section, config_name); |
| 320 current_config_values_[key] = value; | 323 current_config_values_[key] = value; |
| 321 if (ime_connected_) { | 324 if (ime_connected_) { |
| 322 pending_config_requests_[key] = value; | 325 pending_config_requests_[key] = value; |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 return false; | 1186 return false; |
| 1184 } | 1187 } |
| 1185 | 1188 |
| 1186 void SetEnableAutoImeShutdown(bool enable) { | 1189 void SetEnableAutoImeShutdown(bool enable) { |
| 1187 // TODO(yusukes): this is a workaround for crosbug.com/27051. Uncommen this | 1190 // TODO(yusukes): this is a workaround for crosbug.com/27051. Uncommen this |
| 1188 // when the bug is fixed. | 1191 // when the bug is fixed. |
| 1189 | 1192 |
| 1190 // enable_auto_ime_shutdown_ = enable; | 1193 // enable_auto_ime_shutdown_ = enable; |
| 1191 } | 1194 } |
| 1192 | 1195 |
| 1196 void SetEnableExtensionIMEs(bool enable) { |
| 1197 enable_extension_imes_ = enable; |
| 1198 } |
| 1199 |
| 1193 // content::NotificationObserver implementation: | 1200 // content::NotificationObserver implementation: |
| 1194 void Observe(int type, | 1201 void Observe(int type, |
| 1195 const content::NotificationSource& source, | 1202 const content::NotificationSource& source, |
| 1196 const content::NotificationDetails& details) { | 1203 const content::NotificationDetails& details) { |
| 1197 // Stop the input method daemon on browser shutdown. | 1204 // Stop the input method daemon on browser shutdown. |
| 1198 if (type == content::NOTIFICATION_APP_TERMINATING) { | 1205 if (type == content::NOTIFICATION_APP_TERMINATING) { |
| 1199 shutting_down_ = true; | 1206 shutting_down_ = true; |
| 1200 notification_registrar_.RemoveAll(); | 1207 notification_registrar_.RemoveAll(); |
| 1201 StopInputMethodDaemon(); | 1208 StopInputMethodDaemon(); |
| 1202 #if !defined(USE_VIRTUAL_KEYBOARD) | 1209 #if !defined(USE_VIRTUAL_KEYBOARD) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 // This is used to register this object to APP_TERMINATING notification. | 1250 // This is used to register this object to APP_TERMINATING notification. |
| 1244 content::NotificationRegistrar notification_registrar_; | 1251 content::NotificationRegistrar notification_registrar_; |
| 1245 | 1252 |
| 1246 // True if we should launch the input method daemon. | 1253 // True if we should launch the input method daemon. |
| 1247 bool should_launch_ime_; | 1254 bool should_launch_ime_; |
| 1248 // True if the connection to the IBus daemon is alive. | 1255 // True if the connection to the IBus daemon is alive. |
| 1249 bool ime_connected_; | 1256 bool ime_connected_; |
| 1250 // True if we should stop input method daemon when there are no input | 1257 // True if we should stop input method daemon when there are no input |
| 1251 // methods other than one for the hardware keyboard. | 1258 // methods other than one for the hardware keyboard. |
| 1252 bool enable_auto_ime_shutdown_; | 1259 bool enable_auto_ime_shutdown_; |
| 1260 // True if extension IMEs can be enabled. |
| 1261 bool enable_extension_imes_; |
| 1253 // The ID of the tentative current input method (ex. "mozc"). This value | 1262 // The ID of the tentative current input method (ex. "mozc"). This value |
| 1254 // can be different from the actual current input method, if | 1263 // can be different from the actual current input method, if |
| 1255 // ChangeInputMethod() fails. | 1264 // ChangeInputMethod() fails. |
| 1256 // TODO(yusukes): clear this variable when a user logs in. | 1265 // TODO(yusukes): clear this variable when a user logs in. |
| 1257 std::string tentative_current_input_method_id_; | 1266 std::string tentative_current_input_method_id_; |
| 1258 | 1267 |
| 1259 // The candidate window. This will be deleted when the APP_TERMINATING | 1268 // The candidate window. This will be deleted when the APP_TERMINATING |
| 1260 // message is sent. | 1269 // message is sent. |
| 1261 #if !defined(USE_VIRTUAL_KEYBOARD) | 1270 #if !defined(USE_VIRTUAL_KEYBOARD) |
| 1262 scoped_ptr<CandidateWindowController> candidate_window_controller_; | 1271 scoped_ptr<CandidateWindowController> candidate_window_controller_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); | 1305 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImpl); |
| 1297 }; | 1306 }; |
| 1298 | 1307 |
| 1299 // static | 1308 // static |
| 1300 InputMethodManager* InputMethodManager::GetInstance() { | 1309 InputMethodManager* InputMethodManager::GetInstance() { |
| 1301 return InputMethodManagerImpl::GetInstance(); | 1310 return InputMethodManagerImpl::GetInstance(); |
| 1302 } | 1311 } |
| 1303 | 1312 |
| 1304 } // namespace input_method | 1313 } // namespace input_method |
| 1305 } // namespace chromeos | 1314 } // namespace chromeos |
| OLD | NEW |