| 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 "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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 InitWebContents(); | 193 InitWebContents(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 ContentViewCoreImpl::~ContentViewCoreImpl() { | 196 ContentViewCoreImpl::~ContentViewCoreImpl() { |
| 197 JNIEnv* env = base::android::AttachCurrentThread(); | 197 JNIEnv* env = base::android::AttachCurrentThread(); |
| 198 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 198 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 199 java_ref_.reset(); | 199 java_ref_.reset(); |
| 200 if (!j_obj.is_null()) { | 200 if (!j_obj.is_null()) { |
| 201 Java_ContentViewCore_onNativeContentViewCoreDestroyed( | 201 Java_ContentViewCore_onNativeContentViewCoreDestroyed( |
| 202 env, j_obj.obj(), reinterpret_cast<jint>(this)); | 202 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); |
| 203 } | 203 } |
| 204 // Make sure nobody calls back into this object while we are tearing things | 204 // Make sure nobody calls back into this object while we are tearing things |
| 205 // down. | 205 // down. |
| 206 notification_registrar_.RemoveAll(); | 206 notification_registrar_.RemoveAll(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, | 209 void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, |
| 210 jobject obj) { | 210 jobject obj) { |
| 211 DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj)); | 211 DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj)); |
| 212 java_ref_.reset(); | 212 java_ref_.reset(); |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1642 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| 1643 if (rwhv) | 1643 if (rwhv) |
| 1644 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); | 1644 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); |
| 1645 | 1645 |
| 1646 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 1646 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| 1647 web_contents_->GetRenderViewHost()); | 1647 web_contents_->GetRenderViewHost()); |
| 1648 rvhi->SendOrientationChangeEvent(device_orientation_); | 1648 rvhi->SendOrientationChangeEvent(device_orientation_); |
| 1649 } | 1649 } |
| 1650 | 1650 |
| 1651 // This is called for each ContentView. | 1651 // This is called for each ContentView. |
| 1652 jint Init(JNIEnv* env, jobject obj, | 1652 jlong Init(JNIEnv* env, jobject obj, |
| 1653 jboolean hardware_accelerated, | 1653 jboolean hardware_accelerated, |
| 1654 jint native_web_contents, | 1654 jlong native_web_contents, |
| 1655 jlong view_android, | 1655 jlong view_android, |
| 1656 jlong window_android) { | 1656 jlong window_android) { |
| 1657 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1657 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
| 1658 env, obj, hardware_accelerated, | 1658 env, obj, hardware_accelerated, |
| 1659 reinterpret_cast<WebContents*>(native_web_contents), | 1659 reinterpret_cast<WebContents*>(native_web_contents), |
| 1660 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1660 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1661 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1661 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1662 return reinterpret_cast<jint>(view); | 1662 return reinterpret_cast<intptr_t>(view); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 bool RegisterContentViewCore(JNIEnv* env) { | 1665 bool RegisterContentViewCore(JNIEnv* env) { |
| 1666 return RegisterNativesImpl(env); | 1666 return RegisterNativesImpl(env); |
| 1667 } | 1667 } |
| 1668 | 1668 |
| 1669 } // namespace content | 1669 } // namespace content |
| OLD | NEW |