Java Code Examples for org.chromium.chrome.browser.tabmodel.TabModelUtils#getTabById()

The following examples show how to use org.chromium.chrome.browser.tabmodel.TabModelUtils#getTabById() . 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: Stack.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link StackTab}.
 * This function should ONLY be called from {@link #tabCreated(long, int)} and nowhere else.
 *
 * @param id The id of the tab.
 * @return   Whether the tab has successfully been created and added.
 */
private boolean createTabHelper(int id) {
    if (TabModelUtils.getTabById(mTabModel, id) == null) return false;

    // Check to see if the tab already exists in our model.  This is
    // just to cover the case where stackEntered and then tabCreated()
    // called in a row.
    if (mStackTabs != null) {
        final int count = mStackTabs.length;
        for (int i = 0; i < count; ++i) {
            if (mStackTabs[i].getId() == id) {
                return false;
            }
        }
    }

    createStackTabs(true);

    return true;
}
 
Example 2
Source File: Stack.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link StackTab}.
 * This function should ONLY be called from {@link #tabCreated(long, int)} and nowhere else.
 *
 * @param id The id of the tab.
 * @return   Whether the tab has successfully been created and added.
 */
private boolean createTabHelper(int id) {
    if (TabModelUtils.getTabById(mTabModel, id) == null) return false;

    // Check to see if the tab already exists in our model.  This is
    // just to cover the case where stackEntered and then tabCreated()
    // called in a row.
    if (mStackTabs != null) {
        final int count = mStackTabs.length;
        for (int i = 0; i < count; ++i) {
            if (mStackTabs[i].getId() == id) {
                return false;
            }
        }
    }

    createStackTabs(true);

    return true;
}
 
Example 3
Source File: Stack.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link StackTab}.
 * This function should ONLY be called from {@link #tabCreated(long, int)} and nowhere else.
 *
 * @param id The id of the tab.
 * @return   Whether the tab has successfully been created and added.
 */
private boolean createTabHelper(int id) {
    if (TabModelUtils.getTabById(mTabModel, id) == null) return false;

    // Check to see if the tab already exists in our model.  This is
    // just to cover the case where stackEntered and then tabCreated()
    // called in a row.
    if (mStackTabs != null) {
        final int count = mStackTabs.length;
        for (int i = 0; i < count; ++i) {
            if (mStackTabs[i].getId() == id) {
                return false;
            }
        }
    }

    createStackTabs(true);

    return true;
}
 
Example 4
Source File: LayoutManagerChromePhone.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean isIncognito,
        boolean willBeSelected, float originX, float originY) {
    super.tabCreated(id, sourceId, launchType, isIncognito, willBeSelected, originX, originY);

    if (willBeSelected) {
        Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(isIncognito), id);
        if (newTab != null) newTab.requestFocus();
    }
}
 
Example 5
Source File: StackLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack index for the given tab id.
 * @VisibleForTesting
 */
protected int getTabStackIndex(int tabId) {
    if (tabId == Tab.INVALID_TAB_ID) {
        boolean incognito = mTemporarySelectedStack != null
                ? mTemporarySelectedStack
                : mTabModelSelector.isIncognitoSelected();
        return incognito ? 1 : 0;
    } else {
        return TabModelUtils.getTabById(mTabModelSelector.getModel(true), tabId) != null ? 1
                                                                                         : 0;
    }
}
 
Example 6
Source File: LayoutManagerChromePhone.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean isIncognito,
        boolean willBeSelected, float originX, float originY) {
    super.tabCreated(id, sourceId, launchType, isIncognito, willBeSelected, originX, originY);

    if (willBeSelected) {
        Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(isIncognito), id);
        if (newTab != null) newTab.requestFocus();
    }
}
 
Example 7
Source File: StackLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack index for the given tab id.
 * @VisibleForTesting
 */
protected int getTabStackIndex(int tabId) {
    if (tabId == Tab.INVALID_TAB_ID) {
        boolean incognito = mTemporarySelectedStack != null
                ? mTemporarySelectedStack
                : mTabModelSelector.isIncognitoSelected();
        return incognito ? 1 : 0;
    } else {
        return TabModelUtils.getTabById(mTabModelSelector.getModel(true), tabId) != null ? 1
                                                                                         : 0;
    }
}
 
Example 8
Source File: LayoutManagerChromePhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean isIncognito,
        boolean willBeSelected, float originX, float originY) {
    super.tabCreated(id, sourceId, launchType, isIncognito, willBeSelected, originX, originY);

    if (willBeSelected) {
        Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(isIncognito), id);
        if (newTab != null) newTab.requestFocus();
    }
}
 
Example 9
Source File: StackLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Get the tab stack state for the specified tab id.
 *
 * @param tabId The id of the tab to lookup.
 * @return The tab stack index for the given tab id.
 * @VisibleForTesting
 */
protected int getTabStackIndex(int tabId) {
    if (tabId == Tab.INVALID_TAB_ID) {
        boolean incognito = mTemporarySelectedStack != null
                ? mTemporarySelectedStack
                : mTabModelSelector.isIncognitoSelected();
        return incognito ? 1 : 0;
    } else {
        return TabModelUtils.getTabById(mTabModelSelector.getModel(true), tabId) != null ? 1
                                                                                         : 0;
    }
}
 
Example 10
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 3 votes vote down vote up
/**
 * Should be called when a tab created event is triggered.
 * @param id             The id of the tab that was created.
 * @param sourceId       The id of the creating tab if any.
 * @param launchType     How the tab was launched.
 * @param incognito      Whether or not the created tab is incognito.
 * @param willBeSelected Whether or not the created tab will be selected.
 * @param originX        The x coordinate of the action that created this tab in dp.
 * @param originY        The y coordinate of the action that created this tab in dp.
 */
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean incognito,
        boolean willBeSelected, float originX, float originY) {
    Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(incognito), id);
    mCreatingNtp = newTab != null && newTab.isNativePage();

    int newIndex = TabModelUtils.getTabIndexById(getTabModelSelector().getModel(incognito), id);
    getActiveLayout().onTabCreated(
            time(), id, newIndex, sourceId, incognito, !willBeSelected, originX, originY);
}
 
Example 11
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 3 votes vote down vote up
/**
 * Should be called when a tab created event is triggered.
 * @param id             The id of the tab that was created.
 * @param sourceId       The id of the creating tab if any.
 * @param launchType     How the tab was launched.
 * @param incognito      Whether or not the created tab is incognito.
 * @param willBeSelected Whether or not the created tab will be selected.
 * @param originX        The x coordinate of the action that created this tab in dp.
 * @param originY        The y coordinate of the action that created this tab in dp.
 */
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean incognito,
        boolean willBeSelected, float originX, float originY) {
    Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(incognito), id);
    mCreatingNtp = newTab != null && newTab.isNativePage();

    int newIndex = TabModelUtils.getTabIndexById(getTabModelSelector().getModel(incognito), id);
    getActiveLayout().onTabCreated(
            time(), id, newIndex, sourceId, incognito, !willBeSelected, originX, originY);
}
 
Example 12
Source File: LayoutManagerChrome.java    From 365browser with Apache License 2.0 3 votes vote down vote up
/**
 * Should be called when a tab created event is triggered.
 * @param id             The id of the tab that was created.
 * @param sourceId       The id of the creating tab if any.
 * @param launchType     How the tab was launched.
 * @param incognito      Whether or not the created tab is incognito.
 * @param willBeSelected Whether or not the created tab will be selected.
 * @param originX        The x coordinate of the action that created this tab in dp.
 * @param originY        The y coordinate of the action that created this tab in dp.
 */
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean incognito,
        boolean willBeSelected, float originX, float originY) {
    Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(incognito), id);
    mCreatingNtp = newTab != null && newTab.isNativePage();

    int newIndex = TabModelUtils.getTabIndexById(getTabModelSelector().getModel(incognito), id);
    getActiveLayout().onTabCreated(
            time(), id, newIndex, sourceId, incognito, !willBeSelected, originX, originY);
}
 
Example 13
Source File: StripLayoutHelper.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Notify the a title has changed.
 *
 * @param tabId     The id of the tab that has changed.
 * @param title     The new title.
 */
public void tabTitleChanged(int tabId, String title) {
    Tab tab = TabModelUtils.getTabById(mModel, tabId);
    if (tab != null) setAccessibilityDescription(findTabById(tabId), title, tab.isHidden());
}
 
Example 14
Source File: StripLayoutHelper.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Notify the a title has changed.
 *
 * @param tabId     The id of the tab that has changed.
 * @param title     The new title.
 */
public void tabTitleChanged(int tabId, String title) {
    Tab tab = TabModelUtils.getTabById(mModel, tabId);
    if (tab != null) setAccessibilityDescription(findTabById(tabId), title, tab.isHidden());
}
 
Example 15
Source File: StripLayoutHelper.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Notify the a title has changed.
 *
 * @param tabId     The id of the tab that has changed.
 * @param title     The new title.
 */
public void tabTitleChanged(int tabId, String title) {
    Tab tab = TabModelUtils.getTabById(mModel, tabId);
    if (tab != null) setAccessibilityDescription(findTabById(tabId), title, tab.isHidden());
}