Java源码示例:org.chromium.base.FieldTrialList
示例1
@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();
}
示例2
/**
* 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;
}
}
示例3
/**
* 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);
}
}
示例4
/**
* 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;
}
}
示例5
/**
* 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;
}
}
示例6
/**
* @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();
}
示例7
/**
* @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();
}
示例8
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);
}
示例9
/**
* @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();
}
示例10
/**
* @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();
}
示例11
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);
}
示例12
/**
* 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);
}
}
示例13
/**
* @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();
}
示例14
/**
* @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();
}
示例15
/**
* 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);
}
}
示例16
/**
* 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);
}
}
示例17
protected boolean shouldShowDataReductionPage() {
return !DataReductionProxySettings.getInstance().isDataReductionProxyManaged()
&& FieldTrialList.findFullName("DataReductionProxyFREPromo").startsWith("Enabled");
}
示例18
protected boolean shouldShowDataReductionPage() {
return !DataReductionProxySettings.getInstance().isDataReductionProxyManaged()
&& FieldTrialList.findFullName("DataReductionProxyFREPromo").startsWith("Enabled");
}
示例19
protected boolean shouldShowDataReductionPage() {
return !DataReductionProxySettings.getInstance().isDataReductionProxyManaged()
&& FieldTrialList.findFullName("DataReductionProxyFREPromo").startsWith("Enabled");
}