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 "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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 | 341 |
| 342 void ContentViewCoreImpl::Show() { | 342 void ContentViewCoreImpl::Show() { |
| 343 GetWebContents()->WasShown(); | 343 GetWebContents()->WasShown(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 void ContentViewCoreImpl::Hide() { | 346 void ContentViewCoreImpl::Hide() { |
| 347 GetWebContents()->WasHidden(); | 347 GetWebContents()->WasHidden(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void ContentViewCoreImpl::OnTabCrashed() { | 350 void ContentViewCoreImpl::OnTabCrashed() { |
| 351 JNIEnv* env = AttachCurrentThread(); | |
| 352 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 353 if (obj.is_null()) | |
| 354 return; | |
| 355 Java_ContentViewCore_resetVSyncNotification(env, obj.obj()); | |
| 356 | |
| 351 // if tab_crashed_ is already true, just return. e.g. if two tabs share the | 357 // if tab_crashed_ is already true, just return. e.g. if two tabs share the |
| 352 // render process, this will be called for each tab when the render process | 358 // render process, this will be called for each tab when the render process |
| 353 // crashed. If user reload one tab, a new render process is created. It can be | 359 // crashed. If user reload one tab, a new render process is created. It can be |
| 354 // shared by the other tab. But if user closes the tab before reload the other | 360 // shared by the other tab. But if user closes the tab before reload the other |
| 355 // tab, the new render process will be shut down. This will trigger the other | 361 // tab, the new render process will be shut down. This will trigger the other |
| 356 // tab's OnTabCrashed() called again as two tabs share the same | 362 // tab's OnTabCrashed() called again as two tabs share the same |
| 357 // BrowserRenderProcessHost. | 363 // BrowserRenderProcessHost. |
| 358 if (tab_crashed_) | 364 if (tab_crashed_) |
| 359 return; | 365 return; |
| 360 tab_crashed_ = true; | 366 tab_crashed_ = true; |
| 361 JNIEnv* env = AttachCurrentThread(); | |
| 362 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 363 if (obj.is_null()) | |
| 364 return; | |
| 365 Java_ContentViewCore_onTabCrash(env, obj.obj()); | 367 Java_ContentViewCore_onTabCrash(env, obj.obj()); |
| 366 } | 368 } |
| 367 | 369 |
| 368 // All positions and sizes are in CSS pixels. | 370 // All positions and sizes are in CSS pixels. |
| 369 // Note that viewport_width/height is a best effort based. | 371 // Note that viewport_width/height is a best effort based. |
| 370 // ContentViewCore has the actual information about the physical viewport size. | 372 // ContentViewCore has the actual information about the physical viewport size. |
| 371 void ContentViewCoreImpl::UpdateFrameInfo( | 373 void ContentViewCoreImpl::UpdateFrameInfo( |
| 372 const gfx::Vector2dF& scroll_offset, | 374 const gfx::Vector2dF& scroll_offset, |
| 373 float page_scale_factor, | 375 float page_scale_factor, |
| 374 const gfx::Vector2dF& page_scale_factor_limits, | 376 const gfx::Vector2dF& page_scale_factor_limits, |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 void ContentViewCoreImpl::DidProduceRendererFrame() { | 672 void ContentViewCoreImpl::DidProduceRendererFrame() { |
| 671 renderer_frame_pending_ = true; | 673 renderer_frame_pending_ = true; |
| 672 } | 674 } |
| 673 | 675 |
| 674 void ContentViewCoreImpl::LoadUrl( | 676 void ContentViewCoreImpl::LoadUrl( |
| 675 NavigationController::LoadURLParams& params) { | 677 NavigationController::LoadURLParams& params) { |
| 676 GetWebContents()->GetController().LoadURLWithParams(params); | 678 GetWebContents()->GetController().LoadURLWithParams(params); |
| 677 tab_crashed_ = false; | 679 tab_crashed_ = false; |
| 678 } | 680 } |
| 679 | 681 |
| 682 void ContentViewCoreImpl::SetVSyncNotificationEnabled(bool enabled) { | |
| 683 JNIEnv* env = AttachCurrentThread(); | |
| 684 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | |
| 685 if (obj.is_null()) | |
| 686 return; | |
| 687 Java_ContentViewCore_setVSyncNotificationEnabled( | |
| 688 env, obj.obj(), static_cast<jboolean>(enabled)); | |
| 689 } | |
| 690 | |
| 680 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { | 691 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { |
| 681 return window_android_; | 692 return window_android_; |
| 682 } | 693 } |
| 683 | 694 |
| 684 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { | 695 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { |
| 685 return root_layer_.get(); | 696 return root_layer_.get(); |
| 686 } | 697 } |
| 687 | 698 |
| 688 // ---------------------------------------------------------------------------- | 699 // ---------------------------------------------------------------------------- |
| 689 // Methods called from Java via JNI | 700 // Methods called from Java via JNI |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1173 return; | 1184 return; |
| 1174 | 1185 |
| 1175 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | 1186 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
| 1176 view->GetRenderWidgetHost()); | 1187 view->GetRenderWidgetHost()); |
| 1177 | 1188 |
| 1178 host->UpdateVSyncParameters( | 1189 host->UpdateVSyncParameters( |
| 1179 base::TimeTicks::FromInternalValue(timebase_micros), | 1190 base::TimeTicks::FromInternalValue(timebase_micros), |
| 1180 base::TimeDelta::FromMicroseconds(interval_micros)); | 1191 base::TimeDelta::FromMicroseconds(interval_micros)); |
| 1181 } | 1192 } |
| 1182 | 1193 |
| 1194 void ContentViewCoreImpl::SendVSync(JNIEnv* env, jobject /* obj */, | |
| 1195 jlong frame_time_micros) { | |
| 1196 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | |
| 1197 if (!view) | |
| 1198 return; | |
| 1199 | |
| 1200 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | |
| 1201 view->GetRenderWidgetHost()); | |
| 1202 | |
| 1203 host->SendVSync(base::TimeTicks::FromInternalValue(frame_time_micros)); | |
|
no sievers
2013/04/08 17:58:06
Hmm I can't find the definition for this function.
| |
| 1204 } | |
| 1205 | |
| 1183 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, | 1206 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, |
| 1184 jobject obj, | 1207 jobject obj, |
| 1185 jobject jbitmap) { | 1208 jobject jbitmap) { |
| 1186 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1209 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 1187 if (!view) | 1210 if (!view) |
| 1188 return false; | 1211 return false; |
| 1189 | 1212 |
| 1190 return view->PopulateBitmapWithContents(jbitmap); | 1213 return view->PopulateBitmapWithContents(jbitmap); |
| 1191 } | 1214 } |
| 1192 | 1215 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1473 reinterpret_cast<WebContents*>(native_web_contents), | 1496 reinterpret_cast<WebContents*>(native_web_contents), |
| 1474 reinterpret_cast<ui::WindowAndroid*>(native_window)); | 1497 reinterpret_cast<ui::WindowAndroid*>(native_window)); |
| 1475 return reinterpret_cast<jint>(view); | 1498 return reinterpret_cast<jint>(view); |
| 1476 } | 1499 } |
| 1477 | 1500 |
| 1478 bool RegisterContentViewCore(JNIEnv* env) { | 1501 bool RegisterContentViewCore(JNIEnv* env) { |
| 1479 return RegisterNativesImpl(env); | 1502 return RegisterNativesImpl(env); |
| 1480 } | 1503 } |
| 1481 | 1504 |
| 1482 } // namespace content | 1505 } // namespace content |
| OLD | NEW |