Search in sources :

Example 21 with TabModel

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

the class StaticLayout method setStaticTab.

private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
        if (!mLayoutTabs[0].shouldStall())
            setPostHideState();
        return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null)
        return;
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    if (mLayoutTabs == null || mLayoutTabs.length != 1)
        mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
        setPreHideState();
        mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
        setPostHideState();
    }
    requestRender();
}
Also used : LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 22 with TabModel

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

the class ToolbarSwipeLayout method show.

@Override
public void show(long time, boolean animate) {
    super.show(time, animate);
    init();
    if (mTabModelSelector == null)
        return;
    Tab tab = mTabModelSelector.getCurrentTab();
    if (tab != null && tab.isNativePage())
        mTabContentManager.cacheTabThumbnail(tab);
    TabModel model = mTabModelSelector.getCurrentModel();
    if (model == null)
        return;
    int fromTabId = mTabModelSelector.getCurrentTabId();
    if (fromTabId == TabModel.INVALID_TAB_INDEX)
        return;
    mFromTab = createLayoutTab(fromTabId, model.isIncognito(), NO_CLOSE_BUTTON, NEED_TITLE);
    prepareLayoutTabForSwipe(mFromTab, false);
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 23 with TabModel

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

the class SeparateTaskManagedCustomTabActivity method createIntentHandlerDelegate.

@Override
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {

        @Override
        public void processWebSearchIntent(String query) {
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers, TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront, boolean hasUserGesture, Intent intent) {
            Tab currentTab = getTabCreator(false).launchUrlFromExternalApp(url, referer, headers, externalAppId, true, intent, mIntentHandlingTimeMs);
            // Close all existing tabs from the previous session.
            TabModel tabModel = getTabModelSelector().getModel(false);
            for (int i = tabModel.getCount() - 1; i >= 0; i--) {
                if (tabModel.getTabAt(i).equals(currentTab))
                    continue;
                tabModel.closeTab(tabModel.getTabAt(i), false, false, false);
            }
        }
    };
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) Intent(android.content.Intent) IntentHandlerDelegate(org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate) TabOpenType(org.chromium.chrome.browser.IntentHandler.TabOpenType) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 24 with TabModel

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

the class ContextReporter method disable.

/**
     * Stops reporting context. Called when the app goes to the background.
     */
public void disable() {
    reportUsageEndedIfNecessary();
    if (mSelectorTabObserver != null) {
        mSelectorTabObserver.destroy();
        mSelectorTabObserver = null;
    }
    if (mModelObserver != null) {
        for (TabModel model : mActivity.getTabModelSelector().getModels()) {
            model.removeObserver(mModelObserver);
        }
        mModelObserver = null;
    }
    if (mContextualSearchObserver != null && mActivity.getContextualSearchManager() != null) {
        mActivity.getContextualSearchManager().removeObserver(mContextualSearchObserver);
        mContextualSearchObserver = null;
    }
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 25 with TabModel

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

the class FindToolbar method activate.

/**
 * Initializes the find toolbar. Should be called just after the find toolbar is shown.
 * If the toolbar is already showing, this just focuses the toolbar.
 */
public void activate() {
    if (!isViewAvailable())
        return;
    if (mActive) {
        requestQueryFocus();
        return;
    }
    mTabModelSelector.addObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.addObserver(mTabModelObserver);
    }
    mCurrentTab = mTabModelSelector.getCurrentTab();
    mCurrentTab.addObserver(mTabObserver);
    mFindInPageBridge = new FindInPageBridge(mCurrentTab.getWebContents());
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindResultListener(this);
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindMatchRectsListener(this);
    initializeFindText();
    mFindQuery.requestFocus();
    // The keyboard doesn't show itself automatically.
    showKeyboard();
    // Always show the bar to make the FindToolbar more distinct from the Omnibox.
    setResultsBarVisibility(true);
    mActive = true;
    updateVisualsForTabModel(mTabModelSelector.isIncognitoSelected());
    // Let everyone know that we've just updated.
    if (mObserver != null)
        mObserver.onFindToolbarShown();
}
Also used : FindInPageBridge(org.chromium.chrome.browser.findinpage.FindInPageBridge) 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