Search in sources :

Example 16 with TabModel

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

the class ToolbarManager method onNativeLibraryReady.

private void onNativeLibraryReady() {
    mNativeLibraryReady = true;
    mToolbar.onNativeLibraryReady();
    final TemplateUrlService templateUrlService = TemplateUrlService.getInstance();
    TemplateUrlService.LoadListener mTemplateServiceLoadListener = new TemplateUrlService.LoadListener() {

        @Override
        public void onTemplateUrlServiceLoaded() {
            registerTemplateUrlObserver();
            templateUrlService.unregisterLoadListener(this);
        }
    };
    templateUrlService.registerLoadListener(mTemplateServiceLoadListener);
    if (templateUrlService.isLoaded()) {
        mTemplateServiceLoadListener.onTemplateUrlServiceLoaded();
    } else {
        templateUrlService.load();
    }
    mTabModelSelector.addObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) model.addObserver(mTabModelObserver);
    refreshSelectedTab();
    if (mTabModelSelector.isTabStateInitialized())
        mTabRestoreCompleted = true;
    handleTabRestoreCompleted();
}
Also used : TemplateUrlService(org.chromium.chrome.browser.search_engines.TemplateUrlService) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 17 with TabModel

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

the class ActivityTabTaskDescriptionHelper method destroy.

/**
     * Destroys all dependent components of the task description helper.
     */
public void destroy() {
    mFaviconHelper.destroy();
    if (mCurrentTab != null) {
        mCurrentTab.removeObserver(mTabObserver);
    }
    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 18 with TabModel

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

the class ChromeTabbedActivity method onDestroyInternal.

@Override
public void onDestroyInternal() {
    if (mLayoutManager != null)
        mLayoutManager.removeOverviewModeObserver(this);
    if (mTabModelSelectorTabObserver != null) {
        mTabModelSelectorTabObserver.destroy();
        mTabModelSelectorTabObserver = null;
    }
    if (mTabModelObserver != null) {
        for (TabModel model : mTabModelSelectorImpl.getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    if (mUndoBarPopupController != null) {
        mUndoBarPopupController.destroy();
        mUndoBarPopupController = null;
    }
    if (mVrShellDelegate != null) {
        mVrShellDelegate.destroyVrShell();
    }
    super.onDestroyInternal();
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 19 with TabModel

use of org.chromium.chrome.browser.tabmodel.TabModel 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)

Example 20 with TabModel

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

the class LayoutManagerChromeTablet method init.

@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeDelegate, DynamicResourceLoader dynamicResourceLoader) {
    if (mTabStripLayoutHelperManager != null) {
        mTabStripLayoutHelperManager.setTabModelSelector(selector, creator);
    }
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeDelegate, dynamicResourceLoader);
    mTabObserver = new TabModelSelectorTabObserver(selector) {

        @Override
        public void onFaviconUpdated(Tab tab, Bitmap icon) {
            updateTitle(tab);
        }

        @Override
        public void onTitleUpdated(Tab tab) {
            updateTitle(tab);
        }
    };
    // Make sure any tabs already restored get loaded into the title cache.
    List<TabModel> models = selector.getModels();
    for (int i = 0; i < models.size(); i++) {
        TabModel model = models.get(i);
        for (int j = 0; j < model.getCount(); j++) {
            Tab tab = model.getTabAt(j);
            if (tab != null && mTitleCache != null) {
                mTitleCache.getUpdatedTitle(tab, mDefaultTitle);
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) Tab(org.chromium.chrome.browser.tab.Tab) TabModelSelectorTabObserver(org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Aggregations

TabModel (org.chromium.chrome.browser.tabmodel.TabModel)29 Tab (org.chromium.chrome.browser.tab.Tab)8 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)6 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)3 Context (android.content.Context)2 View (android.view.View)2 OnAttachStateChangeListener (android.view.View.OnAttachStateChangeListener)2 EmptyTabModelSelectorObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver)2 TabModelSelector (org.chromium.chrome.browser.tabmodel.TabModelSelector)2 FindToolbarObserver (org.chromium.chrome.browser.widget.findinpage.FindToolbarObserver)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 ArrayList (java.util.ArrayList)1 IntentHandlerDelegate (org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate)1 TabOpenType (org.chromium.chrome.browser.IntentHandler.TabOpenType)1 FindInPageBridge (org.chromium.chrome.browser.findinpage.FindInPageBridge)1 TemplateUrlService (org.chromium.chrome.browser.search_engines.TemplateUrlService)1 EmptyTabModelObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)1 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)1 ContentViewCore (org.chromium.content.browser.ContentViewCore)1