Chromium Code Reviews| 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..eaa10a1999b31afeaadb4a41d19bfe7122366da5 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 active custom tabs and check whether the given tabId belongs to a |
|
gone
2015/09/08 17:51:29
Need to keep using {@link CustomTab} everywhere be
|
| + // {@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); |