Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 13 matching lines...) Expand all Loading... | |
| 40 } | 41 } |
| 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( |
| 51 const std::string& text) { | 52 ui::TextInputType input_type, |
| 53 const std::string& text, | |
| 54 const ImeFeature::ShowImeCallback& callback) { | |
| 55 text_submit_callback_ = callback; | |
| 52 JNIEnv* env = base::android::AttachCurrentThread(); | 56 JNIEnv* env = base::android::AttachCurrentThread(); |
| 53 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type); | 57 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type); |
| 54 Java_ImeHelperDialog_onShowImeRequested( | 58 Java_ImeHelperDialog_onShowImeRequested( |
| 55 env, java_obj_, input_type, | 59 env, java_obj_, input_type, |
| 56 base::android::ConvertUTF8ToJavaString(env, text)); | 60 base::android::ConvertUTF8ToJavaString(env, text)); |
| 57 } | 61 } |
| 58 | 62 |
| 59 void ImeHelperDialog::OnHideImeRequested() { | 63 void ImeHelperDialog::OnHideImeRequested() { |
| 60 JNIEnv* env = base::android::AttachCurrentThread(); | 64 JNIEnv* env = base::android::AttachCurrentThread(); |
| 61 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_); | 65 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_); |
| 62 } | 66 } |
| 63 | 67 |
| 64 void ImeHelperDialog::OnImeTextEntered(JNIEnv* env, | 68 void ImeHelperDialog::OnImeTextEntered(JNIEnv* env, |
| 65 const JavaParamRef<jobject>& jobj, | 69 const JavaParamRef<jobject>& jobj, |
| 66 const JavaParamRef<jstring>& text) { | 70 const JavaParamRef<jstring>& text) { |
| 67 std::string textInput = base::android::ConvertJavaStringToUTF8(env, text); | 71 std::string text_input = base::android::ConvertJavaStringToUTF8(env, text); |
| 68 ime_feature_->OnImeTextEntered(textInput); | 72 text_submit_callback_.Run(text_input); |
|
David Trainor- moved to gerrit
2016/08/31 18:59:54
try
base::ResetAndReturn(&text_submit_callback_)
| |
| 73 text_submit_callback_ = ImeFeature::ShowImeCallback(); | |
| 69 } | 74 } |
| 70 | 75 |
| 76 } // namespace app | |
| 71 } // namespace client | 77 } // namespace client |
| 72 } // namespace blimp | 78 } // namespace blimp |
| OLD | NEW |