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

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: 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() {}
David Trainor- moved to gerrit 2016/03/14 17:59:41 Clear the delegate
shaktisahu 2016/03/15 23:44:13 Done.
30 38
31 void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 39 void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
32 delete this; 40 delete this;
33 } 41 }
34 42
35 void WebInputBox::OnImeRequested(bool show) { 43 void WebInputBox::OnImeRequested(bool show,
44 int input_type,
45 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_onImeRequested(
48 env, java_obj_.obj(), show, input_type,
49 base::android::ConvertUTF8ToJavaString(env, text).obj());
38 } 50 }
39 51
40 void WebInputBox::OnImeTextEntered(JNIEnv* env, 52 void WebInputBox::OnImeTextEntered(JNIEnv* env,
41 const JavaParamRef<jobject>& jobj, 53 const JavaParamRef<jobject>& jobj,
42 const JavaParamRef<jstring>& text) { 54 const JavaParamRef<jstring>& text) {
43 // TODO(shaktisahu): Send text to browser. 55 std::string str = base::android::ConvertJavaStringToUTF8(env, text);
David Trainor- moved to gerrit 2016/03/14 17:59:41 "str" feels a little too 'code lab' to me. Could
shaktisahu 2016/03/15 23:44:13 Done.
56 web_input_feature_->SendImeTextToEngine(str);
44 } 57 }
45 58
46 } // namespace client 59 } // namespace client
47 } // namespace blimp 60 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698