diff options
author | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-19 11:09:33 +0000 |
---|---|---|
committer | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-19 11:09:33 +0000 |
commit | b74dfd59fe25f9f22782285b5d8ab9620f554d91 (patch) | |
tree | 20125830c766625c2c5c5a10c80e086da68d4652 | |
parent | 6c5786bc93ab9917872ec0e4a0853229e9ebb2a5 (diff) | |
download | chromium_src-b74dfd59fe25f9f22782285b5d8ab9620f554d91.zip chromium_src-b74dfd59fe25f9f22782285b5d8ab9620f554d91.tar.gz chromium_src-b74dfd59fe25f9f22782285b5d8ab9620f554d91.tar.bz2 |
Delete IBusDaemonController.
BUG=
Review URL: https://codereview.chromium.org/64823008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235978 0039d316-1c4b-4281-b951-d872f2087c98
12 files changed, 1 insertions, 444 deletions
diff --git a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h index b1dfc8a..70deb44 100644 --- a/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h +++ b/chrome/browser/chromeos/input_method/candidate_window_controller_impl.h @@ -12,7 +12,6 @@ #include "chrome/browser/chromeos/input_method/candidate_window_view.h" #include "chrome/browser/chromeos/input_method/infolist_window_view.h" #include "chromeos/ime/ibus_bridge.h" -#include "chromeos/ime/ibus_daemon_controller.h" namespace views { class Widget; diff --git a/chrome/browser/chromeos/input_method/input_method_configuration.cc b/chrome/browser/chromeos/input_method/input_method_configuration.cc index e44eefa..7ed92d1 100644 --- a/chrome/browser/chromeos/input_method/input_method_configuration.cc +++ b/chrome/browser/chromeos/input_method/input_method_configuration.cc @@ -31,9 +31,7 @@ void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, void Initialize( const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { - IBusDaemonController::Initialize(ui_task_runner, file_task_runner); IBusBridge::Initialize(); - IBusDaemonController::GetInstance()->Start(); InputMethodManagerImpl* impl = new InputMethodManagerImpl( scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); @@ -61,7 +59,6 @@ void Shutdown() { InputMethodManager::Shutdown(); IBusBridge::Shutdown(); - IBusDaemonController::Shutdown(); DVLOG(1) << "InputMethodManager shutdown"; } diff --git a/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc b/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc index 682a529..c2ed60e 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc +++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc @@ -569,13 +569,6 @@ void InputMethodEngineIBus::MenuItemToProperty( // TODO(nona): Support item.children. } -void InputMethodEngineIBus::OnConnected() { - RegisterComponent(); -} - -void InputMethodEngineIBus::OnDisconnected() { -} - void InputMethodEngineIBus::RegisterComponent() { IBusBridge::Get()->SetCreateEngineHandler( ibus_id_, diff --git a/chrome/browser/chromeos/input_method/input_method_engine_ibus.h b/chrome/browser/chromeos/input_method/input_method_engine_ibus.h index bd9c81b..dc92c82 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.h +++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.h @@ -93,12 +93,6 @@ class InputMethodEngineIBus : public InputMethodEngine, virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, uint32 anchor_pos) OVERRIDE; - // Called when the connection with ibus-daemon is connected. - void OnConnected(); - - // Called whtn the connection with ibus-daemon is disconnected. - void OnDisconnected(); - private: // Converts MenuItem to InputMethodProperty. void MenuItemToProperty(const MenuItem& item, diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc index 0fe1eb2..5303093 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc @@ -56,13 +56,11 @@ InputMethodManagerImpl::InputMethodManagerImpl( util_(delegate_.get(), GetSupportedInputMethods()), component_extension_ime_manager_(new ComponentExtensionIMEManager()), weak_ptr_factory_(this) { - IBusDaemonController::GetInstance()->AddObserver(this); } InputMethodManagerImpl::~InputMethodManagerImpl() { if (ibus_controller_.get()) ibus_controller_->RemoveObserver(this); - IBusDaemonController::GetInstance()->RemoveObserver(this); if (candidate_window_controller_.get()) { candidate_window_controller_->RemoveObserver(this); candidate_window_controller_->Shutdown(); @@ -222,9 +220,6 @@ void InputMethodManagerImpl::ReconfigureIMFramework() { // indicator is used by only keyboard layout input methods. if (need_engine || active_input_method_ids_.size() > 1) MaybeInitializeCandidateWindowController(); - - if (need_engine) - IBusDaemonController::GetInstance()->Start(); } bool InputMethodManagerImpl::EnableInputMethod( @@ -454,7 +449,6 @@ void InputMethodManagerImpl::AddInputMethodExtension( // Ensure that the input method daemon is running. MaybeInitializeCandidateWindowController(); - IBusDaemonController::GetInstance()->Start(); } extra_input_method_instances_[id] = @@ -539,7 +533,6 @@ void InputMethodManagerImpl::SetEnabledExtensionImes( if (active_imes_changed) { MaybeInitializeCandidateWindowController(); - IBusDaemonController::GetInstance()->Start(); // If |current_input_method| is no longer in |active_input_method_ids_|, // switch to the first one in |active_input_method_ids_|. @@ -714,32 +707,6 @@ ComponentExtensionIMEManager* return component_extension_ime_manager_.get(); } -void InputMethodManagerImpl::OnConnected() { - for (std::map<std::string, InputMethodEngineIBus*>::iterator ite = - extra_input_method_instances_.begin(); - ite != extra_input_method_instances_.end(); - ite++) { - if (Contains(enabled_extension_imes_, ite->first) || - (component_extension_ime_manager_->IsInitialized() && - component_extension_ime_manager_->IsWhitelisted(ite->first))) { - ite->second->OnConnected(); - } - } - - if (!pending_input_method_.empty()) - ChangeInputMethodInternal(pending_input_method_, false); -} - -void InputMethodManagerImpl::OnDisconnected() { - for (std::map<std::string, InputMethodEngineIBus*>::iterator ite = - extra_input_method_instances_.begin(); - ite != extra_input_method_instances_.end(); - ite++) { - if (Contains(enabled_extension_imes_, ite->first)) - ite->second->OnDisconnected(); - } -} - void InputMethodManagerImpl::InitializeComponentExtension() { ComponentExtensionIMEManagerImpl* impl = new ComponentExtensionIMEManagerImpl(); diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.h b/chrome/browser/chromeos/input_method/input_method_manager_impl.h index 900891b..009af4c 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h @@ -15,7 +15,6 @@ #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" #include "chrome/browser/chromeos/input_method/ibus_controller.h" #include "chrome/browser/chromeos/input_method/input_method_util.h" -#include "chromeos/ime/ibus_daemon_controller.h" #include "chromeos/ime/input_method_manager.h" #include "chromeos/ime/input_method_whitelist.h" @@ -30,8 +29,7 @@ class XKeyboard; // The implementation of InputMethodManager. class InputMethodManagerImpl : public InputMethodManager, public CandidateWindowController::Observer, - public IBusController::Observer, - public IBusDaemonController::Observer { + public IBusController::Observer { public: // Constructs an InputMethodManager instance. The client is responsible for // calling |SetState| in response to relevant changes in browser state. @@ -110,11 +108,6 @@ class InputMethodManagerImpl : public InputMethodManager, // IBusController overrides: virtual void PropertyChanged() OVERRIDE; - // IBusDaemonController overrides: - virtual void OnConnected() OVERRIDE; - virtual void OnDisconnected() OVERRIDE; - - // CandidateWindowController::Observer overrides: virtual void CandidateWindowOpened() OVERRIDE; virtual void CandidateWindowClosed() OVERRIDE; diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc index aa38eea..bcd27c1 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc @@ -19,7 +19,6 @@ #include "chromeos/ime/extension_ime_util.h" #include "chromeos/ime/fake_input_method_delegate.h" #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" -#include "chromeos/ime/mock_ibus_daemon_controller.h" #include "chromeos/ime/mock_ime_engine_handler.h" #include "chromeos/ime/mock_xkeyboard.h" #include "testing/gtest/include/gtest/gtest.h" @@ -57,9 +56,6 @@ class InputMethodManagerImplTest : public testing::Test { virtual ~InputMethodManagerImplTest() {} virtual void SetUp() OVERRIDE { - mock_ibus_daemon_controller_ = new chromeos::MockIBusDaemonController(); - chromeos::IBusDaemonController::InitializeForTesting( - mock_ibus_daemon_controller_); fake_dbus_thread_manager_ = new chromeos::FakeDBusThreadManager(); chromeos::DBusThreadManager::InitializeForTesting( @@ -121,12 +117,9 @@ class InputMethodManagerImplTest : public testing::Test { ext2.engines.push_back(ext2_engine2); ime_list_.push_back(ext2); - - mock_ibus_daemon_controller_->EmulateConnect(); } virtual void TearDown() OVERRIDE { - mock_ibus_daemon_controller_->EmulateDisconnect(); delegate_ = NULL; controller_ = NULL; candidate_window_controller_ = NULL; @@ -135,7 +128,6 @@ class InputMethodManagerImplTest : public testing::Test { IBusBridge::Get()->SetEngineHandler(NULL); IBusBridge::Shutdown(); chromeos::DBusThreadManager::Shutdown(); - chromeos::IBusDaemonController::Shutdown(); } protected: @@ -147,17 +139,10 @@ class InputMethodManagerImplTest : public testing::Test { manager_->InitializeComponentExtensionForTesting(delegate.Pass()); } - // Helper function to initialize IBus bus connection for testing. Do not use - // ibus related mocks before calling this function. - void InitIBusBus() { - mock_ibus_daemon_controller_->EmulateConnect(); - } - scoped_ptr<InputMethodManagerImpl> manager_; FakeInputMethodDelegate* delegate_; MockIBusController* controller_; MockCandidateWindowController* candidate_window_controller_; - MockIBusDaemonController* mock_ibus_daemon_controller_; scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; FakeDBusThreadManager* fake_dbus_thread_manager_; MockXKeyboard* xkeyboard_; @@ -253,7 +238,6 @@ TEST_F(InputMethodManagerImplTest, TestObserver) { // also for the scenario. TestObserver observer; InitComponentExtension(); - InitIBusBus(); manager_->AddObserver(&observer); EXPECT_EQ(0, observer.input_method_changed_count_); manager_->EnableLayouts("en-US", "xkb:us::eng"); @@ -279,7 +263,6 @@ TEST_F(InputMethodManagerImplTest, TestObserver) { TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { InitComponentExtension(); - InitIBusBus(); scoped_ptr<InputMethodDescriptors> methods( manager_->GetSupportedInputMethods()); ASSERT_TRUE(methods.get()); @@ -303,19 +286,15 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { // Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See // ibus_input_method.txt. InitComponentExtension(); - InitIBusBus(); manager_->EnableLayouts("en-US", ""); EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); for (size_t i = 0; i < manager_->GetActiveInputMethodIds().size(); ++i) LOG(ERROR) << manager_->GetActiveInputMethodIds().at(i); - // For http://crbug.com/19655#c11 - (2) - EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); // For http://crbug.com/19655#c11 - (5) // The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. manager_->EnableLayouts("ja", ""); // Japanese EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); - EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); } TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { @@ -351,7 +330,6 @@ TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us:dvorak:eng"); @@ -360,7 +338,6 @@ TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) { EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); // Since all the IDs added avobe are keyboard layouts, Start() should not be // called. - EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); @@ -380,7 +357,6 @@ TEST_F(InputMethodManagerImplTest, TestEnableThreeLayouts) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us::eng"); @@ -412,13 +388,11 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us:dvorak:eng"); ids.push_back(nacl_mozc_us_id); EXPECT_TRUE(manager_->EnableInputMethods(ids)); - EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); @@ -433,14 +407,6 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme) { EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); - // Currently, to work around a crash issue at crosbug.com/27051, - // controller_->Stop(); is NOT called when all IMEs are disabled - // or on shutdown. - EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count()); - - manager_->SetState(InputMethodManager::STATE_TERMINATING); - EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count()); - manager_->RemoveObserver(&observer); } TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { @@ -448,13 +414,11 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayoutAndIme2) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us:dvorak:eng"); ids.push_back(nacl_mozc_us_id); EXPECT_TRUE(manager_->EnableInputMethods(ids)); - EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); @@ -473,13 +437,11 @@ TEST_F(InputMethodManagerImplTest, TestEnableImes) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("_comp_ime_nmblnjkfdkabgdofidlkienfnnbjhnabext2_engine1_engine_id"); ids.push_back("mozc-dv"); EXPECT_TRUE(manager_->EnableInputMethods(ids)); - EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us", xkeyboard_->last_layout_); @@ -507,7 +469,6 @@ TEST_F(InputMethodManagerImplTest, TestEnableLayoutsThenLock) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us::eng"); @@ -549,7 +510,6 @@ TEST_F(InputMethodManagerImplTest, SwithchInputMethodTest) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us:dvorak:eng"); @@ -573,9 +533,6 @@ TEST_F(InputMethodManagerImplTest, SwithchInputMethodTest) { EXPECT_EQ("xkb:us:dvorak:eng", manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); - // controller_->Stop() should never be called when the screen is locked even - // after crosbug.com/27051 is fixed. - EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count()); manager_->SwitchToNextInputMethod(); EXPECT_EQ("xkb:us::eng", // The hardware keyboard layout. manager_->GetCurrentInputMethod().id()); @@ -593,7 +550,6 @@ TEST_F(InputMethodManagerImplTest, SwithchInputMethodTest) { TEST_F(InputMethodManagerImplTest, TestXkbSetting) { // For http://crbug.com/19655#c11 - (8), step 7-11. InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us:dvorak:eng"); @@ -636,7 +592,6 @@ TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { InitComponentExtension(); - InitIBusBus(); EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); @@ -671,7 +626,6 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { InitComponentExtension(); - InitIBusBus(); EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); @@ -714,7 +668,6 @@ TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); // For http://crbug.com/19655#c11 - (1) manager_->EnableLayouts("en-US", "xkb:us::eng"); EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); @@ -748,7 +701,6 @@ TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); keydown_accelerator.set_type(ui::ET_KEY_PRESSED); @@ -805,7 +757,6 @@ TEST_F(InputMethodManagerImplTest, TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); keydown_accelerator.set_type(ui::ET_KEY_PRESSED); @@ -829,7 +780,6 @@ TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->EnableLayouts("en-US", "xkb:us::eng"); EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); @@ -861,7 +811,6 @@ TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { // Enable "xkb:jp::jpn" and press Muhenkan/ZenkakuHankaku. InitComponentExtension(); - InitIBusBus(); ui::Accelerator keydown_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); keydown_accelerator.set_type(ui::ET_KEY_PRESSED); @@ -896,7 +845,6 @@ TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpIme) { InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:jp::jpn"); @@ -948,13 +896,11 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { TestObserver observer; manager_->AddObserver(&observer); InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; ids.push_back("xkb:us:dvorak:eng"); EXPECT_TRUE(manager_->EnableInputMethods(ids)); EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); - EXPECT_EQ(0, mock_ibus_daemon_controller_->start_count()); EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(ids[0], manager_->GetCurrentInputMethod().id()); @@ -983,8 +929,6 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { manager_->SetEnabledExtensionImes(&extension_ime_ids); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); - // should be started. - EXPECT_EQ(1, mock_ibus_daemon_controller_->start_count()); { scoped_ptr<InputMethodDescriptors> methods( manager_->GetActiveInputMethods()); @@ -1023,17 +967,11 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { manager_->RemoveInputMethodExtension( extension_ime_util::GetInputMethodID("cafebabe", "engine_id")); EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); - // Currently, to work around a crash issue at crosbug.com/27051, - // controller_->Stop(); is NOT called when all (extension) IMEs are disabled. - EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count()); - - manager_->RemoveObserver(&observer); } TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { TestObserver observer; InitComponentExtension(); - InitIBusBus(); manager_->AddObserver(&observer); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); std::vector<std::string> ids; @@ -1080,7 +1018,6 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); EXPECT_EQ("us", xkeyboard_->last_layout_); - EXPECT_EQ(0, mock_ibus_daemon_controller_->stop_count()); // Unlock the screen. manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); @@ -1109,7 +1046,6 @@ TEST_F(InputMethodManagerImplTest, EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); manager_->ChangeInputMethod(nacl_mozc_us_id); - InitIBusBus(); InitComponentExtension(); EXPECT_EQ(nacl_mozc_us_id, manager_->GetCurrentInputMethod().id()); } @@ -1126,7 +1062,6 @@ TEST_F(InputMethodManagerImplTest, manager_->ChangeInputMethod(nacl_mozc_jp_id); InitComponentExtension(); - InitIBusBus(); EXPECT_EQ(nacl_mozc_jp_id, manager_->GetCurrentInputMethod().id()); } @@ -1144,7 +1079,6 @@ TEST_F(InputMethodManagerImplTest, manager_->ChangeInputMethod(ext_id); InitComponentExtension(); - InitIBusBus(); EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); } @@ -1168,14 +1102,12 @@ TEST_F(InputMethodManagerImplTest, manager_->ChangeInputMethod(ext_id2); InitComponentExtension(); - InitIBusBus(); EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, ChangeInputMethod_ComponenteExtensionOneIME) { InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); const std::string ext_id = TestableComponentExtensionIMEManager::GetComponentExtensionIMEId( @@ -1191,7 +1123,6 @@ TEST_F(InputMethodManagerImplTest, TEST_F(InputMethodManagerImplTest, ChangeInputMethod_ComponenteExtensionTwoIME) { InitComponentExtension(); - InitIBusBus(); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); const std::string ext_id1 = TestableComponentExtensionIMEManager::GetComponentExtensionIMEId( @@ -1211,63 +1142,5 @@ TEST_F(InputMethodManagerImplTest, EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); } -TEST_F(InputMethodManagerImplTest, - AsyncComponentExtentionInitializeBeforeIBusDaemonConnection) { - const std::string xkb_id = "xkb:cz::cze"; - const std::string ime_id = nacl_mozc_us_id; - const std::string fallback_id = "xkb:us::eng"; - std::vector<std::string> ids; - ids.push_back(xkb_id); - ids.push_back(ime_id); - EXPECT_TRUE(manager_->EnableInputMethods(ids)); - - // If component extension IME is not initialized, even XKB layout cannot be - // enabled. - manager_->ChangeInputMethod(xkb_id); - EXPECT_EQ(fallback_id, manager_->GetCurrentInputMethod().id()); - - // After component extension IME is initialized, previous input method should - // be automatically enabled. - InitComponentExtension(); - EXPECT_EQ(xkb_id, manager_->GetCurrentInputMethod().id()); - - // However input method should not be enabled before establishment of - // connection with ibus-daemon. - manager_->ChangeInputMethod(ime_id); - // TODO(nona): Write expectation, GetCurrentInputMethod returns |ime_id| even - // the actual input method is not changed. - - // After connection with ibus-daemon is established, previous specified input - // method should be enabled automatically. - InitIBusBus(); - EXPECT_EQ(ime_id, manager_->GetCurrentInputMethod().id()); -} - -TEST_F(InputMethodManagerImplTest, - AsyncComponentExtentionInitializeAfterIBusDaemonConnection) { - const std::string xkb_id = "xkb:cz::cze"; - const std::string ime_id = nacl_mozc_us_id; - const std::string fallback_id = "xkb:us::eng"; - std::vector<std::string> ids; - ids.push_back(xkb_id); - ids.push_back(ime_id); - EXPECT_TRUE(manager_->EnableInputMethods(ids)); - - // If component extension IME is not initialized, even XKB layout cannot be - // enabled. - manager_->ChangeInputMethod(xkb_id); - EXPECT_EQ(fallback_id, manager_->GetCurrentInputMethod().id()); - - // Even after connection with ibus-daemon is established, ChangeInputMethod do - // nothing without component extension IME initialization. - InitIBusBus(); - EXPECT_EQ(fallback_id, manager_->GetCurrentInputMethod().id()); - - // After component extension IME is initialized, previous specified input - // method should be automatically enabled. - InitComponentExtension(); - EXPECT_EQ(xkb_id, manager_->GetCurrentInputMethod().id()); -} - } // namespace input_method } // namespace chromeos diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 776597d..4aa79aa 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -207,8 +207,6 @@ 'ime/extension_ime_util.h', 'ime/ibus_bridge.cc', 'ime/ibus_bridge.h', - 'ime/ibus_daemon_controller.cc', - 'ime/ibus_daemon_controller.h', 'ime/ibus_keymap.cc', 'ime/ibus_keymap.h', 'ime/ibus_text.cc', @@ -430,8 +428,6 @@ 'dbus/fake_update_engine_client.h', 'ime/fake_input_method_delegate.cc', 'ime/fake_input_method_delegate.h', - 'ime/mock_ibus_daemon_controller.cc', - 'ime/mock_ibus_daemon_controller.h', 'ime/mock_ime_candidate_window_handler.cc', 'ime/mock_ime_candidate_window_handler.h', 'ime/mock_ime_engine_handler.cc', diff --git a/chromeos/ime/ibus_daemon_controller.cc b/chromeos/ime/ibus_daemon_controller.cc deleted file mode 100644 index 0ff2eb1..0000000 --- a/chromeos/ime/ibus_daemon_controller.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromeos/ime/ibus_daemon_controller.h" - -#include "base/bind.h" -#include "base/files/file_path.h" -#include "base/files/file_path_watcher.h" -#include "base/location.h" -#include "base/logging.h" -#include "base/observer_list.h" -#include "chromeos/dbus/dbus_thread_manager.h" - -namespace chromeos { - -namespace { - -IBusDaemonController* g_ibus_daemon_controller = NULL; - -// An implementation of IBusDaemonController without ibus-daemon interaction. -// Currently this class is used only on linux desktop. -// TODO(nona): Remove IBusDaemonControlelr this once crbug.com/171351 is fixed. -class IBusDaemonControllerDaemonlessImpl : public IBusDaemonController { - public: - IBusDaemonControllerDaemonlessImpl() - : is_started_(false) {} - virtual ~IBusDaemonControllerDaemonlessImpl() {} - - // IBusDaemonController overrides: - virtual void AddObserver(Observer* observer) OVERRIDE { - observers_.AddObserver(observer); - } - - virtual void RemoveObserver(Observer* observer) OVERRIDE { - observers_.RemoveObserver(observer); - } - - virtual bool Start() OVERRIDE { - if (is_started_) - return false; - is_started_ = true; - FOR_EACH_OBSERVER(Observer, observers_, OnConnected()); - return true; - } - virtual bool Stop() OVERRIDE { - if (!is_started_) - return false; - is_started_ = false; - FOR_EACH_OBSERVER(Observer, observers_, OnDisconnected()); - return true; - } - - private: - ObserverList<Observer> observers_; - bool is_started_; - DISALLOW_COPY_AND_ASSIGN(IBusDaemonControllerDaemonlessImpl); -}; - -} // namespace - -/////////////////////////////////////////////////////////////////////////////// -// IBusDaemonController - -IBusDaemonController::IBusDaemonController() { -} - -IBusDaemonController::~IBusDaemonController() { -} - -// static -void IBusDaemonController::Initialize( - const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, - const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { - DCHECK(g_ibus_daemon_controller == NULL) - << "Do not call Initialize function multiple times."; - g_ibus_daemon_controller = new IBusDaemonControllerDaemonlessImpl(); -} - -// static -void IBusDaemonController::InitializeForTesting( - IBusDaemonController* controller) { - DCHECK(g_ibus_daemon_controller == NULL); - DCHECK(controller); - g_ibus_daemon_controller = controller; -} - -// static -void IBusDaemonController::Shutdown() { - delete g_ibus_daemon_controller; - g_ibus_daemon_controller = NULL; -} - -// static -IBusDaemonController* IBusDaemonController::GetInstance() { - return g_ibus_daemon_controller; -} - -} // namespace chromeos diff --git a/chromeos/ime/ibus_daemon_controller.h b/chromeos/ime/ibus_daemon_controller.h deleted file mode 100644 index aa9d91c..0000000 --- a/chromeos/ime/ibus_daemon_controller.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMEOS_IME_IBUS_DAEMON_CONTROLLER_H_ -#define CHROMEOS_IME_IBUS_DAEMON_CONTROLLER_H_ - -#include "base/memory/ref_counted.h" -#include "base/sequenced_task_runner.h" -#include "chromeos/chromeos_export.h" - -namespace chromeos { - -// IBusDaemonController is used to start/stop ibus-daemon process. This class is -// also watching ibus-daemon process and if it is crashed, re-launch it -// automatically. This class is managed as Singleton. -class CHROMEOS_EXPORT IBusDaemonController { - public: - class Observer { - public: - // Called when the connection with ibus-daemon is established. - virtual void OnConnected() = 0; - - // Called when the connection with ibus-daemon is lost. - virtual void OnDisconnected() = 0; - }; - - // Initializes IBusDaemonController. ibus-daemon related file handling is - // posted to |file_task_runner|. This function must be called before any - // GetInstance() function call. - static void Initialize( - const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, - const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); - - // Similar to Initialize(), but can inject alternative IBusDaemonController - // such as MockIBusDaemonController for testing. The injected object object - // will be owned by the internal pointer and deleted by Shutdown(). - static void InitializeForTesting(IBusDaemonController* controller); - - // Destroys the global instance. - static void Shutdown(); - - // Returns actual implementation of IBusDaemonController. If the browser is - // not running on the Chrome OS device, this function returns stub - // implementation. - static CHROMEOS_EXPORT IBusDaemonController* GetInstance(); - - virtual ~IBusDaemonController(); - - virtual void AddObserver(Observer* observer) = 0; - virtual void RemoveObserver(Observer* observer) = 0; - - // Starts ibus-daemon. - virtual bool Start() = 0; - - // Stops ibus-daemon. - virtual bool Stop() = 0; - - protected: - // IBusDaemonController is managed as singleton. Use GetInstance instead. - IBusDaemonController(); - - DISALLOW_COPY_AND_ASSIGN(IBusDaemonController); -}; - -} // namespace chromeos - -#endif // CHROMEOS_IME_IBUS_DAEMON_CONTROLLER_H_ diff --git a/chromeos/ime/mock_ibus_daemon_controller.cc b/chromeos/ime/mock_ibus_daemon_controller.cc deleted file mode 100644 index 48aaeb9..0000000 --- a/chromeos/ime/mock_ibus_daemon_controller.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromeos/ime/mock_ibus_daemon_controller.h" - -namespace chromeos { - -MockIBusDaemonController::MockIBusDaemonController() - : start_count_(0), - stop_count_(0) { -} - -MockIBusDaemonController::~MockIBusDaemonController() { -} - -void MockIBusDaemonController::AddObserver(Observer* observer) { - observers_.AddObserver(observer); -} - -void MockIBusDaemonController::RemoveObserver(Observer* observer) { - observers_.RemoveObserver(observer); -} - -bool MockIBusDaemonController::Start() { - ++start_count_; - return true; -} - -bool MockIBusDaemonController::Stop() { - ++stop_count_; - return true; -} - -void MockIBusDaemonController::EmulateConnect() { - FOR_EACH_OBSERVER(Observer, observers_, OnConnected()); -} - -void MockIBusDaemonController::EmulateDisconnect() { - FOR_EACH_OBSERVER(Observer, observers_, OnDisconnected()); -} - - -} // namespace chromeos diff --git a/chromeos/ime/mock_ibus_daemon_controller.h b/chromeos/ime/mock_ibus_daemon_controller.h deleted file mode 100644 index 7a1c4be..0000000 --- a/chromeos/ime/mock_ibus_daemon_controller.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMEOS_IME_MOCK_IBUS_DAEMON_CONTROLLER_H_ -#define CHROMEOS_IME_MOCK_IBUS_DAEMON_CONTROLLER_H_ - -#include "base/observer_list.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/ime/ibus_daemon_controller.h" - -namespace chromeos { - -// A mock implementation of IBusDaemonController. -class CHROMEOS_EXPORT MockIBusDaemonController : public IBusDaemonController { - public: - MockIBusDaemonController(); - virtual ~MockIBusDaemonController(); - - // IBusDaemonController overrides: - virtual void AddObserver(Observer* observer) OVERRIDE; - virtual void RemoveObserver(Observer* observer) OVERRIDE; - virtual bool Start() OVERRIDE; - virtual bool Stop() OVERRIDE; - - // Emulates connecting/disconnecting the connection with ibus-daemon. - void EmulateConnect(); - void EmulateDisconnect(); - - int start_count() { return start_count_;} - int stop_count() { return stop_count_;} - - private: - int start_count_; - int stop_count_; - - ObserverList<Observer> observers_; - - DISALLOW_COPY_AND_ASSIGN(MockIBusDaemonController); -}; - -} // namespace chromeos - -#endif // CHROMEOS_IME_MOCK_IBUS_DAEMON_CONTROLLER_H_ |