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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2791603002: Revert of Let ImeAdapterAndroid have the same lifecycle as its Java peer (Closed)
Patch Set: Created 3 years, 8 months 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 void ContentViewCoreImpl::WasResized(JNIEnv* env, 1093 void ContentViewCoreImpl::WasResized(JNIEnv* env,
1094 const JavaParamRef<jobject>& obj) { 1094 const JavaParamRef<jobject>& obj) {
1095 gfx::Size physical_size( 1095 gfx::Size physical_size(
1096 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), 1096 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
1097 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); 1097 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
1098 GetViewAndroid()->GetLayer()->SetBounds(physical_size); 1098 GetViewAndroid()->GetLayer()->SetBounds(physical_size);
1099 1099
1100 SendScreenRectsAndResizeWidget(); 1100 SendScreenRectsAndResizeWidget();
1101 } 1101 }
1102 1102
1103 void ContentViewCoreImpl::UpdateImeAdapter(int text_input_type, 1103 long ContentViewCoreImpl::GetNativeImeAdapter(
1104 JNIEnv* env,
1105 const JavaParamRef<jobject>& obj) {
1106 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
1107 if (!rwhva)
1108 return 0;
1109 return rwhva->GetNativeImeAdapter();
1110 }
1111
1112 void ContentViewCoreImpl::ForceUpdateImeAdapter(long native_ime_adapter) {
1113 JNIEnv* env = AttachCurrentThread();
1114 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1115 if (obj.is_null())
1116 return;
1117 Java_ContentViewCore_forceUpdateImeAdapter(env, obj, native_ime_adapter);
1118 }
1119
1120 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter,
1121 int text_input_type,
1104 int text_input_flags, 1122 int text_input_flags,
1105 int text_input_mode, 1123 int text_input_mode,
1106 const std::string& text, 1124 const std::string& text,
1107 int selection_start, 1125 int selection_start,
1108 int selection_end, 1126 int selection_end,
1109 int composition_start, 1127 int composition_start,
1110 int composition_end, 1128 int composition_end,
1111 bool show_ime_if_needed, 1129 bool show_ime_if_needed,
1112 bool reply_to_request) { 1130 bool reply_to_request) {
1113 JNIEnv* env = AttachCurrentThread(); 1131 JNIEnv* env = AttachCurrentThread();
1114 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1132 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1115 if (obj.is_null()) 1133 if (obj.is_null())
1116 return; 1134 return;
1117 1135
1118 ScopedJavaLocalRef<jstring> jstring_text = ConvertUTF8ToJavaString(env, text); 1136 ScopedJavaLocalRef<jstring> jstring_text = ConvertUTF8ToJavaString(env, text);
1119 Java_ContentViewCore_updateImeAdapter( 1137 Java_ContentViewCore_updateImeAdapter(
1120 env, obj, text_input_type, text_input_flags, text_input_mode, 1138 env, obj, native_ime_adapter, text_input_type, text_input_flags,
1121 jstring_text, selection_start, selection_end, composition_start, 1139 text_input_mode, jstring_text, selection_start, selection_end,
1122 composition_end, show_ime_if_needed, reply_to_request); 1140 composition_start, composition_end, show_ime_if_needed, reply_to_request);
1123 } 1141 }
1124 1142
1125 void ContentViewCoreImpl::SetAccessibilityEnabled( 1143 void ContentViewCoreImpl::SetAccessibilityEnabled(
1126 JNIEnv* env, 1144 JNIEnv* env,
1127 const JavaParamRef<jobject>& obj, 1145 const JavaParamRef<jobject>& obj,
1128 bool enabled) { 1146 bool enabled) {
1129 SetAccessibilityEnabledInternal(enabled); 1147 SetAccessibilityEnabledInternal(enabled);
1130 } 1148 }
1131 1149
1132 void ContentViewCoreImpl::SetTextTrackSettings( 1150 void ContentViewCoreImpl::SetTextTrackSettings(
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 DCHECK(wcva); 1337 DCHECK(wcva);
1320 wcva->SetContentViewCore(NULL); 1338 wcva->SetContentViewCore(NULL);
1321 } 1339 }
1322 1340
1323 // This is called for each ContentView. 1341 // This is called for each ContentView.
1324 jlong Init(JNIEnv* env, 1342 jlong Init(JNIEnv* env,
1325 const JavaParamRef<jobject>& obj, 1343 const JavaParamRef<jobject>& obj,
1326 const JavaParamRef<jobject>& jweb_contents, 1344 const JavaParamRef<jobject>& jweb_contents,
1327 const JavaParamRef<jobject>& jview_android_delegate, 1345 const JavaParamRef<jobject>& jview_android_delegate,
1328 jlong jwindow_android, 1346 jlong jwindow_android,
1329 jfloat dip_scale, 1347 jfloat dipScale,
1330 const JavaParamRef<jobject>& retained_objects_set) { 1348 const JavaParamRef<jobject>& retained_objects_set) {
1331 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 1349 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
1332 WebContents::FromJavaWebContents(jweb_contents)); 1350 WebContents::FromJavaWebContents(jweb_contents));
1333 CHECK(web_contents) << 1351 CHECK(web_contents) <<
1334 "A ContentViewCoreImpl should be created with a valid WebContents."; 1352 "A ContentViewCoreImpl should be created with a valid WebContents.";
1335 ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView(); 1353 ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView();
1336 view_android->SetDelegate(jview_android_delegate); 1354 view_android->SetDelegate(jview_android_delegate);
1337 view_android->SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); 1355 view_android->SetLayout(ui::ViewAndroid::LayoutParams::MatchParent());
1338 1356
1339 ui::WindowAndroid* window_android = 1357 ui::WindowAndroid* window_android =
1340 reinterpret_cast<ui::WindowAndroid*>(jwindow_android); 1358 reinterpret_cast<ui::WindowAndroid*>(jwindow_android);
1341 DCHECK(window_android); 1359 DCHECK(window_android);
1342 window_android->AddChild(view_android); 1360 window_android->AddChild(view_android);
1343 1361
1362 // TODO: pass dipScale.
1344 ContentViewCoreImpl* view = new ContentViewCoreImpl( 1363 ContentViewCoreImpl* view = new ContentViewCoreImpl(
1345 env, obj, web_contents, dip_scale, retained_objects_set); 1364 env, obj, web_contents, dipScale, retained_objects_set);
1346 return reinterpret_cast<intptr_t>(view); 1365 return reinterpret_cast<intptr_t>(view);
1347 } 1366 }
1348 1367
1349 static ScopedJavaLocalRef<jobject> FromWebContentsAndroid( 1368 static ScopedJavaLocalRef<jobject> FromWebContentsAndroid(
1350 JNIEnv* env, 1369 JNIEnv* env,
1351 const JavaParamRef<jclass>& clazz, 1370 const JavaParamRef<jclass>& clazz,
1352 const JavaParamRef<jobject>& jweb_contents) { 1371 const JavaParamRef<jobject>& jweb_contents) {
1353 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); 1372 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents);
1354 if (!web_contents) 1373 if (!web_contents)
1355 return ScopedJavaLocalRef<jobject>(); 1374 return ScopedJavaLocalRef<jobject>();
1356 1375
1357 ContentViewCore* view = ContentViewCore::FromWebContents(web_contents); 1376 ContentViewCore* view = ContentViewCore::FromWebContents(web_contents);
1358 if (!view) 1377 if (!view)
1359 return ScopedJavaLocalRef<jobject>(); 1378 return ScopedJavaLocalRef<jobject>();
1360 1379
1361 return view->GetJavaObject(); 1380 return view->GetJavaObject();
1362 } 1381 }
1363 1382
1364 bool RegisterContentViewCore(JNIEnv* env) { 1383 bool RegisterContentViewCore(JNIEnv* env) {
1365 return RegisterNativesImpl(env); 1384 return RegisterNativesImpl(env);
1366 } 1385 }
1367 1386
1368 } // namespace content 1387 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/android/ime_adapter_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698