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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 14018004: [Android] Refactor NativeView to be able to use it for AutofillDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding UI_EXPORT Created 7 years, 8 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 6d44e042af538f17c108e45c3c0b3dc3706ee2b3..471a127e3147f4841c84307d0f549e72bf367938 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
@@ -51,7 +51,9 @@ import org.chromium.content.browser.input.InsertionHandleController;
import org.chromium.content.browser.input.SelectPopupDialog;
import org.chromium.content.browser.input.SelectionHandleController;
import org.chromium.content.common.TraceEvent;
-import org.chromium.ui.gfx.NativeWindow;
+import org.chromium.ui.ViewAndroidDelegate;
+import org.chromium.ui.ViewAndroid;
+import org.chromium.ui.gfx.WindowAndroid;
import java.lang.annotation.Annotation;
import java.util.HashMap;
@@ -248,6 +250,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
// Whether we use hardware-accelerated drawing.
private boolean mHardwareAccelerated = false;
+ private ViewAndroid mViewAndroid;
+
/**
* Constructs a new ContentViewCore. Embedders must call initialize() after constructing
* a ContentViewCore and before using it.
@@ -309,11 +313,11 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
* compatibility breaks with existing applications. If in doubt, contact the
* android_webview/OWNERS
*
- * @return A ContainerViewDelegate that can be used to add and remove views.
+ * @return A ViewAndroidDelegate that can be used to add and remove views.
*/
- @CalledByNative
- public ContainerViewDelegate getContainerViewDelegate() {
- return new ContainerViewDelegate() {
+ @VisibleForTesting
+ public ViewAndroidDelegate getViewAndroidDelegate() {
+ return new ViewAndroidDelegate() {
@Override
public void addViewToContainerView(View view) {
mContainerView.addView(view);
@@ -451,7 +455,10 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
* @param internalDispatcher Handles dispatching all hidden or super methods to the
* containerView.
* @param nativeWebContents A pointer to the native web contents.
- * @param nativeWindow An instance of the NativeWindow.
+ * @param windowAndroid An instance of the WindowAndroid.
+ * @param shouldCreateViewAndroid Whether ContentViewCore creates a ViewAndroid object. WebView
+ * currently does not create ViewAndroid. If that should change,
+ * ViewAndroid should be rewritten to use CleanupReference.
* @param isAccessFromFileURLsGrantedByDefault Default WebSettings configuration.
*/
// Perform important post-construction set up of the ContentViewCore.
@@ -464,7 +471,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
// 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,
- int nativeWebContents, NativeWindow nativeWindow,
+ int nativeWebContents, WindowAndroid windowAndroid, boolean shouldCreateViewAndroid,
joth 2013/04/18 01:41:17 Seems odd to pass in the window here, along with b
aurimas (slooooooooow) 2013/04/18 02:49:57 Does WebView support JavascriptAppModalDialog or S
boolean isAccessFromFileURLsGrantedByDefault) {
// Check whether to use hardware acceleration. This is a bit hacky, and
// only works if the Context is actually an Activity (as it is in the
@@ -486,8 +493,15 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN);
mContainerView = containerView;
+
+ int viewAndroidNativePointer = 0;
+ if (shouldCreateViewAndroid) {
+ mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate());
+ viewAndroidNativePointer = mViewAndroid.getNativePointer();
+ }
+
mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDeliveredAtVSync,
- nativeWebContents, nativeWindow.getNativePointer());
+ nativeWebContents, viewAndroidNativePointer, windowAndroid.getNativePointer());
mContentSettings = new ContentSettings(
this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefault);
initializeContainerView(internalDispatcher);
@@ -639,6 +653,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
if (mNativeContentViewCore != 0) {
nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore);
}
+ if (mViewAndroid != null) mViewAndroid.destroy();
mNativeContentViewCore = 0;
mContentSettings = null;
mJavaScriptInterfaces.clear();
@@ -2643,7 +2658,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
}
private native int nativeInit(boolean hardwareAccelerated, boolean inputEventsDeliveredAtVSync,
- int webContentsPtr, int windowAndroidPtr);
+ int webContentsPtr, int viewAndroidPtr, int windowAndroidPtr);
private native void nativeOnJavaContentViewCoreDestroyed(int nativeContentViewCoreImpl);

Powered by Google App Engine
This is Rietveld 408576698