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

Unified Diff: blimp/client/app/android/web_input_box.cc

Issue 1779673003: Added network components for blimp text input feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit tests and addressed comments Created 4 years, 9 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/app/android/web_input_box.cc
diff --git a/blimp/client/app/android/web_input_box.cc b/blimp/client/app/android/web_input_box.cc
index ffdf9cdd18af1f640c9f8bfedf98ce64057bde63..2b7c83f10334ab81609f135b6f4cc4b203888da3 100644
--- a/blimp/client/app/android/web_input_box.cc
+++ b/blimp/client/app/android/web_input_box.cc
@@ -5,7 +5,9 @@
#include "base/android/jni_string.h"
#include "blimp/client/app/android/blimp_client_session_android.h"
#include "blimp/client/app/android/web_input_box.h"
+#include "blimp/client/feature/ime_feature.h"
#include "jni/WebInputBox_jni.h"
+#include "ui/base/ime/text_input_type.h"
namespace blimp {
namespace client {
@@ -13,7 +15,11 @@ namespace client {
static jlong Init(JNIEnv* env,
const JavaParamRef<jobject>& jobj,
const JavaParamRef<jobject>& blimp_client_session) {
- return reinterpret_cast<intptr_t>(new WebInputBox(env, jobj));
+ BlimpClientSession* client_session =
+ BlimpClientSessionAndroid::FromJavaObject(env,
+ blimp_client_session.obj());
+ return reinterpret_cast<intptr_t>(
Wez 2016/03/18 20:51:27 Why are you reinterpret_cast<>ing to intptr_t rath
shaktisahu 2016/03/22 19:44:19 reinterpret_cast to intptr_t is quite standard in
Wez 2016/03/22 21:43:37 Huh... apparently it's about ensuring that the con
+ new WebInputBox(env, jobj, client_session->GetImeFeature()));
}
// static
@@ -22,25 +28,39 @@ bool WebInputBox::RegisterJni(JNIEnv* env) {
}
WebInputBox::WebInputBox(JNIEnv* env,
- const base::android::JavaParamRef<jobject>& jobj) {
+ const base::android::JavaParamRef<jobject>& jobj,
+ ImeFeature* ime_feature) {
java_obj_.Reset(env, jobj);
+ ime_feature_ = ime_feature;
+ ime_feature_->SetDelegate(this);
}
-WebInputBox::~WebInputBox() {}
+WebInputBox::~WebInputBox() {
+ ime_feature_->SetDelegate(nullptr);
+}
void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
delete this;
}
-void WebInputBox::OnImeRequested(bool show) {
+void WebInputBox::OnShowImeRequested(ui::TextInputType input_type,
+ const std::string& text) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_WebInputBox_onShowImeRequested(
+ env, java_obj_.obj(), input_type,
Wez 2016/03/18 20:51:27 nit: It looks a little strange to have |env| need
shaktisahu 2016/03/22 19:44:19 OnShowImeRequested() is a native-to-Java call wher
Wez 2016/03/22 21:43:37 Acknowledged.
+ base::android::ConvertUTF8ToJavaString(env, text).obj());
+}
+
+void WebInputBox::OnHideImeRequested() {
JNIEnv* env = base::android::AttachCurrentThread();
- Java_WebInputBox_onImeRequested(env, java_obj_.obj(), show);
+ Java_WebInputBox_onHideImeRequested(env, java_obj_.obj());
}
void WebInputBox::OnImeTextEntered(JNIEnv* env,
const JavaParamRef<jobject>& jobj,
const JavaParamRef<jstring>& text) {
- // TODO(shaktisahu): Send text to browser.
+ std::string textInput = base::android::ConvertJavaStringToUTF8(env, text);
+ ime_feature_->SendImeTextToEngine(textInput);
}
} // namespace client

Powered by Google App Engine
This is Rietveld 408576698