Chromium Code Reviews| 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 "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/browser/aw_browser_main_parts.h" | 8 #include "android_webview/browser/aw_browser_main_parts.h" |
| 9 #include "android_webview/browser/browser_view_renderer_impl.h" | 9 #include "android_webview/browser/browser_view_renderer_impl.h" |
| 10 #include "android_webview/browser/net_disk_cache_remover.h" | 10 #include "android_webview/browser/net_disk_cache_remover.h" |
| 11 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 11 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
| 12 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 12 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
| 13 #include "android_webview/common/aw_hit_test_data.h" | 13 #include "android_webview/common/aw_hit_test_data.h" |
| 14 #include "android_webview/native/aw_browser_dependency_factory.h" | 14 #include "android_webview/native/aw_browser_dependency_factory.h" |
| 15 #include "android_webview/native/aw_contents_client_bridge.h" | 15 #include "android_webview/native/aw_contents_client_bridge.h" |
| 16 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 16 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
| 17 #include "android_webview/native/aw_web_contents_delegate.h" | 17 #include "android_webview/native/aw_web_contents_delegate.h" |
| 18 #include "android_webview/native/java_browser_view_renderer_helper.h" | 18 #include "android_webview/native/java_browser_view_renderer_helper.h" |
| 19 #include "android_webview/native/state_serializer.h" | 19 #include "android_webview/native/state_serializer.h" |
| 20 #include "android_webview/public/browser/draw_gl.h" | 20 #include "android_webview/public/browser/draw_gl.h" |
| 21 #include "base/android/jni_android.h" | 21 #include "base/android/jni_android.h" |
| 22 #include "base/android/jni_array.h" | 22 #include "base/android/jni_array.h" |
| 23 #include "base/android/jni_string.h" | 23 #include "base/android/jni_string.h" |
| 24 #include "base/android/scoped_java_ref.h" | |
| 24 #include "base/bind.h" | 25 #include "base/bind.h" |
| 25 #include "base/callback.h" | 26 #include "base/callback.h" |
| 26 #include "base/message_loop.h" | 27 #include "base/message_loop.h" |
| 27 #include "base/pickle.h" | 28 #include "base/pickle.h" |
| 28 #include "base/string16.h" | 29 #include "base/string16.h" |
| 29 #include "base/supports_user_data.h" | 30 #include "base/supports_user_data.h" |
| 30 #include "components/navigation_interception/intercept_navigation_delegate.h" | 31 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 31 #include "content/public/browser/android/content_view_core.h" | 32 #include "content/public/browser/android/content_view_core.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/cert_store.h" | 34 #include "content/public/browser/cert_store.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 104 const content::RenderViewHost* rvh = | 105 const content::RenderViewHost* rvh = |
| 105 content::RenderViewHost::FromID(render_process_id, render_view_id); | 106 content::RenderViewHost::FromID(render_process_id, render_view_id); |
| 106 if (!rvh) return NULL; | 107 if (!rvh) return NULL; |
| 107 content::WebContents* web_contents = | 108 content::WebContents* web_contents = |
| 108 content::WebContents::FromRenderViewHost(rvh); | 109 content::WebContents::FromRenderViewHost(rvh); |
| 109 if (!web_contents) return NULL; | 110 if (!web_contents) return NULL; |
| 110 return FromWebContents(web_contents); | 111 return FromWebContents(web_contents); |
| 111 } | 112 } |
| 112 | 113 |
| 114 // static | |
| 115 BrowserViewRenderer* BrowserViewRenderer::FromWebContents( | |
|
joth
2013/03/08 23:23:46
this is really weird here!
BrowserViewRenderer is
mnaganov (inactive)
2013/03/11 14:39:20
I would be using AwContents directly (because I'm
| |
| 116 content::WebContents* web_contents) { | |
| 117 AwContents* aw_contents = AwContents::FromWebContents(web_contents); | |
| 118 return aw_contents ? aw_contents->browser_view_renderer() : NULL; | |
| 119 } | |
| 120 | |
| 113 AwContents::AwContents(JNIEnv* env, | 121 AwContents::AwContents(JNIEnv* env, |
| 114 jobject obj, | 122 jobject obj, |
| 115 jobject web_contents_delegate, | 123 jobject web_contents_delegate, |
| 116 jobject contents_client_bridge) | 124 jobject contents_client_bridge) |
| 117 : java_ref_(env, obj), | 125 : java_ref_(env, obj), |
| 118 web_contents_delegate_( | 126 web_contents_delegate_( |
| 119 new AwWebContentsDelegate(env, web_contents_delegate)), | 127 new AwWebContentsDelegate(env, web_contents_delegate)), |
| 120 contents_client_bridge_( | 128 contents_client_bridge_( |
| 121 new AwContentsClientBridge(env, contents_client_bridge)), | 129 new AwContentsClientBridge(env, contents_client_bridge)), |
| 122 ALLOW_THIS_IN_INITIALIZER_LIST(browser_view_renderer_( | 130 ALLOW_THIS_IN_INITIALIZER_LIST(browser_view_renderer_( |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 } | 673 } |
| 666 | 674 |
| 667 void AwContents::FocusFirstNode(JNIEnv* env, jobject obj) { | 675 void AwContents::FocusFirstNode(JNIEnv* env, jobject obj) { |
| 668 web_contents_->FocusThroughTabTraversal(false); | 676 web_contents_->FocusThroughTabTraversal(false); |
| 669 } | 677 } |
| 670 | 678 |
| 671 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { | 679 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { |
| 672 return reinterpret_cast<jint>(pending_contents_.release()); | 680 return reinterpret_cast<jint>(pending_contents_.release()); |
| 673 } | 681 } |
| 674 | 682 |
| 683 bool AwContents::isAttachedToViewHierarchy() { | |
| 684 JNIEnv* env = AttachCurrentThread(); | |
| 685 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 686 if (!obj.is_null()) | |
| 687 return Java_AwContents_isAttachedToViewHierarchy(env, obj.obj()); | |
| 688 return false; | |
| 689 } | |
| 690 | |
| 691 gfx::Point AwContents::getLocationOnScreen() { | |
| 692 JNIEnv* env = AttachCurrentThread(); | |
| 693 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 694 if (obj.is_null()) return gfx::Point(); | |
| 695 std::vector<int> location; | |
| 696 base::android::JavaIntArrayToIntVector( | |
| 697 env, | |
| 698 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), | |
| 699 &location); | |
| 700 return gfx::Point(location[0], location[1]); | |
| 701 } | |
| 702 | |
| 675 ScopedJavaLocalRef<jobject> AwContents::CapturePicture(JNIEnv* env, | 703 ScopedJavaLocalRef<jobject> AwContents::CapturePicture(JNIEnv* env, |
| 676 jobject obj) { | 704 jobject obj) { |
| 677 return browser_view_renderer_->CapturePicture(); | 705 return browser_view_renderer_->CapturePicture(); |
| 678 } | 706 } |
| 679 | 707 |
| 680 void AwContents::EnableOnNewPicture(JNIEnv* env, | 708 void AwContents::EnableOnNewPicture(JNIEnv* env, |
| 681 jobject obj, | 709 jobject obj, |
| 682 jboolean enabled, | 710 jboolean enabled, |
| 683 jboolean invalidation_only) { | 711 jboolean invalidation_only) { |
| 684 BrowserViewRenderer::OnNewPictureMode mode = | 712 BrowserViewRenderer::OnNewPictureMode mode = |
| 685 BrowserViewRenderer::kOnNewPictureDisabled; | 713 BrowserViewRenderer::kOnNewPictureDisabled; |
| 686 if (enabled) { | 714 if (enabled) { |
| 687 mode = invalidation_only ? | 715 mode = invalidation_only ? |
| 688 BrowserViewRenderer::kOnNewPictureInvalidationOnly : | 716 BrowserViewRenderer::kOnNewPictureInvalidationOnly : |
| 689 BrowserViewRenderer::kOnNewPictureEnabled; | 717 BrowserViewRenderer::kOnNewPictureEnabled; |
| 690 } | 718 } |
| 691 | 719 |
| 692 browser_view_renderer_->EnableOnNewPicture(mode); | 720 browser_view_renderer_->EnableOnNewPicture(mode); |
| 693 } | 721 } |
| 694 | 722 |
| 695 } // namespace android_webview | 723 } // namespace android_webview |
| OLD | NEW |