Java Code Examples for org.chromium.chrome.browser.util.FeatureUtilities#isDocumentMode()

The following examples show how to use org.chromium.chrome.browser.util.FeatureUtilities#isDocumentMode() . 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: ChromeTabbedActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isStartedUpCorrectly(Intent intent) {
    if (FeatureUtilities.isDocumentMode(this)) {
        Log.e(TAG, "Discarding Intent: Starting ChromeTabbedActivity in Document mode");
        return false;
    }
    return true;
}
 
Example 2
Source File: BookmarkUtils.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the title of chrome shown in recent tasks. It only takes effect in document mode.
 */
public static void setTaskDescriptionInDocumentMode(Activity activity, String description) {
    if (FeatureUtilities.isDocumentMode(activity)) {
        // Setting icon to be null and color to be 0 will means "take no effect".
        ApiCompatibilityUtils.setTaskDescription(activity, description, null, 0);
    }
}
 
Example 3
Source File: ChromeApplication.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called when last of Chrome activities is stopped, ending the foreground session. This will
 * not be called when a Chrome activity is stopped because another Chrome activity takes over.
 * This is ensured by ActivityStatus, which switches to track new activity when its started and
 * will not report the old one being stopped (see createStateListener() below).
 */
private void onForegroundSessionEnd() {
    if (!mIsStarted) return;
    mBackgroundProcessing.suspendTimers();
    flushPersistentData();
    mIsStarted = false;
    mPowerBroadcastReceiver.onForegroundSessionEnd();

    ChildProcessLauncher.onSentToBackground();
    IntentHandler.clearPendingReferrer();

    if (FeatureUtilities.isDocumentMode(this)) {
        if (sDocumentTabModelSelector != null) {
            RecordHistogram.recordCountHistogram("Tab.TotalTabCount.BeforeLeavingApp",
                    sDocumentTabModelSelector.getTotalTabCount());
        }
    } else {
        int totalTabCount = 0;
        for (WeakReference<Activity> reference : ApplicationStatus.getRunningActivities()) {
            Activity activity = reference.get();
            if (activity instanceof ChromeActivity) {
                TabModelSelector tabModelSelector =
                        ((ChromeActivity) activity).getTabModelSelector();
                if (tabModelSelector != null) {
                    totalTabCount += tabModelSelector.getTotalTabCount();
                }
            }
        }
        RecordHistogram.recordCountHistogram(
                "Tab.TotalTabCount.BeforeLeavingApp", totalTabCount);
    }
}
 
Example 4
Source File: TabWebContentsDelegateAndroid.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    boolean isSelected = mTab.getTabModelSelector().getCurrentTab() == mTab;
    mTab.getTabModelSelector().closeTab(mTab);

    // If the parent Tab belongs to another Activity, fire the Intent to bring it back.
    if (isSelected && mTab.getParentIntent() != null
            && mTab.getActivity().getIntent() != mTab.getParentIntent()) {
        boolean mayLaunch = FeatureUtilities.isDocumentMode(mTab.getApplicationContext())
                ? isParentInAndroidOverview() : true;
        if (mayLaunch) {
            mTab.getActivity().startActivity(mTab.getParentIntent());
        }
    }
}
 
Example 5
Source File: DocumentModeAssassin.java    From delion with Apache License 2.0 4 votes vote down vote up
/** @return Whether or not a migration to tabbed mode from document mode is necessary. */
public boolean isMigrationNecessary() {
    return FeatureUtilities.isDocumentMode(ContextUtils.getApplicationContext());
}
 
Example 6
Source File: ToolbarPhone.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mPhoneLocationBar = (LocationBarPhone) findViewById(R.id.location_bar);

    mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons);

    mReturnButton = (TintedImageButton) findViewById(R.id.return_button);
    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);

    mUrlBar = (TextView) findViewById(R.id.url_bar);

    mUrlActionsContainer = findViewById(R.id.url_action_container);

    mBrowsingModeViews.add(mPhoneLocationBar);

    mToolbarBackground = new ColorDrawable(getToolbarColorForVisualState(VisualState.NORMAL));
    mTabSwitcherAnimationBgOverlay =
            new ColorDrawable(getToolbarColorForVisualState(VisualState.NORMAL));

    mLocationBarBackground =
            ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.inset_textbox);
    mLocationBarBackground.getPadding(mUrlBackgroundPadding);
    mPhoneLocationBar.setPadding(
            mUrlBackgroundPadding.left, mUrlBackgroundPadding.top,
            mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom);

    setLayoutTransition(null);

    mMenuButtonWrapper.setVisibility(shouldShowMenuButton() ? View.VISIBLE : View.GONE);
    if (FeatureUtilities.isDocumentMode(getContext())) {
        ApiCompatibilityUtils.setMarginEnd(
                (MarginLayoutParams) mMenuButtonWrapper.getLayoutParams(),
                getResources().getDimensionPixelSize(R.dimen.document_toolbar_menu_offset));
    }

    if (FeatureUtilities.isTabSwitchingEnabled(getContext())) {
        inflateTabSwitchingResources();
    } else {
        hideTabSwitchingResources();
    }

    setWillNotDraw(false);
}
 
Example 7
Source File: ToolbarPhone.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Sets up click and key listeners once we have native library available to handle clicks.
 */
@Override
public void onNativeLibraryReady() {
    super.onNativeLibraryReady();
    getLocationBar().onNativeLibraryReady();

    if (FeatureUtilities.isTabSwitchingEnabledInDocumentMode(getContext())) {
        // We might have hidden some buttons at onFinishInflate() because it was called
        // before native library is ready and chrome switch can be correctly read.
        // Now recover those buttons. Since we want to show toolbar even before native
        // library is ready, and as tab switching is experimental, this is unavoidable.
        unhideTabSwitchingResources();
        inflateTabSwitchingResources();
        enableTabSwitchingResources();
    } else if (FeatureUtilities.isDocumentMode(getContext())) {
        removeTabSwitchingResources();
    } else {  // non-document mode
        enableTabSwitchingResources();
    }

    mHomeButton.setOnClickListener(this);

    mMenuButton.setOnKeyListener(new KeyboardNavigationListener() {
        @Override
        public View getNextFocusForward() {
            return getCurrentTabView();
        }

        @Override
        public View getNextFocusBackward() {
            return mToggleTabStackButton;
        }

        @Override
        protected boolean handleEnterKeyPress() {
            return getMenuButtonHelper().onEnterKeyPress(mMenuButton);
        }
    });
    onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext()));

    updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
 
Example 8
Source File: ExternalNavigationDelegateImpl.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isDocumentMode() {
    return FeatureUtilities.isDocumentMode(mApplicationContext);
}
 
Example 9
Source File: DocumentModeAssassin.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/** @return Whether or not a migration to tabbed mode from document mode is necessary. */
public boolean isMigrationNecessary() {
    return FeatureUtilities.isDocumentMode(ContextUtils.getApplicationContext());
}
 
Example 10
Source File: DocumentModeAssassin.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** @return Whether or not a migration to tabbed mode from document mode is necessary. */
public boolean isMigrationNecessary() {
    return FeatureUtilities.isDocumentMode(ContextUtils.getApplicationContext());
}