Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
index 9f2b7daf463b28f2dd3c1bee1982bbfc9d878fdc..67f0e5b6558ee4a6b681fb92be9ff94a7f705b05 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java |
@@ -50,6 +50,7 @@ import org.chromium.chrome.browser.contextmenu.ContextMenuParams; |
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulatorWrapper; |
import org.chromium.chrome.browser.contextmenu.EmptyChromeContextMenuItemDelegate; |
+import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
import org.chromium.chrome.browser.fullscreen.FullscreenManager; |
import org.chromium.chrome.browser.help.HelpAndFeedback; |
import org.chromium.chrome.browser.infobar.InfoBarContainer; |
@@ -86,6 +87,7 @@ import org.chromium.ui.base.PageTransition; |
import org.chromium.ui.base.WindowAndroid; |
import org.chromium.ui.gfx.DeviceDisplayInfo; |
+import java.lang.ref.WeakReference; |
import java.nio.ByteBuffer; |
import java.util.ArrayList; |
import java.util.List; |
@@ -2842,9 +2844,21 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener, |
} |
/** |
- * Returns an Intent that tells Chrome to open a Tab with a particular ID. |
+ * @return Intent that tells Chrome to bring an Activity for a particular Tab back to the |
+ * foreground, or null if this isn't possible. |
*/ |
public static Intent createBringTabToFrontIntent(int tabId) { |
+ // Iterate through all {@link CustomTab}s and check whether the given tabId belongs to a |
+ // {@link CustomTab}. If so, return null as the client app's task cannot be foregrounded. |
+ List<WeakReference<Activity>> list = ApplicationStatus.getRunningActivities(); |
+ for (WeakReference<Activity> ref : list) { |
+ Activity activity = ref.get(); |
+ if (activity instanceof CustomTabActivity |
+ && tabId == ((CustomTabActivity) activity).getActivityTab().getId()) { |
+ return null; |
+ } |
+ } |
+ |
String packageName = ApplicationStatus.getApplicationContext().getPackageName(); |
Intent intent = new Intent(Intent.ACTION_MAIN); |
intent.putExtra(Browser.EXTRA_APPLICATION_ID, packageName); |