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

Side by Side Diff: ui/platform_window/android/platform_ime_controller_android.cc

Issue 1487123002: Platform Window: Fixing null checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing feedback. Created 5 years 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
« no previous file with comments | « no previous file | ui/platform_window/android/platform_window_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "ui/platform_window/android/platform_ime_controller_android.h" 5 #include "ui/platform_window/android/platform_ime_controller_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "jni/PlatformImeControllerAndroid_jni.h" 9 #include "jni/PlatformImeControllerAndroid_jni.h"
10 10
(...skipping 10 matching lines...) Expand all
21 PlatformImeControllerAndroid::~PlatformImeControllerAndroid() { 21 PlatformImeControllerAndroid::~PlatformImeControllerAndroid() {
22 } 22 }
23 23
24 void PlatformImeControllerAndroid::Init(JNIEnv* env, jobject jobj) { 24 void PlatformImeControllerAndroid::Init(JNIEnv* env, jobject jobj) {
25 DCHECK(java_platform_ime_controller_android_.is_empty()); 25 DCHECK(java_platform_ime_controller_android_.is_empty());
26 java_platform_ime_controller_android_ = JavaObjectWeakGlobalRef(env, jobj); 26 java_platform_ime_controller_android_ = JavaObjectWeakGlobalRef(env, jobj);
27 } 27 }
28 28
29 void PlatformImeControllerAndroid::UpdateTextInputState( 29 void PlatformImeControllerAndroid::UpdateTextInputState(
30 const TextInputState& state) { 30 const TextInputState& state) {
31 if (java_platform_ime_controller_android_.is_empty()) 31 JNIEnv* env = base::android::AttachCurrentThread();
32 ScopedJavaLocalRef<jobject> scoped_obj =
33 java_platform_ime_controller_android_.get(env);
34 if (scoped_obj.is_null())
32 return; 35 return;
33 JNIEnv* env = base::android::AttachCurrentThread();
34 Java_PlatformImeControllerAndroid_updateTextInputState( 36 Java_PlatformImeControllerAndroid_updateTextInputState(
35 env, 37 env,
36 java_platform_ime_controller_android_.get(env).obj(), 38 scoped_obj.obj(),
37 state.type, 39 state.type,
38 state.flags, 40 state.flags,
39 base::android::ConvertUTF8ToJavaString(env, state.text).obj(), 41 base::android::ConvertUTF8ToJavaString(env, state.text).obj(),
40 state.selection_start, 42 state.selection_start,
41 state.selection_end, 43 state.selection_end,
42 state.composition_start, 44 state.composition_start,
43 state.composition_end); 45 state.composition_end);
44 } 46 }
45 47
46 void PlatformImeControllerAndroid::SetImeVisibility(bool visible) { 48 void PlatformImeControllerAndroid::SetImeVisibility(bool visible) {
47 if (java_platform_ime_controller_android_.is_empty()) 49 JNIEnv* env = base::android::AttachCurrentThread();
50 ScopedJavaLocalRef<jobject> scoped_obj =
51 java_platform_ime_controller_android_.get(env);
52 if (scoped_obj.is_null())
48 return; 53 return;
49 JNIEnv* env = base::android::AttachCurrentThread();
50 Java_PlatformImeControllerAndroid_setImeVisibility( 54 Java_PlatformImeControllerAndroid_setImeVisibility(
51 env, 55 env, scoped_obj.obj(), visible);
52 java_platform_ime_controller_android_.get(env).obj(),
53 visible);
54 } 56 }
55 57
56 } // namespace ui 58 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/platform_window/android/platform_window_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698