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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 base::android::ScopedJavaLocalRef<jobject> | 266 base::android::ScopedJavaLocalRef<jobject> |
267 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, jobject obj) { | 267 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, jobject obj) { |
268 return web_contents_->GetJavaWebContents(); | 268 return web_contents_->GetJavaWebContents(); |
269 } | 269 } |
270 | 270 |
271 void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, | 271 void ContentViewCoreImpl::OnJavaContentViewCoreDestroyed(JNIEnv* env, |
272 jobject obj) { | 272 jobject obj) { |
273 DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj)); | 273 DCHECK(env->IsSameObject(java_ref_.get(env).obj(), obj)); |
274 java_ref_.reset(); | 274 java_ref_.reset(); |
| 275 // Java peer has gone, ContentViewCore is not functional and waits to |
| 276 // be destroyed with WebContents. |
| 277 // We need to reset WebContentsViewAndroid's reference, otherwise, there |
| 278 // could have call in when swapping the WebContents, |
| 279 // see http://crbug.com/383939 . |
| 280 DCHECK(web_contents_); |
| 281 static_cast<WebContentsViewAndroid*>( |
| 282 static_cast<WebContentsImpl*>(web_contents_)->GetView())-> |
| 283 SetContentViewCore(NULL); |
275 } | 284 } |
276 | 285 |
277 void ContentViewCoreImpl::InitWebContents() { | 286 void ContentViewCoreImpl::InitWebContents() { |
278 DCHECK(web_contents_); | 287 DCHECK(web_contents_); |
279 static_cast<WebContentsViewAndroid*>( | 288 static_cast<WebContentsViewAndroid*>( |
280 static_cast<WebContentsImpl*>(web_contents_)->GetView())-> | 289 static_cast<WebContentsImpl*>(web_contents_)->GetView())-> |
281 SetContentViewCore(this); | 290 SetContentViewCore(this); |
282 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); | 291 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); |
283 web_contents_->SetUserData(kContentViewUserDataKey, | 292 web_contents_->SetUserData(kContentViewUserDataKey, |
284 new ContentViewUserData(this)); | 293 new ContentViewUserData(this)); |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1662 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1654 retained_objects_set); | 1663 retained_objects_set); |
1655 return reinterpret_cast<intptr_t>(view); | 1664 return reinterpret_cast<intptr_t>(view); |
1656 } | 1665 } |
1657 | 1666 |
1658 bool RegisterContentViewCore(JNIEnv* env) { | 1667 bool RegisterContentViewCore(JNIEnv* env) { |
1659 return RegisterNativesImpl(env); | 1668 return RegisterNativesImpl(env); |
1660 } | 1669 } |
1661 | 1670 |
1662 } // namespace content | 1671 } // namespace content |
OLD | NEW |