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

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: Merge origin/master 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
« no previous file with comments | « blimp/client/app/android/web_input_box.h ('k') | blimp/client/feature/ime_feature.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ime_feature.h"
8 #include "jni/WebInputBox_jni.h" 9 #include "jni/WebInputBox_jni.h"
10 #include "ui/base/ime/text_input_type.h"
9 11
10 namespace blimp { 12 namespace blimp {
11 namespace client { 13 namespace client {
12 14
13 static jlong Init(JNIEnv* env, 15 static jlong Init(JNIEnv* env,
14 const JavaParamRef<jobject>& jobj, 16 const JavaParamRef<jobject>& jobj,
15 const JavaParamRef<jobject>& blimp_client_session) { 17 const JavaParamRef<jobject>& blimp_client_session) {
16 return reinterpret_cast<intptr_t>(new WebInputBox(env, jobj)); 18 BlimpClientSession* client_session =
19 BlimpClientSessionAndroid::FromJavaObject(env,
20 blimp_client_session.obj());
21 return reinterpret_cast<intptr_t>(
22 new WebInputBox(env, jobj, client_session->GetImeFeature()));
17 } 23 }
18 24
19 // static 25 // static
20 bool WebInputBox::RegisterJni(JNIEnv* env) { 26 bool WebInputBox::RegisterJni(JNIEnv* env) {
21 return RegisterNativesImpl(env); 27 return RegisterNativesImpl(env);
22 } 28 }
23 29
24 WebInputBox::WebInputBox(JNIEnv* env, 30 WebInputBox::WebInputBox(JNIEnv* env,
25 const base::android::JavaParamRef<jobject>& jobj) { 31 const base::android::JavaParamRef<jobject>& jobj,
32 ImeFeature* ime_feature) {
26 java_obj_.Reset(env, jobj); 33 java_obj_.Reset(env, jobj);
34 ime_feature_ = ime_feature;
35 ime_feature_->set_delegate(this);
27 } 36 }
28 37
29 WebInputBox::~WebInputBox() {} 38 WebInputBox::~WebInputBox() {
39 ime_feature_->set_delegate(nullptr);
40 }
30 41
31 void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 42 void WebInputBox::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
32 delete this; 43 delete this;
33 } 44 }
34 45
35 void WebInputBox::OnImeRequested(bool show) { 46 void WebInputBox::OnShowImeRequested(ui::TextInputType input_type,
47 const std::string& text) {
36 JNIEnv* env = base::android::AttachCurrentThread(); 48 JNIEnv* env = base::android::AttachCurrentThread();
37 Java_WebInputBox_onImeRequested(env, java_obj_.obj(), show); 49 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type);
50 Java_WebInputBox_onShowImeRequested(
51 env, java_obj_.obj(), input_type,
52 base::android::ConvertUTF8ToJavaString(env, text).obj());
53 }
54
55 void WebInputBox::OnHideImeRequested() {
56 JNIEnv* env = base::android::AttachCurrentThread();
57 Java_WebInputBox_onHideImeRequested(env, java_obj_.obj());
38 } 58 }
39 59
40 void WebInputBox::OnImeTextEntered(JNIEnv* env, 60 void WebInputBox::OnImeTextEntered(JNIEnv* env,
41 const JavaParamRef<jobject>& jobj, 61 const JavaParamRef<jobject>& jobj,
42 const JavaParamRef<jstring>& text) { 62 const JavaParamRef<jstring>& text) {
43 // TODO(shaktisahu): Send text to browser. 63 std::string textInput = base::android::ConvertJavaStringToUTF8(env, text);
64 ime_feature_->OnImeTextEntered(textInput);
44 } 65 }
45 66
46 } // namespace client 67 } // namespace client
47 } // namespace blimp 68 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/app/android/web_input_box.h ('k') | blimp/client/feature/ime_feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698