Search in sources :

Example 1 with EmptyTabModelSelectorObserver

use of org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver in project AndroidChromium by JackyAndroid.

the class IncognitoToggleButtonTablet method setTabModelSelector.

/**
     * Sets the {@link TabModelSelector} that will be queried for information about the state of
     * the system.
     * @param selector A {@link TabModelSelector} that represents the state of the system.
     */
public void setTabModelSelector(TabModelSelector selector) {
    mTabModelSelector = selector;
    if (selector != null) {
        updateButtonResource();
        updateButtonVisibility();
        mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {

            @Override
            public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
                updateButtonResource();
            }
        };
        mTabModelSelector.addObserver(mTabModelSelectorObserver);
        mTabModelObserver = new EmptyTabModelObserver() {

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                updateButtonVisibility();
            }

            @Override
            public void willCloseTab(Tab tab, boolean animate) {
                updateButtonVisibility();
            }

            @Override
            public void tabRemoved(Tab tab) {
                updateButtonVisibility();
            }
        };
        for (TabModel model : mTabModelSelector.getModels()) {
            model.addObserver(mTabModelObserver);
        }
    }
}
Also used : EmptyTabModelSelectorObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver) Tab(org.chromium.chrome.browser.tab.Tab) TabLaunchType(org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType) TabModel(org.chromium.chrome.browser.tabmodel.TabModel) EmptyTabModelObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)

Example 2 with EmptyTabModelSelectorObserver

use of org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver in project AndroidChromium by JackyAndroid.

the class CompositorViewHolder method onFinishNativeInitialization.

/**
     * Sets the appropriate objects this class should represent.
     * @param tabModelSelector        The {@link TabModelSelector} this View should hold and
     *                                represent.
     * @param tabCreatorManager       The {@link TabCreatorManager} for this view.
     * @param tabContentManager       The {@link TabContentManager} for the tabs.
     * @param androidContentContainer The {@link ViewGroup} the {@link LayoutManager} should bind
     *                                Android content to.
     * @param contextualSearchManager A {@link ContextualSearchManagementDelegate} instance.
     * @param readerModeManager       A {@link ReaderModeManagerDelegate} instance.
     */
public void onFinishNativeInitialization(TabModelSelector tabModelSelector, TabCreatorManager tabCreatorManager, TabContentManager tabContentManager, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchManager, ReaderModeManagerDelegate readerModeManager) {
    assert mLayoutManager != null;
    mLayoutManager.init(tabModelSelector, tabCreatorManager, tabContentManager, androidContentContainer, contextualSearchManager, readerModeManager, mCompositorView.getResourceManager().getDynamicResourceLoader());
    mTabModelSelector = tabModelSelector;
    tabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {

        @Override
        public void onChange() {
            onContentChanged();
        }

        @Override
        public void onNewTabCreated(Tab tab) {
            initializeTab(tab);
        }
    });
    mLayerTitleCache.setTabModelSelector(mTabModelSelector);
    onContentChanged();
}
Also used : EmptyTabModelSelectorObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver) Tab(org.chromium.chrome.browser.tab.Tab)

Example 3 with EmptyTabModelSelectorObserver

use of org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver in project AndroidChromium by JackyAndroid.

the class LayoutManagerChrome method init.

@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeDelegate, DynamicResourceLoader dynamicResourceLoader) {
    // TODO: TitleCache should be a part of the ResourceManager.
    mTitleCache = mHost.getTitleCache();
    // Initialize Layouts
    mToolbarSwipeLayout.setTabModelSelector(selector, content);
    mOverviewListLayout.setTabModelSelector(selector, content);
    if (mOverviewLayout != null)
        mOverviewLayout.setTabModelSelector(selector, content);
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeDelegate, dynamicResourceLoader);
    mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {

        @Override
        public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
            tabModelSwitched(newModel.isIncognito());
        }
    };
    selector.addObserver(mTabModelSelectorObserver);
    selector.setCloseAllTabsDelegate(this);
    mTabModelObserver = createTabModelObserver();
    for (TabModel model : selector.getModels()) model.addObserver(mTabModelObserver);
    mTabSelectorTabObserver = new TabModelSelectorTabObserver(selector) {

        @Override
        public void onLoadStarted(Tab tab, boolean toDifferentDocument) {
            tabLoadStarted(tab.getId(), tab.isIncognito());
        }

        @Override
        public void onLoadStopped(Tab tab, boolean toDifferentDocument) {
            tabLoadFinished(tab.getId(), tab.isIncognito());
        }

        @Override
        public void onPageLoadStarted(Tab tab, String url) {
            tabPageLoadStarted(tab.getId(), tab.isIncognito());
        }

        @Override
        public void onPageLoadFinished(Tab tab) {
            tabPageLoadFinished(tab.getId(), tab.isIncognito());
        }

        @Override
        public void onPageLoadFailed(Tab tab, int errorCode) {
            tabPageLoadFinished(tab.getId(), tab.isIncognito());
        }

        @Override
        public void onCrash(Tab tab, boolean sadTabShown) {
            tabPageLoadFinished(tab.getId(), tab.isIncognito());
        }
    };
}
Also used : EmptyTabModelSelectorObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) Tab(org.chromium.chrome.browser.tab.Tab) TabModelSelectorTabObserver(org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Aggregations

Tab (org.chromium.chrome.browser.tab.Tab)3 EmptyTabModelSelectorObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver)3 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)2 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)1 EmptyTabModelObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)1 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)1 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)1