summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/input_method
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/input_method')
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window_controller.cc1
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller.cc21
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller.h54
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_impl.cc91
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_impl.h54
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc74
-rw-r--r--chrome/browser/chromeos/input_method/ibus_controller_unittest.cc24
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_ibus.cc8
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_ibus_browserttests.cc3
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.cc70
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.h26
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc47
-rw-r--r--chrome/browser/chromeos/input_method/mock_ibus_controller.cc53
-rw-r--r--chrome/browser/chromeos/input_method/mock_ibus_controller.h56
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.cc4
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.h2
16 files changed, 68 insertions, 520 deletions
diff --git a/chrome/browser/chromeos/input_method/candidate_window_controller.cc b/chrome/browser/chromeos/input_method/candidate_window_controller.cc
index 9c84aac..c94fc8c 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_controller.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window_controller.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
#include "chrome/browser/chromeos/input_method/candidate_window_controller_impl.h"
-#include "chrome/browser/chromeos/input_method/ibus_controller.h"
namespace chromeos {
namespace input_method {
diff --git a/chrome/browser/chromeos/input_method/ibus_controller.cc b/chrome/browser/chromeos/input_method/ibus_controller.cc
deleted file mode 100644
index 6f8a357..0000000
--- a/chrome/browser/chromeos/input_method/ibus_controller.cc
+++ /dev/null
@@ -1,21 +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 "chrome/browser/chromeos/input_method/ibus_controller.h"
-
-#include "chrome/browser/chromeos/input_method/ibus_controller_impl.h"
-
-namespace chromeos {
-namespace input_method {
-
-IBusController::~IBusController() {
-}
-
-// static
-IBusController* IBusController::Create() {
- return new IBusControllerImpl;
-}
-
-} // namespace input_method
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/ibus_controller.h b/chrome/browser/chromeos/input_method/ibus_controller.h
deleted file mode 100644
index 1645b08..0000000
--- a/chrome/browser/chromeos/input_method/ibus_controller.h
+++ /dev/null
@@ -1,54 +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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_H_
-
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace chromeos {
-namespace input_method {
-
-struct InputMethodProperty;
-typedef std::vector<InputMethodProperty> InputMethodPropertyList;
-
-// IBusController is used to interact with the system input method framework
-// (which is currently IBus).
-class IBusController {
- public:
- class Observer {
- public:
- virtual ~Observer() {}
- virtual void PropertyChanged() = 0;
- // TODO(yusukes): Add functions for IPC error handling.
- };
-
- // Creates an instance of the class.
- static IBusController* Create();
-
- virtual ~IBusController();
-
- virtual void AddObserver(Observer* observer) = 0;
- virtual void RemoveObserver(Observer* observer) = 0;
-
- virtual void ClearProperties() = 0;
-
- // Activates the input method property specified by the |key|. Returns true on
- // success.
- virtual bool ActivateInputMethodProperty(const std::string& key) = 0;
-
- // Gets the latest input method property send from the system input method
- // framework.
- virtual const InputMethodPropertyList& GetCurrentProperties() const = 0;
-};
-
-} // namespace input_method
-} // namespace chromeos
-
-// TODO(yusukes,nona): This interface does not depend on IBus actually.
-// Rename the file if needed.
-
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_H_
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc
deleted file mode 100644
index 988e82d..0000000
--- a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc
+++ /dev/null
@@ -1,91 +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 "chrome/browser/chromeos/input_method/ibus_controller_impl.h"
-
-#include <algorithm> // for std::reverse.
-#include <cstdio>
-#include <cstring> // for std::strcmp.
-#include <set>
-#include <sstream>
-#include <stack>
-#include <utility>
-
-#include "ash/shell.h"
-#include "base/bind.h"
-#include "base/environment.h"
-#include "base/files/file_path_watcher.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/rand_util.h"
-#include "base/strings/string_split.h"
-#include "base/strings/stringprintf.h"
-#include "chrome/browser/chromeos/input_method/input_method_util.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"
-#include "ui/aura/root_window.h"
-#include "ui/base/ime/input_method_ibus.h"
-
-namespace chromeos {
-namespace input_method {
-
-IBusControllerImpl::IBusControllerImpl() {
- IBusBridge::Get()->SetPropertyHandler(this);
-}
-
-IBusControllerImpl::~IBusControllerImpl() {
- IBusBridge::Get()->SetPropertyHandler(NULL);
-}
-
-bool IBusControllerImpl::ActivateInputMethodProperty(const std::string& key) {
- // The third parameter of ibus_input_context_property_activate() has to be
- // true when the |key| points to a radio button. false otherwise.
- bool found = false;
- for (size_t i = 0; i < current_property_list_.size(); ++i) {
- if (current_property_list_[i].key == key) {
- found = true;
- break;
- }
- }
- if (!found) {
- DVLOG(1) << "ActivateInputMethodProperty: unknown key: " << key;
- return false;
- }
-
- IBusEngineHandlerInterface* engine = IBusBridge::Get()->GetEngineHandler();
- if (engine)
- engine->PropertyActivate(key);
- return true;
-}
-
-void IBusControllerImpl::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void IBusControllerImpl::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-const InputMethodPropertyList&
-IBusControllerImpl::GetCurrentProperties() const {
- return current_property_list_;
-}
-
-void IBusControllerImpl::ClearProperties() {
- current_property_list_.clear();
-}
-
-void IBusControllerImpl::RegisterProperties(
- const InputMethodPropertyList& property_list) {
- current_property_list_ = property_list;
- FOR_EACH_OBSERVER(IBusController::Observer, observers_, PropertyChanged());
-}
-
-} // namespace input_method
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.h b/chrome/browser/chromeos/input_method/ibus_controller_impl.h
deleted file mode 100644
index 96f8b75..0000000
--- a/chrome/browser/chromeos/input_method/ibus_controller_impl.h
+++ /dev/null
@@ -1,54 +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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
-
-#include <string>
-#include <vector>
-
-#include "base/observer_list.h"
-#include "chrome/browser/chromeos/input_method/ibus_controller.h"
-#include "chromeos/ime/ibus_bridge.h"
-#include "chromeos/ime/input_method_property.h"
-
-namespace chromeos {
-namespace input_method {
-
-// The IBusController implementation.
-class IBusControllerImpl : public IBusController,
- public IBusPanelPropertyHandlerInterface {
- public:
- IBusControllerImpl();
- virtual ~IBusControllerImpl();
-
- // IBusController overrides:
- virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE;
-
- // IBusController overrides. Derived classes should not override these 4
- // functions.
- virtual void AddObserver(Observer* observer) OVERRIDE;
- virtual void RemoveObserver(Observer* observer) OVERRIDE;
- virtual const InputMethodPropertyList& GetCurrentProperties() const OVERRIDE;
- virtual void ClearProperties() OVERRIDE;
-
- protected:
- ObserverList<Observer> observers_;
-
- // The value which will be returned by GetCurrentProperties(). Derived classes
- // should update this variable when needed.
- InputMethodPropertyList current_property_list_;
-
- private:
- // IBusPanelPropertyHandlerInterface overrides:
- virtual void RegisterProperties(
- const InputMethodPropertyList& properties) OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(IBusControllerImpl);
-};
-
-} // namespace input_method
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_CONTROLLER_IMPL_H_
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc
deleted file mode 100644
index 109a8c9..0000000
--- a/chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc
+++ /dev/null
@@ -1,74 +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 "base/logging.h"
-#include "chrome/browser/chromeos/input_method/ibus_controller_impl.h"
-#include "chromeos/ime/input_method_property.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-namespace input_method {
-
-namespace {
-
-// A mock class for testing AddObserver() and RemoveObserver() methods
-// in IBusControllerImpl.
-class TestIBusController : public IBusControllerImpl {
- public:
- TestIBusController() {
- }
-
- virtual ~TestIBusController() {
- }
-
- bool HasObservers() const {
- return observers_.might_have_observers();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestIBusController);
-};
-
-class TestObserver : public IBusController::Observer {
- public:
- // IBusController::Observer overrides:
- virtual void PropertyChanged() OVERRIDE {}
-};
-} // namespace
-
-TEST(IBusControllerImplTest, TestAddRemoveObserver) {
- IBusBridge::Initialize();
- {
- TestIBusController controller;
- TestObserver observer1;
- TestObserver observer2;
- TestObserver observer3;
- EXPECT_FALSE(controller.HasObservers());
- controller.AddObserver(&observer1);
- EXPECT_TRUE(controller.HasObservers());
- controller.AddObserver(&observer2);
- EXPECT_TRUE(controller.HasObservers());
- controller.RemoveObserver(&observer3); // nop
- EXPECT_TRUE(controller.HasObservers());
- controller.RemoveObserver(&observer1);
- EXPECT_TRUE(controller.HasObservers());
- controller.RemoveObserver(&observer1); // nop
- EXPECT_TRUE(controller.HasObservers());
- controller.RemoveObserver(&observer2);
- EXPECT_FALSE(controller.HasObservers());
- }
- IBusBridge::Shutdown();
-}
-
-TEST(IBusControllerImplTest, TestGetCurrentProperties) {
- IBusBridge::Initialize();
- {
- IBusControllerImpl controller;
- EXPECT_EQ(0U, controller.GetCurrentProperties().size());
- }
- IBusBridge::Shutdown();
-}
-
-} // namespace input_method
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
deleted file mode 100644
index 7b74d96..0000000
--- a/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
+++ /dev/null
@@ -1,24 +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 "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/chromeos/input_method/ibus_controller.h"
-#include "chromeos/ime/ibus_bridge.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-namespace input_method {
-
-TEST(IBusControllerTest, TestCreate) {
- IBusBridge::Initialize();
- {
- scoped_ptr<IBusController> controller(IBusController::Create());
- EXPECT_TRUE(controller.get());
- }
- IBusBridge::Shutdown();
-}
-
-} // namespace input_method
-} // namespace chromeos
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 4b2a020..72dfdf4 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc
@@ -347,10 +347,10 @@ bool InputMethodEngineIBus::UpdateMenuItems(
property_list.push_back(property);
}
- IBusPanelPropertyHandlerInterface* handler =
- IBusBridge::Get()->GetPropertyHandler();
- if (handler)
- handler->RegisterProperties(property_list);
+ input_method::InputMethodManager* manager =
+ input_method::InputMethodManager::Get();
+ if (manager)
+ manager->SetCurrentInputMethodProperties(property_list);
return true;
}
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_ibus_browserttests.cc b/chrome/browser/chromeos/input_method/input_method_engine_ibus_browserttests.cc
index b045bf8..c36d2a5 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine_ibus_browserttests.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus_browserttests.cc
@@ -749,10 +749,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
"});";
ASSERT_TRUE(content::ExecuteScript(
host->host_contents(), set_menu_item_test_script));
- EXPECT_EQ(1, mock_property->register_properties_call_count());
const InputMethodPropertyList& props =
- mock_property->last_registered_properties();
+ InputMethodManager::Get()->GetCurrentInputMethodProperties();
ASSERT_EQ(5U, props.size());
EXPECT_EQ("ID0", props[0].key);
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 d0c9f27..124d788 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -58,8 +58,6 @@ InputMethodManagerImpl::InputMethodManagerImpl(
}
InputMethodManagerImpl::~InputMethodManagerImpl() {
- if (ibus_controller_.get())
- ibus_controller_->RemoveObserver(this);
if (candidate_window_controller_.get()) {
candidate_window_controller_->RemoveObserver(this);
candidate_window_controller_->Shutdown();
@@ -302,9 +300,6 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal(
IBusEngineHandlerInterface* engine = IBusBridge::Get()->GetEngineHandler();
const std::string current_input_method_id = current_input_method_.id();
if (InputMethodUtil::IsKeyboardLayout(input_method_id_to_switch)) {
- FOR_EACH_OBSERVER(InputMethodManager::Observer,
- observers_,
- InputMethodPropertyChanged(this));
if (engine) {
engine->Disable();
IBusBridge::Get()->SetEngineHandler(NULL);
@@ -322,26 +317,12 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal(
}
if (current_input_method_id != input_method_id_to_switch) {
- // Clear input method properties unconditionally if
- // |input_method_id_to_switch| is not equal to |current_input_method_id|.
- //
- // When switching to another input method and no text area is focused,
- // RegisterProperties signal for the new input method will NOT be sent
- // until a text area is focused. Therefore, we have to clear the old input
- // method properties here to keep the input method switcher status
- // consistent.
- //
- // When |input_method_id_to_switch| and |current_input_method_id| are the
- // same, the properties shouldn't be cleared. If we do that, something
- // wrong happens in step #4 below:
- // 1. Enable "xkb:us::eng" and "mozc". Switch to "mozc".
- // 2. Focus Omnibox. IME properties for mozc are sent to Chrome.
- // 3. Switch to "xkb:us::eng". No function in this file is called.
- // 4. Switch back to "mozc". ChangeInputMethod("mozc") is called, but it's
- // basically NOP since ibus-daemon's current IME is already "mozc".
- // IME properties are not sent to Chrome for the same reason.
- // TODO(nona): Revisit above comment once ibus-daemon is gone.
- ibus_controller_->ClearProperties();
+ // Clear property list. Property list would be updated by
+ // extension IMEs via InputMethodEngineIBus::(Set|Update)MenuItems.
+ // If the current input method is a keyboard layout, empty
+ // properties are sufficient.
+ const InputMethodPropertyList empty_property_list;
+ SetCurrentInputMethodProperties(empty_property_list);
const InputMethodDescriptor* descriptor = NULL;
if (!extension_ime_util::IsExtensionIME(input_method_id_to_switch)) {
@@ -414,7 +395,18 @@ void InputMethodManagerImpl::LoadNecessaryComponentExtensions() {
void InputMethodManagerImpl::ActivateInputMethodProperty(
const std::string& key) {
DCHECK(!key.empty());
- ibus_controller_->ActivateInputMethodProperty(key);
+
+ for (size_t i = 0; i < property_list_.size(); ++i) {
+ if (property_list_[i].key == key) {
+ IBusEngineHandlerInterface* engine =
+ IBusBridge::Get()->GetEngineHandler();
+ if (engine)
+ engine->PropertyActivate(key);
+ return;
+ }
+ }
+
+ DVLOG(1) << "ActivateInputMethodProperty: unknown key: " << key;
}
void InputMethodManagerImpl::AddInputMethodExtension(
@@ -464,13 +456,6 @@ void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) {
active_input_method_ids_.erase(i);
extra_input_methods_.erase(id);
- if (ContainsOnlyKeyboardLayout(active_input_method_ids_)) {
- // Do NOT call ibus_controller_->Stop(); here to work around a crash issue
- // at crosbug.com/27051.
- // TODO(yusukes): We can safely call Stop(); here once crosbug.com/26443
- // is implemented.
- }
-
// If |current_input_method| is no longer in |active_input_method_ids_|,
// switch to the first one in |active_input_method_ids_|.
ChangeInputMethod(current_input_method_.id());
@@ -688,8 +673,14 @@ InputMethodManagerImpl::GetCurrentInputMethodProperties() const {
// This check is necessary since an IME property (e.g. for Pinyin) might be
// sent from ibus-daemon AFTER the current input method is switched to XKB.
if (InputMethodUtil::IsKeyboardLayout(GetCurrentInputMethod().id()))
- return InputMethodPropertyList();
- return ibus_controller_->GetCurrentProperties();
+ return InputMethodPropertyList(); // Empty list.
+ return property_list_;
+}
+
+void InputMethodManagerImpl::SetCurrentInputMethodProperties(
+ const InputMethodPropertyList& property_list) {
+ property_list_ = property_list;
+ PropertyChanged();
}
XKeyboard* InputMethodManagerImpl::GetXKeyboard() {
@@ -717,12 +708,9 @@ void InputMethodManagerImpl::InitializeComponentExtension() {
}
void InputMethodManagerImpl::Init(base::SequencedTaskRunner* ui_task_runner) {
- DCHECK(!ibus_controller_.get());
DCHECK(thread_checker_.CalledOnValidThread());
- ibus_controller_.reset(IBusController::Create());
xkeyboard_.reset(XKeyboard::Create());
- ibus_controller_->AddObserver(this);
// We can't call impl->Initialize here, because file thread is not available
// at this moment.
@@ -732,12 +720,6 @@ void InputMethodManagerImpl::Init(base::SequencedTaskRunner* ui_task_runner) {
weak_ptr_factory_.GetWeakPtr()));
}
-void InputMethodManagerImpl::SetIBusControllerForTesting(
- IBusController* ibus_controller) {
- ibus_controller_.reset(ibus_controller);
- ibus_controller_->AddObserver(this);
-}
-
void InputMethodManagerImpl::SetCandidateWindowControllerForTesting(
CandidateWindowController* candidate_window_controller) {
candidate_window_controller_.reset(candidate_window_controller);
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 009af4c..a13fa6d 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
@@ -13,7 +13,6 @@
#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
-#include "chrome/browser/chromeos/input_method/ibus_controller.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chromeos/ime/input_method_manager.h"
#include "chromeos/ime/input_method_whitelist.h"
@@ -28,18 +27,17 @@ class XKeyboard;
// The implementation of InputMethodManager.
class InputMethodManagerImpl : public InputMethodManager,
- public CandidateWindowController::Observer,
- public IBusController::Observer {
+ public CandidateWindowController::Observer {
public:
// Constructs an InputMethodManager instance. The client is responsible for
// calling |SetState| in response to relevant changes in browser state.
explicit InputMethodManagerImpl(scoped_ptr<InputMethodDelegate> delegate);
virtual ~InputMethodManagerImpl();
- // Attach IBusController, CandidateWindowController, and XKeyboard objects
- // to the InputMethodManagerImpl object. You don't have to call this function
- // if you attach them yourself (e.g. in unit tests) using the protected
- // setters.
+ // Attach CandidateWindowController, and XKeyboard objects to the
+ // InputMethodManagerImpl object. You don't have to call this
+ // function if you attach them yourself (e.g. in unit tests) using
+ // the protected setters.
void Init(base::SequencedTaskRunner* ui_task_runner);
// Receives notification of an InputMethodManager::State transition.
@@ -87,14 +85,15 @@ class InputMethodManagerImpl : public InputMethodManager,
virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
virtual InputMethodPropertyList
GetCurrentInputMethodProperties() const OVERRIDE;
+ virtual void SetCurrentInputMethodProperties(
+ const InputMethodPropertyList& property_list) OVERRIDE;
+
virtual XKeyboard* GetXKeyboard() OVERRIDE;
virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
virtual ComponentExtensionIMEManager*
GetComponentExtensionIMEManager() OVERRIDE;
virtual bool IsLoginKeyboard(const std::string& layout) const OVERRIDE;
- // Sets |ibus_controller_|.
- void SetIBusControllerForTesting(IBusController* ibus_controller);
// Sets |candidate_window_controller_|.
void SetCandidateWindowControllerForTesting(
CandidateWindowController* candidate_window_controller);
@@ -105,8 +104,8 @@ class InputMethodManagerImpl : public InputMethodManager,
scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate);
private:
- // IBusController overrides:
- virtual void PropertyChanged() OVERRIDE;
+ // Notifies observers that the property list is updated.
+ void PropertyChanged();
// CandidateWindowController::Observer overrides:
virtual void CandidateWindowOpened() OVERRIDE;
@@ -193,9 +192,8 @@ class InputMethodManagerImpl : public InputMethodManager,
std::map<std::string, InputMethodDescriptor> extra_input_methods_;
std::map<std::string, InputMethodEngineIBus*> extra_input_method_instances_;
- // The IBus controller is used to control the input method status and
- // allow callbacks when the input method status changes.
- scoped_ptr<IBusController> ibus_controller_;
+ // Property list of the input method. This is set by extension IMEs.
+ InputMethodPropertyList property_list_;
// The candidate window. This will be deleted when the APP_TERMINATING
// message is sent.
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 b8598a8..c4d9585 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
@@ -14,7 +14,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.h"
-#include "chrome/browser/chromeos/input_method/mock_ibus_controller.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"
@@ -48,7 +47,6 @@ class InputMethodManagerImplTest : public testing::Test {
public:
InputMethodManagerImplTest()
: delegate_(NULL),
- controller_(NULL),
candidate_window_controller_(NULL),
xkeyboard_(NULL) {
}
@@ -58,8 +56,6 @@ class InputMethodManagerImplTest : public testing::Test {
delegate_ = new FakeInputMethodDelegate();
manager_.reset(new InputMethodManagerImpl(
scoped_ptr<InputMethodDelegate>(delegate_)));
- controller_ = new MockIBusController;
- manager_->SetIBusControllerForTesting(controller_);
candidate_window_controller_ = new MockCandidateWindowController;
manager_->SetCandidateWindowControllerForTesting(
candidate_window_controller_);
@@ -116,7 +112,6 @@ class InputMethodManagerImplTest : public testing::Test {
virtual void TearDown() OVERRIDE {
delegate_ = NULL;
- controller_ = NULL;
candidate_window_controller_ = NULL;
xkeyboard_ = NULL;
manager_.reset();
@@ -135,7 +130,6 @@ class InputMethodManagerImplTest : public testing::Test {
scoped_ptr<InputMethodManagerImpl> manager_;
FakeInputMethodDelegate* delegate_;
- MockIBusController* controller_;
MockCandidateWindowController* candidate_window_controller_;
scoped_ptr<MockIMEEngineHandler> mock_engine_handler_;
MockXKeyboard* xkeyboard_;
@@ -242,15 +236,16 @@ TEST_F(InputMethodManagerImplTest, TestObserver) {
EXPECT_EQ(2, observer.input_method_property_changed_count_);
manager_->ChangeInputMethod("xkb:us:dvorak:eng");
EXPECT_FALSE(observer.last_show_message_);
+
// The observer is always notified even when the same input method ID is
// passed to ChangeInputMethod() more than twice.
+ // TODO(komatsu): Revisit if this is neccessary.
EXPECT_EQ(3, observer.input_method_changed_count_);
- EXPECT_EQ(3, observer.input_method_property_changed_count_);
- controller_->NotifyPropertyChangedForTesting();
- EXPECT_EQ(4, observer.input_method_property_changed_count_);
- controller_->NotifyPropertyChangedForTesting();
- EXPECT_EQ(5, observer.input_method_property_changed_count_);
+ // If the same input method ID is passed, PropertyChanged() is not
+ // notified.
+ EXPECT_EQ(2, observer.input_method_property_changed_count_);
+
manager_->RemoveObserver(&observer);
}
@@ -575,12 +570,17 @@ TEST_F(InputMethodManagerImplTest, TestXkbSetting) {
}
TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) {
- manager_->ActivateInputMethodProperty("key");
- EXPECT_EQ(1, controller_->activate_input_method_property_count_);
- EXPECT_EQ("key", controller_->activate_input_method_property_key_);
+ const std::string kKey = "key";
+ InputMethodPropertyList property_list;
+ property_list.push_back(InputMethodProperty(kKey, "label", false, false));
+ manager_->SetCurrentInputMethodProperties(property_list);
+
+ manager_->ActivateInputMethodProperty(kKey);
+ EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
+
+ // Key2 is not registered, so activated property should not be changed.
manager_->ActivateInputMethodProperty("key2");
- EXPECT_EQ(2, controller_->activate_input_method_property_count_);
- EXPECT_EQ("key2", controller_->activate_input_method_property_key_);
+ EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
}
TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
@@ -601,20 +601,13 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
"label",
false,
false));
- controller_->SetCurrentPropertiesForTesting(current_property_list);
- controller_->NotifyPropertyChangedForTesting();
+ manager_->SetCurrentInputMethodProperties(current_property_list);
ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key);
manager_->ChangeInputMethod("xkb:us::eng");
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
-
- // Delayed asynchronous property update signal from the Mozc IME.
- controller_->NotifyPropertyChangedForTesting();
- // When XKB layout is in use, GetCurrentInputMethodProperties() should always
- // return an empty list.
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty());
}
TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
@@ -634,8 +627,7 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
"label",
false,
false));
- controller_->SetCurrentPropertiesForTesting(current_property_list);
- controller_->NotifyPropertyChangedForTesting();
+ manager_->SetCurrentInputMethodProperties(current_property_list);
ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key);
@@ -650,8 +642,7 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
"label",
false,
false));
- controller_->SetCurrentPropertiesForTesting(current_property_list);
- controller_->NotifyPropertyChangedForTesting();
+ manager_->SetCurrentInputMethodProperties(current_property_list);
ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
EXPECT_EQ("key-chewing",
manager_->GetCurrentInputMethodProperties().at(0).key);
diff --git a/chrome/browser/chromeos/input_method/mock_ibus_controller.cc b/chrome/browser/chromeos/input_method/mock_ibus_controller.cc
deleted file mode 100644
index dbced56..0000000
--- a/chrome/browser/chromeos/input_method/mock_ibus_controller.cc
+++ /dev/null
@@ -1,53 +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 "chrome/browser/chromeos/input_method/mock_ibus_controller.h"
-
-#include "chromeos/ime/input_method_property.h"
-
-namespace chromeos {
-namespace input_method {
-
-MockIBusController::MockIBusController()
- : activate_input_method_property_count_(0),
- activate_input_method_property_return_(true) {
-}
-
-MockIBusController::~MockIBusController() {
-}
-
-bool MockIBusController::ActivateInputMethodProperty(const std::string& key) {
- ++activate_input_method_property_count_;
- activate_input_method_property_key_ = key;
- return activate_input_method_property_return_;
-}
-
-void MockIBusController::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void MockIBusController::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-const InputMethodPropertyList&
-MockIBusController::GetCurrentProperties() const {
- return current_property_list_;
-}
-
-void MockIBusController::ClearProperties() {
- current_property_list_.clear();
-}
-
-void MockIBusController::NotifyPropertyChangedForTesting() {
- FOR_EACH_OBSERVER(Observer, observers_, PropertyChanged());
-}
-
-void MockIBusController::SetCurrentPropertiesForTesting(
- const InputMethodPropertyList& current_property_list) {
- current_property_list_ = current_property_list;
-}
-
-} // 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
deleted file mode 100644
index 180152a..0000000
--- a/chrome/browser/chromeos/input_method/mock_ibus_controller.h
+++ /dev/null
@@ -1,56 +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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_IBUS_CONTROLLER_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_IBUS_CONTROLLER_H_
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/observer_list.h"
-#include "chrome/browser/chromeos/input_method/ibus_controller.h"
-#include "chromeos/ime/input_method_config.h"
-
-namespace chromeos {
-namespace input_method {
-
-// Mock IBusController implementation.
-// TODO(nona): Remove this class and use MockIBus stuff instead.
-class MockIBusController : public IBusController {
- public:
- MockIBusController();
- virtual ~MockIBusController();
-
- // IBusController overrides:
- virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE;
- virtual void AddObserver(Observer* observer) OVERRIDE;
- virtual void RemoveObserver(Observer* observer) OVERRIDE;
- virtual const InputMethodPropertyList& GetCurrentProperties() const OVERRIDE;
- virtual void ClearProperties() OVERRIDE;
-
- // Notifies all |observers_|.
- void NotifyPropertyChangedForTesting();
-
- // Updates |current_property_list_|.
- void SetCurrentPropertiesForTesting(
- const InputMethodPropertyList& current_property_list);
-
- int activate_input_method_property_count_;
- std::string activate_input_method_property_key_;
- bool activate_input_method_property_return_;
-
- protected:
- ObserverList<Observer> observers_;
-
- // The value which will be returned by GetCurrentProperties(). Derived classes
- // should update this variable when needed.
- InputMethodPropertyList current_property_list_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockIBusController);
-};
-
-} // namespace input_method
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_IBUS_CONTROLLER_H_
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 c206fbc..65c3df2 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
@@ -140,6 +140,10 @@ MockInputMethodManager::GetCurrentInputMethodProperties() const {
return InputMethodPropertyList();
}
+void MockInputMethodManager::SetCurrentInputMethodProperties(
+ const InputMethodPropertyList& property_list) {
+}
+
XKeyboard* MockInputMethodManager::GetXKeyboard() {
return &xkeyboard_;
}
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 5139963..4a8ac4d 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.h
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
@@ -62,6 +62,8 @@ class MockInputMethodManager : public InputMethodManager {
virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
virtual InputMethodPropertyList
GetCurrentInputMethodProperties() const OVERRIDE;
+ virtual void SetCurrentInputMethodProperties(
+ const InputMethodPropertyList& property_list) OVERRIDE;
virtual XKeyboard* GetXKeyboard() OVERRIDE;
virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
virtual ComponentExtensionIMEManager*