From 0cd941ea2fcb1c5c7d20dd5c5e6feba227e31ea9 Mon Sep 17 00:00:00 2001 From: mariakhomenko Date: Fri, 18 Sep 2015 14:56:57 -0700 Subject: [PATCH] Improve back button behavior. When Chrome loads a URL from another app that resolves to an intent that ends up in another application, get rid of Chrome from within the back stack before the tab is closed. This allows the user to go back to the original application that launched it (instead of getting stuck on a different Chrome tab, potentially with a back stack). BUG=487938 Review URL: https://codereview.chromium.org/1346283004 Cr-Commit-Position: refs/heads/master@{#349777} --- .../android/java/src/org/chromium/chrome/browser/tab/ChromeTab.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/ChromeTab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/ChromeTab.java index 44f0f0084524..b83ccd52d9ab 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/ChromeTab.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/ChromeTab.java @@ -931,6 +931,12 @@ public class ChromeTab extends Tab { // url, we would like to close it as we will load this url in a // different Activity. if (shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent()) { + if (getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP) { + // Moving task back before closing the tab allows back button to function better + // when Chrome was an intermediate link redirector between two apps. + // crbug.com/487938. + mActivity.moveTaskToBack(true); + } mActivity.getTabModelSelector().closeTab(this); } else if (mTabRedirectHandler.isOnNavigation()) { int lastCommittedEntryIndexBeforeNavigation = -- 2.11.4.GIT