use of org.chromium.chrome.browser.customtabs.CustomTabActivity in project AndroidChromium by JackyAndroid.
the class Tab method createBringTabToFrontIntent.
/**
* @return Intent that tells Chrome to bring an Activity for a particular Tab back to the
* foreground, or null if this isn't possible.
*/
@Nullable
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 && ((CustomTabActivity) activity).getActivityTab() != null && tabId == ((CustomTabActivity) activity).getActivityTab().getId()) {
return null;
}
}
String packageName = ContextUtils.getApplicationContext().getPackageName();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, packageName);
intent.putExtra(TabOpenType.BRING_TAB_TO_FRONT.name(), tabId);
intent.setPackage(packageName);
return intent;
}
use of org.chromium.chrome.browser.customtabs.CustomTabActivity in project AndroidChromium by JackyAndroid.
the class ChromeLauncherActivity method createCustomTabActivityIntent.
/**
* Creates an Intent that can be used to launch a {@link CustomTabActivity}.
*/
public static Intent createCustomTabActivityIntent(Context context, Intent intent, boolean addHerbExtras) {
// Use the copy constructor to carry over the myriad of extras.
Uri uri = Uri.parse(IntentHandler.getUrlFromIntent(intent));
Intent newIntent = new Intent(intent);
newIntent.setAction(Intent.ACTION_VIEW);
newIntent.setClassName(context, CustomTabActivity.class.getName());
newIntent.setData(uri);
// so explicitly remove it to ensure the CCT does not get lost in recents.
if ((newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0 || (newIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
newIntent.setFlags(newIntent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
}
if (addHerbExtras) {
// TODO(tedchoc|mariakhomenko): Specifically not marking the intent is from Chrome via
// IntentHandler.addTrustedIntentExtras as it breaks the
// redirect logic for triggering instant apps. See if
// this is better addressed in TabRedirectHandler long
// term.
newIntent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
} else {
IntentUtils.safeRemoveExtra(intent, CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME);
}
if (addHerbExtras)
updateHerbIntent(context, newIntent);
return newIntent;
}
Aggregations