Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
| index 9c4ac52484b99f412402644971cdf37cdbf94169..93ec5e1ae515dae2503585976994791f3e167e71 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
| @@ -156,7 +156,7 @@ public final class Tab implements ViewGroup.OnHierarchyChangeListener, |
| private final Context mThemedApplicationContext; |
| /** Gives {@link Tab} a way to interact with the Android window. */ |
| - private final WindowAndroid mWindowAndroid; |
| + private WindowAndroid mWindowAndroid; |
| /** Whether or not this {@link Tab} is initialized and should be interacted with. */ |
| private boolean mIsInitialized; |
| @@ -1358,6 +1358,35 @@ public final class Tab implements ViewGroup.OnHierarchyChangeListener, |
| } |
| /** |
| + * Detaches tab and related objects from an existing activity and attaches to a new one. This |
| + * updates many delegates inside the tab and {@link ContentViewCore} both on java and native |
| + * sides. |
| + * @param activity The new activity this tab should be associated with. |
| + * @param tabDelegateFactory The new delegate factory this tab should be using. |
| + */ |
| + public void reparentToActivity(ChromeActivity activity, TabDelegateFactory tabDelegateFactory) { |
|
Ted C
2016/02/26 18:46:29
we might want this to be a two part call eventuall
Yusuf
2016/02/26 19:39:52
Acknowledged.
|
| + // TODO(yusufo): Share these calls with the construction related calls. |
| + |
| + // Update and propagate for the new WindowAndroid. |
| + mWindowAndroid = activity.getWindowAndroid(); |
| + mContentViewCore.updateWindowAndroid(mWindowAndroid); |
| + |
| + // Update for the controllers that need the Compositor from the new Activity. |
| + nativeAttachToTabContentManager(mNativeTabAndroid, activity.getTabContentManager()); |
| + mFullscreenManager = activity.getFullscreenManager(); |
| + activity.getCompositorViewHolder().prepareForTabReparenting(); |
| + |
| + // Update the delegate factory, then recreate and propagate all delegates. |
| + mDelegateFactory = tabDelegateFactory; |
| + mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this); |
| + nativeUpdateDelegates(mNativeTabAndroid, |
| + mWebContentsDelegate, mDelegateFactory.createContextMenuPopulator(this)); |
| + mTopControlsVisibilityDelegate = mDelegateFactory.createTopControlsVisibilityDelegate(this); |
| + setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigationDelegate(this)); |
| + mAppBannerManager = mDelegateFactory.createAppBannerManager(this); |
| + } |
| + |
| + /** |
| * @return The delegate factory for testing purposes only. |
| */ |
| public TabDelegateFactory getDelegateFactory() { |
| @@ -2949,6 +2978,8 @@ public final class Tab implements ViewGroup.OnHierarchyChangeListener, |
| private native void nativeInitWebContents(long nativeTabAndroid, boolean incognito, |
| ContentViewCore contentViewCore, TabWebContentsDelegateAndroid delegate, |
| ContextMenuPopulator contextMenuPopulator); |
| + private native void nativeUpdateDelegates(long nativeTabAndroid, |
| + TabWebContentsDelegateAndroid delegate, ContextMenuPopulator contextMenuPopulator); |
| private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |
| private native Profile nativeGetProfileAndroid(long nativeTabAndroid); |
| private native int nativeLoadUrl(long nativeTabAndroid, String url, String extraHeaders, |