Chromium Code Reviews| 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 c87e2fa3432c35d22d12e63c39b08017f3010c0f..03e86c2508fb0c7257a9d50fd6a3a84684a5d766 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; |
| @@ -647,11 +651,43 @@ public class CustomTabActivity extends ChromeActivity { |
| intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| intent.putExtra(ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, false); |
| - // Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860 |
| + boolean chromeIsDefault; |
| StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
| StrictMode.allowThreadDiskWrites(); |
| try { |
| - startActivity(intent); |
| + chromeIsDefault = ExternalNavigationDelegateImpl |
| + .willChromeHandleIntent(this, intent, true); |
| + } finally { |
| + StrictMode.setThreadPolicy(oldPolicy); |
| + } |
| + |
| + if (chromeIsDefault) { |
| + // Take the activity tab and set it aside for reparenting. |
| + final Tab tab = getActivityTab(); |
| + // TODO(yusufo): The removal should happen as a part of the callback or as a part of |
|
Ted C
2016/02/26 18:46:29
file bugs for the todos and put them in here.
Yusuf
2016/02/26 19:39:52
Done.
|
| + // onDestroy when finish() gets called. Find a way to do this properly without confusing |
| + // the TabModel and without hiding the tab. |
| + getCurrentTabModel().removeTab(getActivityTab()); |
| + tab.getContentViewCore().updateWindowAndroid(null); |
| + |
| + Runnable finalizeCallback = new Runnable() { |
| + @Override |
| + public void run() { |
| + finish(); |
|
Ted C
2016/02/26 18:46:29
we could do the tab model cleanup here, but I gues
Yusuf
2016/02/26 19:39:52
Agreed. Added to the bug and TODO.
|
| + } |
| + }; |
| + AsyncTabParamsManager.add( |
| + tab.getId(), new TabReparentingParams(tab, intent, finalizeCallback)); |
| + intent.putExtra(IntentHandler.EXTRA_TAB_ID, tab.getId()); |
| + intent.setPackage(getPackageName()); |
| + } |
| + |
| + // Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860 |
| + StrictMode.allowThreadDiskReads(); |
| + StrictMode.allowThreadDiskWrites(); |
| + try { |
| + startActivity(intent, ActivityOptionsCompat.makeCustomAnimation( |
| + this, R.anim.abc_fade_in, R.anim.abc_fade_out).toBundle()); |
| } finally { |
| StrictMode.setThreadPolicy(oldPolicy); |
| } |