 Chromium Code Reviews
 Chromium Code Reviews Issue 14018004:
  [Android] Refactor NativeView to be able to use it for AutofillDialog.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 14018004:
  [Android] Refactor NativeView to be able to use it for AutofillDialog.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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 3257751734aa2cf60b6481bb20d4be808ba1c685..8d8a2670ca422041514abae754a0efb569cab83d 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,6 +51,8 @@ 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.ViewAndroid; | 
| +import org.chromium.ui.ViewAndroidDelegate; | 
| import org.chromium.ui.WindowAndroid; | 
| import java.lang.annotation.Annotation; | 
| @@ -255,6 +257,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { | 
| // Whether we received a new frame since consumePendingRendererFrame() was last called. | 
| private boolean mPendingRendererFrame = false; | 
| + private ViewAndroid mViewAndroid; | 
| + | 
| /** | 
| * Constructs a new ContentViewCore. Embedders must call initialize() after constructing | 
| * a ContentViewCore and before using it. | 
| @@ -316,11 +320,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); | 
| @@ -496,8 +500,14 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { | 
| int windowNativePointer = windowAndroid != null ? windowAndroid.getNativePointer() : 0; | 
| + int viewAndroidNativePointer = 0; | 
| + if (windowNativePointer != 0) { | 
| + mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate()); | 
| + viewAndroidNativePointer = mViewAndroid.getNativePointer(); | 
| + } | 
| + | 
| mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDeliveredAtVSync, | 
| - nativeWebContents, windowNativePointer); | 
| + nativeWebContents, viewAndroidNativePointer, windowNativePointer); | 
| mContentSettings = new ContentSettings( | 
| this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefault); | 
| initializeContainerView(internalDispatcher); | 
| @@ -649,6 +659,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { | 
| if (mNativeContentViewCore != 0) { | 
| nativeOnJavaContentViewCoreDestroyed(mNativeContentViewCore); | 
| } | 
| + if (mViewAndroid != null) mViewAndroid.destroy(); | 
| 
joth
2013/04/19 20:59:45
I forget - shouldn't there be a similar mWindowAnd
 
aurimas (slooooooooow)
2013/04/19 21:32:04
It is in Main.java#Destroy().
 | 
| mNativeContentViewCore = 0; | 
| mContentSettings = null; | 
| mJavaScriptInterfaces.clear(); | 
| @@ -2666,7 +2677,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); |