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_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
6 | 6 |
7 #include <algorithm> // std::find | 7 #include <algorithm> // std::find |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 (!InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && | 302 (!InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && |
303 !IsIBusConnectionAlive())) { | 303 !IsIBusConnectionAlive())) { |
304 // We can't change input method before the initialization of component | 304 // We can't change input method before the initialization of component |
305 // extension ime manager or before connection to ibus-daemon is not | 305 // extension ime manager or before connection to ibus-daemon is not |
306 // established. ChangeInputMethod will be called with | 306 // established. ChangeInputMethod will be called with |
307 // |pending_input_method_| when the both initialization is done. | 307 // |pending_input_method_| when the both initialization is done. |
308 pending_input_method_ = input_method_id_to_switch; | 308 pending_input_method_ = input_method_id_to_switch; |
309 return false; | 309 return false; |
310 } | 310 } |
311 | 311 |
| 312 pending_input_method_.clear(); |
312 IBusInputContextClient* input_context = | 313 IBusInputContextClient* input_context = |
313 chromeos::DBusThreadManager::Get()->GetIBusInputContextClient(); | 314 chromeos::DBusThreadManager::Get()->GetIBusInputContextClient(); |
314 const std::string current_input_method_id = current_input_method_.id(); | 315 const std::string current_input_method_id = current_input_method_.id(); |
315 IBusClient* client = DBusThreadManager::Get()->GetIBusClient(); | 316 IBusClient* client = DBusThreadManager::Get()->GetIBusClient(); |
316 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { | 317 if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { |
317 FOR_EACH_OBSERVER(InputMethodManager::Observer, | 318 FOR_EACH_OBSERVER(InputMethodManager::Observer, |
318 observers_, | 319 observers_, |
319 InputMethodPropertyChanged(this)); | 320 InputMethodPropertyChanged(this)); |
320 // Hack for fixing http://crosbug.com/p/12798 | 321 // Hack for fixing http://crosbug.com/p/12798 |
321 // We should notify IME switching to ibus-daemon, otherwise | 322 // We should notify IME switching to ibus-daemon, otherwise |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 395 |
395 void InputMethodManagerImpl::OnComponentExtensionInitialized( | 396 void InputMethodManagerImpl::OnComponentExtensionInitialized( |
396 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { | 397 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { |
397 DCHECK(thread_checker_.CalledOnValidThread()); | 398 DCHECK(thread_checker_.CalledOnValidThread()); |
398 component_extension_ime_manager_->Initialize(delegate.Pass()); | 399 component_extension_ime_manager_->Initialize(delegate.Pass()); |
399 util_.SetComponentExtensions( | 400 util_.SetComponentExtensions( |
400 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor()); | 401 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor()); |
401 | 402 |
402 LoadNecessaryComponentExtensions(); | 403 LoadNecessaryComponentExtensions(); |
403 | 404 |
404 if (!pending_input_method_.empty()) { | 405 if (!pending_input_method_.empty()) |
405 if (ChangeInputMethodInternal(pending_input_method_, false)) | 406 ChangeInputMethodInternal(pending_input_method_, false); |
406 pending_input_method_.clear(); | |
407 } | |
408 | 407 |
409 } | 408 } |
410 | 409 |
411 void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { | 410 void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { |
412 if (!component_extension_ime_manager_->IsInitialized()) | 411 if (!component_extension_ime_manager_->IsInitialized()) |
413 return; | 412 return; |
414 // Load component extensions but also update |active_input_method_ids_| as | 413 // Load component extensions but also update |active_input_method_ids_| as |
415 // some component extension IMEs may have been removed from the Chrome OS | 414 // some component extension IMEs may have been removed from the Chrome OS |
416 // image. If specified component extension IME no longer exists, falling back | 415 // image. If specified component extension IME no longer exists, falling back |
417 // to an existing IME. | 416 // to an existing IME. |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 extra_input_method_instances_.begin(); | 714 extra_input_method_instances_.begin(); |
716 ite != extra_input_method_instances_.end(); | 715 ite != extra_input_method_instances_.end(); |
717 ite++) { | 716 ite++) { |
718 if (Contains(enabled_extension_imes_, ite->first) || | 717 if (Contains(enabled_extension_imes_, ite->first) || |
719 (component_extension_ime_manager_->IsInitialized() && | 718 (component_extension_ime_manager_->IsInitialized() && |
720 component_extension_ime_manager_->IsWhitelisted(ite->first))) { | 719 component_extension_ime_manager_->IsWhitelisted(ite->first))) { |
721 ite->second->OnConnected(); | 720 ite->second->OnConnected(); |
722 } | 721 } |
723 } | 722 } |
724 | 723 |
725 if (!pending_input_method_.empty()) { | 724 if (!pending_input_method_.empty()) |
726 if (ChangeInputMethodInternal(pending_input_method_, false)) | 725 ChangeInputMethodInternal(pending_input_method_, false); |
727 pending_input_method_.clear(); | |
728 } | |
729 } | 726 } |
730 | 727 |
731 void InputMethodManagerImpl::OnDisconnected() { | 728 void InputMethodManagerImpl::OnDisconnected() { |
732 for (std::map<std::string, InputMethodEngineIBus*>::iterator ite = | 729 for (std::map<std::string, InputMethodEngineIBus*>::iterator ite = |
733 extra_input_method_instances_.begin(); | 730 extra_input_method_instances_.begin(); |
734 ite != extra_input_method_instances_.end(); | 731 ite != extra_input_method_instances_.end(); |
735 ite++) { | 732 ite++) { |
736 if (Contains(enabled_extension_imes_, ite->first)) | 733 if (Contains(enabled_extension_imes_, ite->first)) |
737 ite->second->OnDisconnected(); | 734 ite->second->OnDisconnected(); |
738 } | 735 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 else | 862 else |
866 DVLOG(1) << "Failed to initialize the candidate window controller"; | 863 DVLOG(1) << "Failed to initialize the candidate window controller"; |
867 } | 864 } |
868 | 865 |
869 bool InputMethodManagerImpl::IsIBusConnectionAlive() { | 866 bool InputMethodManagerImpl::IsIBusConnectionAlive() { |
870 return DBusThreadManager::Get() && DBusThreadManager::Get()->GetIBusClient(); | 867 return DBusThreadManager::Get() && DBusThreadManager::Get()->GetIBusClient(); |
871 } | 868 } |
872 | 869 |
873 } // namespace input_method | 870 } // namespace input_method |
874 } // namespace chromeos | 871 } // namespace chromeos |
OLD | NEW |