diff options
author | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-13 05:51:29 +0000 |
---|---|---|
committer | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-13 05:51:29 +0000 |
commit | abb2b9f0cb653e30cb43cdc63b527bdaddbedc58 (patch) | |
tree | 9edef0945266ce9172fd79f745178e5d06f94ee3 /chrome/browser/chromeos/input_method | |
parent | 321e8602f4adc6e8e2325c375b8cea591d0c87d5 (diff) | |
download | chromium_src-abb2b9f0cb653e30cb43cdc63b527bdaddbedc58.zip chromium_src-abb2b9f0cb653e30cb43cdc63b527bdaddbedc58.tar.gz chromium_src-abb2b9f0cb653e30cb43cdc63b527bdaddbedc58.tar.bz2 |
Delete IBusClient.
IBusClient is no longer necessary. This patch cleans up the code.
BUG=317500
Review URL: https://codereview.chromium.org/67313006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/input_method')
5 files changed, 22 insertions, 91 deletions
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 1cff6b2..06fd8d8 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc +++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc @@ -14,7 +14,6 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/ibus/ibus_client.h" #include "chromeos/dbus/ibus/ibus_component.h" #include "chromeos/dbus/ibus/ibus_engine_factory_service.h" #include "chromeos/dbus/ibus/ibus_engine_service.h" @@ -113,10 +112,7 @@ void InputMethodEngineIBus::Initialize( component_->mutable_engine_description()->push_back(engine_desc); manager->AddInputMethodExtension(ibus_id_, engine_name, layouts, languages, options_page, input_view, this); - // If connection is avaiable, register component. If there are no connection - // to ibus-daemon, OnConnected callback will register component instead. - if (IsConnected()) - RegisterComponent(); + RegisterComponent(); } void InputMethodEngineIBus::StartIme() { @@ -599,32 +595,13 @@ void InputMethodEngineIBus::OnConnected() { void InputMethodEngineIBus::OnDisconnected() { } -bool InputMethodEngineIBus::IsConnected() { - return DBusThreadManager::Get()->GetIBusClient() != NULL; -} - void InputMethodEngineIBus::RegisterComponent() { - IBusClient* client = DBusThreadManager::Get()->GetIBusClient(); - client->RegisterComponent( - *component_.get(), - base::Bind(&InputMethodEngineIBus::OnComponentRegistered, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&InputMethodEngineIBus::OnComponentRegistrationFailed, - weak_ptr_factory_.GetWeakPtr())); -} - -void InputMethodEngineIBus::OnComponentRegistered() { ibus_engine_factory_service_->SetCreateEngineHandler( ibus_id_, base::Bind(&InputMethodEngineIBus::CreateEngineHandler, weak_ptr_factory_.GetWeakPtr())); } -void InputMethodEngineIBus::OnComponentRegistrationFailed() { - DVLOG(1) << "Failed to register input method components."; - // TODO(nona): Implement error handling. -} - void InputMethodEngineIBus::CreateEngineHandler( const IBusEngineFactoryService::CreateEngineResponseSender& sender) { GetCurrentService()->UnsetEngine(this); 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 9f2ecf0..c8adb11 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.h +++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.h @@ -103,9 +103,6 @@ class InputMethodEngineIBus : public InputMethodEngine, void OnDisconnected(); private: - // Returns true if the connection to ibus-daemon is avaiable. - bool IsConnected(); - // Converts MenuItem to InputMethodProperty. void MenuItemToProperty(const MenuItem& item, input_method::InputMethodProperty* property); @@ -113,12 +110,6 @@ class InputMethodEngineIBus : public InputMethodEngine, // Registers the engine component. void RegisterComponent(); - // Called when the RegisterComponent is failed. - void OnComponentRegistrationFailed(); - - // Called when the RegisterComponent is succeeded. - void OnComponentRegistered(); - // Called when the ibus-daemon sends CreateEngine message with corresponding // engine id. void CreateEngineHandler( 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 820ee13..0fe1eb2 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc @@ -19,7 +19,6 @@ #include "chrome/browser/chromeos/input_method/input_method_engine_ibus.h" #include "chrome/browser/chromeos/language_preferences.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/ibus/ibus_client.h" #include "chromeos/ime/component_extension_ime_manager.h" #include "chromeos/ime/extension_ime_util.h" #include "chromeos/ime/input_method_delegate.h" @@ -296,13 +295,11 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( } } - if (!component_extension_ime_manager_->IsInitialized() || - (!InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch) && - !IsIBusConnectionAlive())) { - // We can't change input method before the initialization of component - // extension ime manager or before connection to ibus-daemon is not - // established. ChangeInputMethod will be called with - // |pending_input_method_| when the both initialization is done. + if (!component_extension_ime_manager_->IsInitialized()) { + // We can't change input method before the initialization of + // component extension ime manager. ChangeInputMethod will be + // called with |pending_input_method_| when the initialization is + // done. pending_input_method_ = input_method_id_to_switch; return false; } @@ -310,7 +307,6 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( pending_input_method_.clear(); IBusEngineHandlerInterface* engine = IBusBridge::Get()->GetEngineHandler(); const std::string current_input_method_id = current_input_method_.id(); - IBusClient* client = DBusThreadManager::Get()->GetIBusClient(); if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) { FOR_EACH_OBSERVER(InputMethodManager::Observer, observers_, @@ -320,9 +316,15 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( IBusBridge::Get()->SetEngineHandler(NULL); } } else { - DCHECK(client); - client->SetGlobalEngine(input_method_id_to_switch, - base::Bind(&base::DoNothing)); + // Disable the current engine and enable the next engine. + if (engine) + engine->Disable(); + IBusBridge::Get()->CreateEngine(input_method_id_to_switch); + IBusEngineHandlerInterface* next_engine = + IBusBridge::Get()->GetEngineHandler(); + IBusBridge::Get()->SetEngineHandler(next_engine); + if (next_engine) + next_engine->Enable(); } if (current_input_method_id != input_method_id_to_switch) { @@ -866,9 +868,5 @@ void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { DVLOG(1) << "Failed to initialize the candidate window controller"; } -bool InputMethodManagerImpl::IsIBusConnectionAlive() { - return DBusThreadManager::Get() && DBusThreadManager::Get()->GetIBusClient(); -} - } // namespace input_method } // namespace chromeos 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 487a079..900891b 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h @@ -136,9 +136,6 @@ class InputMethodManagerImpl : public InputMethodManager, // that only contains an input method ID of a keyboard layout. bool ContainsOnlyKeyboardLayout(const std::vector<std::string>& value); - // Returns true if the connection to ibus-daemon is established. - bool IsIBusConnectionAlive(); - // Creates and initializes |candidate_window_controller_| if it hasn't been // done. void MaybeInitializeCandidateWindowController(); 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 c5b5e8d..aa38eea 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 @@ -16,7 +16,6 @@ #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.h" #include "chrome/browser/chromeos/input_method/mock_ibus_controller.h" #include "chromeos/dbus/fake_dbus_thread_manager.h" -#include "chromeos/dbus/ibus/mock_ibus_client.h" #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" @@ -151,9 +150,6 @@ class InputMethodManagerImplTest : public testing::Test { // Helper function to initialize IBus bus connection for testing. Do not use // ibus related mocks before calling this function. void InitIBusBus() { - mock_ibus_client_ = new MockIBusClient; - fake_dbus_thread_manager_->SetIBusClient( - scoped_ptr<IBusClient>(mock_ibus_client_)); mock_ibus_daemon_controller_->EmulateConnect(); } @@ -163,7 +159,6 @@ class InputMethodManagerImplTest : public testing::Test { MockCandidateWindowController* candidate_window_controller_; MockIBusDaemonController* mock_ibus_daemon_controller_; scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; - MockIBusClient* mock_ibus_client_; FakeDBusThreadManager* fake_dbus_thread_manager_; MockXKeyboard* xkeyboard_; base::MessageLoop message_loop_; @@ -1105,26 +1100,6 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { manager_->RemoveObserver(&observer); } -TEST_F(InputMethodManagerImplTest, TestReset) { - InitComponentExtension(); - InitIBusBus(); - manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); - std::vector<std::string> ids; - ids.push_back("xkb:us::eng"); - ids.push_back(nacl_mozc_us_id); - EXPECT_TRUE(manager_->EnableInputMethods(ids)); - EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); - EXPECT_EQ(0, mock_engine_handler_->reset_call_count()); - manager_->ChangeInputMethod(nacl_mozc_us_id); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(nacl_mozc_us_id, mock_ibus_client_->latest_global_engine_name()); - EXPECT_EQ(0, mock_engine_handler_->reset_call_count()); - manager_->ChangeInputMethod("xkb:us::eng"); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(nacl_mozc_us_id, mock_ibus_client_->latest_global_engine_name()); - EXPECT_EQ(0, mock_engine_handler_->reset_call_count()); -} - TEST_F(InputMethodManagerImplTest, ChangeInputMethodBeforeComponentExtensionInitialization_OneIME) { manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); @@ -1136,8 +1111,7 @@ TEST_F(InputMethodManagerImplTest, InitIBusBus(); InitComponentExtension(); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(nacl_mozc_us_id, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(nacl_mozc_us_id, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, @@ -1153,8 +1127,7 @@ TEST_F(InputMethodManagerImplTest, InitComponentExtension(); InitIBusBus(); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(nacl_mozc_jp_id, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(nacl_mozc_jp_id, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, @@ -1172,8 +1145,7 @@ TEST_F(InputMethodManagerImplTest, InitComponentExtension(); InitIBusBus(); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(ext_id, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, @@ -1197,8 +1169,7 @@ TEST_F(InputMethodManagerImplTest, InitComponentExtension(); InitIBusBus(); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(ext_id2, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, @@ -1214,8 +1185,7 @@ TEST_F(InputMethodManagerImplTest, ids.push_back(ext_id); EXPECT_TRUE(manager_->EnableInputMethods(ids)); EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(ext_id, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, @@ -1236,11 +1206,9 @@ TEST_F(InputMethodManagerImplTest, ids.push_back(ext_id2); EXPECT_TRUE(manager_->EnableInputMethods(ids)); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); - EXPECT_EQ(1, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(ext_id1, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(ext_id1, manager_->GetCurrentInputMethod().id()); manager_->ChangeInputMethod(ext_id2); - EXPECT_EQ(2, mock_ibus_client_->set_global_engine_call_count()); - EXPECT_EQ(ext_id2, mock_ibus_client_->latest_global_engine_name()); + EXPECT_EQ(ext_id2, manager_->GetCurrentInputMethod().id()); } TEST_F(InputMethodManagerImplTest, |