Java Code Examples for org.chromium.chrome.browser.util.FeatureUtilities#getHerbFlavor()

The following examples show how to use org.chromium.chrome.browser.util.FeatureUtilities#getHerbFlavor() . 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 6 votes vote down vote up
/**
 * @return Whether or not a Custom Tab will be forcefully used for the incoming Intent.
 */
private boolean isHerbIntent() {
    if (!canBeHijackedByHerb(getIntent())) return false;

    // Different Herb flavors handle incoming intents differently.
    String flavor = FeatureUtilities.getHerbFlavor();
    if (TextUtils.isEmpty(flavor)
            || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)) {
        return false;
    } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        return IntentUtils.safeGetBooleanExtra(getIntent(),
                ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);
    } else {
        // Legacy Herb Flavors might hit this path before the caching logic corrects it, so
        // treat this as disabled.
        return false;
    }
}
 
Example 2
Source File: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @return Whether or not a Custom Tab will be forcefully used for the incoming Intent.
 */
private boolean isHerbIntent() {
    if (!canBeHijackedByHerb(getIntent())) return false;

    // Different Herb flavors handle incoming intents differently.
    String flavor = FeatureUtilities.getHerbFlavor();
    if (TextUtils.isEmpty(flavor)
            || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)) {
        return false;
    } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        return IntentUtils.safeGetBooleanExtra(getIntent(),
                ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);
    } else {
        // Legacy Herb Flavors might hit this path before the caching logic corrects it, so
        // treat this as disabled.
        return false;
    }
}
 
Example 3
Source File: ChromeTabbedActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Opens a new Tab with the possibility of showing it in a Custom Tab, instead.
 *
 * See IntentHandler#processUrlViewIntent() for an explanation most of the parameters.
 * @param forceNewTab If not handled by a Custom Tab, forces the new tab to be created.
 */
private void openNewTab(String url, String referer, String headers,
        String externalAppId, Intent intent, boolean forceNewTab) {
    boolean isAllowedToReturnToExternalApp = IntentUtils.safeGetBooleanExtra(intent,
            ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true);

    String herbFlavor = FeatureUtilities.getHerbFlavor();
    if (isAllowedToReturnToExternalApp
            && ChromeLauncherActivity.canBeHijackedByHerb(intent)
            && TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DILL, herbFlavor)) {
        Log.d(TAG, "Sending to CustomTabActivity");
        mActivityStopMetrics.setStopReason(
                ActivityStopMetrics.STOP_REASON_CUSTOM_TAB_STARTED);

        Intent newIntent = ChromeLauncherActivity.createCustomTabActivityIntent(
                ChromeTabbedActivity.this, intent, false);
        newIntent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
        newIntent.putExtra(
                CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, true);
        ChromeLauncherActivity.updateHerbIntent(ChromeTabbedActivity.this,
                newIntent, Uri.parse(IntentHandler.getUrlFromIntent(newIntent)));

        // Launch the Activity on top of this task.
        int updatedFlags = newIntent.getFlags();
        updatedFlags &= ~Intent.FLAG_ACTIVITY_NEW_TASK;
        updatedFlags &= ~Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        newIntent.setFlags(updatedFlags);
        startActivityForResult(newIntent, CCT_RESULT);
    } else {
        // Create a new tab.
        Tab newTab =
                launchIntent(url, referer, headers, externalAppId, forceNewTab, intent);
        newTab.setIsAllowedToReturnToExternalApp(isAllowedToReturnToExternalApp);
        RecordUserAction.record("MobileReceivedExternalIntent");
    }
}
 
Example 4
Source File: CustomTabIntentDataProvider.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Parses out extras specifically added for Herb.
 *
 * @param intent Intent fired to open the CustomTabActivity.
 * @param context Context for the package.
 */
private void parseHerbExtras(Intent intent, Context context) {
    String herbFlavor = FeatureUtilities.getHerbFlavor();
    if (TextUtils.isEmpty(herbFlavor)
            || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, herbFlavor)) {
        return;
    }
    if (!IntentHandler.isIntentChromeOrFirstParty(intent, context)) return;

    mIsOpenedByChrome = IntentUtils.safeGetBooleanExtra(
            intent, EXTRA_IS_OPENED_BY_CHROME, false);
    mShowBookmarkItem = IntentUtils.safeGetBooleanExtra(
            intent, EXTRA_SHOW_STAR_ICON, false);
}
 
Example 5
Source File: ToolbarPhone.java    From delion with Apache License 2.0 5 votes vote down vote up
private boolean isReturnButtonVisible() {
    String herbFlavor = FeatureUtilities.getHerbFlavor();
    if (!TextUtils.equals(ChromeSwitches.HERB_FLAVOR_BASIL, herbFlavor)
            && !TextUtils.equals(ChromeSwitches.HERB_FLAVOR_CHIVE, herbFlavor)) {
        return false;
    }

    Tab currentTab = getToolbarDataProvider().getTab();
    return mReturnButtonListener != null && currentTab != null
            && currentTab.isAllowedToReturnToExternalApp();
}