Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 133073012: android: Fix ContentViewCore and RenderWidgetHostViewAndroid lifetime issue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 const base::string16& result) { 1672 const base::string16& result) {
1673 JNIEnv* env = AttachCurrentThread(); 1673 JNIEnv* env = AttachCurrentThread();
1674 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1674 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1675 if (obj.is_null()) 1675 if (obj.is_null())
1676 return; 1676 return;
1677 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); 1677 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result);
1678 Java_ContentViewCore_onSmartClipDataExtracted( 1678 Java_ContentViewCore_onSmartClipDataExtracted(
1679 env, obj.obj(), jresult.obj()); 1679 env, obj.obj(), jresult.obj());
1680 } 1680 }
1681 1681
1682 void ContentViewCoreImpl::OnDetachedFromWebContents(WebContents* web_contents) {
Ted C 2014/01/23 01:28:42 Looking more at this, why don't you do this in Con
powei 2014/01/23 01:38:02 My first instinct was to put it in the destructor
Ted C 2014/01/23 02:00:15 Hmm...that is unfortunate. If that is the case, I
powei 2014/01/23 02:38:40 Done. Turns out ContentViewCoreImpl is already a
1683 DCHECK_EQ(GetWebContents(), web_contents);
1684
1685 WebContentsViewAndroid* wcva =
1686 static_cast<WebContentsViewAndroid*>(GetWebContents()->GetView());
Ted C 2014/01/23 01:28:42 +2
powei 2014/01/23 01:38:02 Done.
1687 DCHECK(wcva);
1688 wcva->SetContentViewCore(NULL);
1689 }
1690
1682 // This is called for each ContentView. 1691 // This is called for each ContentView.
1683 jlong Init(JNIEnv* env, jobject obj, 1692 jlong Init(JNIEnv* env, jobject obj,
1684 jboolean hardware_accelerated, 1693 jboolean hardware_accelerated,
1685 jlong native_web_contents, 1694 jlong native_web_contents,
1686 jlong view_android, 1695 jlong view_android,
1687 jlong window_android) { 1696 jlong window_android) {
1688 ContentViewCoreImpl* view = new ContentViewCoreImpl( 1697 ContentViewCoreImpl* view = new ContentViewCoreImpl(
1689 env, obj, hardware_accelerated, 1698 env, obj, hardware_accelerated,
1690 reinterpret_cast<WebContents*>(native_web_contents), 1699 reinterpret_cast<WebContents*>(native_web_contents),
1691 reinterpret_cast<ui::ViewAndroid*>(view_android), 1700 reinterpret_cast<ui::ViewAndroid*>(view_android),
1692 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1701 reinterpret_cast<ui::WindowAndroid*>(window_android));
1693 return reinterpret_cast<intptr_t>(view); 1702 return reinterpret_cast<intptr_t>(view);
1694 } 1703 }
1695 1704
1696 bool RegisterContentViewCore(JNIEnv* env) { 1705 bool RegisterContentViewCore(JNIEnv* env) {
1697 return RegisterNativesImpl(env); 1706 return RegisterNativesImpl(env);
1698 } 1707 }
1699 1708
1700 } // namespace content 1709 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/android/web_contents_observer_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698