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*>( | |
Yaron
2014/06/30 23:45:03
Ok, the only other consideration is that the WebCo
michaelbai
2014/07/01 01:10:40
How this could happen? from current code path, we
| |
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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1690 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1699 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1691 retained_objects_set); | 1700 retained_objects_set); |
1692 return reinterpret_cast<intptr_t>(view); | 1701 return reinterpret_cast<intptr_t>(view); |
1693 } | 1702 } |
1694 | 1703 |
1695 bool RegisterContentViewCore(JNIEnv* env) { | 1704 bool RegisterContentViewCore(JNIEnv* env) { |
1696 return RegisterNativesImpl(env); | 1705 return RegisterNativesImpl(env); |
1697 } | 1706 } |
1698 | 1707 |
1699 } // namespace content | 1708 } // namespace content |
OLD | NEW |