| 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 0021e8ba9ca3247a30c084f9004def16b7f9d0a1..0f59feee39018f74a3d25a16fbaa562e0e9ac6ad 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
|
| @@ -8,6 +8,7 @@ import android.app.PendingIntent;
|
| import android.content.Intent;
|
| import android.graphics.Bitmap;
|
| import android.net.Uri;
|
| +import android.os.Bundle;
|
| import android.os.IBinder;
|
| import android.os.StrictMode;
|
| import android.support.customtabs.CustomTabsCallback;
|
| @@ -47,12 +48,10 @@ import org.chromium.chrome.browser.pageinfo.WebsiteSettingsPopup;
|
| 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.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.FeatureUtilities;
|
| @@ -701,9 +700,10 @@ public class CustomTabActivity extends ChromeActivity {
|
| * @return Whether or not the tab was sent over successfully.
|
| */
|
| boolean openCurrentUrlInBrowser(boolean forceReparenting) {
|
| - if (getActivityTab() == null) return false;
|
| + Tab tab = getActivityTab();
|
| + if (tab == null) return false;
|
|
|
| - String url = getActivityTab().getUrl();
|
| + String url = tab.getUrl();
|
| if (DomDistillerUrlUtils.isDistilledPage(url)) {
|
| url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
|
| }
|
| @@ -721,37 +721,27 @@ public class CustomTabActivity extends ChromeActivity {
|
| StrictMode.setThreadPolicy(oldPolicy);
|
| }
|
|
|
| + Bundle startActivityOptions = ActivityOptionsCompat.makeCustomAnimation(
|
| + this, R.anim.abc_fade_in, R.anim.abc_fade_out).toBundle();
|
| if (willChromeHandleIntent || forceReparenting) {
|
| - intent.setPackage(getPackageName());
|
| - // 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
|
| - // onDestroy when finish() gets called. Find a way to do this properly without
|
| - // confusing the TabModel and without hiding the tab. crbug.com/590278
|
| - getCurrentTabModel().removeTab(getActivityTab());
|
| - mMainTab = null;
|
| - tab.getContentViewCore().updateWindowAndroid(null);
|
| - tab.attachTabContentManager(null);
|
| -
|
| Runnable finalizeCallback = new Runnable() {
|
| @Override
|
| public void run() {
|
| finishAndClose();
|
| }
|
| };
|
| - AsyncTabParamsManager.add(
|
| - tab.getId(), new TabReparentingParams(tab, intent, finalizeCallback));
|
| - intent.putExtra(IntentHandler.EXTRA_TAB_ID, tab.getId());
|
| - }
|
|
|
| - // 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);
|
| + mMainTab = null;
|
| + tab.detachAndStartReparenting(intent, startActivityOptions, finalizeCallback);
|
| + } else {
|
| + // Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860
|
| + StrictMode.allowThreadDiskReads();
|
| + StrictMode.allowThreadDiskWrites();
|
| + try {
|
| + startActivity(intent, startActivityOptions);
|
| + } finally {
|
| + StrictMode.setThreadPolicy(oldPolicy);
|
| + }
|
| }
|
| return true;
|
| }
|
|
|