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

Side by Side Diff: blimp/client/app/android/ime_helper_dialog.cc

Issue 2292343002: Hooking up Blimp IME with BlimpContents (Closed)
Patch Set: Using Callback Created 4 years, 3 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 "blimp/client/app/android/ime_helper_dialog.h" 5 #include "blimp/client/app/android/ime_helper_dialog.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "blimp/client/app/android/blimp_client_session_android.h" 8 #include "blimp/client/app/android/blimp_client_session_android.h"
9 #include "blimp/client/core/contents/ime_feature.h" 9 #include "blimp/client/core/contents/ime_feature.h"
10 #include "jni/ImeHelperDialog_jni.h" 10 #include "jni/ImeHelperDialog_jni.h"
11 #include "ui/base/ime/text_input_type.h" 11 #include "ui/base/ime/text_input_type.h"
12 12
13 using base::android::JavaParamRef; 13 using base::android::JavaParamRef;
14 14
15 namespace blimp { 15 namespace blimp {
16 namespace client { 16 namespace client {
17 namespace app {
17 18
18 static jlong Init(JNIEnv* env, 19 static jlong Init(JNIEnv* env,
19 const JavaParamRef<jobject>& jobj, 20 const JavaParamRef<jobject>& jobj,
20 const JavaParamRef<jobject>& blimp_client_session) { 21 const JavaParamRef<jobject>& blimp_client_session) {
21 BlimpClientSession* client_session = 22 BlimpClientSession* client_session =
22 BlimpClientSessionAndroid::FromJavaObject(env, 23 BlimpClientSessionAndroid::FromJavaObject(env,
23 blimp_client_session.obj()); 24 blimp_client_session.obj());
24 return reinterpret_cast<intptr_t>( 25 return reinterpret_cast<intptr_t>(
25 new ImeHelperDialog(env, jobj, client_session->GetImeFeature())); 26 new ImeHelperDialog(env, jobj, client_session->GetImeFeature()));
26 } 27 }
(...skipping 14 matching lines...) Expand all
41 42
42 ImeHelperDialog::~ImeHelperDialog() { 43 ImeHelperDialog::~ImeHelperDialog() {
43 ime_feature_->set_delegate(nullptr); 44 ime_feature_->set_delegate(nullptr);
44 } 45 }
45 46
46 void ImeHelperDialog::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 47 void ImeHelperDialog::Destroy(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
47 delete this; 48 delete this;
48 } 49 }
49 50
50 void ImeHelperDialog::OnShowImeRequested(ui::TextInputType input_type, 51 void ImeHelperDialog::OnShowImeRequested(ui::TextInputType input_type,
51 const std::string& text) { 52 const std::string& text,
53 const ShowImeCallback& callback) {
54 textSubmitCallback_ = callback;
52 JNIEnv* env = base::android::AttachCurrentThread(); 55 JNIEnv* env = base::android::AttachCurrentThread();
53 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type); 56 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type);
54 Java_ImeHelperDialog_onShowImeRequested( 57 Java_ImeHelperDialog_onShowImeRequested(
55 env, java_obj_, input_type, 58 env, java_obj_, input_type,
56 base::android::ConvertUTF8ToJavaString(env, text)); 59 base::android::ConvertUTF8ToJavaString(env, text));
57 } 60 }
58 61
59 void ImeHelperDialog::OnHideImeRequested() { 62 void ImeHelperDialog::OnHideImeRequested() {
60 JNIEnv* env = base::android::AttachCurrentThread(); 63 JNIEnv* env = base::android::AttachCurrentThread();
61 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_); 64 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_);
62 } 65 }
63 66
64 void ImeHelperDialog::OnImeTextEntered(JNIEnv* env, 67 void ImeHelperDialog::OnImeTextEntered(JNIEnv* env,
65 const JavaParamRef<jobject>& jobj, 68 const JavaParamRef<jobject>& jobj,
66 const JavaParamRef<jstring>& text) { 69 const JavaParamRef<jstring>& text) {
67 std::string textInput = base::android::ConvertJavaStringToUTF8(env, text); 70 std::string textInput = base::android::ConvertJavaStringToUTF8(env, text);
David Trainor- moved to gerrit 2016/08/31 05:59:09 text_input
shaktisahu 2016/08/31 17:28:21 Done.
68 ime_feature_->OnImeTextEntered(textInput); 71 textSubmitCallback_.Run(textInput);
David Trainor- moved to gerrit 2016/08/31 05:59:09 drop the callback after calling it
shaktisahu 2016/08/31 17:28:21 Done.
69 } 72 }
70 73
74 } // namespace app
71 } // namespace client 75 } // namespace client
72 } // namespace blimp 76 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698