Commit 5ade0d0b authored by uekawa@chromium.org's avatar uekawa@chromium.org

Reland of: Split out InputMethodMenuManager from InputMethodManager.

Rename input_method_property to input_method_menu_item, and move to ash/ime.

This is a reland of https://codereview.chromium.org/150203015,reverted by https://codereview.chromium.org/165453002

Use Singleton<> instead of trying to maintain my own singleton.

BUG=342336, 343044

Review URL: https://codereview.chromium.org/165783002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251327 0039d316-1c4b-4281-b951-d872f2087c98
parent 649ee534
...@@ -167,6 +167,10 @@ ...@@ -167,6 +167,10 @@
'ime/candidate_window_view.h', 'ime/candidate_window_view.h',
'ime/infolist_window.cc', 'ime/infolist_window.cc',
'ime/infolist_window.h', 'ime/infolist_window.h',
'ime/input_method_menu_item.cc',
'ime/input_method_menu_item.h',
'ime/input_method_menu_manager.cc',
'ime/input_method_menu_manager.h',
'ime/mode_indicator_view.cc', 'ime/mode_indicator_view.cc',
'ime/mode_indicator_view.h', 'ime/mode_indicator_view.h',
'keyboard_uma_event_filter.cc', 'keyboard_uma_event_filter.cc',
...@@ -849,6 +853,8 @@ ...@@ -849,6 +853,8 @@
'extended_desktop_unittest.cc', 'extended_desktop_unittest.cc',
'focus_cycler_unittest.cc', 'focus_cycler_unittest.cc',
'ime/candidate_window_view_unittest.cc', 'ime/candidate_window_view_unittest.cc',
'ime/input_method_menu_item_unittest.cc',
'ime/input_method_menu_manager_unittest.cc',
'keyboard_overlay/keyboard_overlay_delegate_unittest.cc', 'keyboard_overlay/keyboard_overlay_delegate_unittest.cc',
'keyboard_overlay/keyboard_overlay_view_unittest.cc', 'keyboard_overlay/keyboard_overlay_view_unittest.cc',
'magnifier/magnification_controller_unittest.cc', 'magnifier/magnification_controller_unittest.cc',
......
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/ime/input_method_property.h" #include "ash/ime/input_method_menu_item.h"
#include <sstream> #include <sstream>
#include "base/logging.h" #include "base/logging.h"
namespace chromeos { namespace ash {
namespace input_method { namespace ime {
InputMethodProperty::InputMethodProperty(const std::string& in_key, InputMethodMenuItem::InputMethodMenuItem(const std::string& in_key,
const std::string& in_label, const std::string& in_label,
bool in_is_selection_item, bool in_is_selection_item,
bool in_is_selection_item_checked) bool in_is_selection_item_checked)
...@@ -22,26 +22,26 @@ InputMethodProperty::InputMethodProperty(const std::string& in_key, ...@@ -22,26 +22,26 @@ InputMethodProperty::InputMethodProperty(const std::string& in_key,
DCHECK(!key.empty()); DCHECK(!key.empty());
} }
InputMethodProperty::InputMethodProperty() InputMethodMenuItem::InputMethodMenuItem()
: is_selection_item(false), : is_selection_item(false),
is_selection_item_checked(false) { is_selection_item_checked(false) {
} }
InputMethodProperty::~InputMethodProperty() { InputMethodMenuItem::~InputMethodMenuItem() {
} }
bool InputMethodProperty::operator==(const InputMethodProperty& other) const { bool InputMethodMenuItem::operator==(const InputMethodMenuItem& other) const {
return key == other.key && return key == other.key &&
label == other.label && label == other.label &&
is_selection_item == other.is_selection_item && is_selection_item == other.is_selection_item &&
is_selection_item_checked == other.is_selection_item_checked; is_selection_item_checked == other.is_selection_item_checked;
} }
bool InputMethodProperty::operator!=(const InputMethodProperty& other) const { bool InputMethodMenuItem::operator!=(const InputMethodMenuItem& other) const {
return !(*this == other); return !(*this == other);
} }
std::string InputMethodProperty::ToString() const { std::string InputMethodMenuItem::ToString() const {
std::stringstream stream; std::stringstream stream;
stream << "key=" << key stream << "key=" << key
<< ", label=" << label << ", label=" << label
...@@ -50,5 +50,5 @@ std::string InputMethodProperty::ToString() const { ...@@ -50,5 +50,5 @@ std::string InputMethodProperty::ToString() const {
return stream.str(); return stream.str();
} }
} // namespace input_method } // namespace ime
} // namespace chromeos } // namespace ash
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_IME_INPUT_METHOD_PROPERTY_H_ #ifndef ASH_IME_INPUT_METHOD_MENU_ITEM_H_
#define CHROMEOS_IME_INPUT_METHOD_PROPERTY_H_ #define ASH_IME_INPUT_METHOD_MENU_ITEM_H_
#include <string> #include <string>
#include <vector> #include <vector>
#include "chromeos/chromeos_export.h" #include "ash/ash_export.h"
namespace chromeos { namespace ash {
namespace input_method { namespace ime {
// A structure which represents a property for an input method engine. // A structure which represents a property for an input method engine.
struct CHROMEOS_EXPORT InputMethodProperty { struct ASH_EXPORT InputMethodMenuItem {
InputMethodProperty(const std::string& in_key, InputMethodMenuItem(const std::string& in_key,
const std::string& in_label, const std::string& in_label,
bool in_is_selection_item, bool in_is_selection_item,
bool in_is_selection_item_checked); bool in_is_selection_item_checked);
InputMethodProperty(); InputMethodMenuItem();
~InputMethodProperty(); ~InputMethodMenuItem();
bool operator==(const InputMethodProperty& other) const; bool operator==(const InputMethodMenuItem& other) const;
bool operator!=(const InputMethodProperty& other) const; bool operator!=(const InputMethodMenuItem& other) const;
// Debug print function. // Debug print function.
std::string ToString() const; std::string ToString() const;
...@@ -36,9 +36,9 @@ struct CHROMEOS_EXPORT InputMethodProperty { ...@@ -36,9 +36,9 @@ struct CHROMEOS_EXPORT InputMethodProperty {
bool is_selection_item_checked; // true if |is_selection_item| is true and bool is_selection_item_checked; // true if |is_selection_item| is true and
// the selection_item is selected. // the selection_item is selected.
}; };
typedef std::vector<InputMethodProperty> InputMethodPropertyList; typedef std::vector<InputMethodMenuItem> InputMethodMenuItemList;
} // namespace input_method } // namespace ime
} // namespace chromeos } // namespace ash
#endif // CHROMEOS_IME_INPUT_METHOD_PROPERTY_H_ #endif // ASH_IME_INPUT_METHOD_MENU_ITEM_H_
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/ime/input_method_menu_item.h"
#include "base/logging.h" #include "base/logging.h"
#include "chromeos/ime/input_method_property.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace chromeos { namespace ash {
namespace input_method { namespace ime {
TEST(InputMethodPropertyTest, TestOperatorEqual) { TEST(InputMethodMenuItemTest, TestOperatorEqual) {
InputMethodProperty empty; InputMethodMenuItem empty;
InputMethodProperty reference("key", "label", true, true); InputMethodMenuItem reference("key", "label", true, true);
InputMethodProperty p1("X", "label", true, true); InputMethodMenuItem p1("X", "label", true, true);
InputMethodProperty p2("key", "X", true, true); InputMethodMenuItem p2("key", "X", true, true);
InputMethodProperty p3("key", "label", false, true); InputMethodMenuItem p3("key", "label", false, true);
InputMethodProperty p4("key", "label", true, false); InputMethodMenuItem p4("key", "label", true, false);
EXPECT_EQ(empty, empty); EXPECT_EQ(empty, empty);
EXPECT_EQ(reference, reference); EXPECT_EQ(reference, reference);
...@@ -27,5 +28,5 @@ TEST(InputMethodPropertyTest, TestOperatorEqual) { ...@@ -27,5 +28,5 @@ TEST(InputMethodPropertyTest, TestOperatorEqual) {
EXPECT_NE(reference, p4); EXPECT_NE(reference, p4);
} }
} // namespace input_method } // namespace ime
} // namespace chromeos } // namespace ash
// Copyright 2014 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 "ash/ime/input_method_menu_manager.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
namespace ash {
namespace ime {
InputMethodMenuManager::InputMethodMenuManager()
: menu_list_(), observers_() {}
InputMethodMenuManager::~InputMethodMenuManager() {}
void InputMethodMenuManager::AddObserver(
InputMethodMenuManager::Observer* observer) {
observers_.AddObserver(observer);
}
void InputMethodMenuManager::RemoveObserver(
InputMethodMenuManager::Observer* observer) {
observers_.RemoveObserver(observer);
}
InputMethodMenuItemList
InputMethodMenuManager::GetCurrentInputMethodMenuItemList() const {
return menu_list_;
}
void InputMethodMenuManager::SetCurrentInputMethodMenuItemList(
const InputMethodMenuItemList& menu_list) {
menu_list_ = menu_list;
FOR_EACH_OBSERVER(InputMethodMenuManager::Observer,
observers_,
InputMethodMenuItemChanged(this));
}
bool InputMethodMenuManager::HasInputMethodMenuItemForKey(
const std::string& key) const {
for (size_t i = 0; i < menu_list_.size(); ++i) {
if (menu_list_[i].key == key) {
return true;
}
}
return false;
}
// static
InputMethodMenuManager* InputMethodMenuManager::GetInstance() {
return Singleton<InputMethodMenuManager>::get();
}
} // namespace ime
} // namespace ash
// Copyright 2014 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 "ash/ash_export.h"
#include "ash/ime/input_method_menu_item.h"
#include "base/observer_list.h"
#ifndef ASH_IME_INPUT_METHOD_MENU_MANAGER_H_
#define ASH_IME_INPUT_METHOD_MENU_MANAGER_H_
template<typename Type> struct DefaultSingletonTraits;
namespace ash {
namespace ime {
class ASH_EXPORT InputMethodMenuManager {
public:
class Observer {
public:
virtual ~Observer() {}
// Called when the list of menu items is changed.
virtual void InputMethodMenuItemChanged(
InputMethodMenuManager* manager) = 0;
};
~InputMethodMenuManager();
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// Obtains the singleton instance.
static InputMethodMenuManager* GetInstance();
// Sets the list of input method menu items. The list could be empty().
void SetCurrentInputMethodMenuItemList(
const InputMethodMenuItemList& menu_list);
// Gets the list of input method menu items. The list could be empty().
InputMethodMenuItemList GetCurrentInputMethodMenuItemList() const;
// True if the key exists in the menu_list_.
bool HasInputMethodMenuItemForKey(const std::string& key) const;
private:
InputMethodMenuManager();
// For Singleton to be able to construct an instance.
friend struct DefaultSingletonTraits<InputMethodMenuManager>;
// Menu item list of the input method. This is set by extension IMEs.
InputMethodMenuItemList menu_list_;
// Observers who will be notified when menu changes.
ObserverList<Observer> observers_;
DISALLOW_COPY_AND_ASSIGN(InputMethodMenuManager);
};
} // namespace ime
} // namespace ash
#endif // ASH_IME_INPUT_METHOD_MENU_MANAGER_H_
// Copyright 2014 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 "ash/ime/input_method_menu_manager.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
namespace ime {
TEST(InputMethodMenuManagerTest, TestGetSingleton) {
EXPECT_TRUE(InputMethodMenuManager::GetInstance());
}
class MockObserver : public InputMethodMenuManager::Observer {
public:
MockObserver() : input_method_menu_item_changed_count_(0) {}
virtual ~MockObserver() {}
// Called when the list of menu items is changed.
virtual void InputMethodMenuItemChanged(
InputMethodMenuManager* manager) OVERRIDE {
input_method_menu_item_changed_count_++;
}
int input_method_menu_item_changed_count_;
};
class InputMethodMenuManagerStatefulTest : public testing::Test{
public:
InputMethodMenuManagerStatefulTest()
: observer_(new MockObserver()) {}
virtual ~InputMethodMenuManagerStatefulTest() {}
virtual void SetUp() OVERRIDE {
menu_manager_ = InputMethodMenuManager::GetInstance();
menu_manager_->AddObserver(observer_.get());
}
virtual void TearDown() OVERRIDE {
menu_manager_->RemoveObserver(observer_.get());
}
InputMethodMenuManager* menu_manager_;
scoped_ptr<MockObserver> observer_;
};
TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) {
EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0);
menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList());
EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 1);
}
TEST_F(InputMethodMenuManagerStatefulTest, AddAndCheckExists) {
InputMethodMenuItemList list;
list.push_back(InputMethodMenuItem("key1", "label1", false, false));
list.push_back(InputMethodMenuItem("key2", "label2", false, false));
menu_manager_->SetCurrentInputMethodMenuItemList(list);
EXPECT_EQ(menu_manager_->GetCurrentInputMethodMenuItemList().size(), 2U);
EXPECT_EQ(
menu_manager_->GetCurrentInputMethodMenuItemList().at(0).ToString(),
"key=key1, label=label1, "
"is_selection_item=0, is_selection_item_checked=0");
EXPECT_EQ(
menu_manager_->GetCurrentInputMethodMenuItemList().at(1).ToString(),
"key=key2, label=label2, "
"is_selection_item=0, is_selection_item_checked=0");
EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1"));
EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2"));
EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist"));
}
} // namespace ime
} // namespace ash
...@@ -28,8 +28,6 @@ class ExtensionInputMethodEventRouter ...@@ -28,8 +28,6 @@ class ExtensionInputMethodEventRouter
virtual void InputMethodChanged( virtual void InputMethodChanged(
input_method::InputMethodManager* manager, input_method::InputMethodManager* manager,
bool show_message) OVERRIDE; bool show_message) OVERRIDE;
virtual void InputMethodPropertyChanged(
input_method::InputMethodManager* manager) OVERRIDE {}
private: private:
content::BrowserContext* context_; content::BrowserContext* context_;
......
...@@ -54,9 +54,5 @@ void Accessibility::InputMethodChanged(InputMethodManager* imm, ...@@ -54,9 +54,5 @@ void Accessibility::InputMethodChanged(InputMethodManager* imm,
ui::AccessibilityTypes::EVENT_ALERT, &event); ui::AccessibilityTypes::EVENT_ALERT, &event);
} }
void Accessibility::InputMethodPropertyChanged(InputMethodManager* imm) {
// Do nothing.
}
} // namespace input_method } // namespace input_method
} // namespace chromeos } // namespace chromeos
...@@ -21,8 +21,6 @@ class Accessibility ...@@ -21,8 +21,6 @@ class Accessibility
// InputMethodManager::Observer implementation. // InputMethodManager::Observer implementation.
virtual void InputMethodChanged(InputMethodManager* imm, virtual void InputMethodChanged(InputMethodManager* imm,
bool show_message) OVERRIDE; bool show_message) OVERRIDE;
virtual void InputMethodPropertyChanged(InputMethodManager* imm) OVERRIDE;
InputMethodManager* imm_; InputMethodManager* imm_;
DISALLOW_COPY_AND_ASSIGN(Accessibility); DISALLOW_COPY_AND_ASSIGN(Accessibility);
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#undef RootWindow #undef RootWindow
#include <map> #include <map>
#include "ash/ime/input_method_menu_item.h"
#include "ash/ime/input_method_menu_manager.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -371,19 +373,17 @@ bool InputMethodEngine::UpdateMenuItems( ...@@ -371,19 +373,17 @@ bool InputMethodEngine::UpdateMenuItems(
if (!active_) if (!active_)
return false; return false;
input_method::InputMethodPropertyList property_list; ash::ime::InputMethodMenuItemList menu_item_list;
for (std::vector<MenuItem>::const_iterator item = items.begin(); for (std::vector<MenuItem>::const_iterator item = items.begin();
item != items.end(); ++item) { item != items.end(); ++item) {
input_method::InputMethodProperty property; ash::ime::InputMethodMenuItem property;
MenuItemToProperty(*item, &property); MenuItemToProperty(*item, &property);
property_list.push_back(property); menu_item_list.push_back(property);
} }
input_method::InputMethodManager* manager = ash::ime::InputMethodMenuManager::GetInstance()->
input_method::InputMethodManager::Get(); SetCurrentInputMethodMenuItemList(
if (manager) menu_item_list);
manager->SetCurrentInputMethodProperties(property_list);
return true; return true;
} }
...@@ -583,9 +583,10 @@ void InputMethodEngine::SetSurroundingText(const std::string& text, ...@@ -583,9 +583,10 @@ void InputMethodEngine::SetSurroundingText(const std::string& text,
static_cast<int>(anchor_pos)); static_cast<int>(anchor_pos));
} }
// TODO(uekawa): rename this method to a more reasonable name.
void InputMethodEngine::MenuItemToProperty( void InputMethodEngine::MenuItemToProperty(
const MenuItem& item, const MenuItem& item,
input_method::InputMethodProperty* property) { ash::ime::InputMethodMenuItem* property) {
property->key = item.id; property->key = item.id;
if (item.modified & MENU_ITEM_MODIFIED_LABEL) { if (item.modified & MENU_ITEM_MODIFIED_LABEL) {
......
...@@ -17,12 +17,17 @@ class CandidateWindow; ...@@ -17,12 +17,17 @@ class CandidateWindow;
class KeyEvent; class KeyEvent;
} // namespace ui } // namespace ui
namespace ash {
namespace ime {
struct InputMethodMenuItem;
} // namespace ime
} // namespace ash
namespace chromeos { namespace chromeos {
class CompositionText; class CompositionText;
namespace input_method { namespace input_method {
struct InputMethodProperty;
struct KeyEventHandle; struct KeyEventHandle;
} // namespace input_method } // namespace input_method
...@@ -95,9 +100,9 @@ class InputMethodEngine : public InputMethodEngineInterface { ...@@ -95,9 +100,9 @@ class InputMethodEngine : public InputMethodEngineInterface {
virtual void HideInputView() OVERRIDE; virtual void HideInputView() OVERRIDE;
private: private:
// Converts MenuItem to InputMethodProperty. // Converts MenuItem to InputMethodMenuItem.
void MenuItemToProperty(const MenuItem& item, void MenuItemToProperty(const MenuItem& item,
input_method::InputMethodProperty* property); ash::ime::InputMethodMenuItem* property);
// Descriptor of this input method. // Descriptor of this input method.
input_method::InputMethodDescriptor descriptor_; input_method::InputMethodDescriptor descriptor_;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/ime/input_method_menu_item.h"
#include "ash/ime/input_method_menu_manager.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_browsertest.h"
...@@ -795,8 +797,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest, ...@@ -795,8 +797,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineIBusBrowserTest,
ASSERT_TRUE(content::ExecuteScript( ASSERT_TRUE(content::ExecuteScript(
host->host_contents(), set_menu_item_test_script)); host->host_contents(), set_menu_item_test_script));
const InputMethodPropertyList& props = const ash::ime::InputMethodMenuItemList& props =
InputMethodManager::Get()->GetCurrentInputMethodProperties(); ash::ime::InputMethodMenuManager::GetInstance()->
GetCurrentInputMethodMenuItemList();
ASSERT_EQ(5U, props.size()); ASSERT_EQ(5U, props.size());
EXPECT_EQ("ID0", props[0].key); EXPECT_EQ("ID0", props[0].key);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <algorithm> // std::find #include <algorithm> // std::find
#include "ash/ime/input_method_menu_item.h"
#include "ash/ime/input_method_menu_manager.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
...@@ -350,8 +352,11 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal( ...@@ -350,8 +352,11 @@ bool InputMethodManagerImpl::ChangeInputMethodInternal(
// extension IMEs via InputMethodEngine::(Set|Update)MenuItems. // extension IMEs via InputMethodEngine::(Set|Update)MenuItems.
// If the current input method is a keyboard layout, empty // If the current input method is a keyboard layout, empty
// properties are sufficient. // properties are sufficient.
const InputMethodPropertyList empty_property_list; const ash::ime::InputMethodMenuItemList empty_menu_item_list;
SetCurrentInputMethodProperties(empty_property_list); ash::ime::InputMethodMenuManager* input_method_menu_manager =
ash::ime::InputMethodMenuManager::GetInstance();
input_method_menu_manager->SetCurrentInputMethodMenuItemList(
empty_menu_item_list);
const InputMethodDescriptor* descriptor = NULL; const InputMethodDescriptor* descriptor = NULL;
if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) { if (extension_ime_util::IsExtensionIME(input_method_id_to_switch)) {
...@@ -419,21 +424,20 @@ void InputMethodManagerImpl::LoadNecessaryComponentExtensions() { ...@@ -419,21 +424,20 @@ void InputMethodManagerImpl::LoadNecessaryComponentExtensions() {
} }
} }
void InputMethodManagerImpl::ActivateInputMethodProperty( void InputMethodManagerImpl::ActivateInputMethodMenuItem(
const std::string& key) { const std::string& key) {
DCHECK(!key.empty()); DCHECK(!key.empty());
for (size_t i = 0; i < property_list_.size(); ++i) { if (ash::ime::InputMethodMenuManager::GetInstance()->
if (property_list_[i].key == key) { HasInputMethodMenuItemForKey(key)) {
IMEEngineHandlerInterface* engine = IMEEngineHandlerInterface* engine =
IMEBridge::Get()->GetCurrentEngineHandler(); IMEBridge::Get()->GetCurrentEngineHandler();
if (engine) if (engine)
engine->PropertyActivate(key); engine->PropertyActivate(key);
return; return;
}
} }
DVLOG(1) << "ActivateInputMethodProperty: unknown key: " << key; DVLOG(1) << "ActivateInputMethodMenuItem: unknown key: " << key;
} }
void InputMethodManagerImpl::AddInputMethodExtension( void InputMethodManagerImpl::AddInputMethodExtension(
...@@ -687,21 +691,6 @@ InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const { ...@@ -687,21 +691,6 @@ InputMethodDescriptor InputMethodManagerImpl::GetCurrentInputMethod() const {
return current_input_method_; return current_input_method_;
} }
InputMethodPropertyList
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(); // Empty list.
return property_list_;
}
void InputMethodManagerImpl::SetCurrentInputMethodProperties(
const InputMethodPropertyList& property_list) {
property_list_ = property_list;
PropertyChanged();
}
XKeyboard* InputMethodManagerImpl::GetXKeyboard() { XKeyboard* InputMethodManagerImpl::GetXKeyboard() {
return xkeyboard_.get(); return xkeyboard_.get();
} }
...@@ -757,12 +746,6 @@ void InputMethodManagerImpl::InitializeComponentExtensionForTesting( ...@@ -757,12 +746,6 @@ void InputMethodManagerImpl::InitializeComponentExtensionForTesting(
OnComponentExtensionInitialized(delegate.Pass()); OnComponentExtensionInitialized(delegate.Pass());
} }
void InputMethodManagerImpl::PropertyChanged() {
FOR_EACH_OBSERVER(InputMethodManager::Observer,
observers_,
InputMethodPropertyChanged(this));
}
void InputMethodManagerImpl::CandidateClicked(int index) { void InputMethodManagerImpl::CandidateClicked(int index) {
IMEEngineHandlerInterface* engine = IMEEngineHandlerInterface* engine =
IMEBridge::Get()->GetCurrentEngineHandler(); IMEBridge::Get()->GetCurrentEngineHandler();
......
...@@ -66,7 +66,7 @@ class InputMethodManagerImpl : public InputMethodManager, ...@@ -66,7 +66,7 @@ class InputMethodManagerImpl : public InputMethodManager,
virtual bool EnableInputMethod(const std::string& new_active_input_method_id) virtual bool EnableInputMethod(const std::string& new_active_input_method_id)
OVERRIDE; OVERRIDE;
virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE; virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE;
virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; virtual void ActivateInputMethodMenuItem(const std::string& key) OVERRIDE;
virtual void AddInputMethodExtension( virtual void AddInputMethodExtension(
const std::string& id, const std::string& id,
InputMethodEngineInterface* instance) OVERRIDE; InputMethodEngineInterface* instance) OVERRIDE;
...@@ -80,10 +80,6 @@ class InputMethodManagerImpl : public InputMethodManager, ...@@ -80,10 +80,6 @@ class InputMethodManagerImpl : public InputMethodManager,
const ui::Accelerator& accelerator) OVERRIDE; const ui::Accelerator& accelerator) OVERRIDE;
virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE;
virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
virtual InputMethodPropertyList
GetCurrentInputMethodProperties() const OVERRIDE;
virtual void SetCurrentInputMethodProperties(
const InputMethodPropertyList& property_list) OVERRIDE;
virtual XKeyboard* GetXKeyboard() OVERRIDE; virtual XKeyboard* GetXKeyboard() OVERRIDE;
virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
...@@ -101,9 +97,6 @@ class InputMethodManagerImpl : public InputMethodManager, ...@@ -101,9 +97,6 @@ class InputMethodManagerImpl : public InputMethodManager,
scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate); scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate);
private: private:
// Notifies observers that the property list is updated.
void PropertyChanged();
// CandidateWindowController::Observer overrides: // CandidateWindowController::Observer overrides:
virtual void CandidateClicked(int index) OVERRIDE; virtual void CandidateClicked(int index) OVERRIDE;
virtual void CandidateWindowOpened() OVERRIDE; virtual void CandidateWindowOpened() OVERRIDE;
...@@ -189,9 +182,6 @@ class InputMethodManagerImpl : public InputMethodManager, ...@@ -189,9 +182,6 @@ class InputMethodManagerImpl : public InputMethodManager,
// those created by extension. // those created by extension.
std::map<std::string, InputMethodDescriptor> extra_input_methods_; std::map<std::string, InputMethodDescriptor> extra_input_methods_;
// 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 // The candidate window. This will be deleted when the APP_TERMINATING
// message is sent. // message is sent.
scoped_ptr<CandidateWindowController> candidate_window_controller_; scoped_ptr<CandidateWindowController> candidate_window_controller_;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <algorithm> #include <algorithm>
#include "ash/ime/input_method_menu_item.h"
#include "ash/ime/input_method_menu_manager.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
...@@ -71,6 +73,8 @@ class InputMethodManagerImplTest : public testing::Test { ...@@ -71,6 +73,8 @@ class InputMethodManagerImplTest : public testing::Test {
IMEBridge::Initialize(); IMEBridge::Initialize();
IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get());
menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance();
ime_list_.clear(); ime_list_.clear();
ComponentExtensionIME ext1; ComponentExtensionIME ext1;
...@@ -121,6 +125,7 @@ class InputMethodManagerImplTest : public testing::Test { ...@@ -121,6 +125,7 @@ class InputMethodManagerImplTest : public testing::Test {
candidate_window_controller_ = NULL; candidate_window_controller_ = NULL;
xkeyboard_ = NULL; xkeyboard_ = NULL;
manager_.reset(); manager_.reset();
IMEBridge::Get()->SetCurrentEngineHandler(NULL); IMEBridge::Get()->SetCurrentEngineHandler(NULL);
IMEBridge::Shutdown(); IMEBridge::Shutdown();
} }
...@@ -153,16 +158,18 @@ class InputMethodManagerImplTest : public testing::Test { ...@@ -153,16 +158,18 @@ class InputMethodManagerImplTest : public testing::Test {
base::MessageLoop message_loop_; base::MessageLoop message_loop_;
MockComponentExtIMEManagerDelegate* mock_delegate_; MockComponentExtIMEManagerDelegate* mock_delegate_;
std::vector<ComponentExtensionIME> ime_list_; std::vector<ComponentExtensionIME> ime_list_;
ash::ime::InputMethodMenuManager* menu_manager_;
private: private:
DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest);
}; };
class TestObserver : public InputMethodManager::Observer { class TestObserver : public InputMethodManager::Observer,
public ash::ime::InputMethodMenuManager::Observer{
public: public:
TestObserver() TestObserver()
: input_method_changed_count_(0), : input_method_changed_count_(0),
input_method_property_changed_count_(0), input_method_menu_item_changed_count_(0),
last_show_message_(false) { last_show_message_(false) {
} }
virtual ~TestObserver() {} virtual ~TestObserver() {}
...@@ -172,13 +179,13 @@ class TestObserver : public InputMethodManager::Observer { ...@@ -172,13 +179,13 @@ class TestObserver : public InputMethodManager::Observer {
++input_method_changed_count_; ++input_method_changed_count_;
last_show_message_ = show_message; last_show_message_ = show_message;
} }
virtual void InputMethodPropertyChanged( virtual void InputMethodMenuItemChanged(
InputMethodManager* manager) OVERRIDE { ash::ime::InputMethodMenuManager* manager) OVERRIDE {
++input_method_property_changed_count_; ++input_method_menu_item_changed_count_;
} }
int input_method_changed_count_; int input_method_changed_count_;
int input_method_property_changed_count_; int input_method_menu_item_changed_count_;
bool last_show_message_; bool last_show_message_;
private: private:
...@@ -236,14 +243,15 @@ TEST_F(InputMethodManagerImplTest, TestObserver) { ...@@ -236,14 +243,15 @@ TEST_F(InputMethodManagerImplTest, TestObserver) {
TestObserver observer; TestObserver observer;
InitComponentExtension(); InitComponentExtension();
manager_->AddObserver(&observer); manager_->AddObserver(&observer);
menu_manager_->AddObserver(&observer);
EXPECT_EQ(0, observer.input_method_changed_count_); EXPECT_EQ(0, observer.input_method_changed_count_);
manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); manager_->EnableLoginLayouts("en-US", "xkb:us::eng");
EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(1, observer.input_method_changed_count_);
EXPECT_EQ(1, observer.input_method_property_changed_count_); EXPECT_EQ(1, observer.input_method_menu_item_changed_count_);
manager_->ChangeInputMethod("xkb:us:dvorak:eng"); manager_->ChangeInputMethod("xkb:us:dvorak:eng");
EXPECT_FALSE(observer.last_show_message_); EXPECT_FALSE(observer.last_show_message_);
EXPECT_EQ(2, observer.input_method_changed_count_); EXPECT_EQ(2, observer.input_method_changed_count_);
EXPECT_EQ(2, observer.input_method_property_changed_count_); EXPECT_EQ(2, observer.input_method_menu_item_changed_count_);
manager_->ChangeInputMethod("xkb:us:dvorak:eng"); manager_->ChangeInputMethod("xkb:us:dvorak:eng");
EXPECT_FALSE(observer.last_show_message_); EXPECT_FALSE(observer.last_show_message_);
...@@ -254,7 +262,7 @@ TEST_F(InputMethodManagerImplTest, TestObserver) { ...@@ -254,7 +262,7 @@ TEST_F(InputMethodManagerImplTest, TestObserver) {
// If the same input method ID is passed, PropertyChanged() is not // If the same input method ID is passed, PropertyChanged() is not
// notified. // notified.
EXPECT_EQ(2, observer.input_method_property_changed_count_); EXPECT_EQ(2, observer.input_method_menu_item_changed_count_);
manager_->RemoveObserver(&observer); manager_->RemoveObserver(&observer);
} }
...@@ -593,23 +601,24 @@ TEST_F(InputMethodManagerImplTest, TestXkbSetting) { ...@@ -593,23 +601,24 @@ TEST_F(InputMethodManagerImplTest, TestXkbSetting) {
EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_);
} }
TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { TEST_F(InputMethodManagerImplTest, TestActivateInputMethodMenuItem) {
const std::string kKey = "key"; const std::string kKey = "key";
InputMethodPropertyList property_list; ash::ime::InputMethodMenuItemList menu_list;
property_list.push_back(InputMethodProperty(kKey, "label", false, false)); menu_list.push_back(ash::ime::InputMethodMenuItem(
manager_->SetCurrentInputMethodProperties(property_list); kKey, "label", false, false));
menu_manager_->SetCurrentInputMethodMenuItemList(menu_list);
manager_->ActivateInputMethodProperty(kKey); manager_->ActivateInputMethodMenuItem(kKey);
EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
// Key2 is not registered, so activated property should not be changed. // Key2 is not registered, so activated property should not be changed.
manager_->ActivateInputMethodProperty("key2"); manager_->ActivateInputMethodMenuItem("key2");
EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property());
} }
TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
InitComponentExtension(); InitComponentExtension();
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
std::vector<std::string> ids; std::vector<std::string> ids;
...@@ -617,26 +626,25 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { ...@@ -617,26 +626,25 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) {
ids.push_back(kNaclMozcUsId); ids.push_back(kNaclMozcUsId);
EXPECT_TRUE(manager_->EnableInputMethods(ids)); EXPECT_TRUE(manager_->EnableInputMethods(ids));
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
manager_->ChangeInputMethod(kNaclMozcUsId); manager_->ChangeInputMethod(kNaclMozcUsId);
InputMethodPropertyList current_property_list; ash::ime::InputMethodMenuItemList current_property_list;
current_property_list.push_back(InputMethodProperty("key", current_property_list.push_back(ash::ime::InputMethodMenuItem(
"label", "key", "label", false, false));
false, menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list);
false));
manager_->SetCurrentInputMethodProperties(current_property_list);
ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size());
EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key); EXPECT_EQ("key",
menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key);
manager_->ChangeInputMethod("xkb:us::eng"); manager_->ChangeInputMethod("xkb:us::eng");
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
} }
TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
InitComponentExtension(); InitComponentExtension();
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
std::vector<std::string> ids; std::vector<std::string> ids;
...@@ -644,32 +652,31 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { ...@@ -644,32 +652,31 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) {
ids.push_back(kExt2Engine1Id); // T-Chinese ids.push_back(kExt2Engine1Id); // T-Chinese
EXPECT_TRUE(manager_->EnableInputMethods(ids)); EXPECT_TRUE(manager_->EnableInputMethods(ids));
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
InputMethodPropertyList current_property_list; ash::ime::InputMethodMenuItemList current_property_list;
current_property_list.push_back(InputMethodProperty("key-mozc", current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc",
"label", "label",
false, false,
false)); false));
manager_->SetCurrentInputMethodProperties(current_property_list); menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list);
ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size());
EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key); EXPECT_EQ("key-mozc",
menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key);
manager_->ChangeInputMethod(kExt2Engine1Id); manager_->ChangeInputMethod(kExt2Engine1Id);
// Since the IME is changed, the property for mozc Japanese should be hidden. // Since the IME is changed, the property for mozc Japanese should be hidden.
EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty());
// Asynchronous property update signal from mozc-chewing. // Asynchronous property update signal from mozc-chewing.
current_property_list.clear(); current_property_list.clear();
current_property_list.push_back(InputMethodProperty("key-chewing", current_property_list.push_back(ash::ime::InputMethodMenuItem(
"label", "key-chewing", "label", false, false));
false, menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list);
false)); ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size());
manager_->SetCurrentInputMethodProperties(current_property_list);
ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size());
EXPECT_EQ("key-chewing", EXPECT_EQ("key-chewing",
manager_->GetCurrentInputMethodProperties().at(0).key); menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key);
} }
TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { TEST_F(InputMethodManagerImplTest, TestNextInputMethod) {
......
...@@ -142,9 +142,6 @@ void InputMethodPersistence::InputMethodChanged( ...@@ -142,9 +142,6 @@ void InputMethodPersistence::InputMethodChanged(
NOTREACHED(); NOTREACHED();
} }
void InputMethodPersistence::InputMethodPropertyChanged(
InputMethodManager* manager) {}
void InputMethodPersistence::OnSessionStateChange( void InputMethodPersistence::OnSessionStateChange(
InputMethodManager::State new_state) { InputMethodManager::State new_state) {
state_ = new_state; state_ = new_state;
......
...@@ -31,7 +31,6 @@ class InputMethodPersistence : public InputMethodManager::Observer { ...@@ -31,7 +31,6 @@ class InputMethodPersistence : public InputMethodManager::Observer {
// InputMethodManager::Observer overrides. // InputMethodManager::Observer overrides.
virtual void InputMethodChanged(InputMethodManager* manager, virtual void InputMethodChanged(InputMethodManager* manager,
bool show_message) OVERRIDE; bool show_message) OVERRIDE;
virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE;
private: private:
InputMethodManager* input_method_manager_; InputMethodManager* input_method_manager_;
......
...@@ -15,13 +15,18 @@ namespace ui { ...@@ -15,13 +15,18 @@ namespace ui {
class KeyEvent; class KeyEvent;
} // namespace ui } // namespace ui
namespace ash {
namespace ime {
struct InputMethodMenuItem;
} // namespace ime
} // namespace ash
namespace chromeos { namespace chromeos {
class CompositionText; class CompositionText;
namespace input_method { namespace input_method {
class CandidateWindow; class CandidateWindow;
struct InputMethodProperty;
struct KeyEventHandle; struct KeyEventHandle;
} // namespace input_method } // namespace input_method
......
...@@ -91,7 +91,7 @@ void MockInputMethodManager::ChangeInputMethod( ...@@ -91,7 +91,7 @@ void MockInputMethodManager::ChangeInputMethod(
const std::string& input_method_id) { const std::string& input_method_id) {
} }
void MockInputMethodManager::ActivateInputMethodProperty( void MockInputMethodManager::ActivateInputMethodMenuItem(
const std::string& key) { const std::string& key) {
} }
...@@ -144,15 +144,6 @@ InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const { ...@@ -144,15 +144,6 @@ InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
return descriptor; return descriptor;
} }
InputMethodPropertyList
MockInputMethodManager::GetCurrentInputMethodProperties() const {
return InputMethodPropertyList();
}
void MockInputMethodManager::SetCurrentInputMethodProperties(
const InputMethodPropertyList& property_list) {
}
XKeyboard* MockInputMethodManager::GetXKeyboard() { XKeyboard* MockInputMethodManager::GetXKeyboard() {
return &xkeyboard_; return &xkeyboard_;
} }
......
...@@ -43,7 +43,7 @@ class MockInputMethodManager : public InputMethodManager { ...@@ -43,7 +43,7 @@ class MockInputMethodManager : public InputMethodManager {
virtual bool EnableInputMethod( virtual bool EnableInputMethod(
const std::string& new_active_input_method_id) OVERRIDE; const std::string& new_active_input_method_id) OVERRIDE;
virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE; virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE;
virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; virtual void ActivateInputMethodMenuItem(const std::string& key) OVERRIDE;
virtual void AddInputMethodExtension( virtual void AddInputMethodExtension(
const std::string& id, const std::string& id,
InputMethodEngineInterface* instance) OVERRIDE; InputMethodEngineInterface* instance) OVERRIDE;
...@@ -57,10 +57,6 @@ class MockInputMethodManager : public InputMethodManager { ...@@ -57,10 +57,6 @@ class MockInputMethodManager : public InputMethodManager {
const ui::Accelerator& accelerator) OVERRIDE; const ui::Accelerator& accelerator) OVERRIDE;
virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE; virtual bool SwitchInputMethod(const ui::Accelerator& accelerator) OVERRIDE;
virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE; virtual InputMethodDescriptor GetCurrentInputMethod() const OVERRIDE;
virtual InputMethodPropertyList
GetCurrentInputMethodProperties() const OVERRIDE;
virtual void SetCurrentInputMethodProperties(
const InputMethodPropertyList& property_list) OVERRIDE;
virtual XKeyboard* GetXKeyboard() OVERRIDE; virtual XKeyboard* GetXKeyboard() OVERRIDE;
virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE; virtual InputMethodUtil* GetInputMethodUtil() OVERRIDE;
virtual ComponentExtensionIMEManager* virtual ComponentExtensionIMEManager*
......
...@@ -92,11 +92,6 @@ void ModeIndicatorController::InputMethodChanged(InputMethodManager* manager, ...@@ -92,11 +92,6 @@ void ModeIndicatorController::InputMethodChanged(InputMethodManager* manager,
ShowModeIndicator(); ShowModeIndicator();
} }
void ModeIndicatorController::InputMethodPropertyChanged(
InputMethodManager* manager) {
// Do nothing.
}
void ModeIndicatorController::ShowModeIndicator() { void ModeIndicatorController::ShowModeIndicator() {
// TODO(komatsu): When this is permanently enabled by defalut, // TODO(komatsu): When this is permanently enabled by defalut,
// delete command_line.h and chromeos_switches.h from the header // delete command_line.h and chromeos_switches.h from the header
......
...@@ -48,7 +48,6 @@ class ModeIndicatorController ...@@ -48,7 +48,6 @@ class ModeIndicatorController
// InputMethodManager::Observer implementation. // InputMethodManager::Observer implementation.
virtual void InputMethodChanged(InputMethodManager* manager, virtual void InputMethodChanged(InputMethodManager* manager,
bool show_message) OVERRIDE; bool show_message) OVERRIDE;
virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE;
// Show the mode inidicator with the current ime's short name if all // Show the mode inidicator with the current ime's short name if all
// the conditions are cleared. // the conditions are cleared.
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "ash/ash_switches.h" #include "ash/ash_switches.h"
#include "ash/desktop_background/desktop_background_controller.h" #include "ash/desktop_background/desktop_background_controller.h"
#include "ash/ime/input_method_menu_item.h"
#include "ash/ime/input_method_menu_manager.h"
#include "ash/metrics/user_metrics_recorder.h" #include "ash/metrics/user_metrics_recorder.h"
#include "ash/session_state_delegate.h" #include "ash/session_state_delegate.h"
#include "ash/session_state_observer.h" #include "ash/session_state_observer.h"
...@@ -297,6 +299,7 @@ void SystemTrayDelegateChromeOS::Initialize() { ...@@ -297,6 +299,7 @@ void SystemTrayDelegateChromeOS::Initialize() {
DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
input_method::InputMethodManager::Get()->AddObserver(this); input_method::InputMethodManager::Get()->AddObserver(this);
ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
UpdateClockType(); UpdateClockType();
if (SystemKeyEventListener::GetInstance()) if (SystemKeyEventListener::GetInstance())
...@@ -357,6 +360,7 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { ...@@ -357,6 +360,7 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
input_method::InputMethodManager::Get()->RemoveObserver(this); input_method::InputMethodManager::Get()->RemoveObserver(this);
ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
if (SystemKeyEventListener::GetInstance()) if (SystemKeyEventListener::GetInstance())
SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this);
bluetooth_adapter_->RemoveObserver(this); bluetooth_adapter_->RemoveObserver(this);
...@@ -766,15 +770,14 @@ void SystemTrayDelegateChromeOS::GetAvailableIMEList(ash::IMEInfoList* list) { ...@@ -766,15 +770,14 @@ void SystemTrayDelegateChromeOS::GetAvailableIMEList(ash::IMEInfoList* list) {
void SystemTrayDelegateChromeOS::GetCurrentIMEProperties( void SystemTrayDelegateChromeOS::GetCurrentIMEProperties(
ash::IMEPropertyInfoList* list) { ash::IMEPropertyInfoList* list) {
input_method::InputMethodManager* manager = ash::ime::InputMethodMenuItemList menu_list =
input_method::InputMethodManager::Get(); ash::ime::InputMethodMenuManager::GetInstance()->
input_method::InputMethodPropertyList properties = GetCurrentInputMethodMenuItemList();
manager->GetCurrentInputMethodProperties(); for (size_t i = 0; i < menu_list.size(); ++i) {
for (size_t i = 0; i < properties.size(); ++i) {
ash::IMEPropertyInfo property; ash::IMEPropertyInfo property;
property.key = properties[i].key; property.key = menu_list[i].key;
property.name = base::UTF8ToUTF16(properties[i].label); property.name = base::UTF8ToUTF16(menu_list[i].label);
property.selected = properties[i].is_selection_item_checked; property.selected = menu_list[i].is_selection_item_checked;
list->push_back(property); list->push_back(property);
} }
} }
...@@ -784,7 +787,7 @@ void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) { ...@@ -784,7 +787,7 @@ void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) {
} }
void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) {
input_method::InputMethodManager::Get()->ActivateInputMethodProperty(key); input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key);
} }
void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) { void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) {
...@@ -1201,8 +1204,9 @@ void SystemTrayDelegateChromeOS::InputMethodChanged( ...@@ -1201,8 +1204,9 @@ void SystemTrayDelegateChromeOS::InputMethodChanged(
GetSystemTrayNotifier()->NotifyRefreshIME(show_message); GetSystemTrayNotifier()->NotifyRefreshIME(show_message);
} }
void SystemTrayDelegateChromeOS::InputMethodPropertyChanged( // Overridden from InputMethodMenuManager::Observer.
input_method::InputMethodManager* manager) { void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged(
ash::ime::InputMethodMenuManager* manager) {
GetSystemTrayNotifier()->NotifyRefreshIME(false); GetSystemTrayNotifier()->NotifyRefreshIME(false);
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_ #ifndef CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_
#define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_ #define CHROME_BROWSER_UI_ASH_SYSTEM_TRAY_DELEGATE_CHROMEOS_H_
#include "ash/ime/input_method_menu_manager.h"
#include "ash/session_state_observer.h" #include "ash/session_state_observer.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
...@@ -30,7 +31,8 @@ ...@@ -30,7 +31,8 @@
namespace chromeos { namespace chromeos {
class SystemTrayDelegateChromeOS class SystemTrayDelegateChromeOS
: public ash::SystemTrayDelegate, : public ash::ime::InputMethodMenuManager::Observer,
public ash::SystemTrayDelegate,
public SessionManagerClient::Observer, public SessionManagerClient::Observer,
public drive::JobListObserver, public drive::JobListObserver,
public content::NotificationObserver, public content::NotificationObserver,
...@@ -180,8 +182,9 @@ class SystemTrayDelegateChromeOS ...@@ -180,8 +182,9 @@ class SystemTrayDelegateChromeOS
virtual void InputMethodChanged(input_method::InputMethodManager* manager, virtual void InputMethodChanged(input_method::InputMethodManager* manager,
bool show_message) OVERRIDE; bool show_message) OVERRIDE;
virtual void InputMethodPropertyChanged( // Overridden from InputMethodMenuManager::Observer.
input_method::InputMethodManager* manager) OVERRIDE; virtual void InputMethodMenuItemChanged(
ash::ime::InputMethodMenuManager* manager) OVERRIDE;
// drive::JobListObserver overrides. // drive::JobListObserver overrides.
virtual void OnJobAdded(const drive::JobInfo& job_info) OVERRIDE; virtual void OnJobAdded(const drive::JobInfo& job_info) OVERRIDE;
......
...@@ -228,8 +228,6 @@ ...@@ -228,8 +228,6 @@
'ime/input_method_descriptor.h', 'ime/input_method_descriptor.h',
'ime/input_method_manager.cc', 'ime/input_method_manager.cc',
'ime/input_method_manager.h', 'ime/input_method_manager.h',
'ime/input_method_property.cc',
'ime/input_method_property.h',
'ime/input_method_whitelist.cc', 'ime/input_method_whitelist.cc',
'ime/input_method_whitelist.h', 'ime/input_method_whitelist.h',
'ime/xkeyboard.cc', 'ime/xkeyboard.cc',
...@@ -491,7 +489,6 @@ ...@@ -491,7 +489,6 @@
'ime/extension_ime_util_unittest.cc', 'ime/extension_ime_util_unittest.cc',
'ime/composition_text_unittest.cc', 'ime/composition_text_unittest.cc',
'ime/input_method_manager.h', 'ime/input_method_manager.h',
'ime/input_method_property_unittest.cc',
'ime/input_method_whitelist_unittest.cc', 'ime/input_method_whitelist_unittest.cc',
'ime/xkeyboard_unittest.cc', 'ime/xkeyboard_unittest.cc',
'login/login_state_unittest.cc', 'login/login_state_unittest.cc',
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chromeos/chromeos_export.h" #include "chromeos/chromeos_export.h"
#include "chromeos/ime/input_method_descriptor.h" #include "chromeos/ime/input_method_descriptor.h"
#include "chromeos/ime/input_method_property.h"
namespace ui { namespace ui {
class Accelerator; class Accelerator;
...@@ -44,8 +43,6 @@ class CHROMEOS_EXPORT InputMethodManager { ...@@ -44,8 +43,6 @@ class CHROMEOS_EXPORT InputMethodManager {
// indicates whether the user should be notified of this change. // indicates whether the user should be notified of this change.
virtual void InputMethodChanged(InputMethodManager* manager, virtual void InputMethodChanged(InputMethodManager* manager,
bool show_message) = 0; bool show_message) = 0;
// Called when the list of properties is changed.
virtual void InputMethodPropertyChanged(InputMethodManager* manager) = 0;
}; };
// CandidateWindowObserver is notified of events related to the candidate // CandidateWindowObserver is notified of events related to the candidate
...@@ -126,7 +123,7 @@ class CHROMEOS_EXPORT InputMethodManager { ...@@ -126,7 +123,7 @@ class CHROMEOS_EXPORT InputMethodManager {
const std::string& initial_layout) = 0; const std::string& initial_layout) = 0;
// Activates the input method property specified by the |key|. // Activates the input method property specified by the |key|.
virtual void ActivateInputMethodProperty(const std::string& key) = 0; virtual void ActivateInputMethodMenuItem(const std::string& key) = 0;
// Updates the list of active input method IDs, and then starts or stops the // Updates the list of active input method IDs, and then starts or stops the
// system input method framework as needed. // system input method framework as needed.
...@@ -159,13 +156,6 @@ class CHROMEOS_EXPORT InputMethodManager { ...@@ -159,13 +156,6 @@ class CHROMEOS_EXPORT InputMethodManager {
// Gets the descriptor of the input method which is currently selected. // Gets the descriptor of the input method which is currently selected.
virtual InputMethodDescriptor GetCurrentInputMethod() const = 0; virtual InputMethodDescriptor GetCurrentInputMethod() const = 0;
// Gets the list of input method properties. The list could be empty().
virtual InputMethodPropertyList GetCurrentInputMethodProperties() const = 0;
// Sets the list of input method properties. The list could be empty().
virtual void SetCurrentInputMethodProperties(
const InputMethodPropertyList& property_list) = 0;
// Returns an X keyboard object which could be used to change the current XKB // Returns an X keyboard object which could be used to change the current XKB
// layout, change the caps lock status, and set the auto repeat rate/interval. // layout, change the caps lock status, and set the auto repeat rate/interval.
virtual XKeyboard* GetXKeyboard() = 0; virtual XKeyboard* GetXKeyboard() = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment