Search in sources :

Example 1 with CommandLine

use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.

the class ChromeTabbedActivity method preInflationStartup.

@Override
public void preInflationStartup() {
    super.preInflationStartup();
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }
    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS) && getIntent() != null && getIntent().hasExtra(ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }
    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && getIntent().getData() != null && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0 && OmahaClient.isFreshInstallOrDataHasBeenCleared(getApplicationContext())) {
        getIntent().setData(null);
    }
}
Also used : CommandLine(org.chromium.base.CommandLine) SuppressLint(android.annotation.SuppressLint)

Example 2 with CommandLine

use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.

the class ChromeTabbedActivity method initializeUI.

private void initializeUI() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeUI");
        CommandLine commandLine = CommandLine.getInstance();
        commandLine.appendSwitch(ContentSwitches.ENABLE_INSTANT_EXTENDED_API);
        CompositorViewHolder compositorViewHolder = getCompositorViewHolder();
        if (DeviceFormFactor.isTablet(this)) {
            boolean enableTabSwitcher = CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK);
            mLayoutManager = new LayoutManagerChromeTablet(compositorViewHolder, enableTabSwitcher ? new StackLayoutFactory() : null);
        } else {
            mLayoutManager = new LayoutManagerChromePhone(compositorViewHolder, new StackLayoutFactory());
        }
        mLayoutManager.setEnableAnimations(DeviceClassManager.enableAnimations(this));
        mLayoutManager.addOverviewModeObserver(this);
        // TODO(yusufo): get rid of findViewById(R.id.url_bar).
        initializeCompositorContent(mLayoutManager, findViewById(R.id.url_bar), mContentContainer, mControlContainer);
        mTabModelSelectorImpl.setOverviewModeBehavior(mLayoutManager);
        mUndoBarPopupController.initialize();
        // Adjust the content container if we're not entering fullscreen mode.
        if (getFullscreenManager() == null) {
            float controlHeight = getResources().getDimension(R.dimen.control_container_height);
            ((FrameLayout.LayoutParams) mContentContainer.getLayoutParams()).topMargin = (int) controlHeight;
        }
        mFindToolbarManager = new FindToolbarManager(this, getToolbarManager().getActionModeController().getActionModeCallback());
        if (getContextualSearchManager() != null) {
            getContextualSearchManager().setFindToolbarManager(mFindToolbarManager);
        }
        OnClickListener tabSwitcherClickHandler = new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (getFullscreenManager() != null && getFullscreenManager().getPersistentFullscreenMode()) {
                    return;
                }
                toggleOverview();
            }
        };
        OnClickListener newTabClickHandler = new OnClickListener() {

            @Override
            public void onClick(View v) {
                getTabModelSelector().getModel(false).commitAllTabClosures();
                // This assumes that the keyboard can not be seen at the same time as the
                // newtab button on the toolbar.
                getCurrentTabCreator().launchNTP();
                mLocaleManager.showSearchEnginePromoIfNeeded(ChromeTabbedActivity.this);
            }
        };
        OnClickListener bookmarkClickHandler = new OnClickListener() {

            @Override
            public void onClick(View v) {
                addOrEditBookmark(getActivityTab());
            }
        };
        getToolbarManager().initializeWithNative(mTabModelSelectorImpl, getFullscreenManager().getBrowserVisibilityDelegate(), mFindToolbarManager, mLayoutManager, mLayoutManager, tabSwitcherClickHandler, newTabClickHandler, bookmarkClickHandler, null);
        if (isTablet()) {
            EmptyBackgroundViewWrapper bgViewWrapper = new EmptyBackgroundViewWrapper(getTabModelSelector(), getTabCreator(false), ChromeTabbedActivity.this, getAppMenuHandler(), getSnackbarManager(), mLayoutManager);
            bgViewWrapper.initialize();
        }
        mLayoutManager.hideOverview(false);
        mUIInitialized = true;
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeUI");
    }
}
Also used : CommandLine(org.chromium.base.CommandLine) LayoutManagerChromePhone(org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone) EmptyBackgroundViewWrapper(org.chromium.chrome.browser.widget.emptybackground.EmptyBackgroundViewWrapper) CompositorViewHolder(org.chromium.chrome.browser.compositor.CompositorViewHolder) FindToolbarManager(org.chromium.chrome.browser.widget.findinpage.FindToolbarManager) FrameLayout(android.widget.FrameLayout) LayoutManagerChromeTablet(org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet) OnClickListener(android.view.View.OnClickListener) View(android.view.View) ContentVideoView(org.chromium.content.browser.ContentVideoView)

Example 3 with CommandLine

use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.

the class CompositorView method resetFlags.

/**
 * Reset the commandline flags. This gets called after we switch over to the
 * native command line.
 */
public void resetFlags() {
    CommandLine commandLine = CommandLine.getInstance();
    mEnableTabletTabStack = commandLine.hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK) && DeviceFormFactor.isTablet(getContext());
}
Also used : CommandLine(org.chromium.base.CommandLine)

Example 4 with CommandLine

use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.

the class FeatureUtilities method cacheHerbFlavor.

/**
 * 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);
    }
}
Also used : Context(android.content.Context) CommandLine(org.chromium.base.CommandLine)

Example 5 with CommandLine

use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.

the class ChromeStrictMode method configureStrictMode.

/**
 * Turn on StrictMode detection based on build and command-line switches.
 */
@UiThread
// FindBugs doesn't like conditionals with compile time results
@SuppressFBWarnings("UCF_USELESS_CONTROL_FLOW")
public static void configureStrictMode() {
    assert ThreadUtils.runningOnUiThread();
    if (sIsStrictModeAlreadyConfigured) {
        return;
    }
    sIsStrictModeAlreadyConfigured = true;
    StrictMode.ThreadPolicy.Builder threadPolicy = new StrictMode.ThreadPolicy.Builder(StrictMode.getThreadPolicy());
    StrictMode.VmPolicy.Builder vmPolicy = new StrictMode.VmPolicy.Builder(StrictMode.getVmPolicy());
    CommandLine commandLine = CommandLine.getInstance();
    if ("eng".equals(Build.TYPE) || BuildConfig.DCHECK_IS_ON || ChromeVersionInfo.isLocalBuild() || commandLine.hasSwitch(ChromeSwitches.STRICT_MODE)) {
        turnOnDetection(threadPolicy, vmPolicy);
        addDefaultPenalties(threadPolicy, vmPolicy);
        if ("death".equals(commandLine.getSwitchValue(ChromeSwitches.STRICT_MODE))) {
            addThreadDeathPenalty(threadPolicy);
            addVmDeathPenalty(vmPolicy);
        } else if ("testing".equals(commandLine.getSwitchValue(ChromeSwitches.STRICT_MODE))) {
            addThreadDeathPenalty(threadPolicy);
        // Currently VmDeathPolicy kills the process, and is not visible on bot test output.
        }
    }
    // Enroll 1% of dev sessions into StrictMode watch. This is done client-side rather than
    // through finch because this decision is as early as possible in the browser initialization
    // process. We need to detect early start-up StrictMode violations before loading native and
    // before warming the SharedPreferences (that is a violation in an of itself). We will
    // closely monitor this on dev channel.
    boolean enableStrictModeWatch = (ChromeVersionInfo.isDevBuild() && Math.random() < UPLOAD_PROBABILITY);
    if ((ChromeVersionInfo.isLocalBuild() && !BuildConfig.DCHECK_IS_ON) || enableStrictModeWatch) {
        turnOnDetection(threadPolicy, vmPolicy);
        initializeStrictModeWatch();
    }
    StrictMode.setThreadPolicy(threadPolicy.build());
    StrictMode.setVmPolicy(vmPolicy.build());
}
Also used : StrictMode(android.os.StrictMode) CommandLine(org.chromium.base.CommandLine) UiThread(android.support.annotation.UiThread) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Aggregations

CommandLine (org.chromium.base.CommandLine)7 Context (android.content.Context)2 SuppressLint (android.annotation.SuppressLint)1 StrictMode (android.os.StrictMode)1 UiThread (android.support.annotation.UiThread)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 FrameLayout (android.widget.FrameLayout)1 SuppressFBWarnings (org.chromium.base.annotations.SuppressFBWarnings)1 CompositorViewHolder (org.chromium.chrome.browser.compositor.CompositorViewHolder)1 LayoutManagerChromePhone (org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone)1 LayoutManagerChromeTablet (org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet)1 EmptyBackgroundViewWrapper (org.chromium.chrome.browser.widget.emptybackground.EmptyBackgroundViewWrapper)1 FindToolbarManager (org.chromium.chrome.browser.widget.findinpage.FindToolbarManager)1 ContentVideoView (org.chromium.content.browser.ContentVideoView)1