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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.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: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index eacf76a46f01c7171add4aee0353ac901b7e5997..33937bb0d6b8f112a4bf20f9b44ea9718a023e78 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -523,6 +523,15 @@ public class ContentViewCore
private ContextualSearchClient mContextualSearchClient;
/**
+ * @param webContents The {@link WebContents} to find a {@link ContentViewCore} of.
+ * @return A {@link ContentViewCore} that is connected to {@code webContents} or
+ * {@code null} if none exists.
+ */
+ public static ContentViewCore fromWebContents(WebContents webContents) {
+ return nativeFromWebContentsAndroid(webContents);
+ }
+
+ /**
* Constructs a new ContentViewCore. Embedders must call initialize() after constructing
* a ContentViewCore and before using it.
*
@@ -698,7 +707,7 @@ public class ContentViewCore
* @param containerView The view that will act as a container for all views created by this.
* @param internalDispatcher Handles dispatching all hidden or super methods to the
* containerView.
- * @param nativeWebContents A pointer to the native web contents.
+ * @param webContents A WebContents instance to connect to.
* @param windowAndroid An instance of the WindowAndroid.
*/
// Perform important post-construction set up of the ContentViewCore.
@@ -711,7 +720,7 @@ public class ContentViewCore
// Note that the caller remains the owner of the nativeWebContents and is responsible for
// deleting it after destroying the ContentViewCore.
public void initialize(ViewGroup containerView, InternalAccessDelegate internalDispatcher,
- long nativeWebContents, WindowAndroid windowAndroid) {
+ WebContents webContents, WindowAndroid windowAndroid) {
createContentViewAndroidDelegate();
setContainerView(containerView);
long windowNativePointer = windowAndroid.getNativePointer();
@@ -724,7 +733,7 @@ public class ContentViewCore
mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE;
mNativeContentViewCore = nativeInit(
- nativeWebContents, viewAndroidNativePointer, windowNativePointer,
+ webContents, viewAndroidNativePointer, windowNativePointer,
mRetainedJavaScriptObjects);
mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore);
mContentSettings = new ContentSettings(this, mNativeContentViewCore);
@@ -3017,9 +3026,9 @@ public class ContentViewCore
if (potentiallyActiveFlingCount > 0) updateGestureStateListener(GestureEventType.FLING_END);
}
- private native long nativeInit(long webContentsPtr,
+ private native long nativeInit(WebContents webContents,
long viewAndroidPtr, long windowAndroidPtr, HashSet<Object> retainedObjectSet);
-
+ private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents);
ContentVideoViewClient getContentVideoViewClient() {
return getContentViewClient().getContentVideoViewClient();
}

Powered by Google App Engine
This is Rietveld 408576698