summaryrefslogtreecommitdiffstats
path: root/ui/base/ime
diff options
context:
space:
mode:
authorbshe <bshe@chromium.org>2015-10-21 11:21:53 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-21 18:23:11 +0000
commit001e85a661d29ff805cd059f007f133e8fa54116 (patch)
tree77658c9be3dac8481d02f432f31dd0bee364f906 /ui/base/ime
parent79c8acaa5fc38ef1ef5c37b229179b7f1c80dc9c (diff)
downloadchromium_src-001e85a661d29ff805cd059f007f133e8fa54116.zip
chromium_src-001e85a661d29ff805cd059f007f133e8fa54116.tar.gz
chromium_src-001e85a661d29ff805cd059f007f133e8fa54116.tar.bz2
Introduce InputMethodAuraAndroid for Aura on Android
This add an InputMethodAuraAndroid class for Aura on Android. Note: the class is not being used anywhere yet and will only be used when android and use_aura are true. BUG=507792 Review URL: https://codereview.chromium.org/1394883004 Cr-Commit-Position: refs/heads/master@{#355345}
Diffstat (limited to 'ui/base/ime')
-rw-r--r--ui/base/ime/BUILD.gn13
-rw-r--r--ui/base/ime/input_method_android.cc62
-rw-r--r--ui/base/ime/input_method_android.h36
-rw-r--r--ui/base/ime/input_method_factory.cc4
4 files changed, 112 insertions, 3 deletions
diff --git a/ui/base/ime/BUILD.gn b/ui/base/ime/BUILD.gn
index 9219b1a..79c8ffb 100644
--- a/ui/base/ime/BUILD.gn
+++ b/ui/base/ime/BUILD.gn
@@ -22,6 +22,7 @@ component("ime") {
"chromeos/fake_ime_keyboard.h",
"chromeos/fake_input_method_delegate.cc",
"chromeos/fake_input_method_delegate.h",
+ "chromeos/ime_candidate_window_handler_interface.h",
"chromeos/ime_keyboard.cc",
"chromeos/ime_keyboard.h",
"chromeos/ime_keyboard_ozone.cc",
@@ -30,7 +31,6 @@ component("ime") {
"chromeos/ime_keyboard_x11.h",
"chromeos/ime_keymap.cc",
"chromeos/ime_keymap.h",
- "chromeos/ime_candidate_window_handler_interface.h",
"chromeos/input_method_delegate.h",
"chromeos/input_method_descriptor.cc",
"chromeos/input_method_descriptor.h",
@@ -51,12 +51,12 @@ component("ime") {
"composition_text_util_pango.cc",
"composition_text_util_pango.h",
"composition_underline.h",
- "infolist_entry.cc",
- "infolist_entry.h",
"ime_bridge.cc",
"ime_bridge.h",
"ime_engine_handler_interface.h",
"ime_input_context_handler_interface.h",
+ "infolist_entry.cc",
+ "infolist_entry.h",
"input_method.h",
"input_method_auralinux.cc",
"input_method_auralinux.h",
@@ -123,6 +123,13 @@ component("ime") {
]
}
+ if (use_aura && is_android) {
+ sources += [
+ "input_method_android.cc",
+ "input_method_android.h",
+ ]
+ }
+
if (!toolkit_views && !use_aura) {
sources -= [
"input_method_factory.cc",
diff --git a/ui/base/ime/input_method_android.cc b/ui/base/ime/input_method_android.cc
new file mode 100644
index 0000000..23f3b50
--- /dev/null
+++ b/ui/base/ime/input_method_android.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 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 "ui/base/ime/input_method_android.h"
+
+#include "ui/base/ime/text_input_client.h"
+#include "ui/events/event.h"
+
+// TODO(bshe): This is currently very similar to InputMethodMUS. Consider unify
+// them in the furture if the two have reasonable similarity.
+
+namespace ui {
+
+////////////////////////////////////////////////////////////////////////////////
+// InputMethodAndroid, public:
+
+InputMethodAndroid::InputMethodAndroid(
+ internal::InputMethodDelegate* delegate) {
+ SetDelegate(delegate);
+}
+
+InputMethodAndroid::~InputMethodAndroid() {}
+
+bool InputMethodAndroid::OnUntranslatedIMEMessage(
+ const base::NativeEvent& event,
+ NativeEventResult* result) {
+ return false;
+}
+
+void InputMethodAndroid::DispatchKeyEvent(ui::KeyEvent* event) {
+ DCHECK(event->type() == ui::ET_KEY_PRESSED ||
+ event->type() == ui::ET_KEY_RELEASED);
+
+ // If no text input client, do nothing.
+ if (!GetTextInputClient()) {
+ ignore_result(DispatchKeyEventPostIME(event));
+ return;
+ }
+
+ ignore_result(DispatchKeyEventPostIME(event));
+}
+
+void InputMethodAndroid::OnCaretBoundsChanged(
+ const ui::TextInputClient* client) {
+}
+
+void InputMethodAndroid::CancelComposition(
+ const ui::TextInputClient* client) {
+}
+
+void InputMethodAndroid::OnInputLocaleChanged() {}
+
+std::string InputMethodAndroid::GetInputLocale() {
+ return "";
+}
+
+bool InputMethodAndroid::IsCandidatePopupOpen() const {
+ return false;
+}
+
+} // namespace ui
diff --git a/ui/base/ime/input_method_android.h b/ui/base/ime/input_method_android.h
new file mode 100644
index 0000000..edadf73
--- /dev/null
+++ b/ui/base/ime/input_method_android.h
@@ -0,0 +1,36 @@
+// Copyright 2015 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 UI_BASE_IME_INPUT_METHOD_ANDROID_H_
+#define UI_BASE_IME_INPUT_METHOD_ANDROID_H_
+
+#include "base/macros.h"
+#include "ui/base/ime/input_method_base.h"
+
+namespace ui {
+
+// A ui::InputMethod implementation for Aura on Android platform.
+class UI_BASE_IME_EXPORT InputMethodAndroid : public InputMethodBase {
+ public:
+ explicit InputMethodAndroid(internal::InputMethodDelegate* delegate);
+ ~InputMethodAndroid() override;
+
+ private:
+ // Overriden from InputMethod.
+ bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
+ NativeEventResult* result) override;
+ void DispatchKeyEvent(ui::KeyEvent* event) override;
+ void OnCaretBoundsChanged(const TextInputClient* client) override;
+ void CancelComposition(const TextInputClient* client) override;
+ void OnInputLocaleChanged() override;
+ std::string GetInputLocale() override;
+ bool IsCandidatePopupOpen() const override;
+
+ DISALLOW_COPY_AND_ASSIGN(InputMethodAndroid);
+};
+
+} // namespace ui
+
+#endif // UI_BASE_IME_INPUT_METHOD_ANDROID_H_
+
diff --git a/ui/base/ime/input_method_factory.cc b/ui/base/ime/input_method_factory.cc
index b4aa3cd..12e38ea 100644
--- a/ui/base/ime/input_method_factory.cc
+++ b/ui/base/ime/input_method_factory.cc
@@ -17,6 +17,8 @@
#elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \
!defined(OS_CHROMEOS)
#include "ui/base/ime/input_method_auralinux.h"
+#elif defined(OS_ANDROID)
+#include "ui/base/ime/input_method_android.h"
#else
#include "ui/base/ime/input_method_minimal.h"
#endif
@@ -59,6 +61,8 @@ scoped_ptr<InputMethod> CreateInputMethod(
#elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \
!defined(OS_CHROMEOS)
return make_scoped_ptr(new InputMethodAuraLinux(delegate));
+#elif defined(OS_ANDROID)
+ return make_scoped_ptr(new InputMethodAndroid(delegate));
#else
return make_scoped_ptr(new InputMethodMinimal(delegate));
#endif