Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / ui / platform_window / android / platform_ime_controller_android.cc
blob58a04ec95835bb9c153fb7d1d786e15d7d38b4a2
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"
11 namespace ui {
13 // static
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())
32 return;
33 JNIEnv* env = base::android::AttachCurrentThread();
34 Java_PlatformImeControllerAndroid_updateTextInputState(
35 env,
36 java_platform_ime_controller_android_.get(env).obj(),
37 state.type,
38 state.flags,
39 base::android::ConvertUTF8ToJavaString(env, state.text).obj(),
40 state.selection_start,
41 state.selection_end,
42 state.composition_start,
43 state.composition_end);
46 void PlatformImeControllerAndroid::SetImeVisibility(bool visible) {
47 if (java_platform_ime_controller_android_.is_empty())
48 return;
49 JNIEnv* env = base::android::AttachCurrentThread();
50 Java_PlatformImeControllerAndroid_setImeVisibility(
51 env,
52 java_platform_ime_controller_android_.get(env).obj(),
53 visible);
56 } // namespace ui