| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/android/load_url_params.h" | 14 #include "content/browser/android/load_url_params.h" |
| 15 #include "content/browser/android/touch_point.h" | 15 #include "content/browser/android/touch_point.h" |
| 16 #include "content/browser/renderer_host/java/java_bound_object.h" | 16 #include "content/browser/renderer_host/java/java_bound_object.h" |
| 17 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 17 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
| 18 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 18 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 21 #include "content/browser/ssl/ssl_host_state.h" | 22 #include "content/browser/ssl/ssl_host_state.h" |
| 22 #include "content/browser/web_contents/navigation_controller_impl.h" | 23 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 23 #include "content/browser/web_contents/navigation_entry_impl.h" | 24 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 24 #include "content/browser/web_contents/web_contents_view_android.h" | 25 #include "content/browser/web_contents/web_contents_view_android.h" |
| 25 #include "content/common/android/device_info.h" | 26 #include "content/common/android/device_info.h" |
| 26 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
| 27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 437 |
| 437 void ContentViewCoreImpl::ShowPastePopup(int x, int y) { | 438 void ContentViewCoreImpl::ShowPastePopup(int x, int y) { |
| 438 JNIEnv* env = AttachCurrentThread(); | 439 JNIEnv* env = AttachCurrentThread(); |
| 439 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 440 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 440 if (obj.is_null()) | 441 if (obj.is_null()) |
| 441 return; | 442 return; |
| 442 Java_ContentViewCore_showPastePopup(env, obj.obj(), static_cast<jint>(x), | 443 Java_ContentViewCore_showPastePopup(env, obj.obj(), static_cast<jint>(x), |
| 443 static_cast<jint>(y)); | 444 static_cast<jint>(y)); |
| 444 } | 445 } |
| 445 | 446 |
| 447 unsigned int ContentViewCoreImpl::GetScaledContentTexture( |
| 448 const gfx::Size& size) { |
| 449 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 450 if (!view) |
| 451 return 0; |
| 452 |
| 453 return view->GetScaledContentTexture(size); |
| 454 } |
| 455 |
| 446 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { | 456 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url) { |
| 447 JNIEnv* env = AttachCurrentThread(); | 457 JNIEnv* env = AttachCurrentThread(); |
| 448 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 458 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 449 if (j_obj.is_null()) | 459 if (j_obj.is_null()) |
| 450 return; | 460 return; |
| 451 ScopedJavaLocalRef<jstring> jcontent_url = | 461 ScopedJavaLocalRef<jstring> jcontent_url = |
| 452 ConvertUTF8ToJavaString(env, content_url.spec()); | 462 ConvertUTF8ToJavaString(env, content_url.spec()); |
| 453 Java_ContentViewCore_startContentIntent(env, | 463 Java_ContentViewCore_startContentIntent(env, |
| 454 j_obj.obj(), | 464 j_obj.obj(), |
| 455 jcontent_url.obj()); | 465 jcontent_url.obj()); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 return; | 880 return; |
| 871 | 881 |
| 872 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | 882 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
| 873 view->GetRenderWidgetHost()); | 883 view->GetRenderWidgetHost()); |
| 874 | 884 |
| 875 host->UpdateVSyncParameters( | 885 host->UpdateVSyncParameters( |
| 876 base::TimeTicks::FromInternalValue(timebase_micros), | 886 base::TimeTicks::FromInternalValue(timebase_micros), |
| 877 base::TimeDelta::FromMicroseconds(interval_micros)); | 887 base::TimeDelta::FromMicroseconds(interval_micros)); |
| 878 } | 888 } |
| 879 | 889 |
| 890 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, |
| 891 jobject obj, |
| 892 jobject jbitmap) { |
| 893 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 894 if (!view) |
| 895 return false; |
| 896 |
| 897 return view->PopulateBitmapWithContents(jbitmap); |
| 898 } |
| 899 |
| 880 void ContentViewCoreImpl::ScrollFocusedEditableNodeIntoView(JNIEnv* env, | 900 void ContentViewCoreImpl::ScrollFocusedEditableNodeIntoView(JNIEnv* env, |
| 881 jobject obj) { | 901 jobject obj) { |
| 882 RenderViewHost* host = web_contents_->GetRenderViewHost(); | 902 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| 883 host->Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(host->GetRoutingID(), | 903 host->Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(host->GetRoutingID(), |
| 884 gfx::Rect())); | 904 gfx::Rect())); |
| 885 } | 905 } |
| 886 | 906 |
| 887 int ContentViewCoreImpl::GetNavigationHistory(JNIEnv* env, | 907 int ContentViewCoreImpl::GetNavigationHistory(JNIEnv* env, |
| 888 jobject obj, | 908 jobject obj, |
| 889 jobject context) { | 909 jobject context) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1056 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 1037 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1057 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 1038 return false; | 1058 return false; |
| 1039 } | 1059 } |
| 1040 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1060 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 1041 | 1061 |
| 1042 return RegisterNativesImpl(env) >= 0; | 1062 return RegisterNativesImpl(env) >= 0; |
| 1043 } | 1063 } |
| 1044 | 1064 |
| 1045 } // namespace content | 1065 } // namespace content |
| OLD | NEW |