| 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/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_impl.h" | 19 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 20 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 21 #include "content/browser/web_contents/navigation_controller_impl.h" | 21 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 22 #include "content/browser/web_contents/navigation_entry_impl.h" | 22 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 23 #include "content/browser/web_contents/web_contents_view_android.h" | 23 #include "content/browser/web_contents/web_contents_view_android.h" |
| 24 #include "content/common/view_messages.h" |
| 24 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/favicon_status.h" | 26 #include "content/public/browser/favicon_status.h" |
| 26 #include "content/public/browser/interstitial_page.h" | 27 #include "content/public/browser/interstitial_page.h" |
| 27 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
| 28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 32 #include "content/public/common/content_client.h" | 33 #include "content/public/common/content_client.h" |
| 33 #include "content/public/common/page_transition_types.h" | 34 #include "content/public/common/page_transition_types.h" |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 WebKit::WebBindings::releaseObject(bound_object); | 720 WebKit::WebBindings::releaseObject(bound_object); |
| 720 } | 721 } |
| 721 | 722 |
| 722 void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env, | 723 void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env, |
| 723 jobject /* obj */, | 724 jobject /* obj */, |
| 724 jstring name) { | 725 jstring name) { |
| 725 web_contents_->java_bridge_dispatcher_host_manager()->RemoveNamedObject( | 726 web_contents_->java_bridge_dispatcher_host_manager()->RemoveNamedObject( |
| 726 ConvertJavaStringToUTF16(env, name)); | 727 ConvertJavaStringToUTF16(env, name)); |
| 727 } | 728 } |
| 728 | 729 |
| 730 void ContentViewCoreImpl::ScrollFocusedEditableNodeIntoView(JNIEnv* env, |
| 731 jobject obj) { |
| 732 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| 733 host->Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(host->GetRoutingID(), |
| 734 gfx::Rect())); |
| 735 } |
| 736 |
| 729 int ContentViewCoreImpl::GetNavigationHistory(JNIEnv* env, | 737 int ContentViewCoreImpl::GetNavigationHistory(JNIEnv* env, |
| 730 jobject obj, | 738 jobject obj, |
| 731 jobject context) { | 739 jobject context) { |
| 732 // Iterate through navigation entries to populate the list | 740 // Iterate through navigation entries to populate the list |
| 733 const NavigationController& controller = web_contents_->GetController(); | 741 const NavigationController& controller = web_contents_->GetController(); |
| 734 int count = controller.GetEntryCount(); | 742 int count = controller.GetEntryCount(); |
| 735 for (int i = 0; i < count; ++i) { | 743 for (int i = 0; i < count; ++i) { |
| 736 NavigationEntry* entry = controller.GetEntryAtIndex(i); | 744 NavigationEntry* entry = controller.GetEntryAtIndex(i); |
| 737 | 745 |
| 738 // Get the details of the current entry | 746 // Get the details of the current entry |
| (...skipping 24 matching lines...) Expand all Loading... |
| 763 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); | 771 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
| 764 if (!rwhva) | 772 if (!rwhva) |
| 765 return 0; | 773 return 0; |
| 766 return rwhva->GetNativeImeAdapter(); | 774 return rwhva->GetNativeImeAdapter(); |
| 767 } | 775 } |
| 768 | 776 |
| 769 jboolean ContentViewCoreImpl::NeedsReload(JNIEnv* env, jobject obj) { | 777 jboolean ContentViewCoreImpl::NeedsReload(JNIEnv* env, jobject obj) { |
| 770 return web_contents_->GetController().NeedsReload(); | 778 return web_contents_->GetController().NeedsReload(); |
| 771 } | 779 } |
| 772 | 780 |
| 781 void ContentViewCoreImpl::UndoScrollFocusedEditableNodeIntoView( |
| 782 JNIEnv* env, |
| 783 jobject obj) { |
| 784 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| 785 host->Send( |
| 786 new ViewMsg_UndoScrollFocusedEditableNodeIntoView(host->GetRoutingID())); |
| 787 } |
| 788 |
| 773 jint ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env, | 789 jint ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env, |
| 774 jobject obj, | 790 jobject obj, |
| 775 jstring script) { | 791 jstring script) { |
| 776 RenderViewHost* host = web_contents_->GetRenderViewHost(); | 792 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
| 777 DCHECK(host); | 793 DCHECK(host); |
| 778 | 794 |
| 779 string16 script_utf16 = ConvertJavaStringToUTF16(env, script); | 795 string16 script_utf16 = ConvertJavaStringToUTF16(env, script); |
| 780 return host->ExecuteJavascriptInWebFrameNotifyResult(string16(), | 796 return host->ExecuteJavascriptInWebFrameNotifyResult(string16(), |
| 781 script_utf16); | 797 script_utf16); |
| 782 } | 798 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 880 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 865 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 881 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 866 return false; | 882 return false; |
| 867 } | 883 } |
| 868 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 884 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 869 | 885 |
| 870 return RegisterNativesImpl(env) >= 0; | 886 return RegisterNativesImpl(env) >= 0; |
| 871 } | 887 } |
| 872 | 888 |
| 873 } // namespace content | 889 } // namespace content |
| OLD | NEW |