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

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

Issue 2785543003: 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 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 void ContentViewCoreImpl::WasResized(JNIEnv* env, 1125 void ContentViewCoreImpl::WasResized(JNIEnv* env,
1126 const JavaParamRef<jobject>& obj) { 1126 const JavaParamRef<jobject>& obj) {
1127 gfx::Size physical_size( 1127 gfx::Size physical_size(
1128 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), 1128 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
1129 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); 1129 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
1130 GetViewAndroid()->GetLayer()->SetBounds(physical_size); 1130 GetViewAndroid()->GetLayer()->SetBounds(physical_size);
1131 1131
1132 SendScreenRectsAndResizeWidget(); 1132 SendScreenRectsAndResizeWidget();
1133 } 1133 }
1134 1134
1135 void ContentViewCoreImpl::UpdateImeAdapter(int text_input_type, 1135 long ContentViewCoreImpl::GetNativeImeAdapter(
1136 JNIEnv* env,
1137 const JavaParamRef<jobject>& obj) {
1138 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
1139 if (!rwhva)
1140 return 0;
1141 return rwhva->GetNativeImeAdapter();
1142 }
1143
1144 void ContentViewCoreImpl::ForceUpdateImeAdapter(long native_ime_adapter) {
1145 JNIEnv* env = AttachCurrentThread();
1146 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1147 if (obj.is_null())
1148 return;
1149 Java_ContentViewCore_forceUpdateImeAdapter(env, obj, native_ime_adapter);
1150 }
1151
1152 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter,
1153 int text_input_type,
1136 int text_input_flags, 1154 int text_input_flags,
1137 int text_input_mode, 1155 int text_input_mode,
1138 const std::string& text, 1156 const std::string& text,
1139 int selection_start, 1157 int selection_start,
1140 int selection_end, 1158 int selection_end,
1141 int composition_start, 1159 int composition_start,
1142 int composition_end, 1160 int composition_end,
1143 bool show_ime_if_needed, 1161 bool show_ime_if_needed,
1144 bool reply_to_request) { 1162 bool reply_to_request) {
1145 JNIEnv* env = AttachCurrentThread(); 1163 JNIEnv* env = AttachCurrentThread();
1146 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1164 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1147 if (obj.is_null()) 1165 if (obj.is_null())
1148 return; 1166 return;
1149 1167
1150 ScopedJavaLocalRef<jstring> jstring_text = ConvertUTF8ToJavaString(env, text); 1168 ScopedJavaLocalRef<jstring> jstring_text = ConvertUTF8ToJavaString(env, text);
1151 Java_ContentViewCore_updateImeAdapter( 1169 Java_ContentViewCore_updateImeAdapter(
1152 env, obj, text_input_type, text_input_flags, text_input_mode, 1170 env, obj, native_ime_adapter, text_input_type, text_input_flags,
1153 jstring_text, selection_start, selection_end, composition_start, 1171 text_input_mode, jstring_text, selection_start, selection_end,
1154 composition_end, show_ime_if_needed, reply_to_request); 1172 composition_start, composition_end, show_ime_if_needed, reply_to_request);
1155 } 1173 }
1156 1174
1157 void ContentViewCoreImpl::SetAccessibilityEnabled( 1175 void ContentViewCoreImpl::SetAccessibilityEnabled(
1158 JNIEnv* env, 1176 JNIEnv* env,
1159 const JavaParamRef<jobject>& obj, 1177 const JavaParamRef<jobject>& obj,
1160 bool enabled) { 1178 bool enabled) {
1161 SetAccessibilityEnabledInternal(enabled); 1179 SetAccessibilityEnabledInternal(enabled);
1162 } 1180 }
1163 1181
1164 void ContentViewCoreImpl::SetTextTrackSettings( 1182 void ContentViewCoreImpl::SetTextTrackSettings(
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 DCHECK(wcva); 1369 DCHECK(wcva);
1352 wcva->SetContentViewCore(NULL); 1370 wcva->SetContentViewCore(NULL);
1353 } 1371 }
1354 1372
1355 // This is called for each ContentView. 1373 // This is called for each ContentView.
1356 jlong Init(JNIEnv* env, 1374 jlong Init(JNIEnv* env,
1357 const JavaParamRef<jobject>& obj, 1375 const JavaParamRef<jobject>& obj,
1358 const JavaParamRef<jobject>& jweb_contents, 1376 const JavaParamRef<jobject>& jweb_contents,
1359 const JavaParamRef<jobject>& jview_android_delegate, 1377 const JavaParamRef<jobject>& jview_android_delegate,
1360 jlong jwindow_android, 1378 jlong jwindow_android,
1361 jfloat dip_scale, 1379 jfloat dipScale,
1362 const JavaParamRef<jobject>& retained_objects_set) { 1380 const JavaParamRef<jobject>& retained_objects_set) {
1363 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 1381 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
1364 WebContents::FromJavaWebContents(jweb_contents)); 1382 WebContents::FromJavaWebContents(jweb_contents));
1365 CHECK(web_contents) << 1383 CHECK(web_contents) <<
1366 "A ContentViewCoreImpl should be created with a valid WebContents."; 1384 "A ContentViewCoreImpl should be created with a valid WebContents.";
1367 ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView(); 1385 ui::ViewAndroid* view_android = web_contents->GetView()->GetNativeView();
1368 view_android->SetDelegate(jview_android_delegate); 1386 view_android->SetDelegate(jview_android_delegate);
1369 view_android->SetLayout(ui::ViewAndroid::LayoutParams::MatchParent()); 1387 view_android->SetLayout(ui::ViewAndroid::LayoutParams::MatchParent());
1370 1388
1371 ui::WindowAndroid* window_android = 1389 ui::WindowAndroid* window_android =
1372 reinterpret_cast<ui::WindowAndroid*>(jwindow_android); 1390 reinterpret_cast<ui::WindowAndroid*>(jwindow_android);
1373 DCHECK(window_android); 1391 DCHECK(window_android);
1374 window_android->AddChild(view_android); 1392 window_android->AddChild(view_android);
1375 1393
1394 // TODO: pass dipScale.
1376 ContentViewCoreImpl* view = new ContentViewCoreImpl( 1395 ContentViewCoreImpl* view = new ContentViewCoreImpl(
1377 env, obj, web_contents, dip_scale, retained_objects_set); 1396 env, obj, web_contents, dipScale, retained_objects_set);
1378 return reinterpret_cast<intptr_t>(view); 1397 return reinterpret_cast<intptr_t>(view);
1379 } 1398 }
1380 1399
1381 static ScopedJavaLocalRef<jobject> FromWebContentsAndroid( 1400 static ScopedJavaLocalRef<jobject> FromWebContentsAndroid(
1382 JNIEnv* env, 1401 JNIEnv* env,
1383 const JavaParamRef<jclass>& clazz, 1402 const JavaParamRef<jclass>& clazz,
1384 const JavaParamRef<jobject>& jweb_contents) { 1403 const JavaParamRef<jobject>& jweb_contents) {
1385 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents); 1404 WebContents* web_contents = WebContents::FromJavaWebContents(jweb_contents);
1386 if (!web_contents) 1405 if (!web_contents)
1387 return ScopedJavaLocalRef<jobject>(); 1406 return ScopedJavaLocalRef<jobject>();
1388 1407
1389 ContentViewCore* view = ContentViewCore::FromWebContents(web_contents); 1408 ContentViewCore* view = ContentViewCore::FromWebContents(web_contents);
1390 if (!view) 1409 if (!view)
1391 return ScopedJavaLocalRef<jobject>(); 1410 return ScopedJavaLocalRef<jobject>();
1392 1411
1393 return view->GetJavaObject(); 1412 return view->GetJavaObject();
1394 } 1413 }
1395 1414
1396 bool RegisterContentViewCore(JNIEnv* env) { 1415 bool RegisterContentViewCore(JNIEnv* env) {
1397 return RegisterNativesImpl(env); 1416 return RegisterNativesImpl(env);
1398 } 1417 }
1399 1418
1400 } // namespace content 1419 } // 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