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

Side by Side 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 proto coverters for TextInputType 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/android/jni_string.h" 5 #include "base/android/jni_string.h"
6 #include "blimp/client/app/android/blimp_client_session_android.h" 6 #include "blimp/client/app/android/blimp_client_session_android.h"
7 #include "blimp/client/app/android/web_input_box.h" 7 #include "blimp/client/app/android/web_input_box.h"
8 #include "blimp/client/feature/web_input_feature.h"
8 #include "jni/WebInputBox_jni.h" 9 #include "jni/WebInputBox_jni.h"
9 10
10 namespace blimp { 11 namespace blimp {
11 namespace client { 12 namespace client {
12 13
13 static jlong Init(JNIEnv* env, 14 static jlong Init(JNIEnv* env,
14 const JavaParamRef<jobject>& jobj, 15 const JavaParamRef<jobject>& jobj,
15 const JavaParamRef<jobject>& blimp_client_session) { 16 const JavaParamRef<jobject>& blimp_client_session) {
16 return reinterpret_cast<intptr_t>(new WebInputBox(env, jobj)); 17 BlimpClientSession* client_session =
18 BlimpClientSessionAndroid::FromJavaObject(env,
19 blimp_client_session.obj());
20 return reinterpret_cast<intptr_t>(
21 new WebInputBox(env, jobj, client_session->GetWebInputFeature()));
17 } 22 }
18 23
19 // static 24 // static
20 bool WebInputBox::RegisterJni(JNIEnv* env) { 25 bool WebInputBox::RegisterJni(JNIEnv* env) {
21 return RegisterNativesImpl(env); 26 return RegisterNativesImpl(env);
22 } 27 }
23 28
24 WebInputBox::WebInputBox(JNIEnv* env, 29 WebInputBox::WebInputBox(JNIEnv* env,
25 const base::android::JavaParamRef<jobject>& jobj) { 30 const base::android::JavaParamRef<jobject>& jobj,
31 WebInputFeature* web_input_feature) {
26 java_obj_.Reset(env, jobj); 32 java_obj_.Reset(env, jobj);
33 web_input_feature_ = web_input_feature;
34 web_input_feature_->SetDelegate(this);
27 } 35 }
28 36
29 WebInputBox::~WebInputBox() {} 37 WebInputBox::~WebInputBox() {
38 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.
39 }
30 40
31 void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 41 void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
32 delete this; 42 delete this;
33 } 43 }
34 44
35 void WebInputBox::OnImeRequested(bool show) { 45 void WebInputBox::OnShowImeRequested(int input_type, const std::string& text) {
36 JNIEnv* env = base::android::AttachCurrentThread(); 46 JNIEnv* env = base::android::AttachCurrentThread();
37 Java_WebInputBox_onImeRequested(env, java_obj_.obj(), show); 47 Java_WebInputBox_onShowImeRequested(
48 env, java_obj_.obj(), input_type,
49 base::android::ConvertUTF8ToJavaString(env, text).obj());
50 }
51
52 void WebInputBox::OnHideImeRequested() {
53 JNIEnv* env = base::android::AttachCurrentThread();
54 Java_WebInputBox_onHideImeRequested(env, java_obj_.obj());
38 } 55 }
39 56
40 void WebInputBox::OnImeTextEntered(JNIEnv* env, 57 void WebInputBox::OnImeTextEntered(JNIEnv* env,
41 const JavaParamRef<jobject>& jobj, 58 const JavaParamRef<jobject>& jobj,
42 const JavaParamRef<jstring>& text) { 59 const JavaParamRef<jstring>& text) {
43 // TODO(shaktisahu): Send text to browser. 60 std::string textInput = base::android::ConvertJavaStringToUTF8(env, text);
61 web_input_feature_->SendImeTextToEngine(textInput);
44 } 62 }
45 63
46 } // namespace client 64 } // namespace client
47 } // namespace blimp 65 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698