Java Code Examples for android.support.customtabs.CustomTabsIntent#shouldAlwaysUseBrowserUI()

The following examples show how to use android.support.customtabs.CustomTabsIntent#shouldAlwaysUseBrowserUI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeLauncherActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether or not an Herb prototype may hijack an Intent.
 */
public static boolean canBeHijackedByHerb(Intent intent) {
    String url = IntentHandler.getUrlFromIntent(intent);

    // Only VIEW Intents with URLs are rerouted to Custom Tabs.
    if (intent == null || !TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())
            || TextUtils.isEmpty(url)) {
        return false;
    }

    // Don't open explicitly opted out intents in custom tabs.
    if (CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)) {
        return false;
    }

    // Don't reroute Chrome Intents.
    Context context = ContextUtils.getApplicationContext();
    if (TextUtils.equals(context.getPackageName(),
            IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID))
            || IntentHandler.wasIntentSenderChrome(intent, context)) {
        return false;
    }

    // Don't reroute internal chrome URLs.
    try {
        URI uri = URI.create(url);
        if (UrlUtilities.isInternalScheme(uri)) return false;
    } catch (IllegalArgumentException e) {
        return false;
    }

    // Don't reroute Home screen shortcuts.
    if (IntentUtils.safeHasExtra(intent, ShortcutHelper.EXTRA_SOURCE)) {
        return false;
    }

    return true;
}
 
Example 2
Source File: ChromeLauncherActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether the intent is for launching a Custom Tab.
 */
public static boolean isCustomTabIntent(Intent intent) {
    if (intent == null
            || CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)
            || !intent.hasExtra(CustomTabsIntent.EXTRA_SESSION)) {
        return false;
    }
    return IntentHandler.getUrlFromIntent(intent) != null;
}
 
Example 3
Source File: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether or not an Herb prototype may hijack an Intent.
 */
public static boolean canBeHijackedByHerb(Intent intent) {
    String url = IntentHandler.getUrlFromIntent(intent);

    // Only VIEW Intents with URLs are rerouted to Custom Tabs.
    if (intent == null || !TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())
            || TextUtils.isEmpty(url)) {
        return false;
    }

    // Don't open explicitly opted out intents in custom tabs.
    if (CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)) {
        return false;
    }

    // Don't reroute Chrome Intents.
    Context context = ContextUtils.getApplicationContext();
    if (TextUtils.equals(context.getPackageName(),
            IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID))
            || IntentHandler.wasIntentSenderChrome(intent)) {
        return false;
    }

    // Don't reroute internal chrome URLs.
    try {
        URI uri = URI.create(url);
        if (UrlUtilities.isInternalScheme(uri)) return false;
    } catch (IllegalArgumentException e) {
        return false;
    }

    // Don't reroute Home screen shortcuts.
    if (IntentUtils.safeHasExtra(intent, ShortcutHelper.EXTRA_SOURCE)) {
        return false;
    }

    return true;
}
 
Example 4
Source File: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether the intent is for launching a Custom Tab.
 */
public static boolean isCustomTabIntent(Intent intent) {
    if (intent == null
            || CustomTabsIntent.shouldAlwaysUseBrowserUI(intent)
            || !intent.hasExtra(CustomTabsIntent.EXTRA_SESSION)) {
        return false;
    }
    return IntentHandler.getUrlFromIntent(intent) != null;
}