Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java |
index 53312f14b1332038f4fc0bcbc76dc6f4cfca5aea..e970e1c788b734c2af7c19d3ea567d0e02b2bc64 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTab.java |
@@ -152,6 +152,7 @@ public class CustomTab extends ChromeTab { |
private CustomTabObserver mTabObserver; |
private final boolean mEnableUrlBarHiding; |
+ private boolean mShouldReplaceCurrentEntry; |
/** |
* Construct an CustomTab. Note that url and referrer given here is only used to retrieve a |
@@ -167,6 +168,11 @@ public class CustomTab extends ChromeTab { |
CustomTabsConnection.getInstance(activity.getApplication()); |
WebContents webContents = customTabsConnection.takePrerenderedUrl(session, url, referrer); |
if (webContents == null) { |
+ webContents = customTabsConnection.takeSpareWebContents(); |
+ // TODO(lizeb): Remove this once crbug.com/521729 is fixed. |
+ if (webContents != null) mShouldReplaceCurrentEntry = true; |
+ } |
+ if (webContents == null) { |
webContents = WebContentsFactory.createWebContents(isIncognito(), false); |
} |
initialize(webContents, activity.getTabContentManager(), false); |
@@ -184,6 +190,8 @@ public class CustomTab extends ChromeTab { |
*/ |
void loadUrlAndTrackFromTimestamp(LoadUrlParams params, long timestamp) { |
mTabObserver.trackNextPageLoadFromTimestamp(timestamp); |
+ if (mShouldReplaceCurrentEntry) params.setShouldReplaceCurrentEntry(true); |
+ mShouldReplaceCurrentEntry = false; |
loadUrl(params); |
} |