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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 1731673002: Add tab reparenting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: 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..67535810e3ada8cce03f38ad662d5cf8327ae6d1 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 needs the Compositor from the new Activity.
gone 2016/02/24 18:40:37 needs -> need
Yusuf 2016/02/24 19:40:35 Done.
+ 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);
+ nativeUpdateDelegates(mNativeTabAndroid,
+ mWebContentsDelegate, mDelegateFactory.createContextMenuPopulator(this));
+ mTopControlsVisibilityDelegate = mDelegateFactory.createTopControlsVisibilityDelegate(this);
+ setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigationDelegate(this));
+ mAppBannerManager = mDelegateFactory.createAppBannerManager(this);
gone 2016/02/24 18:40:37 You're not calling mAppBannerManager.destroy() on
Yusuf 2016/02/24 19:40:35 Done. No, the appbannermanager is the only one. An
+
+ // Take down the old activity, which destroys all the remaining tabmodels and tabs.
+ if (oldActivity != null && !oldActivity.isActivityDestroyed()) oldActivity.finish();
+ }
+
+ /**
* @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,

Powered by Google App Engine
This is Rietveld 408576698