Java Code Examples for org.chromium.chrome.browser.partnercustomizations.HomepageManager#isHomepageEnabled()

The following examples show how to use org.chromium.chrome.browser.partnercustomizations.HomepageManager#isHomepageEnabled() . 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: TabModelImpl.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void closeAllTabs(boolean allowDelegation, boolean uponExit) {
    mTabSaver.cancelLoadingTabs(isIncognito());

    if (uponExit) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (allowDelegation && mModelDelegate.closeAllTabsRequest(isIncognito())) return;

    if (HomepageManager.isHomepageEnabled(ContextUtils.getApplicationContext())) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    closeAllTabs(true, false, true);
}
 
Example 2
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a UI element is done animating the close tab effect started by
 * {@link #uiRequestingCloseTab(long, int)}.  This actually pushes the close event to the model.
 * @param time      The current time of the app in ms.
 * @param id        The id of the tab to close.
 * @param canUndo   Whether or not this close can be undone.
 * @param incognito Whether or not this was for the incognito stack or not.
 */
public void uiDoneClosingTab(long time, int id, boolean canUndo, boolean incognito) {
    // If homepage is enabled and there is a maximum of 1 tab in both models
    // (this is the last tab), the tab closure cannot be undone.
    canUndo &= !(HomepageManager.isHomepageEnabled(getContext())
                       && (mTabModelSelector.getModel(true).getCount()
                                          + mTabModelSelector.getModel(false).getCount()
                                  < 2));

    // Propagate the tab closure to the model.
    TabModelUtils.closeTabById(mTabModelSelector.getModel(incognito), id, canUndo);
}
 
Example 3
Source File: TabModelImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void closeAllTabs(boolean allowDelegation, boolean uponExit) {
    mTabSaver.cancelLoadingTabs(isIncognito());

    if (uponExit) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (allowDelegation && mModelDelegate.closeAllTabsRequest(isIncognito())) return;

    if (HomepageManager.isHomepageEnabled(ContextUtils.getApplicationContext())) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (getCount() == 1) {
        closeTab(getTabAt(0), true, false, true);
        return;
    }

    closeAllTabs(true, false, true);
}
 
Example 4
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a UI element is done animating the close tab effect started by
 * {@link #uiRequestingCloseTab(long, int)}.  This actually pushes the close event to the model.
 * @param time      The current time of the app in ms.
 * @param id        The id of the tab to close.
 * @param canUndo   Whether or not this close can be undone.
 * @param incognito Whether or not this was for the incognito stack or not.
 */
public void uiDoneClosingTab(long time, int id, boolean canUndo, boolean incognito) {
    // If homepage is enabled and there is a maximum of 1 tab in both models
    // (this is the last tab), the tab closure cannot be undone.
    canUndo &= !(HomepageManager.isHomepageEnabled(getContext())
                       && (mTabModelSelector.getModel(true).getCount()
                                          + mTabModelSelector.getModel(false).getCount()
                                  < 2));

    // Propagate the tab closure to the model.
    TabModelUtils.closeTabById(mTabModelSelector.getModel(incognito), id, canUndo);
}
 
Example 5
Source File: TabModelImpl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void closeAllTabs(boolean allowDelegation, boolean uponExit) {
    mTabSaver.cancelLoadingTabs(isIncognito());

    if (uponExit) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (allowDelegation && mModelDelegate.closeAllTabsRequest(isIncognito())) return;

    if (HomepageManager.isHomepageEnabled(ContextUtils.getApplicationContext())) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (getCount() == 1) {
        closeTab(getTabAt(0), true, false, true);
        return;
    }

    closeAllTabs(true, false, true);
}
 
Example 6
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a UI element is done animating the close tab effect started by
 * {@link #uiRequestingCloseTab(long, int)}.  This actually pushes the close event to the model.
 * @param time      The current time of the app in ms.
 * @param id        The id of the tab to close.
 * @param canUndo   Whether or not this close can be undone.
 * @param incognito Whether or not this was for the incognito stack or not.
 */
public void uiDoneClosingTab(long time, int id, boolean canUndo, boolean incognito) {
    // If homepage is enabled and there is a maximum of 1 tab in both models
    // (this is the last tab), the tab closure cannot be undone.
    canUndo &= !(HomepageManager.isHomepageEnabled(getContext())
                       && (mTabModelSelector.getModel(true).getCount()
                                          + mTabModelSelector.getModel(false).getCount()
                                  < 2));

    // Propagate the tab closure to the model.
    TabModelUtils.closeTabById(mTabModelSelector.getModel(incognito), id, canUndo);
}
 
Example 7
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeCompositor() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeCompositor");
        super.initializeCompositor();

        mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());
        mVrShellDelegate.onNativeLibraryReady();

        mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelectorImpl) {
            @Override
            public void didCloseTab(int tabId, boolean incognito) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            @Override
            public void tabPendingClosure(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(true);
            }

            @Override
            public void tabRemoved(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            private void closeIfNoTabsAndHomepageEnabled(boolean isPendingClosure) {
                if (getTabModelSelector().getTotalTabCount() == 0) {
                    // If the last tab is closed, and homepage is enabled, then exit Chrome.
                    if (HomepageManager.isHomepageEnabled(getApplicationContext())) {
                        finish();
                    } else if (isPendingClosure) {
                        NewTabPageUma.recordNTPImpression(
                                NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
                    }
                }
            }

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                if (type == TabLaunchType.FROM_LONGPRESS_BACKGROUND
                        && !DeviceClassManager.enableAnimations(getApplicationContext())) {
                    Toast.makeText(ChromeTabbedActivity.this,
                            R.string.open_in_new_tab_toast,
                            Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void allTabsPendingClosure(List<Integer> tabIds) {
                NewTabPageUma.recordNTPImpression(
                        NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
            }
        };

        Bundle state = getSavedInstanceState();
        if (state != null && state.containsKey(FRE_RUNNING)) {
            mIsOnFirstRun = state.getBoolean(FRE_RUNNING);
        }
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeCompositor");
    }
}
 
Example 8
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeCompositor() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeCompositor");
        super.initializeCompositor();

        mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());

        mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelectorImpl) {
            @Override
            public void didCloseTab(int tabId, boolean incognito) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            @Override
            public void tabPendingClosure(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(true);
            }

            @Override
            public void tabRemoved(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            private void closeIfNoTabsAndHomepageEnabled(boolean isPendingClosure) {
                if (getTabModelSelector().getTotalTabCount() == 0) {
                    // If the last tab is closed, and homepage is enabled, then exit Chrome.
                    if (HomepageManager.isHomepageEnabled(getApplicationContext())) {
                        finish();
                    } else if (isPendingClosure) {
                        NewTabPageUma.recordNTPImpression(
                                NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
                    }
                }
            }

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                if (type == TabLaunchType.FROM_LONGPRESS_BACKGROUND
                        && !DeviceClassManager.enableAnimations()) {
                    Toast.makeText(ChromeTabbedActivity.this,
                            R.string.open_in_new_tab_toast,
                            Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void allTabsPendingClosure(List<Tab> tabs) {
                NewTabPageUma.recordNTPImpression(
                        NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
            }
        };

        Bundle state = getSavedInstanceState();
        if (state != null && state.containsKey(FRE_RUNNING)) {
            mIsOnFirstRun = state.getBoolean(FRE_RUNNING);
        }
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeCompositor");
    }
}