Java Code Examples for org.chromium.chrome.browser.IntentHandler#wasIntentSenderChrome()

The following examples show how to use org.chromium.chrome.browser.IntentHandler#wasIntentSenderChrome() . 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: InstantAppsHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether the intent was fired from Chrome. This happens when the user gets a
 *         disambiguation dialog and chooses to stay in Chrome.
 */
private boolean isIntentFromChrome(Context context, Intent intent) {
    return context.getPackageName().equals(IntentUtils.safeGetStringExtra(
            intent, Browser.EXTRA_APPLICATION_ID))
            // We shouldn't leak internal intents with authentication tokens
            || IntentHandler.wasIntentSenderChrome(intent, context);
}
 
Example 2
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 3
Source File: InstantAppsHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether the intent was fired from Chrome. This happens when the user gets a
 *         disambiguation dialog and chooses to stay in Chrome.
 */
private boolean isIntentFromChrome(Context context, Intent intent) {
    return context.getPackageName().equals(IntentUtils.safeGetStringExtra(
            intent, Browser.EXTRA_APPLICATION_ID))
            // We shouldn't leak internal intents with authentication tokens
            || IntentHandler.wasIntentSenderChrome(intent);
}
 
Example 4
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 5
Source File: WebappLauncherActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
private boolean wasIntentFromChrome(Intent intent) {
    return IntentHandler.wasIntentSenderChrome(intent, ContextUtils.getApplicationContext());
}
 
Example 6
Source File: WebappLauncherActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private boolean wasIntentFromChrome(Intent intent) {
    return IntentHandler.wasIntentSenderChrome(intent, ContextUtils.getApplicationContext());
}
 
Example 7
Source File: WebappLauncherActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private boolean wasIntentFromChrome(Intent intent) {
    return IntentHandler.wasIntentSenderChrome(intent);
}