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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.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/customtabs/CustomTabActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
index 0c00788997a518239244fc8f632828e5c67a17ec..3987725f3da49dd29af3036b329a79beabda1fa3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
@@ -13,6 +13,7 @@ import android.os.IBinder;
import android.os.StrictMode;
import android.support.customtabs.CustomTabsCallback;
import android.support.customtabs.CustomTabsIntent;
+import android.support.v4.app.ActivityOptionsCompat;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MenuItem;
@@ -40,14 +41,17 @@ import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument;
import org.chromium.chrome.browser.datausage.DataUseTabUIManager;
import org.chromium.chrome.browser.document.ChromeLauncherActivity;
+import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl;
import org.chromium.chrome.browser.rappor.RapporServiceBridge;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabIdManager;
+import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
import org.chromium.chrome.browser.tabmodel.TabModelObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorImpl;
+import org.chromium.chrome.browser.tabmodel.TabReparentingParams;
import org.chromium.chrome.browser.toolbar.ToolbarControlContainer;
import org.chromium.chrome.browser.util.ColorUtils;
import org.chromium.chrome.browser.util.IntentUtils;
@@ -642,11 +646,26 @@ public class CustomTabActivity extends ChromeActivity {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, false);
+ boolean chromeIsDefault = ExternalNavigationDelegateImpl
+ .willChromeHandleIntent(this, intent, true);
+
+ if (chromeIsDefault) {
+ // Take the activity tab and set it aside for reparenting.
+ Tab tab = getActivityTab();
+ getCurrentTabModel().removeTab(tab);
+ tab.getContentViewCore().updateWindowAndroid(null);
+
+ AsyncTabParamsManager.add(tab.getId(), new TabReparentingParams(tab, intent));
+ intent.putExtra(IntentHandler.EXTRA_TAB_ID, tab.getId());
+ intent.setPackage(getPackageName());
+ }
+
// Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
try {
- startActivity(intent);
+ startActivity(intent, ActivityOptionsCompat.makeCustomAnimation(
+ this, R.anim.abc_fade_in, R.anim.abc_fade_out).toBundle());
} finally {
StrictMode.setThreadPolicy(oldPolicy);
}

Powered by Google App Engine
This is Rietveld 408576698