Search in sources :

Example 1 with TabModel

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

the class SimpleAnimationLayout method ensureSourceTabCreated.

private void ensureSourceTabCreated(int sourceTabId) {
    if (mLayoutTabs != null && mLayoutTabs.length == 1 && mLayoutTabs[0].getId() == sourceTabId) {
        return;
    }
    // Just draw the source tab on the screen.
    TabModel sourceModel = mTabModelSelector.getModelForTabId(sourceTabId);
    if (sourceModel == null)
        return;
    LayoutTab sourceLayoutTab = createLayoutTab(sourceTabId, sourceModel.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    sourceLayoutTab.setBorderAlpha(0.0f);
    mLayoutTabs = new LayoutTab[] { sourceLayoutTab };
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(sourceTabId)));
}
Also used : LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 2 with TabModel

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

the class LayoutManagerChrome method destroy.

@Override
public void destroy() {
    super.destroy();
    if (mTabModelSelectorObserver != null) {
        getTabModelSelector().removeObserver(mTabModelSelectorObserver);
    }
    if (mTabModelObserver != null) {
        for (TabModel model : getTabModelSelector().getModels()) {
            model.removeObserver(mTabModelObserver);
        }
    }
    if (mTabSelectorTabObserver != null)
        mTabSelectorTabObserver.destroy();
    mOverviewModeObservers.clear();
    if (mOverviewLayout != null) {
        mOverviewLayout.destroy();
        mOverviewLayout = null;
    }
    mOverviewListLayout.destroy();
    mToolbarSwipeLayout.destroy();
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 3 with TabModel

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

the class ToolbarSwipeLayout method swipeStarted.

@Override
public void swipeStarted(long time, ScrollDirection direction, float x, float y) {
    if (mTabModelSelector == null || mToTab != null || direction == ScrollDirection.DOWN) {
        return;
    }
    boolean dragFromLeftEdge = direction == ScrollDirection.RIGHT;
    // Finish off any other animations.
    forceAnimationToFinish();
    // Determine which tabs we're showing.
    TabModel model = mTabModelSelector.getCurrentModel();
    if (model == null)
        return;
    int fromIndex = model.index();
    if (fromIndex == TabModel.INVALID_TAB_INDEX)
        return;
    // On RTL, edge-dragging to the left is the next tab.
    int toIndex = (LocalizationUtils.isLayoutRtl() ^ dragFromLeftEdge) ? fromIndex - 1 : fromIndex + 1;
    int leftIndex = dragFromLeftEdge ? toIndex : fromIndex;
    int rightIndex = !dragFromLeftEdge ? toIndex : fromIndex;
    List<Integer> visibleTabs = new ArrayList<Integer>();
    if (0 <= leftIndex && leftIndex < model.getCount()) {
        int leftTabId = model.getTabAt(leftIndex).getId();
        mLeftTab = createLayoutTab(leftTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
        prepareLayoutTabForSwipe(mLeftTab, leftIndex != fromIndex);
        visibleTabs.add(leftTabId);
    }
    if (0 <= rightIndex && rightIndex < model.getCount()) {
        int rightTabId = model.getTabAt(rightIndex).getId();
        mRightTab = createLayoutTab(rightTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
        prepareLayoutTabForSwipe(mRightTab, rightIndex != fromIndex);
        visibleTabs.add(rightTabId);
    }
    updateCacheVisibleIds(visibleTabs);
    mToTab = null;
    // Reset the tab offsets.
    mOffsetStart = dragFromLeftEdge ? 0 : getWidth();
    mOffset = 0;
    mOffsetTarget = 0;
    if (mLeftTab != null && mRightTab != null) {
        mLayoutTabs = new LayoutTab[] { mLeftTab, mRightTab };
    } else if (mLeftTab != null) {
        mLayoutTabs = new LayoutTab[] { mLeftTab };
    } else if (mRightTab != null) {
        mLayoutTabs = new LayoutTab[] { mRightTab };
    } else {
        mLayoutTabs = null;
    }
    requestUpdate();
}
Also used : ArrayList(java.util.ArrayList) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 4 with TabModel

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

the class UmaSessionStats method recordPageLoadStats.

private void recordPageLoadStats(Tab tab) {
    WebContents webContents = tab.getWebContents();
    boolean isDesktopUserAgent = webContents != null && webContents.getNavigationController().getUseDesktopUserAgent();
    nativeRecordPageLoaded(isDesktopUserAgent);
    if (mKeyboardConnected) {
        nativeRecordPageLoadedWithKeyboard();
    }
    // possible since the TabSelector is needed to figure out the current number of open tabs.
    if (mTabModelSelector == null)
        return;
    TabModel regularModel = mTabModelSelector.getModel(false);
    nativeRecordTabCountPerLoad(getTabCountFromModel(regularModel));
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 5 with TabModel

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

the class OverviewListLayout method onTabsAllClosing.

@Override
public void onTabsAllClosing(long time, boolean incognito) {
    super.onTabsAllClosing(time, incognito);
    TabModel model = mTabModelSelector.getModel(incognito);
    while (model.getCount() > 0) TabModelUtils.closeTabByIndex(model, 0);
    if (incognito) {
        mTabModelSelector.selectModel(!incognito);
    }
    if (mTabModelWrapper == null)
        return;
    mTabModelWrapper.setStateBasedOnModel();
}
Also used : 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