org.chromium.base.FieldTrialList Java Examples

The following examples show how to use org.chromium.base.FieldTrialList. 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: InvalidationController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the instance that will use {@code context} to issue intents.
 *
 * Calling this method will create the instance if it does not yet exist.
 */
public static InvalidationController get(Context context) {
    synchronized (LOCK) {
        if (sInstance == null) {
            // The PageRevisitInstrumentation trial needs sessions invalidations to be on such
            // that local session data is current and can be used to perform checks.
            boolean requireInvalidationsForInstrumentation =
                    FieldTrialList.findFullName("PageRevisitInstrumentation").equals("Enabled");
            // If the NTP is trying to suggest foreign tabs, then recieving invalidations is
            // vital, otherwise data is stale and less useful.
            boolean requireInvalidationsForSuggestions = ChromeFeatureList.isEnabled(
                    ChromeFeatureList.NTP_FOREIGN_SESSIONS_SUGGESTIONS);
            boolean canDisableSessionInvalidations = !requireInvalidationsForInstrumentation
                    && !requireInvalidationsForSuggestions;

            sInstance = new InvalidationController(context, canDisableSessionInvalidations);
        }
        return sInstance;
    }
}
 
Example #2
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 #3
Source File: InvalidationController.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the instance that will use {@code context} to issue intents.
 *
 * Calling this method will create the instance if it does not yet exist.
 */
public static InvalidationController get(Context context) {
    synchronized (LOCK) {
        if (sInstance == null) {
            // The PageRevisitInstrumentation trial needs sessions invalidations to be on such
            // that local session data is current and can be used to perform checks.
            boolean requireInvalidationsForInstrumentation =
                    FieldTrialList.findFullName("PageRevisitInstrumentation").equals("Enabled");
            boolean canDisableSessionInvalidations = !requireInvalidationsForInstrumentation;

            boolean canUseGcmUpstream =
                    FieldTrialList.findFullName("InvalidationsGCMUpstream").equals("Enabled");
            sInstance = new InvalidationController(
                    context, canDisableSessionInvalidations, canUseGcmUpstream);
        }
        return sInstance;
    }
}
 
Example #4
Source File: InvalidationController.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the instance that will use {@code context} to issue intents.
 *
 * Calling this method will create the instance if it does not yet exist.
 */
public static InvalidationController get(Context context) {
    synchronized (LOCK) {
        if (sInstance == null) {
            // The PageRevisitInstrumentation trial needs sessions invalidations to be on such
            // that local session data is current and can be used to perform checks.
            boolean requireInvalidationsForInstrumentation =
                    FieldTrialList.findFullName("PageRevisitInstrumentation").equals("Enabled");
            // If the NTP is trying to suggest foreign tabs, then recieving invalidations is
            // vital, otherwise data is stale and less useful.
            boolean requireInvalidationsForSuggestions = ChromeFeatureList.isEnabled(
                    ChromeFeatureList.NTP_FOREIGN_SESSIONS_SUGGESTIONS);
            boolean canDisableSessionInvalidations = !requireInvalidationsForInstrumentation
                    && !requireInvalidationsForSuggestions;

            boolean canUseGcmUpstream =
                    FieldTrialList.findFullName("InvalidationsGCMUpstream").equals("Enabled");
            sInstance = new InvalidationController(
                    context, canDisableSessionInvalidations, canUseGcmUpstream);
        }
        return sInstance;
    }
}
 
Example #5
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 #6
Source File: DeferredStartupHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void startModerateBindingManagementIfNeeded() {
    // Moderate binding doesn't apply to low end devices.
    if (SysUtils.isLowEndDevice()) return;

    boolean moderateBindingTillBackgrounded =
            FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreation")
                    .equals("Enabled");
    ChildProcessLauncher.startModerateBindingManagement(
            mAppContext, moderateBindingTillBackgrounded);
}
 
Example #7
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 #8
Source File: DataUseTabUIManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return true if the data use tracking ended UI (snackbar or interstitial) should be shown.
 */
public static boolean shouldShowDataUseEndedUI() {
    // UI should be shown only when field trial is active, not disabled in Finch and in
    // non-roaming-cellular connection.
    return FieldTrialList.trialExists(DATA_USE_FIELD_TRIAL)
            && !DISABLE_DATA_USE_UI_PARAM_VALUE.equals(
                       VariationsAssociatedData.getVariationParamValue(
                               DATA_USE_FIELD_TRIAL, DISABLE_DATA_USE_ENDED_UI_PARAM))
            && nativeIsNonRoamingCellularConnection();
}
 
Example #9
Source File: DataUseTabUIManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return true if the data use tracking started UI (snackbar) should be shown.
 */
public static boolean shouldShowDataUseStartedUI() {
    // UI should be shown only when field trial is active, not disabled in Finch and in
    // non-roaming-cellular connection.
    return FieldTrialList.trialExists(DATA_USE_FIELD_TRIAL)
            && !DISABLE_DATA_USE_UI_PARAM_VALUE.equals(
                       VariationsAssociatedData.getVariationParamValue(
                               DATA_USE_FIELD_TRIAL, DISABLE_DATA_USE_STARTED_UI_PARAM))
            && nativeIsNonRoamingCellularConnection();
}
 
Example #10
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 #11
Source File: DataUseTabUIManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return true if the data use tracking started UI (snackbar) should be shown.
 */
public static boolean shouldShowDataUseStartedUI() {
    // UI should be shown only when field trial is active, not disabled in Finch and in
    // non-roaming-cellular connection.
    return FieldTrialList.trialExists(DATA_USE_FIELD_TRIAL)
            && !DISABLE_DATA_USE_UI_PARAM_VALUE.equals(
                       VariationsAssociatedData.getVariationParamValue(
                               DATA_USE_FIELD_TRIAL, DISABLE_DATA_USE_STARTED_UI_PARAM))
            && nativeIsNonRoamingCellularConnection();
}
 
Example #12
Source File: DataUseTabUIManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return true if the data use tracking ended UI (snackbar or interstitial) should be shown.
 */
public static boolean shouldShowDataUseEndedUI() {
    // UI should be shown only when field trial is active, not disabled in Finch and in
    // non-roaming-cellular connection.
    return FieldTrialList.trialExists(DATA_USE_FIELD_TRIAL)
            && !DISABLE_DATA_USE_UI_PARAM_VALUE.equals(
                       VariationsAssociatedData.getVariationParamValue(
                               DATA_USE_FIELD_TRIAL, DISABLE_DATA_USE_ENDED_UI_PARAM))
            && nativeIsNonRoamingCellularConnection();
}
 
Example #13
Source File: DataUseTabUIManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return true if the data use tracking started UI (snackbar) should be shown.
 */
public static boolean shouldShowDataUseStartedUI() {
    // UI should be shown only when field trial is active, not disabled in Finch and in
    // non-roaming-cellular connection.
    return FieldTrialList.trialExists(DATA_USE_FIELD_TRIAL)
            && !DISABLE_DATA_USE_UI_PARAM_VALUE.equals(
                       VariationsAssociatedData.getVariationParamValue(
                               DATA_USE_FIELD_TRIAL, DISABLE_DATA_USE_STARTED_UI_PARAM))
            && nativeIsNonRoamingCellularConnection();
}
 
Example #14
Source File: DeferredStartupHandler.java    From delion with Apache License 2.0 5 votes vote down vote up
private void startModerateBindingManagementIfNeeded() {
    // Moderate binding doesn't apply to low end devices.
    if (SysUtils.isLowEndDevice()) return;

    boolean moderateBindingTillBackgrounded =
            FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreation")
                    .equals("Enabled");
    ChildProcessLauncher.startModerateBindingManagement(
            mAppContext, moderateBindingTillBackgrounded);
}
 
Example #15
Source File: DataUseTabUIManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return true if the data use tracking ended UI (snackbar or interstitial) should be shown.
 */
public static boolean shouldShowDataUseEndedUI() {
    // UI should be shown only when field trial is active, not disabled in Finch and in
    // non-roaming-cellular connection.
    return FieldTrialList.trialExists(DATA_USE_FIELD_TRIAL)
            && !DISABLE_DATA_USE_UI_PARAM_VALUE.equals(
                       VariationsAssociatedData.getVariationParamValue(
                               DATA_USE_FIELD_TRIAL, DISABLE_DATA_USE_ENDED_UI_PARAM))
            && nativeIsNonRoamingCellularConnection();
}
 
Example #16
Source File: FirstRunFlowSequencer.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
protected boolean shouldShowDataReductionPage() {
    return !DataReductionProxySettings.getInstance().isDataReductionProxyManaged()
            && FieldTrialList.findFullName("DataReductionProxyFREPromo").startsWith("Enabled");
}
 
Example #17
Source File: FirstRunFlowSequencer.java    From delion with Apache License 2.0 4 votes vote down vote up
protected boolean shouldShowDataReductionPage() {
    return !DataReductionProxySettings.getInstance().isDataReductionProxyManaged()
            && FieldTrialList.findFullName("DataReductionProxyFREPromo").startsWith("Enabled");
}
 
Example #18
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);
    }
}
 
Example #19
Source File: FirstRunFlowSequencer.java    From 365browser with Apache License 2.0 4 votes vote down vote up
protected boolean shouldShowDataReductionPage() {
    return !DataReductionProxySettings.getInstance().isDataReductionProxyManaged()
            && FieldTrialList.findFullName("DataReductionProxyFREPromo").startsWith("Enabled");
}