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/input_method_engine.cc100
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine.h19
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc54
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_interface.cc51
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_interface.h262
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_unittest.cc32
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.cc5
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl.h14
-rw-r--r--chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc1
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_engine.cc30
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_engine.h10
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.cc3
-rw-r--r--chrome/browser/chromeos/input_method/mock_input_method_manager.h7
13 files changed, 114 insertions, 474 deletions
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.cc b/chrome/browser/chromeos/input_method/input_method_engine.cc
index 66b7508..e417e36 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine.cc
@@ -53,8 +53,8 @@ void UpdateComposition(const ui::CompositionText& composition_text,
ui::IMEInputContextHandlerInterface* input_context =
ui::IMEBridge::Get()->GetInputContextHandler();
if (input_context)
- input_context->UpdateCompositionText(
- composition_text, cursor_pos, is_visible);
+ input_context->UpdateCompositionText(composition_text, cursor_pos,
+ is_visible);
}
// Returns the length of characters of a UTF-8 string with unknown string
@@ -82,9 +82,8 @@ std::string GetKeyFromEvent(const ui::KeyEvent& event) {
return code.substr(5);
if (code == "Escape")
return "Esc";
- if (code == "Backspace" || code == "Tab" ||
- code == "Enter" || code == "CapsLock" ||
- code == "Power")
+ if (code == "Backspace" || code == "Tab" || code == "Enter" ||
+ code == "CapsLock" || code == "Power")
return code;
// Cases for media keys.
switch (event.key_code()) {
@@ -124,8 +123,7 @@ std::string GetKeyFromEvent(const ui::KeyEvent& event) {
uint16 ch = 0;
// Ctrl+? cases, gets key value for Ctrl is not down.
if (event.flags() & ui::EF_CONTROL_DOWN) {
- ui::KeyEvent event_no_ctrl(event.type(),
- event.key_code(),
+ ui::KeyEvent event_no_ctrl(event.type(), event.key_code(),
event.flags() ^ ui::EF_CONTROL_DOWN);
ch = event_no_ctrl.GetCharacter();
} else {
@@ -167,13 +165,11 @@ InputMethodEngine::InputMethodEngine()
sent_key_event_(NULL),
profile_(NULL) {}
-InputMethodEngine::~InputMethodEngine() {
-}
+InputMethodEngine::~InputMethodEngine() {}
-void InputMethodEngine::Initialize(
- scoped_ptr<InputMethodEngineInterface::Observer> observer,
- const char* extension_id,
- Profile* profile) {
+void InputMethodEngine::Initialize(scoped_ptr<ui::IMEEngineObserver> observer,
+ const char* extension_id,
+ Profile* profile) {
DCHECK(observer) << "Observer must not be null.";
// TODO(komatsu): It is probably better to set observer out of Initialize.
@@ -240,8 +236,7 @@ bool InputMethodEngine::SetComposition(
return true;
}
-bool InputMethodEngine::ClearComposition(int context_id,
- std::string* error) {
+bool InputMethodEngine::ClearComposition(int context_id, std::string* error) {
if (!IsActive()) {
*error = kErrorNotActive;
return false;
@@ -257,7 +252,8 @@ bool InputMethodEngine::ClearComposition(int context_id,
return true;
}
-bool InputMethodEngine::CommitText(int context_id, const char* text,
+bool InputMethodEngine::CommitText(int context_id,
+ const char* text,
std::string* error) {
if (!IsActive()) {
// TODO: Commit the text anyways.
@@ -305,9 +301,9 @@ bool InputMethodEngine::SendKeyEvents(
key_code = ui::DomKeycodeToKeyboardCode(event.code);
int flags = ui::EF_NONE;
- flags |= event.alt_key ? ui::EF_ALT_DOWN : ui::EF_NONE;
- flags |= event.ctrl_key ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
- flags |= event.shift_key ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
+ flags |= event.alt_key ? ui::EF_ALT_DOWN : ui::EF_NONE;
+ flags |= event.ctrl_key ? ui::EF_CONTROL_DOWN : ui::EF_NONE;
+ flags |= event.shift_key ? ui::EF_SHIFT_DOWN : ui::EF_NONE;
flags |= event.caps_lock ? ui::EF_CAPS_LOCK_DOWN : ui::EF_NONE;
ui::KeyEvent ui_event(
@@ -332,7 +328,7 @@ InputMethodEngine::GetCandidateWindowProperty() const {
void InputMethodEngine::SetCandidateWindowProperty(
const CandidateWindowProperty& property) {
- // Type conversion from InputMethodEngineInterface::CandidateWindowProperty to
+ // Type conversion from IMEEngineHandlerInterface::CandidateWindowProperty to
// CandidateWindow::CandidateWindowProperty defined in chromeos/ime/.
ui::CandidateWindow::CandidateWindowProperty dest_property;
dest_property.page_size = property.page_size;
@@ -412,7 +408,8 @@ bool InputMethodEngine::SetCandidates(
return true;
}
-bool InputMethodEngine::SetCursorPosition(int context_id, int candidate_id,
+bool InputMethodEngine::SetCursorPosition(int context_id,
+ int candidate_id,
std::string* error) {
if (!IsActive()) {
*error = kErrorNotActive;
@@ -455,9 +452,8 @@ bool InputMethodEngine::UpdateMenuItems(
menu_item_list.push_back(property);
}
- ui::ime::InputMethodMenuManager::GetInstance()->
- SetCurrentInputMethodMenuItemList(
- menu_item_list);
+ ui::ime::InputMethodMenuManager::GetInstance()
+ ->SetCurrentInputMethodMenuItemList(menu_item_list);
return true;
}
@@ -490,7 +486,7 @@ bool InputMethodEngine::DeleteSurroundingText(int context_id,
void InputMethodEngine::HideInputView() {
keyboard::KeyboardController* keyboard_controller =
- keyboard::KeyboardController::GetInstance();
+ keyboard::KeyboardController::GetInstance();
if (keyboard_controller) {
keyboard_controller->HideKeyboard(
keyboard::KeyboardController::HIDE_REASON_MANUAL);
@@ -527,40 +523,9 @@ void InputMethodEngine::FocusIn(
context_id_ = next_context_id_;
++next_context_id_;
- InputMethodEngineInterface::InputContext context;
- context.id = context_id_;
- switch (current_input_type_) {
- case ui::TEXT_INPUT_TYPE_SEARCH:
- context.type = "search";
- break;
- case ui::TEXT_INPUT_TYPE_TELEPHONE:
- context.type = "tel";
- break;
- case ui::TEXT_INPUT_TYPE_URL:
- context.type = "url";
- break;
- case ui::TEXT_INPUT_TYPE_EMAIL:
- context.type = "email";
- break;
- case ui::TEXT_INPUT_TYPE_NUMBER:
- context.type = "number";
- break;
- case ui::TEXT_INPUT_TYPE_PASSWORD:
- context.type = "password";
- break;
- default:
- context.type = "text";
- break;
- }
-
- context.auto_correct =
- !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
- context.auto_complete =
- !(input_context.flags & ui::TEXT_INPUT_FLAG_AUTOCOMPLETE_OFF);
- context.spell_check =
- !(input_context.flags & ui::TEXT_INPUT_FLAG_SPELLCHECK_OFF);
-
- observer_->OnFocus(context);
+ observer_->OnFocus(ui::IMEEngineHandlerInterface::InputContext(
+ context_id_, input_context.type, input_context.mode,
+ input_context.flags));
}
void InputMethodEngine::FocusOut() {
@@ -616,15 +581,11 @@ bool InputMethodEngine::IsInterestedInKeyEvent() const {
return observer_->IsInterestedInKeyEvent();
}
-void InputMethodEngine::ProcessKeyEvent(
- const ui::KeyEvent& key_event,
- const KeyEventDoneCallback& callback) {
+void InputMethodEngine::ProcessKeyEvent(const ui::KeyEvent& key_event,
+ KeyEventDoneCallback& callback) {
if (!CheckProfile())
return;
- KeyEventDoneCallback* handler = new KeyEventDoneCallback();
- *handler = callback;
-
KeyboardEvent ext_event;
GetExtensionKeyboardEventFromKeyEvent(key_event, &ext_event);
@@ -635,10 +596,7 @@ void InputMethodEngine::ProcessKeyEvent(
if (&key_event == sent_key_event_)
ext_event.extension_id = extension_id_;
- observer_->OnKeyEvent(
- active_component_id_,
- ext_event,
- reinterpret_cast<input_method::KeyEventHandle*>(handler));
+ observer_->OnKeyEvent(active_component_id_, ext_event, callback);
}
void InputMethodEngine::CandidateClicked(uint32 index) {
@@ -649,8 +607,8 @@ void InputMethodEngine::CandidateClicked(uint32 index) {
}
// Only left button click is supported at this moment.
- observer_->OnCandidateClicked(
- active_component_id_, candidate_ids_.at(index), MOUSE_BUTTON_LEFT);
+ observer_->OnCandidateClicked(active_component_id_, candidate_ids_.at(index),
+ ui::IMEEngineObserver::MOUSE_BUTTON_LEFT);
}
void InputMethodEngine::SetSurroundingText(const std::string& text,
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.h b/chrome/browser/chromeos/input_method/input_method_engine.h
index 9977042..72e9461 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine.h
+++ b/chrome/browser/chromeos/input_method/input_method_engine.h
@@ -9,8 +9,9 @@
#include <string>
#include <vector>
#include "base/time/time.h"
-#include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
#include "ui/base/ime/chromeos/input_method_descriptor.h"
+#include "ui/base/ime/ime_engine_handler_interface.h"
+#include "ui/base/ime/ime_engine_observer.h"
#include "url/gurl.h"
class Profile;
@@ -18,6 +19,8 @@ class Profile;
namespace ui {
class CandidateWindow;
struct CompositionText;
+class IMEEngineHandlerInterface;
+class IMEEngineObserver;
class KeyEvent;
namespace ime {
@@ -27,21 +30,17 @@ struct InputMethodMenuItem;
namespace chromeos {
-namespace input_method {
-struct KeyEventHandle;
-} // namespace input_method
-
-class InputMethodEngine : public InputMethodEngineInterface {
+class InputMethodEngine : public ui::IMEEngineHandlerInterface {
public:
InputMethodEngine();
~InputMethodEngine() override;
- void Initialize(scoped_ptr<InputMethodEngineInterface::Observer> observer,
+ void Initialize(scoped_ptr<ui::IMEEngineObserver> observer,
const char* extension_id,
Profile* profile);
- // InputMethodEngineInterface overrides.
+ // IMEEngineHandlerInterface overrides.
const std::string& GetActiveComponentId() const override;
bool SetComposition(int context_id,
const char* text,
@@ -83,7 +82,7 @@ class InputMethodEngine : public InputMethodEngineInterface {
void PropertyActivate(const std::string& property_name) override;
void Reset() override;
void ProcessKeyEvent(const ui::KeyEvent& key_event,
- const KeyEventDoneCallback& callback) override;
+ KeyEventDoneCallback& callback) override;
void CandidateClicked(uint32 index) override;
void SetSurroundingText(const std::string& text,
uint32 cursor_pos,
@@ -120,7 +119,7 @@ class InputMethodEngine : public InputMethodEngineInterface {
std::string extension_id_;
// The observer object recieving events for this IME.
- scoped_ptr<InputMethodEngineInterface::Observer> observer_;
+ scoped_ptr<ui::IMEEngineObserver> observer_;
// The current preedit text, and it's cursor position.
scoped_ptr<ui::CompositionText> composition_text_;
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc b/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc
index d242d93..fc0d68c 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc
@@ -185,9 +185,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
KeyEventDoneCallback callback(false); // EchoBackIME doesn't consume keys.
ExtensionTestMessageListener keyevent_listener("onKeyEvent", false);
ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
ASSERT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -269,9 +269,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(
ui::ET_KEY_PRESSED, ui::VKEY_A, ui::DomCode::KEY_A, ui::EF_NONE);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -287,9 +287,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::VKEY_A,
ui::DomCode::KEY_A,
ui::EF_CONTROL_DOWN);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -305,9 +305,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::VKEY_A,
ui::DomCode::KEY_A,
ui::EF_ALT_DOWN);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -323,9 +323,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::VKEY_A,
ui::DomCode::KEY_A,
ui::EF_SHIFT_DOWN);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -341,9 +341,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::VKEY_A,
ui::DomCode::KEY_A,
ui::EF_CAPS_LOCK_DOWN);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -359,9 +359,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::VKEY_A,
ui::DomCode::KEY_A,
ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -377,9 +377,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::VKEY_A,
ui::DomCode::KEY_A,
ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
@@ -425,9 +425,9 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
kMediaKeyCases[i].keycode,
ui::KeycodeConverter::CodeStringToDomCode(kMediaKeyCases[i].code),
ui::EF_NONE);
- engine_handler->ProcessKeyEvent(key_event,
- base::Bind(&KeyEventDoneCallback::Run,
- base::Unretained(&callback)));
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback keyevent_callback =
+ base::Bind(&KeyEventDoneCallback::Run, base::Unretained(&callback));
+ engine_handler->ProcessKeyEvent(key_event, keyevent_callback);
ASSERT_TRUE(keyevent_listener.WaitUntilSatisfied());
EXPECT_TRUE(keyevent_listener.was_satisfied());
callback.WaitUntilCalled();
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_interface.cc b/chrome/browser/chromeos/input_method/input_method_engine_interface.cc
deleted file mode 100644
index 102ef15..0000000
--- a/chrome/browser/chromeos/input_method/input_method_engine_interface.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2013 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/input_method_engine_interface.h"
-
-namespace chromeos {
-
-InputMethodEngineInterface::KeyboardEvent::KeyboardEvent()
- : alt_key(false),
- ctrl_key(false),
- shift_key(false),
- caps_lock(false) {
-}
-
-InputMethodEngineInterface::KeyboardEvent::~KeyboardEvent() {
-}
-
-InputMethodEngineInterface::MenuItem::MenuItem() {
-}
-
-InputMethodEngineInterface::MenuItem::~MenuItem() {
-}
-
-InputMethodEngineInterface::Candidate::Candidate() {
-}
-
-InputMethodEngineInterface::Candidate::~Candidate() {
-}
-
-namespace {
-// The default entry number of a page in CandidateWindowProperty.
-const int kDefaultPageSize = 9;
-} // namespace
-
-// When the default values are changed, please modify
-// CandidateWindow::CandidateWindowProperty defined in chromeos/ime/ too.
-InputMethodEngineInterface::CandidateWindowProperty::CandidateWindowProperty()
- : page_size(kDefaultPageSize),
- is_cursor_visible(true),
- is_vertical(false),
- show_window_at_composition(false) {
-}
-
-InputMethodEngineInterface::CandidateWindowProperty::~CandidateWindowProperty()
-{
-}
-
-InputMethodEngineInterface::Observer::~Observer() {
-}
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_interface.h b/chrome/browser/chromeos/input_method/input_method_engine_interface.h
deleted file mode 100644
index 5120831..0000000
--- a/chrome/browser/chromeos/input_method/input_method_engine_interface.h
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright 2013 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_INPUT_METHOD_ENGINE_INTERFACE_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_INTERFACE_H_
-
-#include <string>
-#include <vector>
-
-#include "ui/base/ime/ime_engine_handler_interface.h"
-
-class GURL;
-
-namespace chromeos {
-
-namespace input_method {
-class InputMethodDescriptor;
-struct KeyEventHandle;
-} // namespace input_method
-
-// InputMethodEngine is used to translate from the Chrome IME API to the native
-// API.
-class InputMethodEngineInterface : public ui::IMEEngineHandlerInterface {
- public:
- struct KeyboardEvent {
- KeyboardEvent();
- virtual ~KeyboardEvent();
-
- std::string type;
- std::string key;
- std::string code;
- int key_code; // only used by on-screen keyboards.
- std::string extension_id;
- bool alt_key;
- bool ctrl_key;
- bool shift_key;
- bool caps_lock;
- };
-
- enum {
- MENU_ITEM_MODIFIED_LABEL = 0x0001,
- MENU_ITEM_MODIFIED_STYLE = 0x0002,
- MENU_ITEM_MODIFIED_VISIBLE = 0x0004,
- MENU_ITEM_MODIFIED_ENABLED = 0x0008,
- MENU_ITEM_MODIFIED_CHECKED = 0x0010,
- MENU_ITEM_MODIFIED_ICON = 0x0020,
- };
-
- enum MenuItemStyle {
- MENU_ITEM_STYLE_NONE,
- MENU_ITEM_STYLE_CHECK,
- MENU_ITEM_STYLE_RADIO,
- MENU_ITEM_STYLE_SEPARATOR,
- };
-
- enum MouseButtonEvent {
- MOUSE_BUTTON_LEFT,
- MOUSE_BUTTON_RIGHT,
- MOUSE_BUTTON_MIDDLE,
- };
-
- enum SegmentStyle {
- SEGMENT_STYLE_UNDERLINE,
- SEGMENT_STYLE_DOUBLE_UNDERLINE,
- SEGMENT_STYLE_NO_UNDERLINE,
- };
-
- enum CandidateWindowPosition {
- WINDOW_POS_CURSOR,
- WINDOW_POS_COMPOSITTION,
- };
-
- struct MenuItem {
- MenuItem();
- virtual ~MenuItem();
-
- std::string id;
- std::string label;
- MenuItemStyle style;
- bool visible;
- bool enabled;
- bool checked;
-
- unsigned int modified;
- std::vector<MenuItem> children;
- };
-
- struct InputContext {
- int id;
- std::string type;
- bool auto_correct;
- bool auto_complete;
- bool spell_check;
- };
-
- struct UsageEntry {
- std::string title;
- std::string body;
- };
-
- struct Candidate {
- Candidate();
- virtual ~Candidate();
-
- std::string value;
- int id;
- std::string label;
- std::string annotation;
- UsageEntry usage;
- std::vector<Candidate> candidates;
- };
-
- struct CandidateWindowProperty {
- CandidateWindowProperty();
- virtual ~CandidateWindowProperty();
- int page_size;
- bool is_cursor_visible;
- bool is_vertical;
- bool show_window_at_composition;
-
- // Auxiliary text is typically displayed in the footer of the candidate
- // window.
- std::string auxiliary_text;
- bool is_auxiliary_text_visible;
- };
-
- struct SegmentInfo {
- int start;
- int end;
- SegmentStyle style;
- };
-
- class Observer {
- public:
- virtual ~Observer();
-
- // Called when the IME becomes the active IME.
- virtual void OnActivate(const std::string& engine_id) = 0;
-
- // Called when the IME is no longer active.
- virtual void OnDeactivated(const std::string& engine_id) = 0;
-
- // Called when a text field gains focus, and will be sending key events.
- virtual void OnFocus(const InputContext& context) = 0;
-
- // Called when a text field loses focus, and will no longer generate events.
- virtual void OnBlur(int context_id) = 0;
-
- // Called when an InputContext's properties change while it is focused.
- virtual void OnInputContextUpdate(const InputContext& context) = 0;
-
- // Returns whether the observer is interested in key events.
- virtual bool IsInterestedInKeyEvent() const = 0;
-
- // Called when the user pressed a key with a text field focused.
- virtual void OnKeyEvent(const std::string& engine_id,
- const KeyboardEvent& event,
- input_method::KeyEventHandle* key_data) = 0;
-
- // Called when the user clicks on an item in the candidate list.
- virtual void OnCandidateClicked(const std::string& engine_id,
- int candidate_id,
- MouseButtonEvent button) = 0;
-
- // Called when a menu item for this IME is interacted with.
- virtual void OnMenuItemActivated(const std::string& engine_id,
- const std::string& menu_id) = 0;
-
- // Called when a surrounding text is changed.
- virtual void OnSurroundingTextChanged(const std::string& engine_id,
- const std::string& text,
- int cursor_pos,
- int anchor_pos,
- int offset_pos) = 0;
-
- // Called when composition bounds are changed.
- virtual void OnCompositionBoundsChanged(
- const std::vector<gfx::Rect>& bounds) = 0;
-
- // Called when Chrome terminates on-going text input session.
- virtual void OnReset(const std::string& engine_id) = 0;
- };
-
- ~InputMethodEngineInterface() override {}
-
- // Set the current composition and associated properties.
- 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) = 0;
-
- // Clear the current composition.
- virtual bool ClearComposition(int context_id, std::string* error) = 0;
-
- // Commit the specified text to the specified context. Fails if the context
- // is not focused.
- virtual bool CommitText(int context_id, const char* text,
- std::string* error) = 0;
-
- // Send the sequence of key events.
- virtual bool SendKeyEvents(int context_id,
- const std::vector<KeyboardEvent>& events) = 0;
-
- // This function returns the current property of the candidate window.
- // The caller can use the returned value as the default property and
- // modify some of specified items.
- virtual const CandidateWindowProperty&
- GetCandidateWindowProperty() const = 0;
-
- // Change the property of the candidate window and repaint the candidate
- // window widget.
- virtual void SetCandidateWindowProperty(
- const CandidateWindowProperty& property) = 0;
-
- // Show or hide the candidate window.
- virtual bool SetCandidateWindowVisible(bool visible, std::string* error) = 0;
-
- // Set the list of entries displayed in the candidate window.
- virtual bool SetCandidates(int context_id,
- const std::vector<Candidate>& candidates,
- std::string* error) = 0;
-
- // Set the position of the cursor in the candidate window.
- virtual bool SetCursorPosition(int context_id, int candidate_id,
- std::string* error) = 0;
-
- // Set the list of items that appears in the language menu when this IME is
- // active.
- virtual bool SetMenuItems(const std::vector<MenuItem>& items) = 0;
-
- // Update the state of the menu items.
- virtual bool UpdateMenuItems(const std::vector<MenuItem>& items) = 0;
-
- // Returns true if this IME is active, false if not.
- virtual bool IsActive() const = 0;
-
- // Returns the current active input_component id.
- virtual const std::string& GetActiveComponentId() const = 0;
-
- // Deletes |number_of_chars| unicode characters as the basis of |offset| from
- // the surrounding text. The |offset| is relative position based on current
- // caret.
- // NOTE: Currently we are falling back to backspace forwarding workaround,
- // because delete_surrounding_text is not supported in Chrome. So this
- // function is restricted for only preceding text.
- // TODO(nona): Support full spec delete surrounding text.
- virtual bool DeleteSurroundingText(int context_id,
- int offset,
- size_t number_of_chars,
- std::string* error) = 0;
-
- // Hides the input view window (from API call).
- virtual void HideInputView() = 0;
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_INTERFACE_H_
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc b/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc
index 75b919c..51127ed 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine_unittest.cc
@@ -9,7 +9,6 @@
#include "base/test/histogram_tester.h"
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/chromeos/input_method/input_method_engine.h"
-#include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
#include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,6 +16,8 @@
#include "ui/base/ime/chromeos/mock_component_extension_ime_manager_delegate.h"
#include "ui/base/ime/chromeos/mock_ime_input_context_handler.h"
#include "ui/base/ime/ime_bridge.h"
+#include "ui/base/ime/ime_engine_handler_interface.h"
+#include "ui/base/ime/ime_engine_observer.h"
#include "ui/base/ime/text_input_flags.h"
#include "ui/gfx/geometry/rect.h"
@@ -65,7 +66,7 @@ void InitInputMethod() {
InitializeForTesting(manager);
}
-class TestObserver : public InputMethodEngineInterface::Observer {
+class TestObserver : public ui::IMEEngineObserver {
public:
TestObserver() : calls_bitmap_(NONE) {}
~TestObserver() override {}
@@ -77,20 +78,20 @@ class TestObserver : public InputMethodEngineInterface::Observer {
calls_bitmap_ |= DEACTIVATED;
}
void OnFocus(
- const InputMethodEngineInterface::InputContext& context) override {
+ const ui::IMEEngineHandlerInterface::InputContext& context) override {
calls_bitmap_ |= ONFOCUS;
}
void OnBlur(int context_id) override { calls_bitmap_ |= ONBLUR; }
bool IsInterestedInKeyEvent() const override { return true; }
- void OnKeyEvent(const std::string& engine_id,
- const InputMethodEngineInterface::KeyboardEvent& event,
- input_method::KeyEventHandle* key_data) override {}
- void OnInputContextUpdate(
- const InputMethodEngineInterface::InputContext& context) override {}
- void OnCandidateClicked(
+ void OnKeyEvent(
const std::string& engine_id,
- int candidate_id,
- InputMethodEngineInterface::MouseButtonEvent button) override {}
+ const ui::IMEEngineHandlerInterface::KeyboardEvent& event,
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) override {}
+ void OnInputContextUpdate(
+ const ui::IMEEngineHandlerInterface::InputContext& context) override {}
+ void OnCandidateClicked(const std::string& engine_id,
+ int candidate_id,
+ MouseButtonEvent button) override {}
void OnMenuItemActivated(const std::string& engine_id,
const std::string& menu_id) override {}
void OnSurroundingTextChanged(const std::string& engine_id,
@@ -116,7 +117,7 @@ class TestObserver : public InputMethodEngineInterface::Observer {
DISALLOW_COPY_AND_ASSIGN(TestObserver);
};
-class InputMethodEngineTest : public testing::Test {
+class InputMethodEngineTest : public testing::Test {
public:
InputMethodEngineTest() : observer_(NULL), input_view_("inputview.html") {
languages_.push_back("en-US");
@@ -137,7 +138,7 @@ class InputMethodEngineTest : public testing::Test {
void CreateEngine(bool whitelisted) {
engine_.reset(new InputMethodEngine());
observer_ = new TestObserver();
- scoped_ptr<InputMethodEngineInterface::Observer> observer_ptr(observer_);
+ scoped_ptr<ui::IMEEngineObserver> observer_ptr(observer_);
engine_->Initialize(observer_ptr.Pass(),
whitelisted ? kTestExtensionId : kTestExtensionId2,
ProfileManager::GetActiveUserProfile());
@@ -240,7 +241,7 @@ TEST_F(InputMethodEngineTest, TestHistograms) {
CreateEngine(true);
FocusIn(ui::TEXT_INPUT_TYPE_TEXT);
engine_->Enable(kTestImeComponentId);
- std::vector<InputMethodEngineInterface::SegmentInfo> segments;
+ std::vector<ui::IMEEngineHandlerInterface::SegmentInfo> segments;
int context = engine_->GetCotextIdForTesting();
std::string error;
base::HistogramTester histograms;
@@ -264,8 +265,7 @@ TEST_F(InputMethodEngineTest, TestCompositionBoundsChanged) {
std::vector<gfx::Rect> rects;
rects.push_back(gfx::Rect());
engine_->SetCompositionBounds(rects);
- EXPECT_EQ(ONCOMPOSITIONBOUNDSCHANGED,
- observer_->GetCallsBitmapAndReset());
+ EXPECT_EQ(ONCOMPOSITIONBOUNDSCHANGED, observer_->GetCallsBitmapAndReset());
}
} // namespace input_method
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
index 4eaf669..7f75d6b 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
#include "chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.h"
-#include "chrome/browser/chromeos/input_method/input_method_engine.h"
#include "chrome/browser/chromeos/input_method/input_method_switch_recorder.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
@@ -446,7 +445,7 @@ bool InputMethodManagerImpl::StateImpl::MethodAwaitsExtensionLoad(
void InputMethodManagerImpl::StateImpl::AddInputMethodExtension(
const std::string& extension_id,
const InputMethodDescriptors& descriptors,
- InputMethodEngineInterface* engine) {
+ ui::IMEEngineHandlerInterface* engine) {
if (manager_->ui_session_ == STATE_TERMINATING)
return;
@@ -975,7 +974,7 @@ void InputMethodManagerImpl::ChangeInputMethodInternal(
if (notify_menu) {
// Clear property list. Property list would be updated by
- // extension IMEs via InputMethodEngine::(Set|Update)MenuItems.
+ // extension IMEs via IMEEngineHandlerInterface::(Set|Update)MenuItems.
// If the current input method is a keyboard layout, empty
// properties are sufficient.
const ui::ime::InputMethodMenuItemList empty_menu_item_list;
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 7b11c0d..8860afc 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.h
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.h
@@ -17,6 +17,11 @@
#include "chrome/browser/profiles/profile.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/chromeos/input_method_whitelist.h"
+#include "ui/base/ime/ime_engine_handler_interface.h"
+
+namespace ui {
+class IMEEngineHandlerInterface;
+} // namespace ui
namespace chromeos {
class ComponentExtensionIMEManager;
@@ -71,9 +76,10 @@ class InputMethodManagerImpl : public InputMethodManager,
// InputMethodManager::State overrides.
scoped_refptr<InputMethodManager::State> Clone() const override;
- void AddInputMethodExtension(const std::string& extension_id,
- const InputMethodDescriptors& descriptors,
- InputMethodEngineInterface* instance) override;
+ void AddInputMethodExtension(
+ const std::string& extension_id,
+ const InputMethodDescriptors& descriptors,
+ ui::IMEEngineHandlerInterface* instance) override;
void RemoveInputMethodExtension(const std::string& extension_id) override;
void ChangeInputMethod(const std::string& input_method_id,
bool show_message) override;
@@ -254,7 +260,7 @@ class InputMethodManagerImpl : public InputMethodManager,
bool enable_extension_loading_;
// The engine map from extension_id to an engine.
- typedef std::map<std::string, InputMethodEngineInterface*> EngineMap;
+ typedef std::map<std::string, ui::IMEEngineHandlerInterface*> EngineMap;
typedef std::map<Profile*, EngineMap, ProfileCompare> ProfileEngineMap;
ProfileEngineMap engine_map_;
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 2b021b5..a91a3fe 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 "base/run_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_input_method_engine.h"
#include "chrome/browser/profiles/profile_manager.h"
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_engine.cc b/chrome/browser/chromeos/input_method/mock_input_method_engine.cc
index 852a095..203527f 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_engine.cc
+++ b/chrome/browser/chromeos/input_method/mock_input_method_engine.cc
@@ -1,3 +1,4 @@
+
// 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.
@@ -28,7 +29,7 @@ bool MockInputMethodEngine::SetComposition(
}
bool MockInputMethodEngine::ClearComposition(int context_id,
- std::string* error) {
+ std::string* error) {
return true;
}
@@ -50,8 +51,7 @@ MockInputMethodEngine::GetCandidateWindowProperty() const {
}
void MockInputMethodEngine::SetCandidateWindowProperty(
- const CandidateWindowProperty& property) {
-}
+ const CandidateWindowProperty& property) {}
bool MockInputMethodEngine::SetCandidateWindowVisible(bool visible,
std::string* error) {
@@ -91,15 +91,12 @@ bool MockInputMethodEngine::DeleteSurroundingText(int context_id,
return true;
}
-void MockInputMethodEngine::HideInputView() {
-}
+void MockInputMethodEngine::HideInputView() {}
void MockInputMethodEngine::FocusIn(
- const IMEEngineHandlerInterface::InputContext& input_context) {
-}
+ const IMEEngineHandlerInterface::InputContext& input_context) {}
-void MockInputMethodEngine::FocusOut() {
-}
+void MockInputMethodEngine::FocusOut() {}
void MockInputMethodEngine::Enable(const std::string& component_id) {
active_component_id_ = component_id;
@@ -113,20 +110,16 @@ void MockInputMethodEngine::PropertyActivate(const std::string& property_name) {
last_activated_property_ = property_name;
}
-void MockInputMethodEngine::Reset() {
-}
+void MockInputMethodEngine::Reset() {}
bool MockInputMethodEngine::IsInterestedInKeyEvent() const {
return true;
}
-void MockInputMethodEngine::ProcessKeyEvent(
- const ui::KeyEvent& key_event,
- const KeyEventDoneCallback& callback) {
-}
+void MockInputMethodEngine::ProcessKeyEvent(const ui::KeyEvent& key_event,
+ KeyEventDoneCallback& callback) {}
-void MockInputMethodEngine::CandidateClicked(uint32 index) {
-}
+void MockInputMethodEngine::CandidateClicked(uint32 index) {}
void MockInputMethodEngine::SetSurroundingText(const std::string& text,
uint32 cursor_pos,
@@ -134,7 +127,6 @@ void MockInputMethodEngine::SetSurroundingText(const std::string& text,
uint32 offset_pos) {}
void MockInputMethodEngine::SetCompositionBounds(
- const std::vector<gfx::Rect>& bounds) {
-}
+ const std::vector<gfx::Rect>& bounds) {}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_engine.h b/chrome/browser/chromeos/input_method/mock_input_method_engine.h
index 5151d39..2aa3952 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_engine.h
+++ b/chrome/browser/chromeos/input_method/mock_input_method_engine.h
@@ -8,10 +8,11 @@
#include <string>
#include <vector>
-#include "chrome/browser/chromeos/input_method/input_method_engine_interface.h"
#include "ui/base/ime/chromeos/input_method_descriptor.h"
+#include "ui/base/ime/ime_engine_handler_interface.h"
namespace ui {
+class IMEEngineHandlerInterface;
class KeyEvent;
namespace ime {
@@ -25,15 +26,14 @@ class CompositionText;
namespace input_method {
class CandidateWindow;
-struct KeyEventHandle;
}
-class MockInputMethodEngine : public InputMethodEngineInterface {
+class MockInputMethodEngine : public ui::IMEEngineHandlerInterface {
public:
MockInputMethodEngine();
~MockInputMethodEngine() override;
- // InputMethodEngineInterface overrides.
+ // IMEEngineHandlerInterface overrides.
const std::string& GetActiveComponentId() const override;
bool SetComposition(int context_id,
const char* text,
@@ -76,7 +76,7 @@ class MockInputMethodEngine : public InputMethodEngineInterface {
void Reset() override;
bool IsInterestedInKeyEvent() const override;
void ProcessKeyEvent(const ui::KeyEvent& key_event,
- const KeyEventDoneCallback& callback) override;
+ KeyEventDoneCallback& callback) override;
void CandidateClicked(uint32 index) override;
void SetSurroundingText(const std::string& text,
uint32 cursor_pos,
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 7254bf9..ef233ac 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.cc
@@ -116,8 +116,7 @@ void MockInputMethodManager::ActivateInputMethodMenuItem(
void MockInputMethodManager::State::AddInputMethodExtension(
const std::string& extension_id,
const InputMethodDescriptors& descriptors,
- InputMethodEngineInterface* instance) {
-}
+ ui::IMEEngineHandlerInterface* instance) {}
void MockInputMethodManager::State::RemoveInputMethodExtension(
const std::string& extension_id) {
diff --git a/chrome/browser/chromeos/input_method/mock_input_method_manager.h b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
index 7673045..3a41db1 100644
--- a/chrome/browser/chromeos/input_method/mock_input_method_manager.h
+++ b/chrome/browser/chromeos/input_method/mock_input_method_manager.h
@@ -23,9 +23,10 @@ class MockInputMethodManager : public InputMethodManager {
explicit State(MockInputMethodManager* manager);
scoped_refptr<InputMethodManager::State> Clone() const override;
- void AddInputMethodExtension(const std::string& extension_id,
- const InputMethodDescriptors& descriptors,
- InputMethodEngineInterface* instance) override;
+ void AddInputMethodExtension(
+ const std::string& extension_id,
+ const InputMethodDescriptors& descriptors,
+ ui::IMEEngineHandlerInterface* instance) override;
void RemoveInputMethodExtension(const std::string& extension_id) override;
void ChangeInputMethod(const std::string& input_method_id,
bool show_message) override;