Chromium Code Reviews| 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..1afb77302a33cfd83373f7920f88a1a30f5ba74c 100644 |
| --- a/blimp/client/app/android/web_input_box.cc |
| +++ b/blimp/client/app/android/web_input_box.cc |
| @@ -5,6 +5,7 @@ |
| #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/web_input_feature.h" |
| #include "jni/WebInputBox_jni.h" |
| namespace blimp { |
| @@ -13,7 +14,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>( |
| + new WebInputBox(env, jobj, client_session->GetWebInputFeature())); |
| } |
| // static |
| @@ -22,25 +27,38 @@ bool WebInputBox::RegisterJni(JNIEnv* env) { |
| } |
| WebInputBox::WebInputBox(JNIEnv* env, |
| - const base::android::JavaParamRef<jobject>& jobj) { |
| + const base::android::JavaParamRef<jobject>& jobj, |
| + WebInputFeature* web_input_feature) { |
| java_obj_.Reset(env, jobj); |
| + web_input_feature_ = web_input_feature; |
| + web_input_feature_->SetDelegate(this); |
| } |
| -WebInputBox::~WebInputBox() {} |
| +WebInputBox::~WebInputBox() { |
| + web_input_feature_->SetDelegate(NULL); |
|
Khushal
2016/03/17 10:02:45
nit: I think we use nullptr in the code now.
shaktisahu
2016/03/18 19:08:05
Done.
|
| +} |
| void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { |
| delete this; |
| } |
| -void WebInputBox::OnImeRequested(bool show) { |
| +void WebInputBox::OnShowImeRequested(int input_type, const std::string& text) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + Java_WebInputBox_onShowImeRequested( |
| + env, java_obj_.obj(), input_type, |
| + 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); |
| + web_input_feature_->SendImeTextToEngine(textInput); |
| } |
| } // namespace client |