| OLD | NEW |
| 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 "android_webview/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| 11 #include "android_webview/browser/aw_browser_main_parts.h" | 11 #include "android_webview/browser/aw_browser_main_parts.h" |
| 12 #include "android_webview/browser/aw_resource_context.h" | 12 #include "android_webview/browser/aw_resource_context.h" |
| 13 #include "android_webview/browser/browser_view_renderer.h" | 13 #include "android_webview/browser/browser_view_renderer.h" |
| 14 #include "android_webview/browser/child_frame.h" | 14 #include "android_webview/browser/child_frame.h" |
| 15 #include "android_webview/browser/deferred_gpu_command_service.h" | 15 #include "android_webview/browser/deferred_gpu_command_service.h" |
| 16 #include "android_webview/browser/net_disk_cache_remover.h" | 16 #include "android_webview/browser/net_disk_cache_remover.h" |
| 17 #include "android_webview/browser/render_thread_manager.h" | 17 #include "android_webview/browser/render_thread_manager.h" |
| 18 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" | 18 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele
gate.h" |
| 19 #include "android_webview/browser/scoped_app_gl_state_restore.h" | 19 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
| 20 #include "android_webview/common/aw_hit_test_data.h" | 20 #include "android_webview/common/aw_hit_test_data.h" |
| 21 #include "android_webview/common/aw_switches.h" | 21 #include "android_webview/common/aw_switches.h" |
| 22 #include "android_webview/common/devtools_instrumentation.h" | 22 #include "android_webview/common/devtools_instrumentation.h" |
| 23 #include "android_webview/native/aw_autofill_client.h" | 23 #include "android_webview/native/aw_autofill_client.h" |
| 24 #include "android_webview/native/aw_contents_client_bridge.h" | 24 #include "android_webview/native/aw_contents_client_bridge.h" |
| 25 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 25 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
| 26 #include "android_webview/native/aw_contents_lifecycle_notifier.h" | 26 #include "android_webview/native/aw_contents_lifecycle_notifier.h" |
| 27 #include "android_webview/native/aw_gl_functor.h" | 27 #include "android_webview/native/aw_gl_functor.h" |
| 28 #include "android_webview/native/aw_pdf_exporter.h" | 28 #include "android_webview/native/aw_pdf_exporter.h" |
| 29 #include "android_webview/native/aw_picture.h" | 29 #include "android_webview/native/aw_picture.h" |
| 30 #include "android_webview/native/aw_renderer_priority_manager.h" |
| 30 #include "android_webview/native/aw_web_contents_delegate.h" | 31 #include "android_webview/native/aw_web_contents_delegate.h" |
| 31 #include "android_webview/native/java_browser_view_renderer_helper.h" | 32 #include "android_webview/native/java_browser_view_renderer_helper.h" |
| 32 #include "android_webview/native/permission/aw_permission_request.h" | 33 #include "android_webview/native/permission/aw_permission_request.h" |
| 33 #include "android_webview/native/permission/permission_request_handler.h" | 34 #include "android_webview/native/permission/permission_request_handler.h" |
| 34 #include "android_webview/native/permission/simple_permission_request.h" | 35 #include "android_webview/native/permission/simple_permission_request.h" |
| 35 #include "android_webview/native/state_serializer.h" | 36 #include "android_webview/native/state_serializer.h" |
| 36 #include "android_webview/public/browser/draw_gl.h" | 37 #include "android_webview/public/browser/draw_gl.h" |
| 37 #include "base/android/jni_android.h" | 38 #include "base/android/jni_android.h" |
| 38 #include "base/android/jni_array.h" | 39 #include "base/android/jni_array.h" |
| 39 #include "base/android/jni_string.h" | 40 #include "base/android/jni_string.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 #include "content/public/browser/android/synchronous_compositor.h" | 61 #include "content/public/browser/android/synchronous_compositor.h" |
| 61 #include "content/public/browser/browser_thread.h" | 62 #include "content/public/browser/browser_thread.h" |
| 62 #include "content/public/browser/child_process_security_policy.h" | 63 #include "content/public/browser/child_process_security_policy.h" |
| 63 #include "content/public/browser/favicon_status.h" | 64 #include "content/public/browser/favicon_status.h" |
| 64 #include "content/public/browser/interstitial_page.h" | 65 #include "content/public/browser/interstitial_page.h" |
| 65 #include "content/public/browser/message_port_provider.h" | 66 #include "content/public/browser/message_port_provider.h" |
| 66 #include "content/public/browser/navigation_entry.h" | 67 #include "content/public/browser/navigation_entry.h" |
| 67 #include "content/public/browser/render_frame_host.h" | 68 #include "content/public/browser/render_frame_host.h" |
| 68 #include "content/public/browser/render_process_host.h" | 69 #include "content/public/browser/render_process_host.h" |
| 69 #include "content/public/browser/render_view_host.h" | 70 #include "content/public/browser/render_view_host.h" |
| 71 #include "content/public/browser/render_widget_host.h" |
| 72 #include "content/public/browser/render_widget_host_iterator.h" |
| 70 #include "content/public/browser/ssl_status.h" | 73 #include "content/public/browser/ssl_status.h" |
| 71 #include "content/public/browser/web_contents.h" | 74 #include "content/public/browser/web_contents.h" |
| 72 #include "content/public/common/mhtml_generation_params.h" | 75 #include "content/public/common/mhtml_generation_params.h" |
| 73 #include "content/public/common/renderer_preferences.h" | 76 #include "content/public/common/renderer_preferences.h" |
| 74 #include "jni/AwContents_jni.h" | 77 #include "jni/AwContents_jni.h" |
| 75 #include "net/base/auth.h" | 78 #include "net/base/auth.h" |
| 76 #include "net/cert/x509_certificate.h" | 79 #include "net/cert/x509_certificate.h" |
| 77 #include "third_party/skia/include/core/SkPicture.h" | 80 #include "third_party/skia/include/core/SkPicture.h" |
| 78 #include "ui/gfx/android/java_bitmap.h" | 81 #include "ui/gfx/android/java_bitmap.h" |
| 79 #include "ui/gfx/geometry/rect_f.h" | 82 #include "ui/gfx/geometry/rect_f.h" |
| 80 #include "ui/gfx/geometry/size.h" | 83 #include "ui/gfx/geometry/size.h" |
| 81 #include "ui/gfx/image/image.h" | 84 #include "ui/gfx/image/image.h" |
| 82 | |
| 83 struct AwDrawSWFunctionTable; | 85 struct AwDrawSWFunctionTable; |
| 84 | 86 |
| 85 using autofill::ContentAutofillDriverFactory; | 87 using autofill::ContentAutofillDriverFactory; |
| 86 using autofill::AutofillManager; | 88 using autofill::AutofillManager; |
| 87 using base::android::AttachCurrentThread; | 89 using base::android::AttachCurrentThread; |
| 88 using base::android::ConvertJavaStringToUTF16; | 90 using base::android::ConvertJavaStringToUTF16; |
| 89 using base::android::ConvertJavaStringToUTF8; | 91 using base::android::ConvertJavaStringToUTF8; |
| 90 using base::android::ConvertUTF16ToJavaString; | 92 using base::android::ConvertUTF16ToJavaString; |
| 91 using base::android::ConvertUTF8ToJavaString; | 93 using base::android::ConvertUTF8ToJavaString; |
| 92 using base::android::JavaParamRef; | 94 using base::android::JavaParamRef; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 | 107 |
| 106 bool g_should_download_favicons = false; | 108 bool g_should_download_favicons = false; |
| 107 | 109 |
| 108 bool g_force_auxiliary_bitmap_rendering = false; | 110 bool g_force_auxiliary_bitmap_rendering = false; |
| 109 | 111 |
| 110 std::string g_locale; | 112 std::string g_locale; |
| 111 | 113 |
| 112 std::string g_locale_list; | 114 std::string g_locale_list; |
| 113 | 115 |
| 114 const void* kAwContentsUserDataKey = &kAwContentsUserDataKey; | 116 const void* kAwContentsUserDataKey = &kAwContentsUserDataKey; |
| 117 const void* kComputedRendererPriorityUserDataKey = |
| 118 &kComputedRendererPriorityUserDataKey; |
| 115 | 119 |
| 116 class AwContentsUserData : public base::SupportsUserData::Data { | 120 class AwContentsUserData : public base::SupportsUserData::Data { |
| 117 public: | 121 public: |
| 118 explicit AwContentsUserData(AwContents* ptr) : contents_(ptr) {} | 122 explicit AwContentsUserData(AwContents* ptr) : contents_(ptr) {} |
| 119 | 123 |
| 120 static AwContents* GetContents(WebContents* web_contents) { | 124 static AwContents* GetContents(WebContents* web_contents) { |
| 121 if (!web_contents) | 125 if (!web_contents) |
| 122 return NULL; | 126 return NULL; |
| 123 AwContentsUserData* data = static_cast<AwContentsUserData*>( | 127 AwContentsUserData* data = static_cast<AwContentsUserData*>( |
| 124 web_contents->GetUserData(kAwContentsUserDataKey)); | 128 web_contents->GetUserData(kAwContentsUserDataKey)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return AwContents::FromWebContents(web_contents); | 196 return AwContents::FromWebContents(web_contents); |
| 193 } | 197 } |
| 194 | 198 |
| 195 AwContents::AwContents(std::unique_ptr<WebContents> web_contents) | 199 AwContents::AwContents(std::unique_ptr<WebContents> web_contents) |
| 196 : content::WebContentsObserver(web_contents.get()), | 200 : content::WebContentsObserver(web_contents.get()), |
| 197 functor_(nullptr), | 201 functor_(nullptr), |
| 198 browser_view_renderer_( | 202 browser_view_renderer_( |
| 199 this, | 203 this, |
| 200 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)), | 204 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)), |
| 201 web_contents_(std::move(web_contents)), | 205 web_contents_(std::move(web_contents)), |
| 202 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()) { | 206 renderer_manager_key_(GLViewRendererManager::GetInstance()->NullKey()), |
| 207 renderer_requested_priority_( |
| 208 AwRendererPriorityManager::RENDERER_PRIORITY_HIGH), |
| 209 renderer_priority_waived_when_not_visible_(false) { |
| 203 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); | 210 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, 1); |
| 204 icon_helper_.reset(new IconHelper(web_contents_.get())); | 211 icon_helper_.reset(new IconHelper(web_contents_.get())); |
| 205 icon_helper_->SetListener(this); | 212 icon_helper_->SetListener(this); |
| 206 web_contents_->SetUserData(android_webview::kAwContentsUserDataKey, | 213 web_contents_->SetUserData(android_webview::kAwContentsUserDataKey, |
| 207 new AwContentsUserData(this)); | 214 new AwContentsUserData(this)); |
| 208 browser_view_renderer_.RegisterWithWebContents(web_contents_.get()); | 215 browser_view_renderer_.RegisterWithWebContents(web_contents_.get()); |
| 209 | 216 |
| 210 CompositorID compositor_id; | 217 CompositorID compositor_id; |
| 211 if (web_contents_->GetRenderProcessHost() && | 218 if (web_contents_->GetRenderProcessHost() && |
| 212 web_contents_->GetRenderViewHost()) { | 219 web_contents_->GetRenderViewHost()) { |
| 213 compositor_id.process_id = web_contents_->GetRenderProcessHost()->GetID(); | 220 compositor_id.process_id = web_contents_->GetRenderProcessHost()->GetID(); |
| 214 compositor_id.routing_id = | 221 compositor_id.routing_id = |
| 215 web_contents_->GetRenderViewHost()->GetRoutingID(); | 222 web_contents_->GetRenderViewHost()->GetRoutingID(); |
| 216 } | 223 } |
| 217 | 224 |
| 218 browser_view_renderer_.SetActiveCompositorID(compositor_id); | 225 browser_view_renderer_.SetActiveCompositorID(compositor_id); |
| 219 render_view_host_ext_.reset( | 226 render_view_host_ext_.reset( |
| 220 new AwRenderViewHostExt(this, web_contents_.get())); | 227 new AwRenderViewHostExt(this, web_contents_.get())); |
| 221 | 228 |
| 222 permission_request_handler_.reset( | 229 permission_request_handler_.reset( |
| 223 new PermissionRequestHandler(this, web_contents_.get())); | 230 new PermissionRequestHandler(this, web_contents_.get())); |
| 224 | 231 |
| 225 AwAutofillClient* autofill_manager_delegate = | 232 AwAutofillClient* autofill_manager_delegate = |
| 226 AwAutofillClient::FromWebContents(web_contents_.get()); | 233 AwAutofillClient::FromWebContents(web_contents_.get()); |
| 227 if (autofill_manager_delegate) | 234 if (autofill_manager_delegate) |
| 228 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); | 235 InitAutofillIfNecessary(autofill_manager_delegate->GetSaveFormData()); |
| 229 content::SynchronousCompositor::SetClientForWebContents( | 236 content::SynchronousCompositor::SetClientForWebContents( |
| 230 web_contents_.get(), &browser_view_renderer_); | 237 web_contents_.get(), &browser_view_renderer_); |
| 238 UpdateRendererPriority(); |
| 239 web_contents_->GetRenderProcessHost()->AddObserver(this); |
| 231 AwContentsLifecycleNotifier::OnWebViewCreated(); | 240 AwContentsLifecycleNotifier::OnWebViewCreated(); |
| 232 } | 241 } |
| 233 | 242 |
| 234 void AwContents::SetJavaPeers( | 243 void AwContents::SetJavaPeers( |
| 235 JNIEnv* env, | 244 JNIEnv* env, |
| 236 const JavaParamRef<jobject>& obj, | 245 const JavaParamRef<jobject>& obj, |
| 237 const JavaParamRef<jobject>& aw_contents, | 246 const JavaParamRef<jobject>& aw_contents, |
| 238 const JavaParamRef<jobject>& web_contents_delegate, | 247 const JavaParamRef<jobject>& web_contents_delegate, |
| 239 const JavaParamRef<jobject>& contents_client_bridge, | 248 const JavaParamRef<jobject>& contents_client_bridge, |
| 240 const JavaParamRef<jobject>& io_thread_client, | 249 const JavaParamRef<jobject>& io_thread_client, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 309 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 301 JNIEnv* env = AttachCurrentThread(); | 310 JNIEnv* env = AttachCurrentThread(); |
| 302 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 311 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 303 if (obj.is_null()) | 312 if (obj.is_null()) |
| 304 return; | 313 return; |
| 305 Java_AwContents_setAwAutofillClient(env, obj, client); | 314 Java_AwContents_setAwAutofillClient(env, obj, client); |
| 306 } | 315 } |
| 307 | 316 |
| 308 AwContents::~AwContents() { | 317 AwContents::~AwContents() { |
| 309 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_.get())); | 318 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_.get())); |
| 319 web_contents_->GetRenderProcessHost()->RemoveObserver(this); |
| 320 UpdateRendererPriority(AwRendererPriorityManager::RENDERER_PRIORITY_WAIVED); |
| 310 web_contents_->RemoveUserData(kAwContentsUserDataKey); | 321 web_contents_->RemoveUserData(kAwContentsUserDataKey); |
| 311 if (find_helper_.get()) | 322 if (find_helper_.get()) |
| 312 find_helper_->SetListener(NULL); | 323 find_helper_->SetListener(NULL); |
| 313 if (icon_helper_.get()) | 324 if (icon_helper_.get()) |
| 314 icon_helper_->SetListener(NULL); | 325 icon_helper_->SetListener(NULL); |
| 315 base::subtle::Atomic32 instance_count = | 326 base::subtle::Atomic32 instance_count = |
| 316 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); | 327 base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1); |
| 317 // When the last WebView is destroyed free all discardable memory allocated by | 328 // When the last WebView is destroyed free all discardable memory allocated by |
| 318 // Chromium, because the app process may continue to run for a long time | 329 // Chromium, because the app process may continue to run for a long time |
| 319 // without ever using another WebView. | 330 // without ever using another WebView. |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 int oh) { | 863 int oh) { |
| 853 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 864 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 854 browser_view_renderer_.OnSizeChanged(w, h); | 865 browser_view_renderer_.OnSizeChanged(w, h); |
| 855 } | 866 } |
| 856 | 867 |
| 857 void AwContents::SetViewVisibility(JNIEnv* env, | 868 void AwContents::SetViewVisibility(JNIEnv* env, |
| 858 const JavaParamRef<jobject>& obj, | 869 const JavaParamRef<jobject>& obj, |
| 859 bool visible) { | 870 bool visible) { |
| 860 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 871 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 861 browser_view_renderer_.SetViewVisibility(visible); | 872 browser_view_renderer_.SetViewVisibility(visible); |
| 873 UpdateRendererPriority(); |
| 862 } | 874 } |
| 863 | 875 |
| 864 void AwContents::SetWindowVisibility(JNIEnv* env, | 876 void AwContents::SetWindowVisibility(JNIEnv* env, |
| 865 const JavaParamRef<jobject>& obj, | 877 const JavaParamRef<jobject>& obj, |
| 866 bool visible) { | 878 bool visible) { |
| 867 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 879 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 868 browser_view_renderer_.SetWindowVisibility(visible); | 880 browser_view_renderer_.SetWindowVisibility(visible); |
| 881 UpdateRendererPriority(); |
| 869 } | 882 } |
| 870 | 883 |
| 871 void AwContents::SetIsPaused(JNIEnv* env, | 884 void AwContents::SetIsPaused(JNIEnv* env, |
| 872 const JavaParamRef<jobject>& obj, | 885 const JavaParamRef<jobject>& obj, |
| 873 bool paused) { | 886 bool paused) { |
| 874 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 887 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 875 browser_view_renderer_.SetIsPaused(paused); | 888 browser_view_renderer_.SetIsPaused(paused); |
| 889 UpdateRendererPriority(); |
| 876 } | 890 } |
| 877 | 891 |
| 878 void AwContents::OnAttachedToWindow(JNIEnv* env, | 892 void AwContents::OnAttachedToWindow(JNIEnv* env, |
| 879 const JavaParamRef<jobject>& obj, | 893 const JavaParamRef<jobject>& obj, |
| 880 int w, | 894 int w, |
| 881 int h) { | 895 int h) { |
| 882 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 896 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 883 browser_view_renderer_.OnAttachedToWindow(w, h); | 897 browser_view_renderer_.OnAttachedToWindow(w, h); |
| 898 UpdateRendererPriority(); |
| 884 } | 899 } |
| 885 | 900 |
| 886 void AwContents::OnDetachedFromWindow(JNIEnv* env, | 901 void AwContents::OnDetachedFromWindow(JNIEnv* env, |
| 887 const JavaParamRef<jobject>& obj) { | 902 const JavaParamRef<jobject>& obj) { |
| 888 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 903 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 889 browser_view_renderer_.OnDetachedFromWindow(); | 904 browser_view_renderer_.OnDetachedFromWindow(); |
| 905 UpdateRendererPriority(); |
| 890 } | 906 } |
| 891 | 907 |
| 892 bool AwContents::IsVisible(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 908 bool AwContents::IsVisible(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 893 return browser_view_renderer_.IsClientVisible(); | 909 return browser_view_renderer_.IsClientVisible(); |
| 894 } | 910 } |
| 895 | 911 |
| 896 base::android::ScopedJavaLocalRef<jbyteArray> AwContents::GetOpaqueState( | 912 base::android::ScopedJavaLocalRef<jbyteArray> AwContents::GetOpaqueState( |
| 897 JNIEnv* env, | 913 JNIEnv* env, |
| 898 const JavaParamRef<jobject>& obj) { | 914 const JavaParamRef<jobject>& obj) { |
| 899 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 915 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 JNIEnv* env, | 1182 JNIEnv* env, |
| 1167 const JavaParamRef<jobject>& obj, | 1183 const JavaParamRef<jobject>& obj, |
| 1168 jlong request_id, | 1184 jlong request_id, |
| 1169 const JavaParamRef<jobject>& callback) { | 1185 const JavaParamRef<jobject>& callback) { |
| 1170 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1186 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1171 web_contents_->GetMainFrame()->InsertVisualStateCallback( | 1187 web_contents_->GetMainFrame()->InsertVisualStateCallback( |
| 1172 base::Bind(&InvokeVisualStateCallback, java_ref_, request_id, | 1188 base::Bind(&InvokeVisualStateCallback, java_ref_, request_id, |
| 1173 ScopedJavaGlobalRef<jobject>(env, callback))); | 1189 ScopedJavaGlobalRef<jobject>(env, callback))); |
| 1174 } | 1190 } |
| 1175 | 1191 |
| 1192 void AwContents::UpdateRendererPriority( |
| 1193 AwRendererPriorityManager::RendererPriority base_priority) { |
| 1194 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1195 content::RenderProcessHost* rph = web_contents_->GetRenderProcessHost(); |
| 1196 AwRendererPriorityManager::RendererPriority computed_priority = base_priority; |
| 1197 |
| 1198 std::unique_ptr<content::RenderWidgetHostIterator> widgets( |
| 1199 content::RenderWidgetHost::GetRenderWidgetHosts()); |
| 1200 content::RenderWidgetHost* widget; |
| 1201 while ((widget = widgets->GetNextHost()) != nullptr && |
| 1202 computed_priority < |
| 1203 AwRendererPriorityManager::RENDERER_PRIORITY_HIGH) { |
| 1204 content::RenderViewHost* view = content::RenderViewHost::From(widget); |
| 1205 if (view && rph == view->GetProcess()) { |
| 1206 content::WebContents* wc = content::WebContents::FromRenderViewHost(view); |
| 1207 if (wc && wc != web_contents_.get()) { |
| 1208 computed_priority = |
| 1209 std::max(FromWebContents(wc)->GetComputedRendererPriority(), |
| 1210 computed_priority); |
| 1211 } |
| 1212 } |
| 1213 } |
| 1214 GetAwRendererPriorityManager()->SetRendererPriority(computed_priority); |
| 1215 } |
| 1216 |
| 1217 AwRendererPriorityManager::RendererPriority |
| 1218 AwContents::GetComputedRendererPriority() { |
| 1219 if (renderer_priority_waived_when_not_visible_ && |
| 1220 !browser_view_renderer_.IsClientVisible()) { |
| 1221 return AwRendererPriorityManager::RENDERER_PRIORITY_WAIVED; |
| 1222 } |
| 1223 return renderer_requested_priority_; |
| 1224 } |
| 1225 |
| 1226 void AwContents::UpdateRendererPriority() { |
| 1227 UpdateRendererPriority(GetComputedRendererPriority()); |
| 1228 } |
| 1229 |
| 1230 AwRendererPriorityManager* AwContents::GetAwRendererPriorityManager() { |
| 1231 content::RenderProcessHost* rph = web_contents_->GetRenderProcessHost(); |
| 1232 AwRendererPriorityManager* manager = static_cast<AwRendererPriorityManager*>( |
| 1233 rph->GetUserData(kComputedRendererPriorityUserDataKey)); |
| 1234 if (manager == nullptr) { |
| 1235 rph->SetUserData(kComputedRendererPriorityUserDataKey, |
| 1236 manager = new AwRendererPriorityManager(rph)); |
| 1237 } |
| 1238 return manager; |
| 1239 } |
| 1240 |
| 1241 AwRendererPriorityManager::RendererPriority |
| 1242 AwContents::GetCurrentRendererPriority() { |
| 1243 return GetAwRendererPriorityManager()->GetRendererPriority(); |
| 1244 } |
| 1245 |
| 1246 jint AwContents::GetRendererCurrentPriority( |
| 1247 JNIEnv* env, |
| 1248 const base::android::JavaParamRef<jobject>& obj) { |
| 1249 return GetCurrentRendererPriority(); |
| 1250 } |
| 1251 |
| 1252 jint AwContents::GetRendererRequestedPriority( |
| 1253 JNIEnv* env, |
| 1254 const base::android::JavaParamRef<jobject>& obj) { |
| 1255 return renderer_requested_priority_; |
| 1256 } |
| 1257 |
| 1258 jboolean AwContents::GetRendererPriorityWaivedWhenNotVisible( |
| 1259 JNIEnv* env, |
| 1260 const base::android::JavaParamRef<jobject>& obj) { |
| 1261 return renderer_priority_waived_when_not_visible_; |
| 1262 } |
| 1263 |
| 1264 void AwContents::SetRendererPriorityPolicy( |
| 1265 JNIEnv* env, |
| 1266 const JavaParamRef<jobject>& obj, |
| 1267 jint renderer_requested_priority, |
| 1268 jboolean renderer_priority_waived_when_not_visible) { |
| 1269 renderer_requested_priority_ = |
| 1270 static_cast<AwRendererPriorityManager::RendererPriority>( |
| 1271 renderer_requested_priority); |
| 1272 renderer_priority_waived_when_not_visible_ = |
| 1273 renderer_priority_waived_when_not_visible; |
| 1274 UpdateRendererPriority(renderer_requested_priority_); |
| 1275 } |
| 1276 |
| 1176 void AwContents::ClearView(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 1277 void AwContents::ClearView(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 1177 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1278 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1178 browser_view_renderer_.ClearView(); | 1279 browser_view_renderer_.ClearView(); |
| 1179 } | 1280 } |
| 1180 | 1281 |
| 1181 void AwContents::SetExtraHeadersForUrl( | 1282 void AwContents::SetExtraHeadersForUrl( |
| 1182 JNIEnv* env, | 1283 JNIEnv* env, |
| 1183 const JavaParamRef<jobject>& obj, | 1284 const JavaParamRef<jobject>& obj, |
| 1184 const JavaParamRef<jstring>& url, | 1285 const JavaParamRef<jstring>& url, |
| 1185 const JavaParamRef<jstring>& jextra_headers) { | 1286 const JavaParamRef<jstring>& jextra_headers) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1437 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1337 JNIEnv* env = AttachCurrentThread(); | 1438 JNIEnv* env = AttachCurrentThread(); |
| 1338 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1439 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1339 if (obj.is_null()) | 1440 if (obj.is_null()) |
| 1340 return false; | 1441 return false; |
| 1341 | 1442 |
| 1342 return Java_AwContents_onRenderProcessGoneDetail(env, obj, | 1443 return Java_AwContents_onRenderProcessGoneDetail(env, obj, |
| 1343 child_process_id, crashed); | 1444 child_process_id, crashed); |
| 1344 } | 1445 } |
| 1345 | 1446 |
| 1447 void AwContents::RenderProcessReady(content::RenderProcessHost* host) { |
| 1448 UpdateRendererPriority(); |
| 1449 } |
| 1450 |
| 1346 } // namespace android_webview | 1451 } // namespace android_webview |
| OLD | NEW |