Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: blimp/client/core/contents/android/ime_helper_dialog.cc

Issue 2292343002: Hooking up Blimp IME with BlimpContents (Closed)
Patch Set: Fixed linux client Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/contents/android/ime_helper_dialog.cc
diff --git a/blimp/client/core/contents/android/ime_helper_dialog.cc b/blimp/client/core/contents/android/ime_helper_dialog.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9bfcff18d2da1fc03478cc8d3f60175e62a3a567
--- /dev/null
+++ b/blimp/client/core/contents/android/ime_helper_dialog.cc
@@ -0,0 +1,59 @@
+// Copyright 2016 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 "blimp/client/core/contents/android/ime_helper_dialog.h"
+
+#include "base/android/jni_string.h"
+#include "base/callback_helpers.h"
+#include "jni/ImeHelperDialog_jni.h"
+#include "ui/android/window_android.h"
+
+using base::android::JavaParamRef;
+
+namespace blimp {
+namespace client {
+
+// static
+bool ImeHelperDialog::RegisterJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+ImeHelperDialog::ImeHelperDialog(ui::WindowAndroid* window) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ java_obj_.Reset(Java_ImeHelperDialog_create(
+ env, reinterpret_cast<intptr_t>(this), window->GetJavaObject()));
+}
+
+ImeHelperDialog::~ImeHelperDialog() {
+ Java_ImeHelperDialog_clearNativePtr(base::android::AttachCurrentThread(),
+ java_obj_);
+}
+
+void ImeHelperDialog::OnShowImeRequested(
+ ui::TextInputType input_type,
+ const std::string& text,
+ const ImeFeature::ShowImeCallback& callback) {
+ text_submit_callback_ = callback;
+
+ JNIEnv* env = base::android::AttachCurrentThread();
+ DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type);
+ Java_ImeHelperDialog_onShowImeRequested(
+ env, java_obj_, input_type,
+ base::android::ConvertUTF8ToJavaString(env, text));
+}
+
+void ImeHelperDialog::OnHideImeRequested() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_ImeHelperDialog_onHideImeRequested(env, java_obj_);
+}
+
+void ImeHelperDialog::OnImeTextEntered(JNIEnv* env,
+ const JavaParamRef<jobject>& jobj,
+ const JavaParamRef<jstring>& text) {
+ std::string text_input = base::android::ConvertJavaStringToUTF8(env, text);
+ base::ResetAndReturn(&text_submit_callback_).Run(text_input);
+}
+
+} // namespace client
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698