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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java

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/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java
index e5c9d523339ee6d10d14f435351db248d0917e45..5af6e7407bfa8b233984211f5778877d143869d8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ContentViewUtil.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser;
import org.chromium.content.browser.ContentViewCore;
+import org.chromium.content_public.browser.WebContents;
/**
* This class provides a way to create the native WebContents required for instantiating a
@@ -16,40 +17,49 @@ public abstract class ContentViewUtil {
}
/**
- * @return pointer to native WebContents instance, suitable for using with a
- * (java) ContentViewCore instance.
+ * A factory method to build a {@link WebContents} object.
+ * @param incognito Whether or not the {@link WebContents} should be built with an
+ * incognito profile or not.
+ * @param initiallyHidden Whether or not the {@link WebContents} should be initially hidden.
+ * @return A newly created {@link WebContents} object.
*/
- public static long createNativeWebContents(boolean incognito) {
- return nativeCreateNativeWebContents(incognito, false);
+ public static WebContents createWebContents(boolean incognito, boolean initiallyHidden) {
+ return nativeCreateWebContents(incognito, initiallyHidden);
}
/**
- * @return pointer to native WebContents instance, suitable for using with a
- * (java) ContentViewCore instance.
+ * TODO(dtrainor): Remove when this is no longer used.
+ * Helper method for getting a {@link WebContents} from a native WebContents pointer.
+ * @param webContentsPtr A native WebContents pointer.
+ * @return A {@link WebContents} object that is linked to {@code webContentsPtr}.
*/
- public static long createNativeWebContents(boolean incognito, boolean initiallyHidden) {
- return nativeCreateNativeWebContents(incognito, initiallyHidden);
+ public static WebContents fromNativeWebContents(long webContentsPtr) {
+ return nativeGetWebContentsFromNative(webContentsPtr);
}
/**
- * @return pointer to native WebContents instance, suitable for using with a
- * (java) ContentViewCore instance.
+ * TODO(dtrainor): Remove when this is no longer used.
+ * Helper method for getting a native WebContents pointer from a {@link WebContents} object.
+ * @param webContents A {@link WebContents} object.
+ * @return A native WebContents poniter that is linked to {@code webContents}.
*/
- public static long createNativeWebContentsWithSharedSiteInstance(
- ContentViewCore contentViewCore) {
- return nativeCreateNativeWebContentsWithSharedSiteInstance(contentViewCore);
+ public static long getNativeWebContentsFromWebContents(WebContents webContents) {
+ return nativeGetNativeWebContentsPtr(webContents);
}
/**
- * @param webContentsPtr The WebContents reference to be deleted.
+ * @return pointer to native WebContents instance, suitable for using with a
+ * (java) ContentViewCore instance.
*/
- public static void destroyNativeWebContents(long webContentsPtr) {
- nativeDestroyNativeWebContents(webContentsPtr);
+ public static WebContents createWebContentsWithSharedSiteInstance(
+ ContentViewCore contentViewCore) {
+ return nativeCreateWebContentsWithSharedSiteInstance(contentViewCore);
}
- private static native long nativeCreateNativeWebContents(boolean incognito,
+ private static native WebContents nativeCreateWebContents(boolean incognito,
boolean initiallyHidden);
- private static native long nativeCreateNativeWebContentsWithSharedSiteInstance(
+ private static native WebContents nativeCreateWebContentsWithSharedSiteInstance(
ContentViewCore contentViewCore);
- private static native void nativeDestroyNativeWebContents(long webContentsPtr);
+ private static native WebContents nativeGetWebContentsFromNative(long webContentsPtr);
+ private static native long nativeGetNativeWebContentsPtr(WebContents webContents);
}

Powered by Google App Engine
This is Rietveld 408576698