Java Code Examples for org.chromium.components.variations.VariationsAssociatedData#getVariationParamValue()

The following examples show how to use org.chromium.components.variations.VariationsAssociatedData#getVariationParamValue() . 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: ContextualSearchFieldTrial.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an integer value for a Finch parameter, or the default value if no parameter exists
 * in the current configuration.  Also checks for a command-line switch with the same name.
 * @param paramName The name of the Finch parameter (or command-line switch) to get a value for.
 * @param defaultValue The default value to return when there's no param or switch.
 * @return An integer value -- either the param or the default.
 */
private static int getIntParamValueOrDefault(String paramName, int defaultValue) {
    String value = CommandLine.getInstance().getSwitchValue(paramName);
    if (TextUtils.isEmpty(value)) {
        value = VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName);
    }
    if (!TextUtils.isEmpty(value)) {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }

    return defaultValue;
}
 
Example 2
Source File: ContextualSearchFieldTrial.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an integer value for a Finch parameter, or the default value if no parameter exists
 * in the current configuration.  Also checks for a command-line switch with the same name.
 * @param paramName The name of the Finch parameter (or command-line switch) to get a value for.
 * @param defaultValue The default value to return when there's no param or switch.
 * @return An integer value -- either the param or the default.
 */
private static int getIntParamValueOrDefault(String paramName, int defaultValue) {
    String value = CommandLine.getInstance().getSwitchValue(paramName);
    if (TextUtils.isEmpty(value)) {
        value = VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName);
    }
    if (!TextUtils.isEmpty(value)) {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }

    return defaultValue;
}
 
Example 3
Source File: ContextualSearchFieldTrial.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an integer value for a Finch parameter, or the default value if no parameter exists
 * in the current configuration.  Also checks for a command-line switch with the same name.
 * @param paramName The name of the Finch parameter (or command-line switch) to get a value for.
 * @param defaultValue The default value to return when there's no param or switch.
 * @return An integer value -- either the param or the default.
 */
private static int getIntParamValueOrDefault(String paramName, int defaultValue) {
    String value = CommandLine.getInstance().getSwitchValue(paramName);
    if (TextUtils.isEmpty(value)) {
        value = VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName);
    }
    if (!TextUtils.isEmpty(value)) {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }

    return defaultValue;
}
 
Example 4
Source File: UpdateMenuItemHelper.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a String VariationsAssociatedData parameter. Also checks for a command-line switch with
 * the same name, for easy local testing.
 * @param paramName The name of the parameter (or command-line switch) to get a value for.
 * @return The command-line flag value if present, or the param is value if present.
 */
private static String getStringParamValue(String paramName) {
    String value = CommandLine.getInstance().getSwitchValue(paramName);
    if (TextUtils.isEmpty(value)) {
        value = VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName);
    }
    return value;
}
 
Example 5
Source File: CardsVariationParameters.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private static int getIntValue(String paramName, int defaultValue) {
    // TODO(jkrcal): Get parameter by feature name, not field trial name.
    String value = VariationsAssociatedData.getVariationParamValue(
            FIELD_TRIAL_NAME, paramName);

    if (!TextUtils.isEmpty(value)) {
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException ex) {
            Log.w(TAG, "Cannot parse %s experiment value, %s.", paramName, value);
        }
    }

    return defaultValue;
}
 
Example 6
Source File: UpdateMenuItemHelper.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a String VariationsAssociatedData parameter. Also checks for a command-line switch with
 * the same name, for easy local testing.
 * @param paramName The name of the parameter (or command-line switch) to get a value for.
 * @return The command-line flag value if present, or the param is value if present.
 */
private static String getStringParamValue(String paramName) {
    String value = CommandLine.getInstance().getSwitchValue(paramName);
    if (TextUtils.isEmpty(value)) {
        value = VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName);
    }
    return value;
}
 
Example 7
Source File: DataReductionPromoSnackbarController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of a {@link DataReductionPromoSnackbarController}.
 *
 * @param context The {@link Context} in which snackbar is shown.
 * @param snackbarManager The manager that helps to show the snackbar.
 */
public DataReductionPromoSnackbarController(Context context, SnackbarManager snackbarManager) {
    mSnackbarManager = snackbarManager;
    mContext = context;

    String variationParamValue = VariationsAssociatedData
            .getVariationParamValue(PROMO_FIELD_TRIAL_NAME, PROMO_PARAM_NAME);

    if (variationParamValue.isEmpty()) {
        if (CommandLine.getInstance()
                .hasSwitch(ENABLE_DATA_REDUCTION_PROXY_SAVINGS_PROMO_SWITCH)) {
            mPromoDataSavingsMB = new int[1];
            mPromoDataSavingsMB[0] = 1;
        } else {
            mPromoDataSavingsMB = new int[0];
        }
    } else {
        variationParamValue = variationParamValue.replace(" ", "");
        String[] promoDataSavingStrings = variationParamValue.split(";");

        if (CommandLine.getInstance()
                .hasSwitch(ENABLE_DATA_REDUCTION_PROXY_SAVINGS_PROMO_SWITCH)) {
            mPromoDataSavingsMB = new int[promoDataSavingStrings.length + 1];
            mPromoDataSavingsMB[promoDataSavingStrings.length] = 1;
        } else {
            mPromoDataSavingsMB = new int[promoDataSavingStrings.length];
        }

        for (int i = 0; i < promoDataSavingStrings.length; i++) {
            try {
                mPromoDataSavingsMB[i] = Integer.parseInt(promoDataSavingStrings[i]);
            } catch (NumberFormatException e) {
                mPromoDataSavingsMB[i] = -1;
            }
        }
    }
}
 
Example 8
Source File: CardsVariationParameters.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static String getParamValue(String fieldTrialName, String paramName) {
    if (sTestVariationParams != null) {
        String value = sTestVariationParams.get(paramName);
        if (value == null) return "";
        return value;
    }

    return VariationsAssociatedData.getVariationParamValue(fieldTrialName, paramName);
}
 
Example 9
Source File: UpdateMenuItemHelper.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a String VariationsAssociatedData parameter. Also checks for a command-line switch with
 * the same name, for easy local testing.
 * @param paramName The name of the parameter (or command-line switch) to get a value for.
 * @return The command-line flag value if present, or the param is value if present.
 */
private static String getStringParamValue(String paramName) {
    String value = CommandLine.getInstance().getSwitchValue(paramName);
    if (TextUtils.isEmpty(value)) {
        value = VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName);
    }
    return value;
}
 
Example 10
Source File: DataReductionPromoSnackbarController.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of a {@link DataReductionPromoSnackbarController}.
 *
 * @param context The {@link Context} in which snackbar is shown.
 * @param snackbarManager The manager that helps to show the snackbar.
 */
public DataReductionPromoSnackbarController(Context context, SnackbarManager snackbarManager) {
    mSnackbarManager = snackbarManager;
    mContext = context;

    String variationParamValue = VariationsAssociatedData
            .getVariationParamValue(PROMO_FIELD_TRIAL_NAME, PROMO_PARAM_NAME);

    if (variationParamValue.isEmpty()) {
        if (CommandLine.getInstance()
                .hasSwitch(ENABLE_DATA_REDUCTION_PROXY_SAVINGS_PROMO_SWITCH)) {
            mPromoDataSavingsMB = new int[1];
            mPromoDataSavingsMB[0] = 1;
        } else {
            mPromoDataSavingsMB = new int[0];
        }
    } else {
        variationParamValue = variationParamValue.replace(" ", "");
        String[] promoDataSavingStrings = variationParamValue.split(";");

        if (CommandLine.getInstance()
                .hasSwitch(ENABLE_DATA_REDUCTION_PROXY_SAVINGS_PROMO_SWITCH)) {
            mPromoDataSavingsMB = new int[promoDataSavingStrings.length + 1];
            mPromoDataSavingsMB[promoDataSavingStrings.length] = 1;
        } else {
            mPromoDataSavingsMB = new int[promoDataSavingStrings.length];
        }

        for (int i = 0; i < promoDataSavingStrings.length; i++) {
            try {
                mPromoDataSavingsMB[i] = Integer.parseInt(promoDataSavingStrings[i]);
            } catch (NumberFormatException e) {
                mPromoDataSavingsMB[i] = -1;
            }
        }
    }

    if (CommandLine.getInstance().hasSwitch(CLEAR_DATA_REDUCTION_PROXY_DATA_SAVINGS_SWITCH)) {
        DataReductionPromoUtils.saveSnackbarPromoDisplayed(0);
    }
}