summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 07:44:26 +0000
committernona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 07:44:26 +0000
commitc95448eaa22f6ac5c6558ce73a704b9af04c5e7c (patch)
tree30701c4c9392f3fa53b0efd6422ac0bb850fe22e
parent07516269ca14f8ef4cf6bfaa721f169290ef7318 (diff)
downloadchromium_src-c95448eaa22f6ac5c6558ce73a704b9af04c5e7c.zip
chromium_src-c95448eaa22f6ac5c6558ce73a704b9af04c5e7c.tar.gz
chromium_src-c95448eaa22f6ac5c6558ce73a704b9af04c5e7c.tar.bz2
Decouple chromeos/dbus/ibus from IBusController.
With this CL, IBusConfigClient will be removed. IBus config is no longer used in Chrome, all configuration is managed by extension. BUG=275262 TEST=IME does not break. Review URL: https://chromiumcodereview.appspot.com/22927011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218934 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller.h11
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_base.cc28
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_base.h22
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc105
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_impl.cc107
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_impl.h35
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_unittest.cc7
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.cc13
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.h4
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc22
-rw-r--r--chrome/browser/chromeos/input_method/mock_ibus_controller.cc14
-rw-r--r--chrome/browser/chromeos/input_method/mock_ibus_controller.h11
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.cc7
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.h4
-rw-r--r--chrome/browser/chromeos/preferences.cc150
-rw-r--r--chrome/browser/chromeos/preferences.h25
-rw-r--r--chrome/browser/chromeos/preferences_unittest.cc10
-rw-r--r--chromeos/chromeos.gyp5
-rw-r--r--chromeos/dbus/dbus_thread_manager.cc8
-rw-r--r--chromeos/dbus/dbus_thread_manager.h2
-rw-r--r--chromeos/dbus/ibus/ibus_config_client.cc318
-rw-r--r--chromeos/dbus/ibus/ibus_config_client.h77
-rw-r--r--chromeos/dbus/ibus/ibus_config_client_unittest.cc627
-rw-r--r--chromeos/dbus/ibus/mock_ibus_config_client.cc44
-rw-r--r--chromeos/dbus/ibus/mock_ibus_config_client.h47
-rw-r--r--chromeos/dbus/mock_dbus_thread_manager.cc1
-rw-r--r--chromeos/dbus/mock_dbus_thread_manager.h1
-rw-r--r--chromeos/dbus/mock_dbus_thread_manager_without_gmock.cc6
-rw-r--r--chromeos/dbus/mock_dbus_thread_manager_without_gmock.h7
-rw-r--r--chromeos/ime/input_method_manager.h6
30 files changed, 13 insertions, 1711 deletions
diff --git a/chrome/browser/chromeos/input_method/ibus_controller.h b/chrome/browser/chromeos/input_method/ibus_controller.h
index 0c3830a..1645b08 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller.h
+++ b/chrome/browser/chromeos/input_method/ibus_controller.h
@@ -12,14 +12,11 @@
namespace chromeos {
namespace input_method {
-struct InputMethodConfigValue;
struct InputMethodProperty;
typedef std::vector<InputMethodProperty> InputMethodPropertyList;
// IBusController is used to interact with the system input method framework
// (which is currently IBus).
-// TODO(nona): Split this class into IBusPropertyHandler and IBusConfigHandler.
-// Note: IBusConfig will be deprecated once ibus-daemon is gone.
class IBusController {
public:
class Observer {
@@ -39,14 +36,6 @@ class IBusController {
virtual void ClearProperties() = 0;
- // Sets a configuration of an input method engine. Returns true if the
- // configuration is successfully set. For example, when you set
- // "engine/Mozc/history_learning_level", |section| should be "engine/Mozc",
- // and |config_name| should be "history_learning_level".
- virtual bool SetInputMethodConfig(const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) = 0;
-
// Activates the input method property specified by the |key|. Returns true on
// success.
virtual bool ActivateInputMethodProperty(const std::string& key) = 0;
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_base.cc b/chrome/browser/chromeos/input_method/ibus_controller_base.cc
index be8592b..0f16084 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_base.cc
+++ b/chrome/browser/chromeos/input_method/ibus_controller_base.cc
@@ -21,39 +21,11 @@ void IBusControllerBase::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
-bool IBusControllerBase::SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) {
- DCHECK(!section.empty());
- DCHECK(!config_name.empty());
-
- const ConfigKeyType key(section, config_name);
- if (!SetInputMethodConfigInternal(key, value))
- return false;
- current_config_values_[key] = value;
- return true;
-}
-
const InputMethodPropertyList&
IBusControllerBase::GetCurrentProperties() const {
return current_property_list_;
}
-bool IBusControllerBase::GetInputMethodConfigForTesting(
- const std::string& section,
- const std::string& config_name,
- InputMethodConfigValue* out_value) {
- DCHECK(out_value);
- const ConfigKeyType key(section, config_name);
- InputMethodConfigRequests::const_iterator iter =
- current_config_values_.find(key);
- if (iter == current_config_values_.end())
- return false;
- *out_value = iter->second;
- return true;
-}
-
void IBusControllerBase::ClearProperties() {
current_property_list_.clear();
}
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_base.h b/chrome/browser/chromeos/input_method/ibus_controller_base.h
index 2503b51..83b0f93 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_base.h
+++ b/chrome/browser/chromeos/input_method/ibus_controller_base.h
@@ -10,7 +10,6 @@
#include "base/observer_list.h"
#include "chrome/browser/chromeos/input_method/ibus_controller.h"
-#include "chromeos/ime/input_method_config.h"
#include "chromeos/ime/input_method_property.h"
namespace chromeos {
@@ -27,18 +26,9 @@ class IBusControllerBase : public IBusController {
// functions.
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
- virtual bool SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) OVERRIDE;
virtual const InputMethodPropertyList& GetCurrentProperties() const OVERRIDE;
virtual void ClearProperties() OVERRIDE;
- // Gets the current input method configuration.
- bool GetInputMethodConfigForTesting(const std::string& section,
- const std::string& config_name,
- InputMethodConfigValue* out_value);
-
// Notifies all |observers_|.
void NotifyPropertyChangedForTesting();
@@ -47,20 +37,8 @@ class IBusControllerBase : public IBusController {
const InputMethodPropertyList& current_property_list);
protected:
- typedef std::pair<std::string, std::string> ConfigKeyType;
- typedef std::map<
- ConfigKeyType, InputMethodConfigValue> InputMethodConfigRequests;
-
- virtual bool SetInputMethodConfigInternal(
- const ConfigKeyType& key,
- const InputMethodConfigValue& value) = 0;
-
ObserverList<Observer> observers_;
- // Values that have been set via SetInputMethodConfig(). We keep a copy
- // available to (re)send when the system input method framework (re)starts.
- InputMethodConfigRequests current_config_values_;
-
// The value which will be returned by GetCurrentProperties(). Derived classes
// should update this variable when needed.
InputMethodPropertyList current_property_list_;
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc
index 611cf3d..353b109 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc
+++ b/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc
@@ -5,7 +5,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/input_method/ibus_controller_base.h"
-#include "chromeos/ime/input_method_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
@@ -17,9 +16,7 @@ namespace {
// RemoveObserver() methods in IBusControllerBase.
class TestIBusController : public IBusControllerBase {
public:
- TestIBusController()
- : set_input_method_config_internal_count_(0),
- set_input_method_config_internal_return_(true) {
+ TestIBusController() {
}
virtual ~TestIBusController() {
}
@@ -34,28 +31,7 @@ class TestIBusController : public IBusControllerBase {
return observers_.size();
}
- int set_input_method_config_internal_count() const {
- return set_input_method_config_internal_count_;
- }
- void set_set_input_method_config_internal_return(bool new_value) {
- set_input_method_config_internal_return_ = new_value;
- }
- const ConfigKeyType& last_key() const { return last_key_; }
-
- protected:
- virtual bool SetInputMethodConfigInternal(
- const ConfigKeyType& key,
- const InputMethodConfigValue& value) OVERRIDE {
- ++set_input_method_config_internal_count_;
- last_key_ = key;
- return set_input_method_config_internal_return_;
- }
-
private:
- int set_input_method_config_internal_count_;
- bool set_input_method_config_internal_return_;
- ConfigKeyType last_key_;
-
DISALLOW_COPY_AND_ASSIGN(TestIBusController);
};
@@ -80,85 +56,6 @@ class IBusControllerBaseTest : public testing::Test {
} // namespace
-TEST_F(IBusControllerBaseTest, TestSetInputMethodConfig) {
- InputMethodConfigValue value_set;
- InputMethodConfigValue value_get;
- EXPECT_FALSE(controller_->GetInputMethodConfigForTesting("section",
- "name",
- &value_get));
- EXPECT_EQ(0, controller_->set_input_method_config_internal_count());
-
- // Set a value.
- value_set.type = InputMethodConfigValue::kValueTypeInt;
- value_set.int_value = 12345;
- EXPECT_TRUE(controller_->SetInputMethodConfig("section",
- "name",
- value_set));
- EXPECT_EQ(1, controller_->set_input_method_config_internal_count());
- EXPECT_EQ("section", controller_->last_key().first);
- EXPECT_EQ("name", controller_->last_key().second);
-
- // Get the value.
- EXPECT_TRUE(controller_->GetInputMethodConfigForTesting("section",
- "name",
- &value_get));
- EXPECT_EQ(value_set.type, value_get.type);
- EXPECT_EQ(value_set.int_value, value_get.int_value);
-
- // Set another value.
- value_set.type = InputMethodConfigValue::kValueTypeBool;
- value_set.bool_value = true;
- EXPECT_TRUE(controller_->SetInputMethodConfig("section/2",
- "name2",
- value_set));
- EXPECT_EQ(2, controller_->set_input_method_config_internal_count());
- EXPECT_EQ("section/2", controller_->last_key().first);
- EXPECT_EQ("name2", controller_->last_key().second);
-
- // Overwrite the first value.
- value_set.type = InputMethodConfigValue::kValueTypeInt;
- value_set.int_value = 54321;
- EXPECT_TRUE(controller_->SetInputMethodConfig("section",
- "name",
- value_set));
- EXPECT_EQ(3, controller_->set_input_method_config_internal_count());
- EXPECT_EQ("section", controller_->last_key().first);
- EXPECT_EQ("name", controller_->last_key().second);
-
- // Get the value.
- EXPECT_TRUE(controller_->GetInputMethodConfigForTesting("section",
- "name",
- &value_get));
- EXPECT_EQ(value_set.type, value_get.type);
- EXPECT_EQ(value_set.int_value, value_get.int_value);
-
- // Get a non existent value.
- EXPECT_FALSE(controller_->GetInputMethodConfigForTesting("sectionX",
- "name",
- &value_get));
- EXPECT_FALSE(controller_->GetInputMethodConfigForTesting("section",
- "nameX",
- &value_get));
-}
-
-TEST_F(IBusControllerBaseTest, TestSetInputMethodConfigInternal) {
- InputMethodConfigValue value_set;
- InputMethodConfigValue value_get;
- // Set a value. In this case, SetInputMethodConfigInternal returns false.
- controller_->set_set_input_method_config_internal_return(false);
- value_set.type = InputMethodConfigValue::kValueTypeInt;
- value_set.int_value = 12345;
- EXPECT_FALSE(controller_->SetInputMethodConfig("section",
- "name",
- value_set));
- EXPECT_EQ(1, controller_->set_input_method_config_internal_count());
-
- // Getting the value should fail.
- EXPECT_FALSE(controller_->GetInputMethodConfigForTesting("section",
- "name",
- &value_get));
-}
-
TEST_F(IBusControllerBaseTest, TestAddRemoveObserver) {
TestObserver observer1;
TestObserver observer2;
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc
index 5cb4461..1bd85f9 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc
+++ b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc
@@ -22,16 +22,11 @@
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/ibus/ibus_client.h"
-#include "chromeos/dbus/ibus/ibus_config_client.h"
-#include "chromeos/dbus/ibus/ibus_constants.h"
-#include "chromeos/dbus/ibus/ibus_input_context_client.h"
-#include "chromeos/dbus/ibus/ibus_panel_service.h"
#include "chromeos/dbus/ibus/ibus_property.h"
#include "chromeos/ime/component_extension_ime_manager.h"
#include "chromeos/ime/extension_ime_util.h"
#include "chromeos/ime/ibus_bridge.h"
+#include "chromeos/ime/ime_constants.h"
#include "chromeos/ime/input_method_config.h"
#include "chromeos/ime/input_method_property.h"
#include "ui/aura/client/aura_constants.h"
@@ -55,10 +50,6 @@ bool FindAndUpdateProperty(
return false;
}
-void ConfigSetValueErrorCallback() {
- DVLOG(1) << "IBusConfig: SetValue is failed.";
-}
-
} // namespace
namespace chromeos {
@@ -190,21 +181,15 @@ bool FlattenPropertyList(const IBusPropertyList& ibus_prop_list,
} // namespace
-IBusControllerImpl::IBusControllerImpl()
- : weak_ptr_factory_(this) {
- IBusDaemonController::GetInstance()->AddObserver(this);
+IBusControllerImpl::IBusControllerImpl() {
+ IBusBridge::Get()->SetPropertyHandler(this);
}
IBusControllerImpl::~IBusControllerImpl() {
- IBusDaemonController::GetInstance()->RemoveObserver(this);
+ IBusBridge::Get()->SetPropertyHandler(NULL);
}
bool IBusControllerImpl::ActivateInputMethodProperty(const std::string& key) {
- if (!IBusConnectionsAreAlive()) {
- DVLOG(1) << "ActivateInputMethodProperty: IBus connection is not alive";
- return false;
- }
-
// The third parameter of ibus_input_context_property_activate() has to be
// true when the |key| points to a radio button. false otherwise.
bool is_radio = true;
@@ -220,68 +205,13 @@ bool IBusControllerImpl::ActivateInputMethodProperty(const std::string& key) {
return false;
}
- IBusInputContextClient* client
- = DBusThreadManager::Get()->GetIBusInputContextClient();
- if (client)
- client->PropertyActivate(key,
+ IBusEngineHandlerInterface* engine = IBusBridge::Get()->GetEngineHandler();
+ if (engine)
+ engine->PropertyActivate(key,
static_cast<ibus::IBusPropertyState>(is_radio));
return true;
}
-bool IBusControllerImpl::IBusConnectionsAreAlive() {
- return DBusThreadManager::Get() &&
- DBusThreadManager::Get()->GetIBusBus() != NULL;
-}
-
-bool IBusControllerImpl::SetInputMethodConfigInternal(
- const ConfigKeyType& key,
- const InputMethodConfigValue& value) {
- if (value.type != InputMethodConfigValue::kValueTypeString &&
- value.type != InputMethodConfigValue::kValueTypeInt &&
- value.type != InputMethodConfigValue::kValueTypeBool &&
- value.type != InputMethodConfigValue::kValueTypeStringList) {
- DVLOG(1) << "SendInputMethodConfig: unknown value.type";
- return false;
- }
-
- IBusConfigClient* client = DBusThreadManager::Get()->GetIBusConfigClient();
- if (!client) {
- // Should return true if the ibus-memconf is not ready to use, otherwise IME
- // configuration will not be initialized.
- return true;
- }
-
- switch (value.type) {
- case InputMethodConfigValue::kValueTypeString:
- client->SetStringValue(key.first,
- key.second,
- value.string_value,
- base::Bind(&ConfigSetValueErrorCallback));
- return true;
- case InputMethodConfigValue::kValueTypeInt:
- client->SetIntValue(key.first,
- key.second,
- value.int_value,
- base::Bind(&ConfigSetValueErrorCallback));
- return true;
- case InputMethodConfigValue::kValueTypeBool:
- client->SetBoolValue(key.first,
- key.second,
- value.bool_value,
- base::Bind(&ConfigSetValueErrorCallback));
- return true;
- case InputMethodConfigValue::kValueTypeStringList:
- client->SetStringListValue(key.first,
- key.second,
- value.string_list_value,
- base::Bind(&ConfigSetValueErrorCallback));
- return true;
- default:
- NOTREACHED() << "SendInputMethodConfig: unknown value.type";
- return false;
- }
-}
-
void IBusControllerImpl::RegisterProperties(
const IBusPropertyList& ibus_prop_list) {
current_property_list_.clear();
@@ -307,29 +237,6 @@ void IBusControllerImpl::UpdateProperty(const IBusProperty& ibus_prop) {
}
}
-void IBusControllerImpl::OnIBusConfigClientInitialized() {
- DCHECK(thread_checker_.CalledOnValidThread());
- InputMethodConfigRequests::const_iterator iter =
- current_config_values_.begin();
- for (; iter != current_config_values_.end(); ++iter) {
- SetInputMethodConfigInternal(iter->first, iter->second);
- }
-}
-
-void IBusControllerImpl::OnConnected() {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- DBusThreadManager::Get()->GetIBusPanelService()->SetUpPropertyHandler(this);
-
- DBusThreadManager::Get()->GetIBusConfigClient()->InitializeAsync(
- base::Bind(&IBusControllerImpl::OnIBusConfigClientInitialized,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void IBusControllerImpl::OnDisconnected() {
- DBusThreadManager::Get()->GetIBusPanelService()->SetUpPropertyHandler(NULL);
-}
-
// static
bool IBusControllerImpl::FindAndUpdatePropertyForTesting(
const chromeos::input_method::InputMethodProperty& new_prop,
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.h b/chrome/browser/chromeos/input_method/ibus_controller_impl.h
index 486094f..e262e8d 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_impl.h
+++ b/chrome/browser/chromeos/input_method/ibus_controller_impl.h
@@ -8,20 +8,12 @@
#include <string>
#include <vector>
-#include "base/threading/thread_checker.h"
#include "chrome/browser/chromeos/input_method/ibus_controller_base.h"
-#include "chromeos/dbus/ibus/ibus_panel_service.h"
#include "chromeos/ime/ibus_bridge.h"
-#include "chromeos/ime/ibus_daemon_controller.h"
-
-namespace ui {
-class InputMethodIBus;
-} // namespace ui
namespace chromeos {
namespace input_method {
-struct InputMethodConfigValue;
struct InputMethodProperty;
typedef std::vector<InputMethodProperty> InputMethodPropertyList;
@@ -29,8 +21,7 @@ typedef std::vector<InputMethodProperty> InputMethodPropertyList;
// TODO(nona): Merge to IBusControllerBase, there is no longer reason to split
// this class into Impl and Base.
class IBusControllerImpl : public IBusControllerBase,
- public IBusPanelPropertyHandlerInterface,
- public IBusDaemonController::Observer {
+ public IBusPanelPropertyHandlerInterface {
public:
IBusControllerImpl();
virtual ~IBusControllerImpl();
@@ -45,35 +36,11 @@ class IBusControllerImpl : public IBusControllerBase,
InputMethodPropertyList* prop_list);
private:
- // IBusDaemonController overrides:
- virtual void OnConnected() OVERRIDE;
- virtual void OnDisconnected() OVERRIDE;
-
- // IBusControllerBase overrides:
- virtual bool SetInputMethodConfigInternal(
- const ConfigKeyType& key,
- const InputMethodConfigValue& value) OVERRIDE;
-
// IBusPanelPropertyHandlerInterface overrides:
virtual void RegisterProperties(
const IBusPropertyList& properties) OVERRIDE;
virtual void UpdateProperty(const IBusProperty& property) OVERRIDE;
- // Checks if |ibus_| and |ibus_config_| connections are alive.
- bool IBusConnectionsAreAlive();
-
- // Called when the IBusConfigClient is initialized.
- void OnIBusConfigClientInitialized();
-
- // Current input context path.
- std::string current_input_context_path_;
-
- // IBusControllerImpl should be used only on UI thread.
- base::ThreadChecker thread_checker_;
-
- // Used for making callbacks for PostTask.
- base::WeakPtrFactory<IBusControllerImpl> weak_ptr_factory_;
-
DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl);
};
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
index fd32f51..7b74d96 100644
--- a/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
+++ b/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
@@ -5,20 +5,19 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/input_method/ibus_controller.h"
-#include "chromeos/ime/mock_ibus_daemon_controller.h"
+#include "chromeos/ime/ibus_bridge.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace input_method {
TEST(IBusControllerTest, TestCreate) {
- chromeos::IBusDaemonController::InitializeForTesting(
- new chromeos::MockIBusDaemonController());
+ IBusBridge::Initialize();
{
scoped_ptr<IBusController> controller(IBusController::Create());
EXPECT_TRUE(controller.get());
}
- chromeos::IBusDaemonController::Shutdown();
+ IBusBridge::Shutdown();
}
} // namespace input_method
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 20fba08..5a41b15 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -381,19 +381,6 @@ bool InputMethodManagerImpl::MigrateKoreanKeyboard(
return false;
}
-bool InputMethodManagerImpl::SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) {
- DCHECK(section != language_prefs::kGeneralSectionName ||
- config_name != language_prefs::kPreloadEnginesConfigName);
-
- if (state_ == STATE_TERMINATING)
- return false;
-
- return ibus_controller_->SetInputMethodConfig(section, config_name, value);
-}
-
void InputMethodManagerImpl::ChangeInputMethod(
const std::string& input_method_id) {
ChangeInputMethodInternal(input_method_id, false);
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 1d0d417..88f1875 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
@@ -73,10 +73,6 @@ class InputMethodManagerImpl : public InputMethodManager,
virtual bool MigrateKoreanKeyboard(
const std::string& keyboard_id,
std::vector<std::string>* input_method_ids) OVERRIDE;
- virtual bool SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) OVERRIDE;
virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE;
virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE;
virtual void AddInputMethodExtension(
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 d0547bd..e68fe3e 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
@@ -346,28 +346,6 @@ TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) {
EXPECT_TRUE(Contain(*methods.get(), *id_to_find));
}
-TEST_F(InputMethodManagerImplTest, TestSetInputMethodConfig) {
- InputMethodConfigValue config;
- config.type = InputMethodConfigValue::kValueTypeString;
- config.string_value = "string";
- EXPECT_EQ(0, controller_->set_input_method_config_internal_count_);
- EXPECT_TRUE(manager_->SetInputMethodConfig("section", "name", config));
- EXPECT_EQ(1, controller_->set_input_method_config_internal_count_);
- EXPECT_EQ("section",
- controller_->set_input_method_config_internal_key_.first);
- EXPECT_EQ("name",
- controller_->set_input_method_config_internal_key_.second);
- EXPECT_EQ(config.type,
- controller_->set_input_method_config_internal_value_.type);
- EXPECT_EQ(config.string_value,
- controller_->set_input_method_config_internal_value_.string_value);
-
- // SetInputMethodConfig should be no-op in STATE_TERMINATING.
- manager_->SetState(InputMethodManager::STATE_TERMINATING);
- EXPECT_FALSE(manager_->SetInputMethodConfig("section", "name", config));
- EXPECT_EQ(1, controller_->set_input_method_config_internal_count_);
-}
-
TEST_F(InputMethodManagerImplTest, TestEnableTwoLayouts) {
// For http://crbug.com/19655#c11 - (8), step 6.
TestObserver observer;
diff --git a/chrome/browser/chromeos/input_method/mock_ibus_controller.cc b/chrome/browser/chromeos/input_method/mock_ibus_controller.cc
index 05f067c..babc5d9 100644
--- a/chrome/browser/chromeos/input_method/mock_ibus_controller.cc
+++ b/chrome/browser/chromeos/input_method/mock_ibus_controller.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/chromeos/input_method/mock_ibus_controller.h"
-#include "chromeos/ime/input_method_config.h"
#include "chromeos/ime/input_method_property.h"
namespace chromeos {
@@ -12,9 +11,7 @@ namespace input_method {
MockIBusController::MockIBusController()
: activate_input_method_property_count_(0),
- activate_input_method_property_return_(true),
- set_input_method_config_internal_count_(0),
- set_input_method_config_internal_return_(true) {
+ activate_input_method_property_return_(true) {
}
MockIBusController::~MockIBusController() {
@@ -26,14 +23,5 @@ bool MockIBusController::ActivateInputMethodProperty(const std::string& key) {
return activate_input_method_property_return_;
}
-bool MockIBusController::SetInputMethodConfigInternal(
- const ConfigKeyType& key,
- const InputMethodConfigValue& value) {
- ++set_input_method_config_internal_count_;
- set_input_method_config_internal_key_ = key;
- set_input_method_config_internal_value_ = value;
- return set_input_method_config_internal_return_;
-}
-
} // namespace input_method
} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/mock_ibus_controller.h b/chrome/browser/chromeos/input_method/mock_ibus_controller.h
index c405d8e..e27c336 100644
--- a/chrome/browser/chromeos/input_method/mock_ibus_controller.h
+++ b/chrome/browser/chromeos/input_method/mock_ibus_controller.h
@@ -10,7 +10,6 @@
namespace chromeos {
namespace input_method {
-struct InputMethodConfigValue;
struct InputMethodProperty;
// Mock IBusController implementation.
@@ -26,16 +25,6 @@ class MockIBusController : public IBusControllerBase {
int activate_input_method_property_count_;
std::string activate_input_method_property_key_;
bool activate_input_method_property_return_;
- int set_input_method_config_internal_count_;
- ConfigKeyType set_input_method_config_internal_key_;
- InputMethodConfigValue set_input_method_config_internal_value_;
- bool set_input_method_config_internal_return_;
-
- protected:
- // IBusControllerBase overrides:
- virtual bool SetInputMethodConfigInternal(
- const ConfigKeyType& key,
- const InputMethodConfigValue& value) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(MockIBusController);
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_manager.cc b/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
index 4aeef61..da3369414 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
@@ -85,13 +85,6 @@ bool MockInputMethodManager::MigrateKoreanKeyboard(
return false;
}
-bool MockInputMethodManager::SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) {
- return true;
-}
-
void MockInputMethodManager::ChangeInputMethod(
const std::string& input_method_id) {
}
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_manager.h b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
index 5db4950..0534b8a 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.h
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
@@ -45,10 +45,6 @@ class MockInputMethodManager : public InputMethodManager {
virtual bool MigrateKoreanKeyboard(
const std::string& keyboard_id,
std::vector<std::string>* input_method_ids) OVERRIDE;
- virtual bool SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) OVERRIDE;
virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE;
virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE;
virtual void AddInputMethodExtension(
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 00f5cd0..a031a16 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -656,113 +656,6 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
input_method_manager_->SetEnabledExtensionImes(&split_values);
}
- // Do not check |*pref_name| of the prefs for remembering current/previous
- // input methods here. We're only interested in initial values of the prefs.
-
- // TODO(nona): remove all IME preference entries. crbug.com/256102
- for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kChewingBooleanPrefs[i].pref_name) {
- SetLanguageConfigBoolean(
- language_prefs::kChewingSectionName,
- language_prefs::kChewingBooleanPrefs[i].ibus_config_name,
- chewing_boolean_prefs_[i].GetValue());
- }
- }
- for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; ++i) {
- if (!pref_name ||
- *pref_name ==
- language_prefs::kChewingMultipleChoicePrefs[i].pref_name) {
- SetLanguageConfigString(
- language_prefs::kChewingSectionName,
- language_prefs::kChewingMultipleChoicePrefs[i].ibus_config_name,
- chewing_multiple_choice_prefs_[i].GetValue());
- }
- }
- if (!pref_name ||
- *pref_name == language_prefs::kChewingHsuSelKeyType.pref_name) {
- SetLanguageConfigInteger(
- language_prefs::kChewingSectionName,
- language_prefs::kChewingHsuSelKeyType.ibus_config_name,
- chewing_hsu_sel_key_type_.GetValue());
- }
- for (size_t i = 0; i < language_prefs::kNumChewingIntegerPrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kChewingIntegerPrefs[i].pref_name) {
- SetLanguageConfigInteger(
- language_prefs::kChewingSectionName,
- language_prefs::kChewingIntegerPrefs[i].ibus_config_name,
- chewing_integer_prefs_[i].GetValue());
- }
- }
- if (!pref_name ||
- *pref_name == prefs::kLanguageHangulKeyboard) {
- std::vector<std::string> new_input_method_ids;
- if (input_method_manager_->MigrateKoreanKeyboard(
- hangul_keyboard_.GetValue(),
- &new_input_method_ids)) {
- preload_engines_.SetValue(JoinString(new_input_method_ids, ','));
- hangul_keyboard_.SetValue("dummy_value_already_migrated");
- }
- }
- if (!pref_name || *pref_name == prefs::kLanguageHangulHanjaBindingKeys) {
- SetLanguageConfigString(language_prefs::kHangulSectionName,
- language_prefs::kHangulHanjaBindingKeysConfigName,
- hangul_hanja_binding_keys_.GetValue());
- }
- for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kPinyinBooleanPrefs[i].pref_name) {
- SetLanguageConfigBoolean(
- language_prefs::kPinyinSectionName,
- language_prefs::kPinyinBooleanPrefs[i].ibus_config_name,
- pinyin_boolean_prefs_[i].GetValue());
- }
- }
- for (size_t i = 0; i < language_prefs::kNumPinyinIntegerPrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kPinyinIntegerPrefs[i].pref_name) {
- SetLanguageConfigInteger(
- language_prefs::kPinyinSectionName,
- language_prefs::kPinyinIntegerPrefs[i].ibus_config_name,
- pinyin_int_prefs_[i].GetValue());
- }
- }
- if (!pref_name ||
- *pref_name == language_prefs::kPinyinDoublePinyinSchema.pref_name) {
- SetLanguageConfigInteger(
- language_prefs::kPinyinSectionName,
- language_prefs::kPinyinDoublePinyinSchema.ibus_config_name,
- pinyin_double_pinyin_schema_.GetValue());
- }
- for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kMozcBooleanPrefs[i].pref_name) {
- SetLanguageConfigBoolean(
- language_prefs::kMozcSectionName,
- language_prefs::kMozcBooleanPrefs[i].ibus_config_name,
- mozc_boolean_prefs_[i].GetValue());
- }
- }
- for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kMozcMultipleChoicePrefs[i].pref_name) {
- SetLanguageConfigString(
- language_prefs::kMozcSectionName,
- language_prefs::kMozcMultipleChoicePrefs[i].ibus_config_name,
- mozc_multiple_choice_prefs_[i].GetValue());
- }
- }
- for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) {
- if (!pref_name ||
- *pref_name == language_prefs::kMozcIntegerPrefs[i].pref_name) {
- SetLanguageConfigInteger(
- language_prefs::kMozcSectionName,
- language_prefs::kMozcIntegerPrefs[i].ibus_config_name,
- mozc_integer_prefs_[i].GetValue());
- }
- }
-
// Change the download directory to the default value if a Drive directory is
// selected and Drive is disabled.
if (!pref_name || *pref_name == prefs::kDisableDrive) {
@@ -793,45 +686,6 @@ void Preferences::ForceNaturalScrollDefault() {
}
}
-void Preferences::SetLanguageConfigBoolean(const char* section,
- const char* name,
- bool value) {
- input_method::InputMethodConfigValue config;
- config.type = input_method::InputMethodConfigValue::kValueTypeBool;
- config.bool_value = value;
- input_method_manager_->SetInputMethodConfig(section, name, config);
-}
-
-void Preferences::SetLanguageConfigInteger(const char* section,
- const char* name,
- int value) {
- input_method::InputMethodConfigValue config;
- config.type = input_method::InputMethodConfigValue::kValueTypeInt;
- config.int_value = value;
- input_method_manager_->SetInputMethodConfig(section, name, config);
-}
-
-void Preferences::SetLanguageConfigString(const char* section,
- const char* name,
- const std::string& value) {
- input_method::InputMethodConfigValue config;
- config.type = input_method::InputMethodConfigValue::kValueTypeString;
- config.string_value = value;
- input_method_manager_->SetInputMethodConfig(section, name, config);
-}
-
-void Preferences::SetLanguageConfigStringList(
- const char* section,
- const char* name,
- const std::vector<std::string>& values) {
- input_method::InputMethodConfigValue config;
- config.type = input_method::InputMethodConfigValue::kValueTypeStringList;
- for (size_t i = 0; i < values.size(); ++i)
- config.string_list_value.push_back(values[i]);
-
- input_method_manager_->SetInputMethodConfig(section, name, config);
-}
-
void Preferences::SetLanguageConfigStringListAsCSV(const char* section,
const char* name,
const std::string& value) {
@@ -850,10 +704,6 @@ void Preferences::SetLanguageConfigStringListAsCSV(const char* section,
input_method_manager_->EnableInputMethods(split_values);
return;
}
-
- // We should call the cros API even when |value| is empty, to disable default
- // config.
- SetLanguageConfigStringList(section, name, split_values);
}
void Preferences::SetInputMethodList() {
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index 9c98650..dda3427 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -64,31 +64,6 @@ class Preferences : public PrefServiceSyncableObserver,
// stored in the preferences.
void NotifyPrefChanged(const std::string* pref_name);
- // Writes boolean |value| to the input method (IBus) configuration daemon.
- // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should
- // not be NULL.
- void SetLanguageConfigBoolean(const char* section,
- const char* name,
- bool value);
-
- // Writes integer |value| to the input method (IBus) configuration daemon.
- // |section| and |name| should not be NULL.
- void SetLanguageConfigInteger(const char* section,
- const char* name,
- int value);
-
- // Writes string |value| to the input method (IBus) configuration daemon.
- // |section| and |name| should not be NULL.
- void SetLanguageConfigString(const char* section,
- const char* name,
- const std::string& value);
-
- // Writes a string list to the input method (IBus) configuration daemon.
- // |section| and |name| should not be NULL.
- void SetLanguageConfigStringList(const char* section,
- const char* name,
- const std::vector<std::string>& values);
-
// A variant of SetLanguageConfigStringList. You can pass comma-separated
// values. Examples of |value|: "", "Control+space,Hiragana"
void SetLanguageConfigStringListAsCSV(const char* section,
diff --git a/chrome/browser/chromeos/preferences_unittest.cc b/chrome/browser/chromeos/preferences_unittest.cc
index cbab4a6..979e154 100644
--- a/chrome/browser/chromeos/preferences_unittest.cc
+++ b/chrome/browser/chromeos/preferences_unittest.cc
@@ -25,16 +25,6 @@ class MyMockInputMethodManager : public input_method::MockInputMethodManager {
virtual ~MyMockInputMethodManager() {
}
- virtual bool SetInputMethodConfig(
- const std::string& section,
- const std::string& config_name,
- const input_method::InputMethodConfigValue& value) OVERRIDE {
- // Assume the preload engines list is "KeyboardC,KeyboardA,KeyboardB".
- // Switch to the first one, C.
- ChangeInputMethod("KeyboardC");
- return true;
- }
-
virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE {
last_input_method_id_ = input_method_id;
// Do the same thing as BrowserStateMonitor::UpdateUserPreferences.
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp
index 9082a52..dae10d7 100644
--- a/chromeos/chromeos.gyp
+++ b/chromeos/chromeos.gyp
@@ -141,8 +141,6 @@
'dbus/ibus/ibus_client.h',
'dbus/ibus/ibus_component.cc',
'dbus/ibus/ibus_component.h',
- 'dbus/ibus/ibus_config_client.cc',
- 'dbus/ibus/ibus_config_client.h',
'dbus/ibus/ibus_constants.h',
'dbus/ibus/ibus_engine_service.cc',
'dbus/ibus/ibus_engine_service.h',
@@ -428,8 +426,6 @@
'dbus/mock_dbus_thread_manager_without_gmock.h',
'dbus/ibus/mock_ibus_client.cc',
'dbus/ibus/mock_ibus_client.h',
- 'dbus/ibus/mock_ibus_config_client.cc',
- 'dbus/ibus/mock_ibus_config_client.h',
'dbus/ibus/mock_ibus_input_context_client.cc',
'dbus/ibus/mock_ibus_input_context_client.h',
'dbus/ibus/mock_ibus_engine_factory_service.cc',
@@ -476,7 +472,6 @@
'dbus/gsm_sms_client_unittest.cc',
'dbus/ibus/ibus_client_unittest.cc',
'dbus/ibus/ibus_component_unittest.cc',
- 'dbus/ibus/ibus_config_client_unittest.cc',
'dbus/ibus/ibus_engine_factory_service_unittest.cc',
'dbus/ibus/ibus_engine_service_unittest.cc',
'dbus/ibus/ibus_input_context_client_unittest.cc',
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index 9404f3e..70ed816 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -30,7 +30,6 @@
#include "chromeos/dbus/shill_service_client.h"
#include "chromeos/dbus/system_clock_client.h"
#include "chromeos/dbus/ibus/ibus_client.h"
-#include "chromeos/dbus/ibus/ibus_config_client.h"
#include "chromeos/dbus/ibus/ibus_engine_factory_service.h"
#include "chromeos/dbus/ibus/ibus_engine_service.h"
#include "chromeos/dbus/ibus/ibus_input_context_client.h"
@@ -205,8 +204,6 @@ class DBusThreadManagerImpl : public DBusThreadManager {
ibus_client_.reset(
IBusClient::Create(client_type, ibus_bus_.get()));
- ibus_config_client_.reset(
- IBusConfigClient::Create(client_type, ibus_bus_.get()));
ibus_input_context_client_.reset(
IBusInputContextClient::Create(client_type));
ibus_engine_factory_service_.reset(
@@ -334,10 +331,6 @@ class DBusThreadManagerImpl : public DBusThreadManager {
return ibus_client_.get();
}
- virtual IBusConfigClient* GetIBusConfigClient() OVERRIDE {
- return ibus_config_client_.get();
- }
-
virtual IBusInputContextClient* GetIBusInputContextClient() OVERRIDE {
return ibus_input_context_client_.get();
}
@@ -407,7 +400,6 @@ class DBusThreadManagerImpl : public DBusThreadManager {
scoped_ptr<SMSClient> sms_client_;
scoped_ptr<UpdateEngineClient> update_engine_client_;
scoped_ptr<IBusClient> ibus_client_;
- scoped_ptr<IBusConfigClient> ibus_config_client_;
scoped_ptr<IBusInputContextClient> ibus_input_context_client_;
scoped_ptr<IBusEngineFactoryService> ibus_engine_factory_service_;
std::map<dbus::ObjectPath, IBusEngineService*> ibus_engine_services_;
diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h
index 07894ef..6d918af 100644
--- a/chromeos/dbus/dbus_thread_manager.h
+++ b/chromeos/dbus/dbus_thread_manager.h
@@ -37,7 +37,6 @@ class CryptohomeClient;
class DebugDaemonClient;
class GsmSMSClient;
class IBusClient;
-class IBusConfigClient;
class IBusEngineFactoryService;
class IBusEngineService;
class IBusInputContextClient;
@@ -131,7 +130,6 @@ class CHROMEOS_EXPORT DBusThreadManager {
virtual DebugDaemonClient* GetDebugDaemonClient() = 0;
virtual GsmSMSClient* GetGsmSMSClient() = 0;
virtual IBusClient* GetIBusClient() = 0;
- virtual IBusConfigClient* GetIBusConfigClient() = 0;
virtual IBusEngineFactoryService* GetIBusEngineFactoryService() = 0;
virtual IBusEngineService* GetIBusEngineService(
const dbus::ObjectPath& object_path) = 0;
diff --git a/chromeos/dbus/ibus/ibus_config_client.cc b/chromeos/dbus/ibus/ibus_config_client.cc
deleted file mode 100644
index 1e01d27..0000000
--- a/chromeos/dbus/ibus/ibus_config_client.cc
+++ /dev/null
@@ -1,318 +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/dbus/ibus/ibus_config_client.h"
-
-#include <vector>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "chromeos/dbus/ibus/ibus_constants.h"
-#include "chromeos/dbus/ibus/ibus_component.h"
-#include "dbus/bus.h"
-#include "dbus/message.h"
-#include "dbus/object_path.h"
-#include "dbus/object_proxy.h"
-
-namespace chromeos {
-
-namespace {
-
-// Called when the |signal| is connected.
-void OnSignalConnected(const std::string& interface,
- const std::string& signal,
- bool succeeded) {
- LOG_IF(ERROR, !succeeded) << "Connect to " << interface << " "
- << signal << " failed.";
-}
-
-// Called when the GetNameOwner method call is failed.
-void OnGetNameOwnerFail(dbus::ErrorResponse* response) {
- // Do nothing, because method call sometimes fails due to bootstrap timing of
- // ibus-memconf.
-}
-
-// The IBusConfigClient implementation.
-class IBusConfigClientImpl : public IBusConfigClient {
- public:
- explicit IBusConfigClientImpl(dbus::Bus* bus)
- : proxy_(NULL),
- bus_(bus),
- weak_ptr_factory_(this) {
- }
-
- virtual ~IBusConfigClientImpl() {}
-
- // IBusConfigClient override.
- virtual void InitializeAsync(const OnIBusConfigReady& on_ready) OVERRIDE {
- // We should check that the ibus-config daemon actually works first, so we
- // can't initialize synchronously.
- // NameOwnerChanged signal will be emitted by ibus-daemon, but from the
- // service name kDBusServiceName instead of kServiceName. The signal will be
- // used to detect start of ibus-daemon.
- dbus::ObjectProxy* dbus_proxy = bus_->GetObjectProxy(
- ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath));
-
- // Watch NameOwnerChanged signal which is fired when the ibus-config daemon
- // request its name ownership.
- dbus_proxy->ConnectToSignal(
- ibus::kDBusInterface,
- ibus::kNameOwnerChangedSignal,
- base::Bind(&IBusConfigClientImpl::OnNameOwnerChanged,
- weak_ptr_factory_.GetWeakPtr(),
- on_ready),
- base::Bind(&OnSignalConnected));
-
- dbus::MethodCall method_call(ibus::kDBusInterface,
- ibus::kGetNameOwnerMethod);
- dbus::MessageWriter writer(&method_call);
- writer.AppendString(ibus::config::kServiceName);
- dbus_proxy->CallMethodWithErrorCallback(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&IBusConfigClientImpl::OnGetNameOwner,
- weak_ptr_factory_.GetWeakPtr(),
- on_ready),
- base::Bind(&OnGetNameOwnerFail));
- }
-
- // IBusConfigClient override.
- virtual void SetStringValue(const std::string& section,
- const std::string& key,
- const std::string& value,
- const ErrorCallback& error_callback) OVERRIDE {
- if (!proxy_)
- return;
- DCHECK(!error_callback.is_null());
- dbus::MethodCall method_call(ibus::config::kServiceInterface,
- ibus::config::kSetValueMethod);
- dbus::MessageWriter writer(&method_call);
- writer.AppendString(section);
- writer.AppendString(key);
- dbus::MessageWriter variant_writer(NULL);
- writer.OpenVariant("s", &variant_writer);
- variant_writer.AppendString(value);
- writer.CloseContainer(&variant_writer);
- CallWithDefaultCallback(&method_call, error_callback);
- }
-
- // IBusConfigClient override.
- virtual void SetIntValue(const std::string& section,
- const std::string& key,
- int value,
- const ErrorCallback& error_callback) OVERRIDE {
- if (!proxy_)
- return;
- DCHECK(!error_callback.is_null());
- dbus::MethodCall method_call(ibus::config::kServiceInterface,
- ibus::config::kSetValueMethod);
- dbus::MessageWriter writer(&method_call);
- writer.AppendString(section);
- writer.AppendString(key);
- dbus::MessageWriter variant_writer(NULL);
- writer.OpenVariant("i", &variant_writer);
- variant_writer.AppendInt32(value);
- writer.CloseContainer(&variant_writer);
- CallWithDefaultCallback(&method_call, error_callback);
- }
-
- // IBusConfigClient override.
- virtual void SetBoolValue(const std::string& section,
- const std::string& key,
- bool value,
- const ErrorCallback& error_callback) OVERRIDE {
- if (!proxy_)
- return;
- DCHECK(!error_callback.is_null());
- dbus::MethodCall method_call(ibus::config::kServiceInterface,
- ibus::config::kSetValueMethod);
- dbus::MessageWriter writer(&method_call);
- writer.AppendString(section);
- writer.AppendString(key);
- dbus::MessageWriter variant_writer(NULL);
- writer.OpenVariant("b", &variant_writer);
- variant_writer.AppendBool(value);
- writer.CloseContainer(&variant_writer);
- CallWithDefaultCallback(&method_call, error_callback);
- }
-
- // IBusConfigClient override.
- virtual void SetStringListValue(
- const std::string& section,
- const std::string& key,
- const std::vector<std::string>& value,
- const ErrorCallback& error_callback) OVERRIDE {
- if (!proxy_)
- return;
- DCHECK(!error_callback.is_null());
- dbus::MethodCall method_call(ibus::config::kServiceInterface,
- ibus::config::kSetValueMethod);
- dbus::MessageWriter writer(&method_call);
- writer.AppendString(section);
- writer.AppendString(key);
- dbus::MessageWriter variant_writer(NULL);
- dbus::MessageWriter array_writer(NULL);
-
- writer.OpenVariant("as", &variant_writer);
- variant_writer.OpenArray("s", &array_writer);
- for (size_t i = 0; i < value.size(); ++i) {
- array_writer.AppendString(value[i]);
- }
- variant_writer.CloseContainer(&array_writer);
- writer.CloseContainer(&variant_writer);
- CallWithDefaultCallback(&method_call, error_callback);
- }
-
- private:
- void CallWithDefaultCallback(dbus::MethodCall* method_call,
- const ErrorCallback& error_callback) {
- if (!proxy_)
- return;
- proxy_->CallMethodWithErrorCallback(
- method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&IBusConfigClientImpl::OnSetValue,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback),
- base::Bind(&IBusConfigClientImpl::OnSetValueFail,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
- }
-
- void OnSetValue(const ErrorCallback& error_callback,
- dbus::Response* response) {
- if (!response) {
- LOG(ERROR) << "Response is NULL.";
- error_callback.Run();
- return;
- }
- }
-
- void OnSetValueFail(const ErrorCallback& error_callback,
- dbus::ErrorResponse* response) {
- error_callback.Run();
- }
-
- void OnNameOwnerChanged(const OnIBusConfigReady& on_ready,
- dbus::Signal* signal) {
- DCHECK(signal);
- std::string name;
- std::string old_owner;
- std::string new_owner;
-
- dbus::MessageReader reader(signal);
- if (!reader.PopString(&name) ||
- !reader.PopString(&old_owner) ||
- !reader.PopString(&new_owner)) {
- DLOG(ERROR) << "Invalid response of NameOwnerChanged."
- << signal->ToString();
- return;
- }
-
- if (name != ibus::config::kServiceName)
- return; // Not a signal for ibus-config.
-
- if (!old_owner.empty() || new_owner.empty()) {
- DVLOG(1) << "Unexpected name owner change: name=" << name
- << ", old_owner=" << old_owner << ", new_owner=" << new_owner;
- proxy_ = NULL;
- return;
- }
-
- if (proxy_)
- return; // Already initialized.
-
- proxy_ = bus_->GetObjectProxy(ibus::config::kServiceName,
- dbus::ObjectPath(
- ibus::config::kServicePath));
- if (!on_ready.is_null())
- on_ready.Run();
- }
-
- // Handles response of GetNameOwner.
- void OnGetNameOwner(const OnIBusConfigReady& on_ready,
- dbus::Response* response) {
- if (!response) {
- LOG(ERROR) << "Response is NULL.";
- return;
- }
- std::string owner;
- dbus::MessageReader reader(response);
-
- if (!reader.PopString(&owner)) {
- LOG(ERROR) << "Invalid response of GetNameOwner."
- << response->ToString();
- return;
- }
-
- // If the owner is empty, ibus-config daemon is not ready. So will
- // initialize object proxy on NameOwnerChanged signal.
- if (owner.empty())
- return;
-
- proxy_ = bus_->GetObjectProxy(ibus::config::kServiceName,
- dbus::ObjectPath(
- ibus::config::kServicePath));
- if (!on_ready.is_null())
- on_ready.Run();
- }
-
- dbus::ObjectProxy* proxy_;
- dbus::Bus* bus_;
- base::WeakPtrFactory<IBusConfigClientImpl> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(IBusConfigClientImpl);
-};
-
-// A stub implementation of IBusConfigClient.
-// A configuration framework based on ibus will not be used after Extension IME
-// migration.
-class IBusConfigClientStubImpl : public IBusConfigClient {
- public:
- IBusConfigClientStubImpl() {}
- virtual ~IBusConfigClientStubImpl() {}
- virtual void InitializeAsync(const OnIBusConfigReady& on_ready) OVERRIDE {}
- virtual void SetStringValue(const std::string& section,
- const std::string& key,
- const std::string& value,
- const ErrorCallback& error_callback) OVERRIDE {}
- virtual void SetIntValue(const std::string& section,
- const std::string& key,
- int value,
- const ErrorCallback& error_callback) OVERRIDE {}
- virtual void SetBoolValue(const std::string& section,
- const std::string& key,
- bool value,
- const ErrorCallback& error_callback) OVERRIDE {}
- virtual void SetStringListValue(
- const std::string& section,
- const std::string& key,
- const std::vector<std::string>& value,
- const ErrorCallback& error_callback) OVERRIDE {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IBusConfigClientStubImpl);
-};
-
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////
-// IBusConfigClient
-
-IBusConfigClient::IBusConfigClient() {}
-
-IBusConfigClient::~IBusConfigClient() {}
-
-// static
-IBusConfigClient* IBusConfigClient::Create(DBusClientImplementationType type,
- dbus::Bus* bus) {
- if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) {
- return new IBusConfigClientImpl(bus);
- }
- DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
- return new IBusConfigClientStubImpl();
-}
-
-} // namespace chromeos
diff --git a/chromeos/dbus/ibus/ibus_config_client.h b/chromeos/dbus/ibus/ibus_config_client.h
deleted file mode 100644
index a7a384a..0000000
--- a/chromeos/dbus/ibus/ibus_config_client.h
+++ /dev/null
@@ -1,77 +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_DBUS_IBUS_IBUS_CONFIG_CLIENT_H_
-#define CHROMEOS_DBUS_IBUS_IBUS_CONFIG_CLIENT_H_
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "chromeos/chromeos_export.h"
-#include "chromeos/dbus/dbus_client_implementation_type.h"
-#include "dbus/object_path.h"
-
-namespace dbus {
-class Bus;
-} // namespace dbus
-
-namespace chromeos {
-
-class IBusComponent;
-class IBusInputContextClient;
-
-// A class to make the actual DBus calls for IBusConfig service.
-class CHROMEOS_EXPORT IBusConfigClient {
- public:
- typedef base::Callback<void()> ErrorCallback;
- typedef base::Callback<void()> OnIBusConfigReady;
- virtual ~IBusConfigClient();
-
- // Initializes IBusConfig asynchronously. |on_ready| will be called if it is
- // ready.
- virtual void InitializeAsync(const OnIBusConfigReady& on_ready) = 0;
-
- // Requests the IBusConfig to set a string value.
- virtual void SetStringValue(const std::string& section,
- const std::string& key,
- const std::string& value,
- const ErrorCallback& error_callback) = 0;
-
- // Requests the IBusConfig to set a integer value.
- virtual void SetIntValue(const std::string& section,
- const std::string& key,
- int value,
- const ErrorCallback& error_callback) = 0;
-
- // Requests the IBusConfig to set a boolean value.
- virtual void SetBoolValue(const std::string& section,
- const std::string& key,
- bool value,
- const ErrorCallback& error_callback) = 0;
-
- // Requests the IBusConfig to set multiple string values.
- virtual void SetStringListValue(const std::string& section,
- const std::string& key,
- const std::vector<std::string>& value,
- const ErrorCallback& error_callback) = 0;
-
- // Factory function, creates a new instance and returns ownership.
- // For normal usage, access the singleton via DBusThreadManager::Get().
- static CHROMEOS_EXPORT IBusConfigClient* Create(
- DBusClientImplementationType type,
- dbus::Bus* bus);
-
- protected:
- // Create() should be used instead.
- IBusConfigClient();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IBusConfigClient);
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_DBUS_IBUS_IBUS_CONFIG_CLIENT_H_
diff --git a/chromeos/dbus/ibus/ibus_config_client_unittest.cc b/chromeos/dbus/ibus/ibus_config_client_unittest.cc
deleted file mode 100644
index 656bf4d..0000000
--- a/chromeos/dbus/ibus/ibus_config_client_unittest.cc
+++ /dev/null
@@ -1,627 +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/dbus/ibus/ibus_config_client.h"
-
-#include <vector>
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/values.h"
-#include "chromeos/dbus/ibus/ibus_constants.h"
-#include "dbus/message.h"
-#include "dbus/mock_bus.h"
-#include "dbus/mock_object_proxy.h"
-#include "dbus/object_path.h"
-#include "dbus/values_util.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using testing::Invoke;
-using testing::Return;
-using testing::_;
-
-namespace {
-const char kSection[] = "IBus/Section";
-const char kKey[] = "key";
-
-enum HandlerBehavior {
- HANDLER_SUCCESS,
- HANDLER_FAIL,
-};
-} // namespace
-
-namespace chromeos {
-
-class MockErrorCallback {
- public:
- MOCK_METHOD0(Run, void());
-};
-
-class MockOnIBusConfigReadyCallback {
- public:
- MOCK_METHOD0(Run, void());
-};
-
-// The base class of each type specified SetValue function handler. This class
-// checks "section" and "key" field in SetValue message and callback success or
-// error callback based on given |success| flag.
-class SetValueVerifierBase {
- public:
- SetValueVerifierBase(const std::string& expected_section,
- const std::string& expected_key,
- HandlerBehavior behavior)
- : expected_section_(expected_section),
- expected_key_(expected_key),
- behavior_(behavior) {}
-
- virtual ~SetValueVerifierBase() {}
-
- // Handles SetValue method call. This function checks "section" and "key"
- // field. For the "value" field, subclass checks it with over riding
- // VeirfyVariant member function.
- void Run(dbus::MethodCall* method_call,
- int timeout_ms,
- const dbus::ObjectProxy::ResponseCallback& callback,
- const dbus::ObjectProxy::ErrorCallback& error_callback) {
- dbus::MessageReader reader(method_call);
- std::string section;
- std::string key;
-
- EXPECT_TRUE(reader.PopString(&section));
- EXPECT_EQ(expected_section_, section);
- EXPECT_TRUE(reader.PopString(&key));
- EXPECT_EQ(expected_key_, key);
- dbus::MessageReader variant_reader(NULL);
- EXPECT_TRUE(reader.PopVariant(&variant_reader));
-
- VerifyVariant(&variant_reader);
-
- EXPECT_FALSE(reader.HasMoreData());
- if (behavior_ == HANDLER_SUCCESS) {
- scoped_ptr<dbus::Response> response(
- dbus::Response::FromMethodCall(method_call));
- callback.Run(response.get());
- } else {
- scoped_ptr<dbus::ErrorResponse> error_response(
- dbus::ErrorResponse::FromMethodCall(method_call, "Error",
- "Error Message"));
- error_callback.Run(error_response.get());
- }
- }
-
- // Verifies "value" field in SetValue method call.
- virtual void VerifyVariant(dbus::MessageReader* reader) = 0;
-
- private:
- const std::string expected_section_;
- const std::string expected_key_;
- const HandlerBehavior behavior_;
-
- DISALLOW_COPY_AND_ASSIGN(SetValueVerifierBase);
-};
-
-// The class to verify SetStringValue method call arguments.
-class SetStringValueHandler : public SetValueVerifierBase {
- public:
- SetStringValueHandler(const std::string& expected_key,
- const std::string& expected_section,
- const std::string& expected_value,
- HandlerBehavior behavior)
- : SetValueVerifierBase(expected_section, expected_key, behavior),
- expected_value_(expected_value) {}
-
-
- // SetValueVerifierBase override.
- virtual void VerifyVariant(dbus::MessageReader* reader) OVERRIDE {
- std::string value;
- EXPECT_TRUE(reader->PopString(&value));
- EXPECT_EQ(expected_value_, value);
- }
-
- private:
- const std::string expected_value_;
-
- DISALLOW_COPY_AND_ASSIGN(SetStringValueHandler);
-};
-
-// The class to verify SetIntValue method call arguments.
-class SetIntValueHandler : public SetValueVerifierBase {
- public:
- SetIntValueHandler(const std::string& expected_key,
- const std::string& expected_section,
- int expected_value,
- HandlerBehavior behavior)
- : SetValueVerifierBase(expected_section, expected_key, behavior),
- expected_value_(expected_value) {}
-
- // SetValueVerifierBase override.
- virtual void VerifyVariant(dbus::MessageReader* reader) OVERRIDE {
- int value = -1;
- EXPECT_TRUE(reader->PopInt32(&value));
- EXPECT_EQ(expected_value_, value);
- }
-
- private:
- const int expected_value_;
-
- DISALLOW_COPY_AND_ASSIGN(SetIntValueHandler);
-};
-
-// The class to verify SetBoolValue method call arguments.
-class SetBoolValueHandler : public SetValueVerifierBase {
- public:
- SetBoolValueHandler(const std::string& expected_key,
- const std::string& expected_section,
- bool expected_value,
- HandlerBehavior behavior)
- : SetValueVerifierBase(expected_section, expected_key, behavior),
- expected_value_(expected_value) {}
-
- // SetValueVerifierBase override.
- virtual void VerifyVariant(dbus::MessageReader* reader) OVERRIDE {
- bool value = false;
- EXPECT_TRUE(reader->PopBool(&value));
- EXPECT_EQ(expected_value_, value);
- }
-
- private:
- const bool expected_value_;
-
- DISALLOW_COPY_AND_ASSIGN(SetBoolValueHandler);
-};
-
-// The class to verify SetStringListValue method call arguments.
-class SetStringListValueHandler : public SetValueVerifierBase {
- public:
- SetStringListValueHandler(const std::string& expected_key,
- const std::string& expected_section,
- const std::vector<std::string>& expected_value,
- HandlerBehavior behavior)
- : SetValueVerifierBase(expected_section, expected_key, behavior),
- expected_value_(expected_value) {}
-
- // SetValueVerifierBase override
- virtual void VerifyVariant(dbus::MessageReader* reader) OVERRIDE {
- dbus::MessageReader array_reader(NULL);
- ASSERT_TRUE(reader->PopArray(&array_reader));
- for (size_t i = 0; i < expected_value_.size(); ++i) {
- std::string value;
- ASSERT_TRUE(array_reader.HasMoreData());
- EXPECT_TRUE(array_reader.PopString(&value));
- EXPECT_EQ(expected_value_[i], value);
- }
- EXPECT_FALSE(array_reader.HasMoreData());
- }
-
- private:
- const std::vector<std::string>& expected_value_;
-
- DISALLOW_COPY_AND_ASSIGN(SetStringListValueHandler);
-};
-
-// The class verifies GetNameOwner method call and emits response callback
-// asynchronouslly.
-class MockGetNameOwnerMethodCallHandler {
- public:
- MockGetNameOwnerMethodCallHandler() {}
-
- // Handles CallMethod function.
- void Run(dbus::MethodCall* method_call,
- int timeout_ms,
- const dbus::ObjectProxy::ResponseCallback& callback,
- const dbus::ObjectProxy::ErrorCallback& error_callback) {
- dbus::MessageReader reader(method_call);
- std::string target_name;
- EXPECT_TRUE(reader.PopString(&target_name));
- EXPECT_EQ(ibus::config::kServiceName, target_name);
- EXPECT_FALSE(reader.HasMoreData());
-
- callback_ = callback;
- }
-
- // Invokes reply with given |callback_| in Run method.
- void EmitReplyCallback(const std::string& owner) {
- scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
- dbus::MessageWriter writer(response.get());
- writer.AppendString(owner);
- callback_.Run(response.get());
- }
-
- private:
- dbus::ObjectProxy::ResponseCallback callback_;
-
- DISALLOW_COPY_AND_ASSIGN(MockGetNameOwnerMethodCallHandler);
-};
-
-
-// The class emulate GetNameOwner signal.
-class NameOwnerChangedHandler {
- public:
- NameOwnerChangedHandler() {}
-
- // OnConnectToSignal mock function.
- void OnConnectToSignal(
- const std::string& interface_name,
- const std::string& signal_name,
- const dbus::ObjectProxy::SignalCallback& signal_callback,
- const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback) {
- callback_ = signal_callback;
- on_connected_callback.Run(interface_name, signal_name, true);
- }
-
- // Invokes reply with given |callback_| in Run method.
- void InvokeSignal(const std::string& name,
- const std::string& old_owner,
- const std::string& new_owner) {
- dbus::Signal signal(ibus::kDBusInterface, ibus::kGetNameOwnerMethod);
- dbus::MessageWriter writer(&signal);
- writer.AppendString(name);
- writer.AppendString(old_owner);
- writer.AppendString(new_owner);
- callback_.Run(&signal);
- }
-
- private:
- dbus::ObjectProxy::SignalCallback callback_;
-
- DISALLOW_COPY_AND_ASSIGN(NameOwnerChangedHandler);
-};
-
-
-class IBusConfigClientTest : public testing::Test {
- public:
- IBusConfigClientTest() {}
-
- protected:
- virtual void SetUp() OVERRIDE {
- dbus::Bus::Options options;
- mock_bus_ = new dbus::MockBus(options);
- mock_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(),
- ibus::kServiceName,
- dbus::ObjectPath(
- ibus::config::kServicePath));
- EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock());
- client_.reset(IBusConfigClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION,
- mock_bus_.get()));
-
- // Surpress uninteresting mock function call warning.
- EXPECT_CALL(*mock_bus_.get(), AssertOnOriginThread())
- .WillRepeatedly(Return());
- }
-
- virtual void TearDown() OVERRIDE {
- mock_bus_->ShutdownAndBlock();
- }
-
- // Initialize |client_| by replying valid owner name synchronously.
- void InitializeSync() {
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::config::kServiceName,
- dbus::ObjectPath(ibus::config::kServicePath)))
- .WillOnce(Return(mock_proxy_.get()));
-
- scoped_refptr<dbus::MockObjectProxy> mock_dbus_proxy
- = new dbus::MockObjectProxy(mock_bus_.get(),
- ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath));
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath)))
- .WillOnce(Return(mock_dbus_proxy.get()));
-
- MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call;
- EXPECT_CALL(*mock_dbus_proxy.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&mock_get_name_owner_method_call,
- &MockGetNameOwnerMethodCallHandler::Run));
- NameOwnerChangedHandler handler;
- EXPECT_CALL(*mock_dbus_proxy.get(),
- ConnectToSignal(
- ibus::kDBusInterface, ibus::kNameOwnerChangedSignal, _, _))
- .WillOnce(
- Invoke(&handler, &NameOwnerChangedHandler::OnConnectToSignal));
- client_->InitializeAsync(base::Bind(&base::DoNothing));
- mock_get_name_owner_method_call.EmitReplyCallback(":0.1");
- }
-
- // The IBus config client to be tested.
- scoped_ptr<IBusConfigClient> client_;
-
- // A message loop to emulate asynchronous behavior.
- base::MessageLoop message_loop_;
- scoped_refptr<dbus::MockBus> mock_bus_;
- scoped_refptr<dbus::MockObjectProxy> mock_proxy_;
-};
-
-TEST_F(IBusConfigClientTest, SetStringValueTest) {
- // Set expectations
- InitializeSync();
- const char value[] = "value";
- SetStringValueHandler handler(kSection, kKey, value, HANDLER_SUCCESS);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run()).Times(0);
-
- // Call SetStringValue.
- client_->SetStringValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetStringValueTest_Fail) {
- // Set expectations
- InitializeSync();
- const char value[] = "value";
- SetStringValueHandler handler(kSection, kKey, value, HANDLER_FAIL);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run());
-
- // Call SetStringValue.
- client_->SetStringValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetIntValueTest) {
- // Set expectations
- InitializeSync();
- const int value = 1234;
- SetIntValueHandler handler(kSection, kKey, value, HANDLER_SUCCESS);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run()).Times(0);
-
- // Call SetIntValue.
- client_->SetIntValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetIntValueTest_Fail) {
- // Set expectations
- InitializeSync();
- const int value = 1234;
- SetIntValueHandler handler(kSection, kKey, value, HANDLER_FAIL);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run());
-
- // Call SetIntValue.
- client_->SetIntValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetBoolValueTest) {
- // Set expectations
- InitializeSync();
- const bool value = true;
- SetBoolValueHandler handler(kSection, kKey, value, HANDLER_SUCCESS);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run()).Times(0);
-
- // Call SetBoolValue.
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetBoolValueTest_Fail) {
- // Set expectations
- InitializeSync();
- const bool value = true;
- SetBoolValueHandler handler(kSection, kKey, value, HANDLER_FAIL);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run());
-
- // Call SetBoolValue.
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetStringListValueTest) {
- // Set expectations
- InitializeSync();
- std::vector<std::string> value;
- value.push_back("Sample value 1");
- value.push_back("Sample value 2");
-
- SetStringListValueHandler handler(kSection, kKey, value, HANDLER_SUCCESS);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run()).Times(0);
-
- // Call SetStringListValue.
- client_->SetStringListValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, SetStringListValueTest_Fail) {
- // Set expectations
- InitializeSync();
- std::vector<std::string> value;
- value.push_back("Sample value 1");
- value.push_back("Sample value 2");
-
- SetStringListValueHandler handler(kSection, kKey, value, HANDLER_FAIL);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run());
-
- // Call SetStringListValue.
- client_->SetStringListValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, IBusConfigDaemon_NotAvailableTest) {
- MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call;
-
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::kServiceName,
- dbus::ObjectPath(ibus::config::kServicePath)))
- .Times(0);
-
- scoped_refptr<dbus::MockObjectProxy> mock_dbus_proxy
- = new dbus::MockObjectProxy(mock_bus_.get(),
- ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath));
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath)))
- .WillOnce(Return(mock_dbus_proxy.get()));
- EXPECT_CALL(*mock_dbus_proxy.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&mock_get_name_owner_method_call,
- &MockGetNameOwnerMethodCallHandler::Run));
- NameOwnerChangedHandler handler;
- EXPECT_CALL(*mock_dbus_proxy.get(),
- ConnectToSignal(
- ibus::kDBusInterface, ibus::kNameOwnerChangedSignal, _, _))
- .WillOnce(Invoke(&handler, &NameOwnerChangedHandler::OnConnectToSignal));
- client_->InitializeAsync(base::Bind(&base::DoNothing));
-
- // Passing empty string means there is no owner, thus ibus-config daemon is
- // not ready.
- mock_get_name_owner_method_call.EmitReplyCallback("");
-
- // Make sure not crashing by function call without initialize.
- const bool value = true;
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .Times(0);
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run()).Times(0);
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, IBusConfigDaemon_SlowInitializeTest) {
- MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call;
-
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::config::kServiceName,
- dbus::ObjectPath(ibus::config::kServicePath)))
- .WillOnce(Return(mock_proxy_.get()));
-
- scoped_refptr<dbus::MockObjectProxy> mock_dbus_proxy
- = new dbus::MockObjectProxy(mock_bus_.get(),
- ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath));
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath)))
- .WillOnce(Return(mock_dbus_proxy.get()));
- EXPECT_CALL(*mock_dbus_proxy.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&mock_get_name_owner_method_call,
- &MockGetNameOwnerMethodCallHandler::Run));
- NameOwnerChangedHandler name_owner_changed_handler;
- EXPECT_CALL(*mock_dbus_proxy.get(),
- ConnectToSignal(
- ibus::kDBusInterface, ibus::kNameOwnerChangedSignal, _, _))
- .WillOnce(Invoke(&name_owner_changed_handler,
- &NameOwnerChangedHandler::OnConnectToSignal));
- client_->InitializeAsync(base::Bind(&base::DoNothing));
-
- // Passing empty string means there is no owner, thus ibus-config daemon is
- // not ready.
- mock_get_name_owner_method_call.EmitReplyCallback("");
-
- // Fire NameOwnerChanged signal to emulate ibus-config daemon was acquired
- // well-known name.
- name_owner_changed_handler.InvokeSignal(ibus::config::kServiceName,
- "",
- ":0.1");
-
- // Make sure it is possible to emit method calls.
- const bool value = true;
- SetBoolValueHandler handler(kSection, kKey, value, HANDLER_FAIL);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run());
-
- // Call SetBoolValue.
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-TEST_F(IBusConfigClientTest, IBusConfigDaemon_ShutdownTest) {
- MockGetNameOwnerMethodCallHandler mock_get_name_owner_method_call;
-
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::config::kServiceName,
- dbus::ObjectPath(ibus::config::kServicePath)))
- .WillRepeatedly(Return(mock_proxy_.get()));
-
- scoped_refptr<dbus::MockObjectProxy> mock_dbus_proxy
- = new dbus::MockObjectProxy(mock_bus_.get(),
- ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath));
- EXPECT_CALL(*mock_bus_.get(),
- GetObjectProxy(ibus::kDBusServiceName,
- dbus::ObjectPath(ibus::kDBusObjectPath)))
- .WillOnce(Return(mock_dbus_proxy.get()));
- EXPECT_CALL(*mock_dbus_proxy.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillOnce(Invoke(&mock_get_name_owner_method_call,
- &MockGetNameOwnerMethodCallHandler::Run));
- NameOwnerChangedHandler name_owner_changed_handler;
- EXPECT_CALL(*mock_dbus_proxy.get(),
- ConnectToSignal(
- ibus::kDBusInterface, ibus::kNameOwnerChangedSignal, _, _))
- .WillOnce(Invoke(&name_owner_changed_handler,
- &NameOwnerChangedHandler::OnConnectToSignal));
- client_->InitializeAsync(base::Bind(&base::DoNothing));
-
- const bool value = true;
- SetBoolValueHandler handler(kSection, kKey, value, HANDLER_FAIL);
- EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
- .WillRepeatedly(Invoke(&handler, &SetValueVerifierBase::Run));
- MockErrorCallback error_callback;
- EXPECT_CALL(error_callback, Run()).WillRepeatedly(Return());
-
- // Initialize succeeded sucessfully.
- mock_get_name_owner_method_call.EmitReplyCallback(":0.2");
-
- // Call SetBoolValue.
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-
- // Fire NameOwnerChanged signal to emulate shutting down the ibus-config
- // daemon.
- name_owner_changed_handler.InvokeSignal(ibus::config::kServiceName,
- ":0.1",
- "");
-
- // Make sure not crashing on emitting method call.
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-
- // Fire NameOwnerChanged signal to emulate that ibus-daemon is revived.
- name_owner_changed_handler.InvokeSignal(ibus::config::kServiceName,
- "",
- ":0.2");
-
- // Make sure it is possible to emit method calls.
- client_->SetBoolValue(kKey, kSection, value,
- base::Bind(&MockErrorCallback::Run,
- base::Unretained(&error_callback)));
-}
-
-} // namespace chromeos
diff --git a/chromeos/dbus/ibus/mock_ibus_config_client.cc b/chromeos/dbus/ibus/mock_ibus_config_client.cc
deleted file mode 100644
index f32ffd0..0000000
--- a/chromeos/dbus/ibus/mock_ibus_config_client.cc
+++ /dev/null
@@ -1,44 +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/dbus/ibus/mock_ibus_config_client.h"
-
-#include <vector>
-
-namespace chromeos {
-
-MockIBusConfigClient::MockIBusConfigClient() {
-}
-
-MockIBusConfigClient::~MockIBusConfigClient() {}
-
-void MockIBusConfigClient::InitializeAsync(const OnIBusConfigReady& onready) {
-}
-
-void MockIBusConfigClient::SetStringValue(const std::string& key,
- const std::string& section,
- const std::string& value,
- const ErrorCallback& error_callback) {
-}
-
-void MockIBusConfigClient::SetIntValue(const std::string& key,
- const std::string& section,
- int value,
- const ErrorCallback& error_callback) {
-}
-
-void MockIBusConfigClient::SetBoolValue(const std::string& key,
- const std::string& section,
- bool value,
- const ErrorCallback& error_callback) {
-}
-
-void MockIBusConfigClient::SetStringListValue(
- const std::string& key,
- const std::string& section,
- const std::vector<std::string>& value,
- const ErrorCallback& error_callback) {
-}
-
-} // namespace chromeos
diff --git a/chromeos/dbus/ibus/mock_ibus_config_client.h b/chromeos/dbus/ibus/mock_ibus_config_client.h
deleted file mode 100644
index 2112dc1..0000000
--- a/chromeos/dbus/ibus/mock_ibus_config_client.h
+++ /dev/null
@@ -1,47 +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_DBUS_IBUS_MOCK_IBUS_CONFIG_CLIENT_H_
-#define CHROMEOS_DBUS_IBUS_MOCK_IBUS_CONFIG_CLIENT_H_
-
-#include <string>
-#include <vector>
-
-#include "chromeos/dbus/ibus/ibus_config_client.h"
-
-namespace chromeos {
-
-class MockIBusConfigClient : public IBusConfigClient {
- public:
- MockIBusConfigClient();
- virtual ~MockIBusConfigClient();
- virtual void InitializeAsync(const OnIBusConfigReady& onready) OVERRIDE;
-
- virtual void SetStringValue(const std::string& key,
- const std::string& section,
- const std::string& value,
- const ErrorCallback& error_callback) OVERRIDE;
-
- virtual void SetIntValue(const std::string& key,
- const std::string& section,
- int value,
- const ErrorCallback& error_callback) OVERRIDE;
-
- virtual void SetBoolValue(const std::string& key,
- const std::string& section,
- bool value,
- const ErrorCallback& error_callback) OVERRIDE;
-
- virtual void SetStringListValue(const std::string& key,
- const std::string& section,
- const std::vector<std::string>& value,
- const ErrorCallback& error_callback) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockIBusConfigClient);
-};
-
-} // namespace chromeos
-
-#endif // CHROMEOS_DBUS_IBUS_MOCK_IBUS_CONFIG_CLIENT_H_
diff --git a/chromeos/dbus/mock_dbus_thread_manager.cc b/chromeos/dbus/mock_dbus_thread_manager.cc
index 6245e46..9cf664c 100644
--- a/chromeos/dbus/mock_dbus_thread_manager.cc
+++ b/chromeos/dbus/mock_dbus_thread_manager.cc
@@ -11,7 +11,6 @@
#include "chromeos/dbus/fake_bluetooth_input_client.h"
#include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
#include "chromeos/dbus/ibus/mock_ibus_client.h"
-#include "chromeos/dbus/ibus/mock_ibus_config_client.h"
#include "chromeos/dbus/ibus/mock_ibus_engine_factory_service.h"
#include "chromeos/dbus/ibus/mock_ibus_engine_service.h"
#include "chromeos/dbus/ibus/mock_ibus_input_context_client.h"
diff --git a/chromeos/dbus/mock_dbus_thread_manager.h b/chromeos/dbus/mock_dbus_thread_manager.h
index 60f61ee..16c4be1 100644
--- a/chromeos/dbus/mock_dbus_thread_manager.h
+++ b/chromeos/dbus/mock_dbus_thread_manager.h
@@ -79,7 +79,6 @@ class MockDBusThreadManager : public DBusThreadManager {
MOCK_METHOD0(GetSystemClockClient, SystemClockClient*(void));
MOCK_METHOD0(GetUpdateEngineClient, UpdateEngineClient*(void));
MOCK_METHOD0(GetIBusClient, IBusClient*(void));
- MOCK_METHOD0(GetIBusConfigClient, IBusConfigClient*(void));
MOCK_METHOD0(GetIBusInputContextClient, IBusInputContextClient*(void));
MOCK_METHOD0(GetIBusEngineFactoryService, IBusEngineFactoryService*(void));
MOCK_METHOD1(GetIBusEngineService,
diff --git a/chromeos/dbus/mock_dbus_thread_manager_without_gmock.cc b/chromeos/dbus/mock_dbus_thread_manager_without_gmock.cc
index 579d410..8bd95a1 100644
--- a/chromeos/dbus/mock_dbus_thread_manager_without_gmock.cc
+++ b/chromeos/dbus/mock_dbus_thread_manager_without_gmock.cc
@@ -21,7 +21,6 @@
#include "chromeos/dbus/fake_system_clock_client.h"
#include "chromeos/dbus/fake_update_engine_client.h"
#include "chromeos/dbus/ibus/mock_ibus_client.h"
-#include "chromeos/dbus/ibus/mock_ibus_config_client.h"
#include "chromeos/dbus/ibus/mock_ibus_engine_factory_service.h"
#include "chromeos/dbus/ibus/mock_ibus_engine_service.h"
#include "chromeos/dbus/ibus/mock_ibus_input_context_client.h"
@@ -75,7 +74,6 @@ void MockDBusThreadManagerWithoutGMock::InitIBusBus(
// Non-null bus address is used to ensure the connection to ibus-daemon.
ibus_bus_ = reinterpret_cast<dbus::Bus*>(0xdeadbeef);
mock_ibus_client_.reset(new MockIBusClient);
- mock_ibus_config_client_.reset(new MockIBusConfigClient);
mock_ibus_input_context_client_.reset(new MockIBusInputContextClient);
mock_ibus_engine_service_.reset(new MockIBusEngineService);
mock_ibus_engine_factory_service_.reset(new MockIBusEngineFactoryService);
@@ -217,10 +215,6 @@ IBusClient* MockDBusThreadManagerWithoutGMock::GetIBusClient() {
return mock_ibus_client_.get();
}
-IBusConfigClient* MockDBusThreadManagerWithoutGMock::GetIBusConfigClient() {
- return mock_ibus_config_client_.get();
-}
-
IBusInputContextClient*
MockDBusThreadManagerWithoutGMock::GetIBusInputContextClient() {
return mock_ibus_input_context_client_.get();
diff --git a/chromeos/dbus/mock_dbus_thread_manager_without_gmock.h b/chromeos/dbus/mock_dbus_thread_manager_without_gmock.h
index f7c9479..f5c5841 100644
--- a/chromeos/dbus/mock_dbus_thread_manager_without_gmock.h
+++ b/chromeos/dbus/mock_dbus_thread_manager_without_gmock.h
@@ -35,7 +35,6 @@ class FakeShillManagerClient;
class FakeSystemClockClient;
class FakeUpdateEngineClient;
class MockIBusClient;
-class MockIBusConfigClient;
class MockIBusEngineFactoryService;
class MockIBusEngineService;
class MockIBusInputContextClient;
@@ -86,7 +85,6 @@ class MockDBusThreadManagerWithoutGMock : public DBusThreadManager {
virtual SystemClockClient* GetSystemClockClient() OVERRIDE;
virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE;
virtual IBusClient* GetIBusClient() OVERRIDE;
- virtual IBusConfigClient* GetIBusConfigClient() OVERRIDE;
virtual IBusInputContextClient* GetIBusInputContextClient() OVERRIDE;
virtual IBusEngineFactoryService* GetIBusEngineFactoryService() OVERRIDE;
virtual IBusEngineService* GetIBusEngineService(
@@ -159,10 +157,6 @@ class MockDBusThreadManagerWithoutGMock : public DBusThreadManager {
return mock_ibus_client_.get();
}
- MockIBusConfigClient* mock_ibus_config_client() {
- return mock_ibus_config_client_.get();
- }
-
MockIBusInputContextClient* mock_ibus_input_context_client() {
return mock_ibus_input_context_client_.get();
}
@@ -207,7 +201,6 @@ class MockDBusThreadManagerWithoutGMock : public DBusThreadManager {
scoped_ptr<FakeUpdateEngineClient> fake_update_engine_client_;
scoped_ptr<MockIBusClient> mock_ibus_client_;
- scoped_ptr<MockIBusConfigClient> mock_ibus_config_client_;
scoped_ptr<MockIBusInputContextClient> mock_ibus_input_context_client_;
scoped_ptr<MockIBusEngineService> mock_ibus_engine_service_;
scoped_ptr<MockIBusEngineFactoryService> mock_ibus_engine_factory_service_;
diff --git a/chromeos/ime/input_method_manager.h b/chromeos/ime/input_method_manager.h
index 5a94455..7b18124 100644
--- a/chromeos/ime/input_method_manager.h
+++ b/chromeos/ime/input_method_manager.h
@@ -145,12 +145,6 @@ class CHROMEOS_EXPORT InputMethodManager {
const std::string& keyboard_id,
std::vector<std::string>* input_method_ids) = 0;
- // Updates a configuration of a system input method engine with |value|.
- // Returns true if the configuration is correctly set.
- virtual bool SetInputMethodConfig(const std::string& section,
- const std::string& config_name,
- const InputMethodConfigValue& value) = 0;
-
// Adds an input method extension. This function does not takes ownership of
// |instance|.
virtual void AddInputMethodExtension(