| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 env->GetIntField(obj, g_native_content_view)); | 156 env->GetIntField(obj, g_native_content_view)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 159 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
| 160 bool hardware_accelerated, | 160 bool hardware_accelerated, |
| 161 bool input_events_delivered_at_vsync, | 161 bool input_events_delivered_at_vsync, |
| 162 WebContents* web_contents, | 162 WebContents* web_contents, |
| 163 ui::WindowAndroid* window_android) | 163 ui::WindowAndroid* window_android) |
| 164 : java_ref_(env, obj), | 164 : java_ref_(env, obj), |
| 165 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 165 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 166 root_layer_(cc::Layer::create()), | 166 root_layer_(cc::Layer::Create()), |
| 167 tab_crashed_(false), | 167 tab_crashed_(false), |
| 168 input_events_delivered_at_vsync_(input_events_delivered_at_vsync), | 168 input_events_delivered_at_vsync_(input_events_delivered_at_vsync), |
| 169 renderer_frame_pending_(false), | 169 renderer_frame_pending_(false), |
| 170 window_android_(window_android) { | 170 window_android_(window_android) { |
| 171 CHECK(web_contents) << | 171 CHECK(web_contents) << |
| 172 "A ContentViewCoreImpl should be created with a valid WebContents."; | 172 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 173 | 173 |
| 174 // When a tab is restored (from a saved state), it does not have a renderer | 174 // When a tab is restored (from a saved state), it does not have a renderer |
| 175 // process. We treat it like the tab is crashed. If the content is loaded | 175 // process. We treat it like the tab is crashed. If the content is loaded |
| 176 // when the tab is shown, tab_crashed_ will be reset. Since | 176 // when the tab is shown, tab_crashed_ will be reset. Since |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj.obj()), | 637 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj.obj()), |
| 638 Java_ContentViewCore_getViewportHeightPix(env, j_obj.obj())); | 638 Java_ContentViewCore_getViewportHeightPix(env, j_obj.obj())); |
| 639 } | 639 } |
| 640 | 640 |
| 641 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { | 641 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { |
| 642 return gfx::ToCeiledSize( | 642 return gfx::ToCeiledSize( |
| 643 gfx::ScaleSize(GetViewportSizePix(), 1.0f / GetDpiScale())); | 643 gfx::ScaleSize(GetViewportSizePix(), 1.0f / GetDpiScale())); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { | 646 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
| 647 root_layer_->addChild(layer); | 647 root_layer_->AddChild(layer); |
| 648 } | 648 } |
| 649 | 649 |
| 650 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { | 650 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { |
| 651 layer->removeFromParent(); | 651 layer->RemoveFromParent(); |
| 652 } | 652 } |
| 653 | 653 |
| 654 void ContentViewCoreImpl::DidProduceRendererFrame() { | 654 void ContentViewCoreImpl::DidProduceRendererFrame() { |
| 655 renderer_frame_pending_ = true; | 655 renderer_frame_pending_ = true; |
| 656 } | 656 } |
| 657 | 657 |
| 658 void ContentViewCoreImpl::LoadUrl( | 658 void ContentViewCoreImpl::LoadUrl( |
| 659 NavigationController::LoadURLParams& params) { | 659 NavigationController::LoadURLParams& params) { |
| 660 GetWebContents()->GetController().LoadURLWithParams(params); | 660 GetWebContents()->GetController().LoadURLWithParams(params); |
| 661 tab_crashed_ = false; | 661 tab_crashed_ = false; |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1434 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 1435 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1435 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 1436 return false; | 1436 return false; |
| 1437 } | 1437 } |
| 1438 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1438 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 1439 | 1439 |
| 1440 return RegisterNativesImpl(env) >= 0; | 1440 return RegisterNativesImpl(env) >= 0; |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 } // namespace content | 1443 } // namespace content |
| OLD | NEW |