org.chromium.base.CommandLine Java Examples

The following examples show how to use org.chromium.base.CommandLine. 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 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 #2
Source File: ApplicationInitialization.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Enable fullscreen related startup flags.
 * @param resources Resources to use while calculating initialization constants.
 * @param resControlContainerHeight The resource id for the height of the browser controls.
 */
public static void enableFullscreenFlags(
        Resources resources, Context context, int resControlContainerHeight) {
    ContentApplication.initCommandLine(context);

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN)) return;

    TypedValue threshold = new TypedValue();
    resources.getValue(R.dimen.top_controls_show_threshold, threshold, true);
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_SHOW_THRESHOLD, threshold.coerceToString().toString());
    resources.getValue(R.dimen.top_controls_hide_threshold, threshold, true);
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_HIDE_THRESHOLD, threshold.coerceToString().toString());
}
 
Example #3
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 #4
Source File: ContextualSearchFieldTrial.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private static boolean detectEnabled() {
    if (SysUtils.isLowEndDevice()) {
        return false;
    }

    // Allow this user-flippable flag to disable the feature.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CONTEXTUAL_SEARCH)) {
        return false;
    }

    // Allow this user-flippable flag to enable the feature.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH)) {
        return true;
    }

    // Allow disabling the feature remotely.
    if (getBooleanParam(DISABLED_PARAM)) {
        return false;
    }

    return true;
}
 
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: ApplicationInitialization.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Enable fullscreen related startup flags.
 * @param resources Resources to use while calculating initialization constants.
 * @param resControlContainerHeight The resource id for the height of the browser controls.
 */
public static void enableFullscreenFlags(
        Resources resources, Context context, int resControlContainerHeight) {
    ContentApplication.initCommandLine(context);

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN)) return;

    TypedValue threshold = new TypedValue();
    resources.getValue(R.dimen.top_controls_show_threshold, threshold, true);
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_SHOW_THRESHOLD, threshold.coerceToString().toString());
    resources.getValue(R.dimen.top_controls_hide_threshold, threshold, true);
    Log.w("renshuai: ", "hello" + threshold.coerceToString().toString());
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_HIDE_THRESHOLD, threshold.coerceToString().toString());

}
 
Example #7
Source File: ChromeBrowserInitializer.java    From delion with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, mApplication);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)) {
        ChromeWebApkHost.init();
    }

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example #8
Source File: FirstRunFlowSequencer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Starts determining parameters for the First Run.
 * Once finished, calls onFlowIsKnown().
 */
public void start() {
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(mActivity)) {
        onFlowIsKnown(null);
        return;
    }

    new AndroidEduAndChildAccountHelper() {
        @Override
        public void onParametersReady() {
            initializeSharedState(isAndroidEduDevice(), hasChildAccount());
            processFreEnvironmentPreNative();
        }
    }.start(mActivity.getApplicationContext());
}
 
Example #9
Source File: FirstRunFlowSequencer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Starts determining parameters for the First Run.
 * Once finished, calls onFlowIsKnown().
 */
public void start() {
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
            || ApiCompatibilityUtils.isDemoUser(mActivity)) {
        onFlowIsKnown(null);
        return;
    }

    if (!mLaunchProperties.getBoolean(FirstRunActivity.EXTRA_USE_FRE_FLOW_SEQUENCER)) {
        onFlowIsKnown(mLaunchProperties);
        return;
    }

    new AndroidEduAndChildAccountHelper() {
        @Override
        public void onParametersReady() {
            processFreEnvironment(isAndroidEduDevice(), hasChildAccount());
        }
    }.start(mActivity.getApplicationContext());
}
 
Example #10
Source File: ApplicationInitialization.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Enable fullscreen related startup flags.
 * @param resources Resources to use while calculating initialization constants.
 * @param resControlContainerHeight The resource id for the height of the top controls.
 */
public static void enableFullscreenFlags(
        Resources resources, Context context, int resControlContainerHeight) {
    ContentApplication.initCommandLine(context);

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN)) return;

    TypedValue threshold = new TypedValue();
    resources.getValue(R.dimen.top_controls_show_threshold, threshold, true);
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_SHOW_THRESHOLD, threshold.coerceToString().toString());
    resources.getValue(R.dimen.top_controls_hide_threshold, threshold, true);
    commandLine.appendSwitchWithValue(
            ContentSwitches.TOP_CONTROLS_HIDE_THRESHOLD, threshold.coerceToString().toString());
}
 
Example #11
Source File: ContextualSearchFieldTrial.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private static boolean detectEnabled() {
    if (SysUtils.isLowEndDevice()) {
        return false;
    }

    // Allow this user-flippable flag to disable the feature.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CONTEXTUAL_SEARCH)) {
        return false;
    }

    // Allow this user-flippable flag to enable the feature.
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH)) {
        return true;
    }

    // Allow disabling the feature remotely.
    if (getBooleanParam(DISABLED_PARAM)) {
        return false;
    }

    return true;
}
 
Example #12
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onNewIntentWithNative(Intent intent) {
    try {
        TraceEvent.begin("ChromeTabbedActivity.onNewIntentWithNative");

        super.onNewIntentWithNative(intent);
        if (isMainIntentFromLauncher(intent)) {
            if (IntentHandler.getUrlFromIntent(intent) == null) {
                maybeLaunchNtpFromMainIntent(intent);
            }
            logMainIntentBehavior(intent);
        }

        if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)) {
            handleDebugIntent(intent);
        }
    } finally {
        TraceEvent.end("ChromeTabbedActivity.onNewIntentWithNative");
    }
}
 
Example #13
Source File: PhysicalDisplayAndroid.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private static boolean hasForcedDIPScale() {
    if (sForcedDIPScale == null) {
        String forcedScaleAsString = CommandLine.getInstance().getSwitchValue(
                DisplaySwitches.FORCE_DEVICE_SCALE_FACTOR);
        if (forcedScaleAsString == null) {
            sForcedDIPScale = Float.valueOf(0.0f);
        } else {
            boolean isInvalid = false;
            try {
                sForcedDIPScale = Float.valueOf(forcedScaleAsString);
                // Negative values are discarded.
                if (sForcedDIPScale.floatValue() <= 0.0f) isInvalid = true;
            } catch (NumberFormatException e) {
                // Strings that do not represent numbers are discarded.
                isInvalid = true;
            }

            if (isInvalid) {
                Log.w(TAG, "Ignoring invalid forced DIP scale '" + forcedScaleAsString + "'");
                sForcedDIPScale = Float.valueOf(0.0f);
            }
        }
    }
    return sForcedDIPScale.floatValue() > 0;
}
 
Example #14
Source File: UpdateMenuItemHelper.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a boolean VariationsAssociatedData parameter, assuming the <paramName>="true" format.
 * 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 Whether the param is defined with a value "true", if there's a command-line
 *         flag present with any value.
 */
private static boolean getBooleanParam(String paramName) {
    if (CommandLine.getInstance().hasSwitch(paramName)) {
        return true;
    }
    return TextUtils.equals(ENABLED_VALUE,
            VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName));
}
 
Example #15
Source File: ToolbarTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar);

    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
    mBackButton = (TintedImageButton) findViewById(R.id.back_button);
    mForwardButton = (TintedImageButton) findViewById(R.id.forward_button);
    mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button);
    mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext())
            || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK);

    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true);

    mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button);
    mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable);
    updateSwitcherButtonVisibility(mShowTabStack);

    mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button);

    mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
    mMenuButtonWrapper.setVisibility(View.VISIBLE);

    if (mAccessibilitySwitcherButton.getVisibility() == View.GONE
            && mMenuButtonWrapper.getVisibility() == View.GONE) {
        ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0,
                getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0);
    }

    mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button);

    // Initialize values needed for showing/hiding toolbar buttons when the activity size
    // changes.
    mShouldAnimateButtonVisibilityChange = false;
    mToolbarButtonsVisible = true;
    mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton};
}
 
Example #16
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 #17
Source File: LibraryLoader.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void ensureCommandLineSwitchedAlreadyLocked() {
    assert mLoaded;
    if (mCommandLineSwitched) {
        return;
    }
    nativeInitCommandLine(CommandLine.getJavaSwitchesOrNull());
    CommandLine.enableNativeProxy();
    mCommandLineSwitched = true;
}
 
Example #18
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * This is needed for device class manager which depends on commandline args that are
 * initialized in preInflationStartup()
 */
private void preInflationStartupDone() {
    // Domain reliability uses significant enough memory that we should disable it on low memory
    // devices for now.
    // TODO(zbowling): remove this after domain reliability is refactored. (crbug.com/495342)
    if (SysUtils.isLowEndDevice()) {
        CommandLine.getInstance().appendSwitch(ChromeSwitches.DISABLE_DOMAIN_RELIABILITY);
    }
}
 
Example #19
Source File: PartnerBrowserCustomizations.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return Home page URL from Android provider. If null, that means either there is no homepage
 *         provider or provider set it to null to disable homepage.
 */
public static String getHomePageUrl() {
    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ChromeSwitches.PARTNER_HOMEPAGE_FOR_TESTING)) {
        return commandLine.getSwitchValue(ChromeSwitches.PARTNER_HOMEPAGE_FOR_TESTING);
    }
    return sHomepage;
}
 
Example #20
Source File: TabContentManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param context               The context that this cache is created in.
 * @param resourceId            The resource that this value might be defined in.
 * @param commandLineSwitch     The switch for which we would like to extract value from.
 * @return the value of an integer resource.  If the value is overridden on the command line
 * with the given switch, return the override instead.
 */
private static int getIntegerResourceWithOverride(Context context, int resourceId,
        String commandLineSwitch) {
    int val = context.getResources().getInteger(resourceId);
    String switchCount = CommandLine.getInstance().getSwitchValue(commandLineSwitch);
    if (switchCount != null) {
        int count = Integer.parseInt(switchCount);
        val = count;
    }
    return val;
}
 
Example #21
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 #22
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether Reader mode and its new UI are enabled.
 * @param context A context
 */
public static boolean isEnabled(Context context) {
    if (context == null) return false;

    boolean enabled = CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_DOM_DISTILLER)
            && !CommandLine.getInstance().hasSwitch(
                       ChromeSwitches.DISABLE_READER_MODE_BOTTOM_BAR)
            && !DeviceFormFactor.isTablet()
            && DomDistillerTabUtils.isDistillerHeuristicsEnabled()
            && !SysUtils.isLowEndDevice();
    return enabled;
}
 
Example #23
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeState() {
    super.initializeState();
    mBlimpClientContextDelegate =
            ChromeBlimpClientContextDelegate.createAndSetDelegateForContext(
                    Profile.getLastUsedProfile().getOriginalProfile());

    IntentHandler.setTestIntentsEnabled(
            CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS));
    mIntentHandler = new IntentHandler(createIntentHandlerDelegate(), getPackageName());
}
 
Example #24
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * This is needed for device class manager which depends on commandline args that are
 * initialized in preInflationStartup()
 */
private void preInflationStartupDone() {
    // Domain reliability uses significant enough memory that we should disable it on low memory
    // devices for now.
    // TODO(zbowling): remove this after domain reliability is refactored. (crbug.com/495342)
    if (DeviceClassManager.disableDomainReliability()) {
        CommandLine.getInstance().appendSwitch(ChromeSwitches.DISABLE_DOMAIN_RELIABILITY);
    }
}
 
Example #25
Source File: ContextualSearchFieldTrial.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a boolean Finch parameter, assuming the <paramName>="true" format.  Also checks for a
 * command-line switch with the same name, for easy local testing.
 * @param paramName The name of the Finch parameter (or command-line switch) to get a value for.
 * @return Whether the Finch param is defined with a value "true", if there's a command-line
 *         flag present with any value.
 */
private static boolean getBooleanParam(String paramName) {
    if (CommandLine.getInstance().hasSwitch(paramName)) {
        return true;
    }
    return TextUtils.equals(ENABLED_VALUE,
            VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName));
}
 
Example #26
Source File: PartnerBrowserCustomizations.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Home page URL from Android provider. If null, that means either there is no homepage
 *         provider or provider set it to null to disable homepage.
 */
public static String getHomePageUrl() {
    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ChromeSwitches.PARTNER_HOMEPAGE_FOR_TESTING)) {
        return commandLine.getSwitchValue(ChromeSwitches.PARTNER_HOMEPAGE_FOR_TESTING);
    }
    return sHomepage;
}
 
Example #27
Source File: CustomTabsConnection.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * <strong>DO NOT CALL</strong>
 * Public to be instanciable from {@link ChromeApplication}. This is however
 * intended to be private.
 */
public CustomTabsConnection(Application application) {
    super();
    mApplication = application;
    mClientManager = new ClientManager(mApplication);
    mLogRequests = CommandLine.getInstance().hasSwitch(LOG_SERVICE_REQUESTS);
}
 
Example #28
Source File: TabContentManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param context               The context that this cache is created in.
 * @param resourceId            The resource that this value might be defined in.
 * @param commandLineSwitch     The switch for which we would like to extract value from.
 * @return the value of an integer resource.  If the value is overridden on the command line
 * with the given switch, return the override instead.
 */
private static int getIntegerResourceWithOverride(Context context, int resourceId,
        String commandLineSwitch) {
    int val = context.getResources().getInteger(resourceId);
    String switchCount = CommandLine.getInstance().getSwitchValue(commandLineSwitch);
    if (switchCount != null) {
        int count = Integer.parseInt(switchCount);
        val = count;
    }
    return val;
}
 
Example #29
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether Reader mode and its new UI are enabled.
 * @param context A context
 */
public static boolean isEnabled(Context context) {
    if (context == null) return false;

    boolean enabled = CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_DOM_DISTILLER)
            && !CommandLine.getInstance().hasSwitch(
                    ChromeSwitches.DISABLE_READER_MODE_BOTTOM_BAR)
            && !DeviceFormFactor.isTablet(context)
            && DomDistillerTabUtils.isDistillerHeuristicsEnabled()
            && !SysUtils.isLowEndDevice();
    return enabled;
}
 
Example #30
Source File: DeviceClassManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * The {@link DeviceClassManager} constructor should be self contained and
 * rely on system information and command line flags.
 */
private DeviceClassManager() {
    // Device based configurations.
    if (SysUtils.isLowEndDevice()) {
        mEnableSnapshots = false;
        mEnableLayerDecorationCache = true;
        mEnableAccessibilityLayout = true;
        mEnableAnimations = false;
        mEnablePrerendering = false;
        mEnableToolbarSwipe = false;
        mDisableDomainReliability = true;
    } else {
        mEnableSnapshots = true;
        mEnableLayerDecorationCache = true;
        mEnableAccessibilityLayout = false;
        mEnableAnimations = true;
        mEnablePrerendering = true;
        mEnableToolbarSwipe = true;
        mDisableDomainReliability = false;
    }

    if (DeviceFormFactor.isTablet(ContextUtils.getApplicationContext())) {
        mEnableAccessibilityLayout = false;
    }

    // Flag based configurations.
    CommandLine commandLine = CommandLine.getInstance();
    mEnableAccessibilityLayout |= commandLine
            .hasSwitch(ChromeSwitches.ENABLE_ACCESSIBILITY_TAB_SWITCHER);
    mEnableFullscreen =
            !commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN);

    // Related features.
    if (mEnableAccessibilityLayout) {
        mEnableAnimations = false;
    }
}