use of org.chromium.chrome.browser.tabmodel.TabReparentingParams in project AndroidChromium by JackyAndroid.
the class Tab method detachAndStartReparenting.
/**
* Begins the tab reparenting process. Detaches the tab from its current activity and fires
* an Intent to reparent the tab into its new host activity.
*
* @param intent An optional intent with the desired component, flags, or extras to use when
* launching the new host activity. This intent's URI and action will be
* overriden. This may be null if no intent customization is needed.
* @param startActivityOptions Options to pass to {@link Activity#startActivity(Intent, Bundle)}
* @param finalizeCallback A callback that will be called after the tab is attached to the new
* host activity in {@link #attachAndFinishReparenting}.
* @return Whether reparenting succeeded. If false, the tab was not removed and the intent was
* not fired.
*/
public boolean detachAndStartReparenting(Intent intent, Bundle startActivityOptions, Runnable finalizeCallback) {
ChromeActivity activity = getActivity();
if (activity == null)
return false;
if (intent == null)
intent = new Intent();
if (intent.getComponent() == null) {
intent.setClass(mThemedApplicationContext, ChromeLauncherActivity.class);
}
intent.setAction(Intent.ACTION_VIEW);
if (TextUtils.isEmpty(intent.getDataString()))
intent.setData(Uri.parse(getUrl()));
if (isIncognito()) {
intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true);
}
IntentHandler.addTrustedIntentExtras(intent, activity);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_REPARENTING)) {
TabModelSelector tabModelSelector = getTabModelSelector();
if (tabModelSelector == null)
return false;
mIsDetachedForReparenting = true;
// Add the tab to AsyncTabParamsManager before removing it from the current model to
// ensure the global count of tabs is correct. See crbug.com/611806.
intent.putExtra(IntentHandler.EXTRA_TAB_ID, mId);
AsyncTabParamsManager.add(mId, new TabReparentingParams(this, intent, finalizeCallback));
tabModelSelector.getModel(mIncognito).removeTab(this);
// TODO(mthiesse): File a bug when crbug isn't down.
if (mContentViewCore != null)
mContentViewCore.updateWindowAndroid(null);
attachTabContentManager(null);
}
activity.startActivity(intent, startActivityOptions);
return true;
}
Aggregations