Index: android_webview/java/src/org/chromium/android_webview/AwContents.java |
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
index cffd535812ff6731ec2521883ef876108733150c..9b53b1b525d16d703b0923b21fdde10e085b362e 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
@@ -24,6 +24,7 @@ import android.webkit.ValueCallback; |
import org.chromium.base.CalledByNative; |
import org.chromium.base.JNINamespace; |
import org.chromium.base.ThreadUtils; |
+import org.chromium.content.browser.ContentSettings; |
import org.chromium.content.browser.ContentViewCore; |
import org.chromium.content.browser.LoadUrlParams; |
import org.chromium.content.browser.NavigationHistory; |
@@ -77,6 +78,7 @@ public class AwContents { |
private AwContentsClient mContentsClient; |
private AwContentsIoThreadClient mIoThreadClient; |
private InterceptNavigationDelegateImpl mInterceptNavigationDelegate; |
+ private ContentViewCore.InternalAccessDelegate mInternalAccessAdapter; |
// This can be accessed on any thread after construction. See AwContentsIoThreadClient. |
private final AwSettings mSettings; |
private final ClientCallbackHandler mClientCallbackHandler; |
@@ -212,6 +214,7 @@ public class AwContents { |
* @param contentsClient will receive API callbacks from this WebView Contents |
* @param privateBrowsing whether this is a private browsing instance of WebView. |
* @param isAccessFromFileURLsGrantedByDefault passed to ContentViewCore.initialize. |
+ * TODO(benm): Remove the nativeWindow parameter. |
*/ |
public AwContents(ViewGroup containerView, |
ContentViewCore.InternalAccessDelegate internalAccessAdapter, |
@@ -219,6 +222,7 @@ public class AwContents { |
NativeWindow nativeWindow, boolean privateBrowsing, |
boolean isAccessFromFileURLsGrantedByDefault) { |
mContainerView = containerView; |
+ mInternalAccessAdapter = internalAccessAdapter; |
// Note that ContentViewCore must be set up before AwContents, as ContentViewCore |
// setup performs process initialisation work needed by AwContents. |
mContentViewCore = new ContentViewCore(containerView.getContext(), |
@@ -229,9 +233,10 @@ public class AwContents { |
mClientCallbackHandler = new ClientCallbackHandler(); |
mContentViewCore.initialize(containerView, internalAccessAdapter, |
- nativeGetWebContents(mNativeAwContents), nativeWindow, |
+ nativeGetWebContents(mNativeAwContents), |
+ new AwNativeWindow(mContainerView.getContext()), |
isAccessFromFileURLsGrantedByDefault); |
- mContentViewCore.setContentViewClient(contentsClient); |
+ mContentViewCore.setContentViewClient(mContentsClient); |
mContentsClient.installWebContentsObserver(mContentViewCore); |
mSettings = new AwSettings(mContentViewCore.getContext()); |
@@ -350,6 +355,50 @@ public class AwContents { |
} |
} |
+ /** |
+ * Called on the "source" AwContents that is opening the popup window to |
+ * provide the AwContents to host the pop up content. |
+ */ |
+ public void supplyContentsForPopup(AwContents newContents) { |
+ int popupWebContents = nativeReleasePopupWebContents(mNativeAwContents); |
+ assert popupWebContents != 0; |
+ newContents.setNewWebContents(popupWebContents); |
+ } |
+ |
+ private void setNewWebContents(int newWebContentsPtr) { |
+ // When setting a new WebContents, we new up a ContentViewCore that will |
+ // wrap it and then swap it. |
+ ContentViewCore newCore = new ContentViewCore(mContainerView.getContext(), |
+ ContentViewCore.PERSONALITY_VIEW); |
+ // Note we pass false for isAccessFromFileURLsGrantedByDefault as we'll |
+ // set it correctly when when we copy the settings from the old ContentViewCore |
+ // into the new one. |
+ newCore.initialize(mContainerView, mInternalAccessAdapter, |
+ newWebContentsPtr, new AwNativeWindow(mContainerView.getContext()), |
+ false); |
+ newCore.setContentViewClient(mContentsClient); |
+ mContentsClient.installWebContentsObserver(newCore); |
+ |
+ ContentSettings oldSettings = mContentViewCore.getContentSettings(); |
+ newCore.getContentSettings().initFrom(oldSettings); |
+ |
+ // Now swap the Java side reference. |
+ mContentViewCore.destroy(); |
+ mContentViewCore = newCore; |
+ |
+ // Now rewire native side to use the new WebContents. |
+ nativeSetWebContents(mNativeAwContents, newWebContentsPtr); |
+ nativeSetIoThreadClient(mNativeAwContents, mIoThreadClient); |
+ nativeSetInterceptNavigationDelegate(mNativeAwContents, mInterceptNavigationDelegate); |
+ |
+ // Finally poke the new ContentViewCore with the size of the container view and show it. |
+ if (mContainerView.getWidth() != 0 || mContainerView.getHeight() != 0) { |
+ mContentViewCore.onSizeChanged( |
+ mContainerView.getWidth(), mContainerView.getHeight(), 0, 0); |
+ } |
joth
2012/11/17 01:38:21
In my patch, I've had to add nativeDidInitializeC
benm (inactive)
2012/11/28 20:00:05
Done.
|
+ mContentViewCore.onShow(); |
joth
2012/11/16 21:52:57
1) I *think* this needs to be conditional on wheth
benm (inactive)
2012/11/28 20:00:05
Seems reasonable.
|
+ } |
+ |
//-------------------------------------------------------------------------------------------- |
// WebView[Provider] method implementations (where not provided by ContentViewCore) |
//-------------------------------------------------------------------------------------------- |
@@ -762,4 +811,6 @@ public class AwContents { |
private native void nativeOnSizeChanged(int nativeAwContents, int w, int h, int ow, int oh); |
private native void nativeSetWindowViewVisibility(int nativeAwContents, boolean windowVisible, |
boolean viewVisible); |
+ private native int nativeReleasePopupWebContents(int nativeAwContents); |
+ private native void nativeSetWebContents(int nativeAwContents, int nativeNewWebContents); |
} |