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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.cc

Issue 165783002: Reland of: Split out InputMethodMenuManager from InputMethodManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile Created 6 years, 10 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 | Annotate | Revision Log
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 #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 "ash/ime/input_method_menu_item.h"
10 #include "ash/ime/input_method_menu_manager.h"
9 #include "base/basictypes.h" 11 #include "base/basictypes.h"
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/location.h" 13 #include "base/location.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
16 #include "base/sys_info.h" 18 #include "base/sys_info.h"
17 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" 20 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 next_engine->Enable(); 345 next_engine->Enable();
344 } 346 }
345 347
346 // TODO(komatsu): Check if it is necessary to perform the above routine 348 // TODO(komatsu): Check if it is necessary to perform the above routine
347 // when the current input method is equal to |input_method_id_to_swich|. 349 // when the current input method is equal to |input_method_id_to_swich|.
348 if (current_input_method_.id() != input_method_id_to_switch) { 350 if (current_input_method_.id() != input_method_id_to_switch) {
349 // Clear property list. Property list would be updated by 351 // Clear property list. Property list would be updated by
350 // extension IMEs via InputMethodEngine::(Set|Update)MenuItems. 352 // extension IMEs via InputMethodEngine::(Set|Update)MenuItems.
351 // If the current input method is a keyboard layout, empty 353 // If the current input method is a keyboard layout, empty
352 // properties are sufficient. 354 // properties are sufficient.
353 const InputMethodPropertyList empty_property_list; 355 const ash::ime::InputMethodMenuItemList empty_menu_item_list;
354 SetCurrentInputMethodProperties(empty_property_list); 356 ash::ime::InputMethodMenuManager* input_method_menu_manager =
357 ash::ime::InputMethodMenuManager::GetInstance();
358 input_method_menu_manager->SetCurrentInputMethodMenuItemList(
359 empty_menu_item_list);
355 360
356 const InputMethodDescriptor* descriptor = NULL; 361 const InputMethodDescriptor* descriptor = NULL;
357 if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) { 362 if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) {
358 DCHECK(extra_input_methods_.find(input_method_id_to_switch) != 363 DCHECK(extra_input_methods_.find(input_method_id_to_switch) !=
359 extra_input_methods_.end()); 364 extra_input_methods_.end());
360 descriptor = &(extra_input_methods_[input_method_id_to_switch]); 365 descriptor = &(extra_input_methods_[input_method_id_to_switch]);
361 } else { 366 } else {
362 descriptor = 367 descriptor =
363 util_.GetInputMethodDescriptorFromId(input_method_id_to_switch); 368 util_.GetInputMethodDescriptorFromId(input_method_id_to_switch);
364 } 369 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 active_input_method_ids_.push_back(unfiltered_input_method_ids[i]); 417 active_input_method_ids_.push_back(unfiltered_input_method_ids[i]);
413 } else if (component_extension_ime_manager_->IsWhitelisted( 418 } else if (component_extension_ime_manager_->IsWhitelisted(
414 unfiltered_input_method_ids[i])) { 419 unfiltered_input_method_ids[i])) {
415 component_extension_ime_manager_->LoadComponentExtensionIME( 420 component_extension_ime_manager_->LoadComponentExtensionIME(
416 unfiltered_input_method_ids[i]); 421 unfiltered_input_method_ids[i]);
417 active_input_method_ids_.push_back(unfiltered_input_method_ids[i]); 422 active_input_method_ids_.push_back(unfiltered_input_method_ids[i]);
418 } 423 }
419 } 424 }
420 } 425 }
421 426
422 void InputMethodManagerImpl::ActivateInputMethodProperty( 427 void InputMethodManagerImpl::ActivateInputMethodMenuItem(
423 const std::string& key) { 428 const std::string& key) {
424 DCHECK(!key.empty()); 429 DCHECK(!key.empty());
425 430
426 for (size_t i = 0; i < property_list_.size(); ++i) { 431 if (ash::ime::InputMethodMenuManager::GetInstance()->
427 if (property_list_[i].key == key) { 432 HasInputMethodMenuItemForKey(key)) {
428 IMEEngineHandlerInterface* engine = 433 IMEEngineHandlerInterface* engine =
429 IMEBridge::Get()->GetCurrentEngineHandler(); 434 IMEBridge::Get()->GetCurrentEngineHandler();
430 if (engine) 435 if (engine)
431 engine->PropertyActivate(key); 436 engine->PropertyActivate(key);
432 return; 437 return;
433 }
434 } 438 }
435 439
436 DVLOG(1) << "ActivateInputMethodProperty: unknown key: " << key; 440 DVLOG(1) << "ActivateInputMethodMenuItem: unknown key: " << key;
437 } 441 }
438 442
439 void InputMethodManagerImpl::AddInputMethodExtension( 443 void InputMethodManagerImpl::AddInputMethodExtension(
440 const std::string& id, 444 const std::string& id,
441 InputMethodEngineInterface* engine) { 445 InputMethodEngineInterface* engine) {
442 if (state_ == STATE_TERMINATING) 446 if (state_ == STATE_TERMINATING)
443 return; 447 return;
444 448
445 if (!extension_ime_util::IsExtensionIME(id) && 449 if (!extension_ime_util::IsExtensionIME(id) &&
446 !extension_ime_util::IsComponentExtensionIME(id)) { 450 !extension_ime_util::IsComponentExtensionIME(id)) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 ChangeInputMethodInternal(*iter, true); 684 ChangeInputMethodInternal(*iter, true);
681 } 685 }
682 686
683 InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const { 687 InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const {
684 if (current_input_method_.id().empty()) 688 if (current_input_method_.id().empty())
685 return InputMethodUtil::GetFallbackInputMethodDescriptor(); 689 return InputMethodUtil::GetFallbackInputMethodDescriptor();
686 690
687 return current_input_method_; 691 return current_input_method_;
688 } 692 }
689 693
690 InputMethodPropertyList
691 InputMethodManagerImpl::GetCurrentInputMethodProperties() const {
692 // This check is necessary since an IME property (e.g. for Pinyin) might be
693 // sent from ibus-daemon AFTER the current input method is switched to XKB.
694 if (InputMethodUtil::IsKeyboardLayout(GetCurrentInputMethod().id()))
695 return InputMethodPropertyList(); // Empty list.
696 return property_list_;
697 }
698
699 void InputMethodManagerImpl::SetCurrentInputMethodProperties(
700 const InputMethodPropertyList& property_list) {
701 property_list_ = property_list;
702 PropertyChanged();
703 }
704
705 XKeyboard* InputMethodManagerImpl::GetXKeyboard() { 694 XKeyboard* InputMethodManagerImpl::GetXKeyboard() {
706 return xkeyboard_.get(); 695 return xkeyboard_.get();
707 } 696 }
708 697
709 InputMethodUtil* InputMethodManagerImpl::GetInputMethodUtil() { 698 InputMethodUtil* InputMethodManagerImpl::GetInputMethodUtil() {
710 return &util_; 699 return &util_;
711 } 700 }
712 701
713 ComponentExtensionIMEManager* 702 ComponentExtensionIMEManager*
714 InputMethodManagerImpl::GetComponentExtensionIMEManager() { 703 InputMethodManagerImpl::GetComponentExtensionIMEManager() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 739
751 void InputMethodManagerImpl::SetXKeyboardForTesting(XKeyboard* xkeyboard) { 740 void InputMethodManagerImpl::SetXKeyboardForTesting(XKeyboard* xkeyboard) {
752 xkeyboard_.reset(xkeyboard); 741 xkeyboard_.reset(xkeyboard);
753 } 742 }
754 743
755 void InputMethodManagerImpl::InitializeComponentExtensionForTesting( 744 void InputMethodManagerImpl::InitializeComponentExtensionForTesting(
756 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { 745 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) {
757 OnComponentExtensionInitialized(delegate.Pass()); 746 OnComponentExtensionInitialized(delegate.Pass());
758 } 747 }
759 748
760 void InputMethodManagerImpl::PropertyChanged() {
761 FOR_EACH_OBSERVER(InputMethodManager::Observer,
762 observers_,
763 InputMethodPropertyChanged(this));
764 }
765
766 void InputMethodManagerImpl::CandidateClicked(int index) { 749 void InputMethodManagerImpl::CandidateClicked(int index) {
767 IMEEngineHandlerInterface* engine = 750 IMEEngineHandlerInterface* engine =
768 IMEBridge::Get()->GetCurrentEngineHandler(); 751 IMEBridge::Get()->GetCurrentEngineHandler();
769 if (engine) 752 if (engine)
770 engine->CandidateClicked(index); 753 engine->CandidateClicked(index);
771 } 754 }
772 755
773 void InputMethodManagerImpl::CandidateWindowOpened() { 756 void InputMethodManagerImpl::CandidateWindowOpened() {
774 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, 757 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver,
775 candidate_window_observers_, 758 candidate_window_observers_,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 if (candidate_window_controller_.get()) 819 if (candidate_window_controller_.get())
837 return; 820 return;
838 821
839 candidate_window_controller_.reset( 822 candidate_window_controller_.reset(
840 CandidateWindowController::CreateCandidateWindowController()); 823 CandidateWindowController::CreateCandidateWindowController());
841 candidate_window_controller_->AddObserver(this); 824 candidate_window_controller_->AddObserver(this);
842 } 825 }
843 826
844 } // namespace input_method 827 } // namespace input_method
845 } // namespace chromeos 828 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698