1 // Copyright 2015 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.
5 #include "ui/platform_window/android/platform_ime_controller_android.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "jni/PlatformImeControllerAndroid_jni.h"
14 bool PlatformImeControllerAndroid::Register(JNIEnv
* env
) {
15 return RegisterNativesImpl(env
);
18 PlatformImeControllerAndroid::PlatformImeControllerAndroid() {
21 PlatformImeControllerAndroid::~PlatformImeControllerAndroid() {
24 void PlatformImeControllerAndroid::Init(JNIEnv
* env
, jobject jobj
) {
25 DCHECK(java_platform_ime_controller_android_
.is_empty());
26 java_platform_ime_controller_android_
= JavaObjectWeakGlobalRef(env
, jobj
);
29 void PlatformImeControllerAndroid::UpdateTextInputState(
30 const TextInputState
& state
) {
31 if (java_platform_ime_controller_android_
.is_empty())
33 JNIEnv
* env
= base::android::AttachCurrentThread();
34 Java_PlatformImeControllerAndroid_updateTextInputState(
36 java_platform_ime_controller_android_
.get(env
).obj(),
39 base::android::ConvertUTF8ToJavaString(env
, state
.text
).obj(),
40 state
.selection_start
,
42 state
.composition_start
,
43 state
.composition_end
);
46 void PlatformImeControllerAndroid::SetImeVisibility(bool visible
) {
47 if (java_platform_ime_controller_android_
.is_empty())
49 JNIEnv
* env
= base::android::AttachCurrentThread();
50 Java_PlatformImeControllerAndroid_setImeVisibility(
52 java_platform_ime_controller_android_
.get(env
).obj(),