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

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: Kept same error checking behavior for aw_contents.cc 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..42d14ea92aca1d0a6178e556cc40ec26c4d005a9 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;
+ reinterpret_cast<content::WebContents*>(web_contents_ptr);
Ted C 2015/01/21 20:45:42 indented too much
David Trainor- moved to gerrit 2015/01/21 23:13:24 Done.
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698