Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/client/core/contents/android/ime_helper_dialog.h" | |
| 6 | |
| 7 #include "base/android/jni_string.h" | |
| 8 #include "jni/ImeHelperDialog_jni.h" | |
| 9 #include "ui/android/window_android.h" | |
| 10 | |
| 11 using base::android::JavaParamRef; | |
| 12 | |
| 13 namespace blimp { | |
| 14 namespace client { | |
| 15 | |
| 16 // static | |
| 17 bool ImeHelperDialog::RegisterJni(JNIEnv* env) { | |
| 18 return RegisterNativesImpl(env); | |
| 19 } | |
| 20 | |
| 21 ImeHelperDialog::ImeHelperDialog(ui::WindowAndroid* window) { | |
| 22 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 23 java_obj_.Reset(Java_ImeHelperDialog_create( | |
| 24 env, reinterpret_cast<intptr_t>(this), window->GetJavaObject())); | |
| 25 } | |
| 26 | |
| 27 ImeHelperDialog::~ImeHelperDialog() { | |
| 28 Java_ImeHelperDialog_clearNativePtr(base::android::AttachCurrentThread(), | |
| 29 java_obj_); | |
| 30 } | |
| 31 | |
| 32 void ImeHelperDialog::OnShowImeRequested( | |
| 33 ui::TextInputType input_type, | |
| 34 const std::string& text, | |
| 35 const ImeFeature::ShowImeCallback& callback) { | |
| 36 text_submit_callback_ = callback; | |
| 37 | |
| 38 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 39 DCHECK_NE(ui::TEXT_INPUT_TYPE_NONE, input_type); | |
| 40 Java_ImeHelperDialog_onShowImeRequested( | |
| 41 env, java_obj_, input_type, | |
| 42 base::android::ConvertUTF8ToJavaString(env, text)); | |
| 43 } | |
| 44 | |
| 45 void ImeHelperDialog::OnHideImeRequested() { | |
| 46 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 47 Java_ImeHelperDialog_onHideImeRequested(env, java_obj_); | |
| 48 } | |
| 49 | |
| 50 void ImeHelperDialog::OnImeTextEntered(JNIEnv* env, | |
| 51 const JavaParamRef<jobject>& jobj, | |
| 52 const JavaParamRef<jstring>& text) { | |
| 53 std::string text_input = base::android::ConvertJavaStringToUTF8(env, text); | |
| 54 text_submit_callback_.Run(text_input); | |
|
David Trainor- moved to gerrit
2016/08/31 18:59:54
ResetAndReturn again?
| |
| 55 text_submit_callback_ = ImeFeature::ShowImeCallback(); | |
| 56 } | |
| 57 | |
| 58 } // namespace client | |
| 59 } // namespace blimp | |
| OLD | NEW |