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

Unified Diff: chrome/browser/android/content_view_util.cc

Issue 831523005: Remove most native WebContents references from Java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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 side-by-side diff with in-line comments
Download patch
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) {
« no previous file with comments | « chrome/browser/android/chrome_web_contents_delegate_android.cc ('k') | chrome/browser/android/tab_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698