Commit 1a936ba7 authored by komatsu@chromium.org's avatar komatsu@chromium.org

Refactoring around descriptor. The descriptor representing InputMethodEngine...

Refactoring around descriptor.  The descriptor representing InputMethodEngine was previously generated in InpuMethodManager.  This patch makes InputMethodEngine generates its own descriptor and manage it.

BUG=N/A

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243763 0039d316-1c4b-4281-b951-d872f2087c98
parent a27d34ab
...@@ -65,7 +65,7 @@ InputMethodEngine::InputMethodEngine() ...@@ -65,7 +65,7 @@ InputMethodEngine::InputMethodEngine()
window_visible_(false) {} window_visible_(false) {}
InputMethodEngine::~InputMethodEngine() { InputMethodEngine::~InputMethodEngine() {
input_method::InputMethodManager::Get()->RemoveInputMethodExtension(ibus_id_); input_method::InputMethodManager::Get()->RemoveInputMethodExtension(imm_id_);
} }
void InputMethodEngine::Initialize( void InputMethodEngine::Initialize(
...@@ -79,31 +79,45 @@ void InputMethodEngine::Initialize( ...@@ -79,31 +79,45 @@ void InputMethodEngine::Initialize(
const GURL& input_view) { const GURL& input_view) {
DCHECK(observer) << "Observer must not be null."; DCHECK(observer) << "Observer must not be null.";
// TODO(komatsu): It is probably better to set observer out of Initialize.
observer_ = observer; observer_ = observer;
engine_id_ = engine_id; engine_id_ = engine_id;
input_method::InputMethodManager* manager = input_method::InputMethodManager* manager =
input_method::InputMethodManager::Get(); input_method::InputMethodManager::Get();
ComponentExtensionIMEManager* comp_ext_ime_manager ComponentExtensionIMEManager* comp_ext_ime_manager =
= manager->GetComponentExtensionIMEManager(); manager->GetComponentExtensionIMEManager();
if (comp_ext_ime_manager->IsInitialized() && if (comp_ext_ime_manager->IsInitialized() &&
comp_ext_ime_manager->IsWhitelistedExtension(extension_id)) { comp_ext_ime_manager->IsWhitelistedExtension(extension_id)) {
ibus_id_ = comp_ext_ime_manager->GetId(extension_id, engine_id); imm_id_ = comp_ext_ime_manager->GetId(extension_id, engine_id);
} else { } else {
ibus_id_ = extension_ime_util::GetInputMethodID(extension_id, engine_id); imm_id_ = extension_ime_util::GetInputMethodID(extension_id, engine_id);
} }
input_view_url_ = input_view; input_view_url_ = input_view;
descriptor_ = input_method::InputMethodDescriptor(imm_id_,
engine_name,
layouts,
languages,
false, // is_login_keyboard
options_page,
input_view);
// TODO(komatsu): It is probably better to call AddInputMethodExtension
// out of Initialize.
manager->AddInputMethodExtension(imm_id_, this);
}
manager->AddInputMethodExtension(ibus_id_, engine_name, layouts, languages, const input_method::InputMethodDescriptor& InputMethodEngine::GetDescriptor()
options_page, input_view, this); const {
return descriptor_;
} }
void InputMethodEngine::StartIme() { void InputMethodEngine::StartIme() {
input_method::InputMethodManager* manager = input_method::InputMethodManager* manager =
input_method::InputMethodManager::Get(); input_method::InputMethodManager::Get();
if (manager && ibus_id_ == manager->GetCurrentInputMethod().id()) if (manager && imm_id_ == manager->GetCurrentInputMethod().id())
Enable(); Enable();
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
#include "chromeos/ime/input_method_descriptor.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace ui { namespace ui {
...@@ -42,6 +43,8 @@ class InputMethodEngine : public InputMethodEngineInterface { ...@@ -42,6 +43,8 @@ class InputMethodEngine : public InputMethodEngineInterface {
const GURL& input_view); const GURL& input_view);
// InputMethodEngineInterface overrides. // InputMethodEngineInterface overrides.
virtual const input_method::InputMethodDescriptor& GetDescriptor()
const OVERRIDE;
virtual void StartIme() OVERRIDE; virtual void StartIme() OVERRIDE;
virtual bool SetComposition(int context_id, virtual bool SetComposition(int context_id,
const char* text, const char* text,
...@@ -96,6 +99,9 @@ class InputMethodEngine : public InputMethodEngineInterface { ...@@ -96,6 +99,9 @@ class InputMethodEngine : public InputMethodEngineInterface {
void MenuItemToProperty(const MenuItem& item, void MenuItemToProperty(const MenuItem& item,
input_method::InputMethodProperty* property); input_method::InputMethodProperty* property);
// Descriptor of this input method.
input_method::InputMethodDescriptor descriptor_;
// True if the current context has focus. // True if the current context has focus.
bool focused_; bool focused_;
...@@ -111,8 +117,8 @@ class InputMethodEngine : public InputMethodEngineInterface { ...@@ -111,8 +117,8 @@ class InputMethodEngine : public InputMethodEngineInterface {
// This IME ID in Chrome Extension. // This IME ID in Chrome Extension.
std::string engine_id_; std::string engine_id_;
// This IME ID in ibus. // This IME ID in InputMethodManager.
std::string ibus_id_; std::string imm_id_;
// Pointer to the object recieving events for this IME. // Pointer to the object recieving events for this IME.
InputMethodEngineInterface::Observer* observer_; InputMethodEngineInterface::Observer* observer_;
......
...@@ -15,6 +15,7 @@ class GURL; ...@@ -15,6 +15,7 @@ class GURL;
namespace chromeos { namespace chromeos {
namespace input_method { namespace input_method {
class InputMethodDescriptor;
struct KeyEventHandle; struct KeyEventHandle;
} // namespace input_method } // namespace input_method
...@@ -169,6 +170,8 @@ class InputMethodEngineInterface : public IBusEngineHandlerInterface { ...@@ -169,6 +170,8 @@ class InputMethodEngineInterface : public IBusEngineHandlerInterface {
virtual ~InputMethodEngineInterface() {} virtual ~InputMethodEngineInterface() {}
virtual const input_method::InputMethodDescriptor& GetDescriptor() const = 0;
// Called when the input metho initialization is done. // Called when the input metho initialization is done.
// This function is called from private API. // This function is called from private API.
// TODO(nona): Remove this function. // TODO(nona): Remove this function.
......
...@@ -420,11 +420,6 @@ void InputMethodManagerImpl::ActivateInputMethodProperty( ...@@ -420,11 +420,6 @@ void InputMethodManagerImpl::ActivateInputMethodProperty(
void InputMethodManagerImpl::AddInputMethodExtension( void InputMethodManagerImpl::AddInputMethodExtension(
const std::string& id, const std::string& id,
const std::string& name,
const std::vector<std::string>& layouts,
const std::vector<std::string>& languages,
const GURL& options_url,
const GURL& inputview_url,
InputMethodEngineInterface* engine) { InputMethodEngineInterface* engine) {
if (state_ == STATE_TERMINATING) if (state_ == STATE_TERMINATING)
return; return;
...@@ -435,15 +430,17 @@ void InputMethodManagerImpl::AddInputMethodExtension( ...@@ -435,15 +430,17 @@ void InputMethodManagerImpl::AddInputMethodExtension(
return; return;
} }
extra_input_methods_[id] = InputMethodDescriptor( DCHECK(engine);
id, name, layouts, languages, false, options_url, inputview_url);
const InputMethodDescriptor& descriptor = engine->GetDescriptor();
extra_input_methods_[id] = descriptor;
if (Contains(enabled_extension_imes_, id) && if (Contains(enabled_extension_imes_, id) &&
!extension_ime_util::IsComponentExtensionIME(id)) { !extension_ime_util::IsComponentExtensionIME(id)) {
if (!Contains(active_input_method_ids_, id)) { if (!Contains(active_input_method_ids_, id)) {
active_input_method_ids_.push_back(id); active_input_method_ids_.push_back(id);
} else { } else {
DVLOG(1) << "AddInputMethodExtension: alread added: " DVLOG(1) << "AddInputMethodExtension: alread added: "
<< id << ", " << name; << id << ", " << descriptor.name();
// Call Start() anyway, just in case. // Call Start() anyway, just in case.
} }
...@@ -451,9 +448,7 @@ void InputMethodManagerImpl::AddInputMethodExtension( ...@@ -451,9 +448,7 @@ void InputMethodManagerImpl::AddInputMethodExtension(
MaybeInitializeCandidateWindowController(); MaybeInitializeCandidateWindowController();
} }
// TODO(komatsu): Engine should not be NULL even in unittests. IBusBridge::Get()->SetEngineHandler(id, engine);
if (engine)
IBusBridge::Get()->SetEngineHandler(id, engine);
} }
void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) { void InputMethodManagerImpl::RemoveInputMethodExtension(const std::string& id) {
......
...@@ -67,11 +67,6 @@ class InputMethodManagerImpl : public InputMethodManager, ...@@ -67,11 +67,6 @@ class InputMethodManagerImpl : public InputMethodManager,
virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE;
virtual void AddInputMethodExtension( virtual void AddInputMethodExtension(
const std::string& id, const std::string& id,
const std::string& name,
const std::vector<std::string>& layouts,
const std::vector<std::string>& languages,
const GURL& options_page,
const GURL& input_view,
InputMethodEngineInterface* instance) OVERRIDE; InputMethodEngineInterface* instance) OVERRIDE;
virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE; virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE;
virtual void GetInputMethodExtensions( virtual void GetInputMethodExtensions(
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
#include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.h" #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.h"
#include "chrome/browser/chromeos/input_method/mock_input_method_engine.h"
#include "chromeos/ime/extension_ime_util.h" #include "chromeos/ime/extension_ime_util.h"
#include "chromeos/ime/fake_input_method_delegate.h" #include "chromeos/ime/fake_input_method_delegate.h"
#include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h"
...@@ -205,7 +207,6 @@ class TestCandidateWindowObserver ...@@ -205,7 +207,6 @@ class TestCandidateWindowObserver
private: private:
DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver);
}; };
} // namespace } // namespace
TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) { TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) {
...@@ -911,24 +912,24 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { ...@@ -911,24 +912,24 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
layouts.push_back("us"); layouts.push_back("us");
std::vector<std::string> languages; std::vector<std::string> languages;
languages.push_back("en-US"); languages.push_back("en-US");
const std::string ext1_id = const std::string ext1_id =
extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); extension_ime_util::GetInputMethodID("deadbeef", "engine_id");
manager_->AddInputMethodExtension( const InputMethodDescriptor descriptor1(ext1_id,
ext1_id, "deadbeef input method",
"deadbeef input method", layouts,
layouts, languages,
languages, false, // is_login_keyboard
GURL(), GURL(),
GURL(), GURL());
NULL); MockInputMethodEngine engine(descriptor1);
IBusBridge::Get()->SetEngineHandler(ext1_id, mock_engine_handler_.get()); manager_->AddInputMethodExtension(ext1_id, &engine);
// Extension IMEs are not enabled by default. // Extension IMEs are not enabled by default.
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
std::vector<std::string> extension_ime_ids; std::vector<std::string> extension_ime_ids;
extension_ime_ids.push_back( extension_ime_ids.push_back(ext1_id);
extension_ime_util::GetInputMethodID("deadbeef", "engine_id"));
manager_->SetEnabledExtensionImes(&extension_ime_ids); manager_->SetEnabledExtensionImes(&extension_ime_ids);
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
...@@ -936,42 +937,39 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) { ...@@ -936,42 +937,39 @@ TEST_F(InputMethodManagerImplTest, TestAddRemoveExtensionInputMethods) {
scoped_ptr<InputMethodDescriptors> methods( scoped_ptr<InputMethodDescriptors> methods(
manager_->GetActiveInputMethods()); manager_->GetActiveInputMethods());
ASSERT_EQ(2U, methods->size()); ASSERT_EQ(2U, methods->size());
EXPECT_EQ(extension_ime_util::GetInputMethodID("deadbeef", "engine_id"), // Ext IMEs should be at the end of the list.
// Ext IMEs should be at the end of the list. EXPECT_EQ(ext1_id, methods->at(1).id());
methods->at(1).id());
} }
const std::string ext2_id = const std::string ext2_id =
extension_ime_util::GetInputMethodID("cafebabe", "engine_id"); extension_ime_util::GetInputMethodID("cafebabe", "engine_id");
manager_->AddInputMethodExtension( const InputMethodDescriptor descriptor2(ext2_id,
ext2_id, "cafebabe input method",
"cafebabe input method", layouts,
layouts, languages,
languages, false, // is_login_keyboard
GURL(), GURL(),
GURL(), GURL());
NULL); MockInputMethodEngine engine2(descriptor2);
IBusBridge::Get()->SetEngineHandler(ext2_id, mock_engine_handler_.get()); manager_->AddInputMethodExtension(ext2_id, &engine2);
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
extension_ime_ids.push_back( extension_ime_ids.push_back(ext2_id);
extension_ime_util::GetInputMethodID("cafebabe", "engine_id"));
manager_->SetEnabledExtensionImes(&extension_ime_ids); manager_->SetEnabledExtensionImes(&extension_ime_ids);
EXPECT_EQ(3U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(3U, manager_->GetNumActiveInputMethods());
{ {
scoped_ptr<InputMethodDescriptors> methods( scoped_ptr<InputMethodDescriptors> methods(
manager_->GetActiveInputMethods()); manager_->GetActiveInputMethods());
ASSERT_EQ(3U, methods->size()); ASSERT_EQ(3U, methods->size());
EXPECT_EQ(extension_ime_util::GetInputMethodID("deadbeef", "engine_id"), // Ext IMEs should be at the end of the list.
// Ext IMEs should be at the end of the list. EXPECT_EQ(ext1_id, methods->at(1).id());
methods->at(1).id()); EXPECT_EQ(ext2_id, methods->at(2).id());
} }
// Remove them. // Remove them.
manager_->RemoveInputMethodExtension( manager_->RemoveInputMethodExtension(ext1_id);
extension_ime_util::GetInputMethodID("deadbeef", "engine_id"));
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
manager_->RemoveInputMethodExtension( manager_->RemoveInputMethodExtension(ext2_id);
extension_ime_util::GetInputMethodID("cafebabe", "engine_id"));
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
} }
...@@ -993,33 +991,32 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { ...@@ -993,33 +991,32 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
layouts.push_back("us(dvorak)"); layouts.push_back("us(dvorak)");
std::vector<std::string> languages; std::vector<std::string> languages;
languages.push_back("en-US"); languages.push_back("en-US");
const std::string ext_id = const std::string ext_id =
extension_ime_util::GetInputMethodID("deadbeef", "engine_id"); extension_ime_util::GetInputMethodID("deadbeef", "engine_id");
manager_->AddInputMethodExtension( const InputMethodDescriptor descriptor(ext_id,
ext_id, "deadbeef input method",
"deadbeef input method", layouts,
layouts, languages,
languages, false, // is_login_keyboard
GURL(), GURL(),
GURL(), GURL());
NULL); MockInputMethodEngine engine(descriptor);
IBusBridge::Get()->SetEngineHandler(ext_id, mock_engine_handler_.get()); manager_->AddInputMethodExtension(ext_id, &engine);
// Extension IME is not enabled by default. // Extension IME is not enabled by default.
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
EXPECT_EQ(1, observer.input_method_changed_count_); EXPECT_EQ(1, observer.input_method_changed_count_);
std::vector<std::string> extension_ime_ids; std::vector<std::string> extension_ime_ids;
extension_ime_ids.push_back( extension_ime_ids.push_back(ext_id);
extension_ime_util::GetInputMethodID("deadbeef", "engine_id"));
manager_->SetEnabledExtensionImes(&extension_ime_ids); manager_->SetEnabledExtensionImes(&extension_ime_ids);
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
// Switch to the IME. // Switch to the IME.
manager_->SwitchToNextInputMethod(); manager_->SwitchToNextInputMethod();
EXPECT_EQ(3, observer.input_method_changed_count_); EXPECT_EQ(3, observer.input_method_changed_count_);
EXPECT_EQ(extension_ime_util::GetInputMethodID("deadbeef", "engine_id"), EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
manager_->GetCurrentInputMethod().id());
EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
// Lock the screen. This is for crosbug.com/27049. // Lock the screen. This is for crosbug.com/27049.
...@@ -1032,17 +1029,15 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) { ...@@ -1032,17 +1029,15 @@ TEST_F(InputMethodManagerImplTest, TestAddExtensionInputThenLockScreen) {
// Unlock the screen. // Unlock the screen.
manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN);
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); EXPECT_EQ(2U, manager_->GetNumActiveInputMethods());
EXPECT_EQ(extension_ime_util::GetInputMethodID("deadbeef", "engine_id"), EXPECT_EQ(ext_id, manager_->GetCurrentInputMethod().id());
manager_->GetCurrentInputMethod().id());
EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_); EXPECT_EQ("us(dvorak)", xkeyboard_->last_layout_);
{ {
// This is for crosbug.com/27052. // This is for crosbug.com/27052.
scoped_ptr<InputMethodDescriptors> methods( scoped_ptr<InputMethodDescriptors> methods(
manager_->GetActiveInputMethods()); manager_->GetActiveInputMethods());
ASSERT_EQ(2U, methods->size()); ASSERT_EQ(2U, methods->size());
EXPECT_EQ(extension_ime_util::GetInputMethodID("deadbeef", "engine_id"), // Ext. IMEs should be at the end of the list.
// Ext. IMEs should be at the end of the list. EXPECT_EQ(ext_id, methods->at(1).id());
methods->at(1).id());
} }
manager_->RemoveObserver(&observer); manager_->RemoveObserver(&observer);
} }
......
// 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 "chrome/browser/chromeos/input_method/mock_input_method_engine.h"
#include <map>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chromeos/ime/candidate_window.h"
#include "chromeos/ime/component_extension_ime_manager.h"
#include "chromeos/ime/extension_ime_util.h"
#include "chromeos/ime/ibus_keymap.h"
#include "chromeos/ime/ibus_text.h"
#include "chromeos/ime/input_method_manager.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom4/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/keyboard/keyboard_controller.h"
namespace chromeos {
MockInputMethodEngine::MockInputMethodEngine(
const input_method::InputMethodDescriptor& descriptor)
: descriptor_(descriptor) {}
MockInputMethodEngine::~MockInputMethodEngine() {}
const input_method::InputMethodDescriptor&
MockInputMethodEngine::GetDescriptor() const {
return descriptor_;
}
void MockInputMethodEngine::StartIme() {
}
bool MockInputMethodEngine::SetComposition(
int context_id,
const char* text,
int selection_start,
int selection_end,
int cursor,
const std::vector<SegmentInfo>& segments,
std::string* error) {
return true;
}
bool MockInputMethodEngine::ClearComposition(int context_id,
std::string* error) {
return true;
}
bool MockInputMethodEngine::CommitText(int context_id,
const char* text,
std::string* error) {
return true;
}
bool MockInputMethodEngine::SendKeyEvents(
int context_id,
const std::vector<KeyboardEvent>& events) {
return true;
}
const MockInputMethodEngine::CandidateWindowProperty&
MockInputMethodEngine::GetCandidateWindowProperty() const {
return candidate_window_property_;
}
void MockInputMethodEngine::SetCandidateWindowProperty(
const CandidateWindowProperty& property) {
}
bool MockInputMethodEngine::SetCandidateWindowVisible(bool visible,
std::string* error) {
return true;
}
bool MockInputMethodEngine::SetCandidates(
int context_id,
const std::vector<Candidate>& candidates,
std::string* error) {
return true;
}
bool MockInputMethodEngine::SetCursorPosition(int context_id,
int candidate_id,
std::string* error) {
return true;
}
bool MockInputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) {
return true;
}
bool MockInputMethodEngine::UpdateMenuItems(
const std::vector<MenuItem>& items) {
return true;
}
bool MockInputMethodEngine::IsActive() const {
return true;
}
void MockInputMethodEngine::KeyEventDone(input_method::KeyEventHandle* key_data,
bool handled) {
}
bool MockInputMethodEngine::DeleteSurroundingText(int context_id,
int offset,
size_t number_of_chars,
std::string* error) {
return true;
}
void MockInputMethodEngine::HideInputView() {
}
void MockInputMethodEngine::FocusIn(
const IBusEngineHandlerInterface::InputContext& input_context) {
}
void MockInputMethodEngine::FocusOut() {
}
void MockInputMethodEngine::Enable() {
}
void MockInputMethodEngine::Disable() {
}
void MockInputMethodEngine::PropertyActivate(const std::string& property_name) {
}
void MockInputMethodEngine::Reset() {
}
void MockInputMethodEngine::ProcessKeyEvent(
const ui::KeyEvent& key_event,
const KeyEventDoneCallback& callback) {
}
void MockInputMethodEngine::CandidateClicked(uint32 index) {
}
void MockInputMethodEngine::SetSurroundingText(const std::string& text,
uint32 cursor_pos,
uint32 anchor_pos) {
}
} // namespace chromeos
// 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.
#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_
#include <string>
#include <vector>
#include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
#include "chromeos/ime/input_method_descriptor.h"
#include "url/gurl.h"
namespace ui {
class KeyEvent;
} // namespace ui
namespace chromeos {
class IBusText;
namespace input_method {
class CandidateWindow;
struct InputMethodProperty;
struct KeyEventHandle;
} // namespace input_method
class MockInputMethodEngine : public InputMethodEngineInterface {
public:
explicit MockInputMethodEngine(
const input_method::InputMethodDescriptor& descriptor);
virtual ~MockInputMethodEngine();
// InputMethodEngineInterface overrides.
virtual const input_method::InputMethodDescriptor& GetDescriptor()
const OVERRIDE;
virtual void StartIme() OVERRIDE;
virtual bool SetComposition(int context_id,
const char* text,
int selection_start,
int selection_end,
int cursor,
const std::vector<SegmentInfo>& segments,
std::string* error) OVERRIDE;
virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE;
virtual bool CommitText(int context_id, const char* text,
std::string* error) OVERRIDE;
virtual bool SendKeyEvents(int context_id,
const std::vector<KeyboardEvent>& events) OVERRIDE;
virtual const CandidateWindowProperty&
GetCandidateWindowProperty() const OVERRIDE;
virtual void SetCandidateWindowProperty(
const CandidateWindowProperty& property) OVERRIDE;
virtual bool SetCandidateWindowVisible(bool visible,
std::string* error) OVERRIDE;
virtual bool SetCandidates(int context_id,
const std::vector<Candidate>& candidates,
std::string* error) OVERRIDE;
virtual bool SetCursorPosition(int context_id, int candidate_id,
std::string* error) OVERRIDE;
virtual bool SetMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) OVERRIDE;
virtual bool IsActive() const OVERRIDE;
virtual void KeyEventDone(input_method::KeyEventHandle* key_data,
bool handled) OVERRIDE;
virtual bool DeleteSurroundingText(int context_id,
int offset,
size_t number_of_chars,
std::string* error) OVERRIDE;
// IBusEngineHandlerInterface overrides.
virtual void FocusIn(
const IBusEngineHandlerInterface::InputContext& input_context) OVERRIDE;
virtual void FocusOut() OVERRIDE;
virtual void Enable() OVERRIDE;
virtual void Disable() OVERRIDE;
virtual void PropertyActivate(const std::string& property_name) OVERRIDE;
virtual void Reset() OVERRIDE;
virtual void ProcessKeyEvent(const ui::KeyEvent& key_event,
const KeyEventDoneCallback& callback) OVERRIDE;
virtual void CandidateClicked(uint32 index) OVERRIDE;
virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos,
uint32 anchor_pos) OVERRIDE;
virtual void HideInputView() OVERRIDE;
private:
// Descriptor of this input method.
input_method::InputMethodDescriptor descriptor_;
// The current candidate window property.
CandidateWindowProperty candidate_window_property_;
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_
...@@ -84,11 +84,6 @@ void MockInputMethodManager::ActivateInputMethodProperty( ...@@ -84,11 +84,6 @@ void MockInputMethodManager::ActivateInputMethodProperty(
void MockInputMethodManager::AddInputMethodExtension( void MockInputMethodManager::AddInputMethodExtension(
const std::string& id, const std::string& id,
const std::string& name,
const std::vector<std::string>& layouts,
const std::vector<std::string>& languages,
const GURL& options_url,
const GURL& inputview_url,
InputMethodEngineInterface* instance) { InputMethodEngineInterface* instance) {
} }
......
...@@ -44,11 +44,6 @@ class MockInputMethodManager : public InputMethodManager { ...@@ -44,11 +44,6 @@ class MockInputMethodManager : public InputMethodManager {
virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE; virtual void ActivateInputMethodProperty(const std::string& key) OVERRIDE;
virtual void AddInputMethodExtension( virtual void AddInputMethodExtension(
const std::string& id, const std::string& id,
const std::string& name,
const std::vector<std::string>& layouts,
const std::vector<std::string>& languages,
const GURL& options_url,
const GURL& inputview_url,
InputMethodEngineInterface* instance) OVERRIDE; InputMethodEngineInterface* instance) OVERRIDE;
virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE; virtual void RemoveInputMethodExtension(const std::string& id) OVERRIDE;
virtual void GetInputMethodExtensions( virtual void GetInputMethodExtensions(
......
...@@ -24,7 +24,7 @@ class Profile; ...@@ -24,7 +24,7 @@ class Profile;
namespace chromeos { namespace chromeos {
class InputMethodEngineInterface; class InputMethodEngineInterface;
class ImeObserver; class ImeObserver;
} } // namespace chromeos
namespace extensions { namespace extensions {
struct InputComponentInfo; struct InputComponentInfo;
......
...@@ -68,6 +68,8 @@ ...@@ -68,6 +68,8 @@
'browser/chromeos/contacts/contact_test_util.h', 'browser/chromeos/contacts/contact_test_util.h',
'browser/chromeos/input_method/mock_candidate_window_controller.cc', 'browser/chromeos/input_method/mock_candidate_window_controller.cc',
'browser/chromeos/input_method/mock_candidate_window_controller.h', 'browser/chromeos/input_method/mock_candidate_window_controller.h',
'browser/chromeos/input_method/mock_input_method_engine.cc',
'browser/chromeos/input_method/mock_input_method_engine.h',
'browser/chromeos/input_method/mock_input_method_manager.cc', 'browser/chromeos/input_method/mock_input_method_manager.cc',
'browser/chromeos/input_method/mock_input_method_manager.h', 'browser/chromeos/input_method/mock_input_method_manager.h',
'browser/chromeos/login/fake_login_utils.cc', 'browser/chromeos/login/fake_login_utils.cc',
......
...@@ -22,7 +22,6 @@ namespace chromeos { ...@@ -22,7 +22,6 @@ namespace chromeos {
class ComponentExtensionIMEManager; class ComponentExtensionIMEManager;
class InputMethodEngineInterface; class InputMethodEngineInterface;
namespace input_method { namespace input_method {
class InputMethodUtil; class InputMethodUtil;
class XKeyboard; class XKeyboard;
...@@ -137,12 +136,7 @@ class CHROMEOS_EXPORT InputMethodManager { ...@@ -137,12 +136,7 @@ class CHROMEOS_EXPORT InputMethodManager {
// Adds an input method extension. This function does not takes ownership of // Adds an input method extension. This function does not takes ownership of
// |instance|. // |instance|.
virtual void AddInputMethodExtension( virtual void AddInputMethodExtension(
const std::string& id, const std::string& imm_id,
const std::string& name,
const std::vector<std::string>& layouts,
const std::vector<std::string>& languages,
const GURL& options_url,
const GURL& inputview_url,
InputMethodEngineInterface* instance) = 0; InputMethodEngineInterface* instance) = 0;
// Removes an input method extension. // Removes an input method extension.
......
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