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 33b3ad40e8f7409be087937f66a876725f9d6e14..de358d94b8e1cf1d129b6e0a5fe121d566e48527 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 |
| @@ -153,7 +153,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; |
| @@ -1355,6 +1355,38 @@ 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) { |
| + ChromeActivity oldActivity = getActivity(); |
| + |
| + // 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().onActiveTabReparented(); |
| + |
| + // Update the delegate factory, then recreate and propagate all delegates. |
| + mDelegateFactory = tabDelegateFactory; |
| + mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this); |
|
Ted C
2016/02/25 20:05:22
can the bulk of this method be shared w/ the defau
Yusuf
2016/02/25 23:05:00
No?.... :S I mean yes, but it gets so hairy that b
|
| + nativeUpdateDelegates(mNativeTabAndroid, |
| + mWebContentsDelegate, mDelegateFactory.createContextMenuPopulator(this)); |
| + mTopControlsVisibilityDelegate = mDelegateFactory.createTopControlsVisibilityDelegate(this); |
| + setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigationDelegate(this)); |
| + mAppBannerManager = mDelegateFactory.createAppBannerManager(this); |
| + |
| + // Take down the old activity, which destroys all the remaining tabmodels and tabs. |
| + if (oldActivity != null && !oldActivity.isActivityDestroyed()) oldActivity.finish(); |
|
Ted C
2016/02/25 20:05:22
this is...umm...scary.
I don't think this is wher
Yusuf
2016/02/25 23:05:00
Done.
|
| + } |
| + |
| + /** |
| * @return The delegate factory for testing purposes only. |
| */ |
| public TabDelegateFactory getDelegateFactory() { |
| @@ -2945,6 +2977,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, |