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)));
}
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();
}
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();
}
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));
}
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();
}
Aggregations