| 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" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 151 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
| 152 bool hardware_accelerated, | 152 bool hardware_accelerated, |
| 153 bool input_events_delivered_at_vsync, | 153 bool input_events_delivered_at_vsync, |
| 154 WebContents* web_contents, | 154 WebContents* web_contents, |
| 155 ui::WindowAndroid* window_android) | 155 ui::WindowAndroid* window_android) |
| 156 : java_ref_(env, obj), | 156 : java_ref_(env, obj), |
| 157 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 157 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 158 root_layer_(cc::Layer::Create()), | 158 root_layer_(cc::Layer::Create()), |
| 159 tab_crashed_(false), | 159 tab_crashed_(false), |
| 160 input_events_delivered_at_vsync_(input_events_delivered_at_vsync), | 160 input_events_delivered_at_vsync_(input_events_delivered_at_vsync), |
| 161 renderer_frame_pending_(false), | |
| 162 window_android_(window_android) { | 161 window_android_(window_android) { |
| 163 CHECK(web_contents) << | 162 CHECK(web_contents) << |
| 164 "A ContentViewCoreImpl should be created with a valid WebContents."; | 163 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 165 | 164 |
| 166 // When a tab is restored (from a saved state), it does not have a renderer | 165 // When a tab is restored (from a saved state), it does not have a renderer |
| 167 // process. We treat it like the tab is crashed. If the content is loaded | 166 // process. We treat it like the tab is crashed. If the content is loaded |
| 168 // when the tab is shown, tab_crashed_ will be reset. Since | 167 // when the tab is shown, tab_crashed_ will be reset. Since |
| 169 // RenderWidgetHostView is associated with the lifetime of the renderer | 168 // RenderWidgetHostView is associated with the lifetime of the renderer |
| 170 // process, we use it to test whether there is a renderer process. | 169 // process, we use it to test whether there is a renderer process. |
| 171 tab_crashed_ = !(web_contents->GetRenderWidgetHostView()); | 170 tab_crashed_ = !(web_contents->GetRenderWidgetHostView()); |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 659 } |
| 661 | 660 |
| 662 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { | 661 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
| 663 root_layer_->AddChild(layer); | 662 root_layer_->AddChild(layer); |
| 664 } | 663 } |
| 665 | 664 |
| 666 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { | 665 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { |
| 667 layer->RemoveFromParent(); | 666 layer->RemoveFromParent(); |
| 668 } | 667 } |
| 669 | 668 |
| 670 void ContentViewCoreImpl::DidProduceRendererFrame() { | |
| 671 renderer_frame_pending_ = true; | |
| 672 } | |
| 673 | |
| 674 void ContentViewCoreImpl::LoadUrl( | 669 void ContentViewCoreImpl::LoadUrl( |
| 675 NavigationController::LoadURLParams& params) { | 670 NavigationController::LoadURLParams& params) { |
| 676 GetWebContents()->GetController().LoadURLWithParams(params); | 671 GetWebContents()->GetController().LoadURLWithParams(params); |
| 677 tab_crashed_ = false; | 672 tab_crashed_ = false; |
| 678 } | 673 } |
| 679 | 674 |
| 680 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { | 675 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { |
| 681 return window_android_; | 676 return window_android_; |
| 682 } | 677 } |
| 683 | 678 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 web_contents_, false, url, delegate); | 1200 web_contents_, false, url, delegate); |
| 1206 delegate->set_interstitial_page(interstitial); | 1201 delegate->set_interstitial_page(interstitial); |
| 1207 interstitial->Show(); | 1202 interstitial->Show(); |
| 1208 } | 1203 } |
| 1209 | 1204 |
| 1210 jboolean ContentViewCoreImpl::IsShowingInterstitialPage(JNIEnv* env, | 1205 jboolean ContentViewCoreImpl::IsShowingInterstitialPage(JNIEnv* env, |
| 1211 jobject obj) { | 1206 jobject obj) { |
| 1212 return web_contents_->ShowingInterstitialPage(); | 1207 return web_contents_->ShowingInterstitialPage(); |
| 1213 } | 1208 } |
| 1214 | 1209 |
| 1215 jboolean ContentViewCoreImpl::ConsumePendingRendererFrame(JNIEnv* env, | |
| 1216 jobject obj) { | |
| 1217 bool had_pending_frame = renderer_frame_pending_; | |
| 1218 renderer_frame_pending_ = false; | |
| 1219 return had_pending_frame; | |
| 1220 } | |
| 1221 | |
| 1222 void ContentViewCoreImpl::AttachExternalVideoSurface(JNIEnv* env, | 1210 void ContentViewCoreImpl::AttachExternalVideoSurface(JNIEnv* env, |
| 1223 jobject obj, | 1211 jobject obj, |
| 1224 jint player_id, | 1212 jint player_id, |
| 1225 jobject jsurface) { | 1213 jobject jsurface) { |
| 1226 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 1214 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| 1227 web_contents_->GetRenderViewHost()); | 1215 web_contents_->GetRenderViewHost()); |
| 1228 if (rvhi && rvhi->media_player_manager()) { | 1216 if (rvhi && rvhi->media_player_manager()) { |
| 1229 rvhi->media_player_manager()->AttachExternalVideoSurface( | 1217 rvhi->media_player_manager()->AttachExternalVideoSurface( |
| 1230 static_cast<int>(player_id), jsurface); | 1218 static_cast<int>(player_id), jsurface); |
| 1231 } | 1219 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 reinterpret_cast<WebContents*>(native_web_contents), | 1467 reinterpret_cast<WebContents*>(native_web_contents), |
| 1480 reinterpret_cast<ui::WindowAndroid*>(native_window)); | 1468 reinterpret_cast<ui::WindowAndroid*>(native_window)); |
| 1481 return reinterpret_cast<jint>(view); | 1469 return reinterpret_cast<jint>(view); |
| 1482 } | 1470 } |
| 1483 | 1471 |
| 1484 bool RegisterContentViewCore(JNIEnv* env) { | 1472 bool RegisterContentViewCore(JNIEnv* env) { |
| 1485 return RegisterNativesImpl(env); | 1473 return RegisterNativesImpl(env); |
| 1486 } | 1474 } |
| 1487 | 1475 |
| 1488 } // namespace content | 1476 } // namespace content |
| OLD | NEW |