Java Code Examples for org.chromium.base.FieldTrialList#findFullName()

The following examples show how to use org.chromium.base.FieldTrialList#findFullName() . 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: SiteSettingsPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.site_settings_preferences);
    getActivity().setTitle(R.string.prefs_site_settings);

    mProtectedContentMenuAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;

    String autoplayTrialGroupName =
            FieldTrialList.findFullName("MediaElementGestureOverrideExperiment");
    mAutoplayMenuAvailable = autoplayTrialGroupName.startsWith("Enabled")
            || ChromeFeatureList.isEnabled(AUTOPLAY_MUTED_VIDEOS);

    String category = "";
    if (getArguments() != null) {
        category = getArguments().getString(SingleCategoryPreferences.EXTRA_CATEGORY, "");
        if (MEDIA_KEY.equals(category)) {
            mMediaSubMenu = true;
            getActivity().setTitle(findPreference(MEDIA_KEY).getTitle().toString());
        }
    }

    configurePreferences();
    updatePreferenceStates();
}
 
Example 2
Source File: InstantAppsHandler.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Cache whether the Instant Apps feature is enabled.
 * This should only be called with the native library loaded.
 */
public void cacheInstantAppsEnabled() {
    Context context = ContextUtils.getApplicationContext();
    boolean isEnabled = false;
    boolean wasEnabled = isEnabled(context);
    CommandLine instance = CommandLine.getInstance();
    if (instance.hasSwitch(ChromeSwitches.DISABLE_APP_LINK)) {
        isEnabled = false;
    } else if (instance.hasSwitch(ChromeSwitches.ENABLE_APP_LINK)) {
        isEnabled = true;
    } else {
        String experiment = FieldTrialList.findFullName(INSTANT_APPS_EXPERIMENT_NAME);
        if (INSTANT_APPS_DISABLED_ARM.equals(experiment)) {
            isEnabled = false;
        } else if (INSTANT_APPS_ENABLED_ARM.equals(experiment)) {
            isEnabled = true;
        }
    }

    if (isEnabled != wasEnabled) {
        ChromePreferenceManager.getInstance(context).setCachedInstantAppsEnabled(isEnabled);
    }
}
 
Example 3
Source File: FeatureUtilities.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Caches which flavor of Herb the user prefers from native.
 */
private static void cacheHerbFlavor() {
    Context context = ContextUtils.getApplicationContext();
    if (isHerbDisallowed(context)) return;

    String oldFlavor = getHerbFlavor();

    // Check the experiment value before the command line to put the user in the correct group.
    // The first clause does the null checks so so we can freely use the startsWith() function.
    String newFlavor = FieldTrialList.findFullName(HERB_EXPERIMENT_NAME);
    Log.d(TAG, "Experiment flavor: " + newFlavor);
    if (!TextUtils.isEmpty(newFlavor)
            && newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY;
    } else {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED;
    }

    CommandLine instance = CommandLine.getInstance();
    if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DISABLED_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ELDERBERRY_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY;
    }

    Log.d(TAG, "Caching flavor: " + newFlavor);
    sCachedHerbFlavor = newFlavor;

    if (!TextUtils.equals(oldFlavor, newFlavor)) {
        ChromePreferenceManager.getInstance(context).setCachedHerbFlavor(newFlavor);
    }
}
 
Example 4
Source File: FeatureUtilities.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Caches which flavor of Herb the user prefers from native.
 */
private static void cacheHerbFlavor() {
    Context context = ContextUtils.getApplicationContext();
    if (isHerbDisallowed(context)) return;

    String oldFlavor = getHerbFlavor();

    // Check the experiment value before the command line to put the user in the correct group.
    // The first clause does the null checks so so we can freely use the startsWith() function.
    String newFlavor = FieldTrialList.findFullName(HERB_EXPERIMENT_NAME);
    Log.d(TAG, "Experiment flavor: " + newFlavor);
    if (!TextUtils.isEmpty(newFlavor)
            && newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY;
    } else {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED;
    }

    CommandLine instance = CommandLine.getInstance();
    if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DISABLED_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ELDERBERRY_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY;
    }

    Log.d(TAG, "Caching flavor: " + newFlavor);
    sCachedHerbFlavor = newFlavor;

    if (!TextUtils.equals(oldFlavor, newFlavor)) {
        ChromePreferenceManager.getInstance().setCachedHerbFlavor(newFlavor);
    }
}
 
Example 5
Source File: FeatureUtilities.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Caches which flavor of Herb the user prefers from native.
 */
private static void cacheHerbFlavor() {
    Context context = ContextUtils.getApplicationContext();
    if (isHerbDisallowed(context)) return;

    String oldFlavor = getHerbFlavor();

    // Check the experiment value before the command line to put the user in the correct group.
    // The first clause does the null checks so so we can freely use the startsWith() function.
    String newFlavor = FieldTrialList.findFullName(HERB_EXPERIMENT_NAME);
    Log.d(TAG, "Experiment flavor: " + newFlavor);
    if (TextUtils.isEmpty(newFlavor)
            || newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_CONTROL)
            || newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_DEFAULT)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED;
    } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ANISE)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ANISE;
    } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_BASIL)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_BASIL;
    } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_CHIVE)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_CHIVE;
    } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_DILL)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DILL;
    } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY;
    }

    CommandLine instance = CommandLine.getInstance();
    if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DISABLED_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ANISE_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ANISE;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_BASIL_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_BASIL;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_CHIVE_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_CHIVE;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DILL_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_DILL;
    } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ELDERBERRY_SWITCH)) {
        newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY;
    }

    Log.d(TAG, "Caching flavor: " + newFlavor);
    sCachedHerbFlavor = newFlavor;

    if (!TextUtils.equals(oldFlavor, newFlavor)) {
        ChromePreferenceManager.getInstance(context).setCachedHerbFlavor(newFlavor);
    }
}