Index: chrome/browser/android/content_view_util.cc |
diff --git a/chrome/browser/android/content_view_util.cc b/chrome/browser/android/content_view_util.cc |
index 467494cf32deaf81205b2491546c3a804a4087e3..75eaff968af15feb5c53ef679297e3eb06fca81e 100644 |
--- a/chrome/browser/android/content_view_util.cc |
+++ b/chrome/browser/android/content_view_util.cc |
@@ -12,7 +12,7 @@ |
#include "content/public/browser/web_contents.h" |
#include "jni/ContentViewUtil_jni.h" |
-static jlong CreateNativeWebContents( |
+static jobject CreateWebContents( |
JNIEnv* env, jclass clazz, jboolean incognito, jboolean initially_hidden) { |
Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile(); |
if (incognito) |
@@ -20,10 +20,10 @@ static jlong CreateNativeWebContents( |
content::WebContents::CreateParams params(profile); |
params.initially_hidden = static_cast<bool>(initially_hidden); |
- return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); |
+ return content::WebContents::Create(params)->GetJavaWebContents().Release(); |
} |
-static jlong CreateNativeWebContentsWithSharedSiteInstance( |
+static jobject CreateWebContentsWithSharedSiteInstance( |
JNIEnv* env, |
jclass clazz, |
jobject jcontent_view_core) { |
@@ -38,14 +38,22 @@ static jlong CreateNativeWebContentsWithSharedSiteInstance( |
content::WebContents::CreateParams params( |
profile, content_view_core->GetWebContents()->GetSiteInstance()); |
- return reinterpret_cast<intptr_t>(content::WebContents::Create(params)); |
+ return content::WebContents::Create(params)->GetJavaWebContents().Release(); |
} |
-static void DestroyNativeWebContents( |
+static jobject GetWebContentsFromNative( |
JNIEnv* env, jclass clazz, jlong web_contents_ptr) { |
content::WebContents* web_contents = |
reinterpret_cast<content::WebContents*>(web_contents_ptr); |
- delete web_contents; |
+ if (!web_contents) |
+ return NULL; |
+ return web_contents->GetJavaWebContents().Release(); |
+} |
+ |
+static jlong GetNativeWebContentsPtr( |
+ JNIEnv* env, jclass clazz, jobject jweb_contents) { |
+ return reinterpret_cast<intptr_t>( |
+ content::WebContents::FromJavaWebContents(jweb_contents)); |
} |
bool RegisterContentViewUtil(JNIEnv* env) { |