summaryrefslogtreecommitdiffstats
path: root/mojo/converters/ime
diff options
context:
space:
mode:
authorpenghuang <penghuang@chromium.org>2015-08-17 07:36:12 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-17 14:36:41 +0000
commitd1e9dbab0625b85ef3db72b1a100fb7d9db5cb3c (patch)
tree49d0ddab018bf3734714aca06c223e7fd6da9cd3 /mojo/converters/ime
parentc3c6cebcd9baf209b9be17936777c6e3fdf58717 (diff)
downloadchromium_src-d1e9dbab0625b85ef3db72b1a100fb7d9db5cb3c.zip
chromium_src-d1e9dbab0625b85ef3db72b1a100fb7d9db5cb3c.tar.gz
chromium_src-d1e9dbab0625b85ef3db72b1a100fb7d9db5cb3c.tar.bz2
Mandoline: Enable Android software keyboard for the Omnibox.
BUG=498624 Review URL: https://codereview.chromium.org/1286383003 Cr-Commit-Position: refs/heads/master@{#343679}
Diffstat (limited to 'mojo/converters/ime')
-rw-r--r--mojo/converters/ime/BUILD.gn28
-rw-r--r--mojo/converters/ime/DEPS6
-rw-r--r--mojo/converters/ime/ime_type_converters.cc74
-rw-r--r--mojo/converters/ime/ime_type_converters.h31
-rw-r--r--mojo/converters/ime/mojo_ime_export.h32
5 files changed, 171 insertions, 0 deletions
diff --git a/mojo/converters/ime/BUILD.gn b/mojo/converters/ime/BUILD.gn
new file mode 100644
index 0000000..5e9105f
--- /dev/null
+++ b/mojo/converters/ime/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+# This target does NOT depend on skia. One can depend on this target to avoid
+# picking up a dependency on skia.
+component("ime") {
+ output_name = "mojo_ime_lib"
+
+ public_deps = [
+ "//ui/base/ime",
+ ]
+ deps = [
+ "//base",
+ "//mojo/environment:chromium",
+ "//third_party/mojo/src/mojo/public/c/system:for_component",
+ "//ui/mojo/ime:interfaces",
+ "//ui/platform_window",
+ ]
+
+ defines = [ "MOJO_IME_IMPLEMENTATION" ]
+
+ sources = [
+ "ime_type_converters.cc",
+ "ime_type_converters.h",
+ "mojo_ime_export.h",
+ ]
+}
diff --git a/mojo/converters/ime/DEPS b/mojo/converters/ime/DEPS
new file mode 100644
index 0000000..9d81a76
--- /dev/null
+++ b/mojo/converters/ime/DEPS
@@ -0,0 +1,6 @@
+include_rules = [
+ "+ui/base/ime/text_input_flags.h",
+ "+ui/base/ime/text_input_type.h",
+ "+ui/mojo/ime",
+ "+ui/platform_window/text_input_state.h",
+]
diff --git a/mojo/converters/ime/ime_type_converters.cc b/mojo/converters/ime/ime_type_converters.cc
new file mode 100644
index 0000000..9a59f2f
--- /dev/null
+++ b/mojo/converters/ime/ime_type_converters.cc
@@ -0,0 +1,74 @@
+// 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 "mojo/converters/ime/ime_type_converters.h"
+
+#include "base/basictypes.h"
+#include "base/macros.h"
+
+namespace mojo {
+
+#define TEXT_INPUT_TYPE_ASSERT(NAME) \
+ COMPILE_ASSERT(static_cast<int32>(TEXT_INPUT_TYPE_##NAME) == \
+ static_cast<int32>(ui::TEXT_INPUT_TYPE_##NAME), \
+ text_input_type_should_match)
+TEXT_INPUT_TYPE_ASSERT(NONE);
+TEXT_INPUT_TYPE_ASSERT(TEXT);
+TEXT_INPUT_TYPE_ASSERT(PASSWORD);
+TEXT_INPUT_TYPE_ASSERT(SEARCH);
+TEXT_INPUT_TYPE_ASSERT(EMAIL);
+TEXT_INPUT_TYPE_ASSERT(NUMBER);
+TEXT_INPUT_TYPE_ASSERT(TELEPHONE);
+TEXT_INPUT_TYPE_ASSERT(URL);
+TEXT_INPUT_TYPE_ASSERT(DATE);
+TEXT_INPUT_TYPE_ASSERT(DATE_TIME);
+TEXT_INPUT_TYPE_ASSERT(DATE_TIME_LOCAL);
+TEXT_INPUT_TYPE_ASSERT(MONTH);
+TEXT_INPUT_TYPE_ASSERT(TIME);
+TEXT_INPUT_TYPE_ASSERT(WEEK);
+TEXT_INPUT_TYPE_ASSERT(TEXT_AREA);
+
+#define TEXT_INPUT_FLAG_ASSERT(NAME) \
+ COMPILE_ASSERT(static_cast<int32>(TEXT_INPUT_FLAG_##NAME) == \
+ static_cast<int32>(ui::TEXT_INPUT_FLAG_##NAME), \
+ text_input_flag_should_match)
+TEXT_INPUT_FLAG_ASSERT(NONE);
+TEXT_INPUT_FLAG_ASSERT(AUTOCOMPLETE_ON);
+TEXT_INPUT_FLAG_ASSERT(AUTOCOMPLETE_OFF);
+TEXT_INPUT_FLAG_ASSERT(AUTOCORRECT_ON);
+TEXT_INPUT_FLAG_ASSERT(AUTOCORRECT_OFF);
+TEXT_INPUT_FLAG_ASSERT(SPELLCHECK_ON);
+TEXT_INPUT_FLAG_ASSERT(SPELLCHECK_OFF);
+TEXT_INPUT_FLAG_ASSERT(AUTOCAPITALIZE_NONE);
+TEXT_INPUT_FLAG_ASSERT(AUTOCAPITALIZE_CHARACTERS);
+TEXT_INPUT_FLAG_ASSERT(AUTOCAPITALIZE_WORDS);
+TEXT_INPUT_FLAG_ASSERT(AUTOCAPITALIZE_SENTENCES);
+
+// static
+TextInputType TypeConverter<TextInputType, ui::TextInputType>::Convert(
+ const ui::TextInputType& input) {
+ return static_cast<TextInputType>(input);
+}
+
+// static
+ui::TextInputType TypeConverter<ui::TextInputType, TextInputType>::Convert(
+ const TextInputType& input) {
+ return static_cast<ui::TextInputType>(input);
+}
+
+// static
+ui::TextInputState
+TypeConverter<ui::TextInputState, TextInputStatePtr>::Convert(
+ const TextInputStatePtr& input) {
+ return ui::TextInputState(ConvertTo<ui::TextInputType>(input->type),
+ input->flags,
+ input->text.To<std::string>(),
+ input->selection_start,
+ input->selection_end,
+ input->composition_start,
+ input->composition_end,
+ input->can_compose_inline);
+}
+
+} // namespace mojo
diff --git a/mojo/converters/ime/ime_type_converters.h b/mojo/converters/ime/ime_type_converters.h
new file mode 100644
index 0000000..11fa01d
--- /dev/null
+++ b/mojo/converters/ime/ime_type_converters.h
@@ -0,0 +1,31 @@
+// 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 MOJO_CONVERTERS_IME_IME_TYPE_CONVERTERS_H_
+#define MOJO_CONVERTERS_IME_IME_TYPE_CONVERTERS_H_
+
+#include "mojo/converters/ime/mojo_ime_export.h"
+#include "ui/mojo/ime/text_input_state.mojom.h"
+#include "ui/platform_window/text_input_state.h"
+
+namespace mojo {
+
+template <>
+struct MOJO_IME_EXPORT TypeConverter<TextInputType, ui::TextInputType> {
+ static TextInputType Convert(const ui::TextInputType& input);
+};
+
+template <>
+struct MOJO_IME_EXPORT TypeConverter<ui::TextInputType, TextInputType> {
+ static ui::TextInputType Convert(const TextInputType& input);
+};
+
+template <>
+struct MOJO_IME_EXPORT TypeConverter<ui::TextInputState, TextInputStatePtr> {
+ static ui::TextInputState Convert(const TextInputStatePtr& input);
+};
+
+} // namespace mojo
+
+#endif // MOJO_CONVERTERS_IME_IME_TYPE_CONVERTERS_H_
diff --git a/mojo/converters/ime/mojo_ime_export.h b/mojo/converters/ime/mojo_ime_export.h
new file mode 100644
index 0000000..77d18fd
--- /dev/null
+++ b/mojo/converters/ime/mojo_ime_export.h
@@ -0,0 +1,32 @@
+// 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 MOJO_CONVERTERS_IME_MOJO_IME_EXPORT_H_
+#define MOJO_CONVERTERS_IME_MOJO_IME_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+
+#if defined(WIN32)
+
+#if defined(MOJO_IME_IMPLEMENTATION)
+#define MOJO_IME_EXPORT __declspec(dllexport)
+#else
+#define MOJO_IME_EXPORT __declspec(dllimport)
+#endif
+
+#else // !defined(WIN32)
+
+#if defined(MOJO_IME_IMPLEMENTATION)
+#define MOJO_IME_EXPORT __attribute__((visibility("default")))
+#else
+#define MOJO_IME_EXPORT
+#endif
+
+#endif // defined(WIN32)
+
+#else // !defined(COMPONENT_BUILD)
+#define MOJO_IME_EXPORT
+#endif
+
+#endif // MOJO_CONVERTERS_IME_MOJO_IME_EXPORT_H_