Search in sources :

Example 21 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class BarOverlapTapSuppression method getContentHeightPx.

/**
     * @return The height of the content view area of the base page in pixels, or 0 if the
     *         Height cannot be reliably obtained.
     */
private float getContentHeightPx() {
    Tab currentTab = mActivity.getActivityTab();
    ChromeFullscreenManager fullscreenManager = mActivity.getFullscreenManager();
    if (fullscreenManager == null || currentTab == null)
        return 0.f;
    float controlsOffset = fullscreenManager.getControlOffset();
    float controlsHeight = fullscreenManager.getTopControlsHeight();
    float tabHeight = currentTab.getHeight();
    return tabHeight - (controlsHeight + controlsOffset);
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) ChromeFullscreenManager(org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager)

Example 22 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class ContextualSearchManager method listenForTabModelSelectorNotifications.

/**
     * Listens for notifications that should hide the Contextual Search bar.
     */
private void listenForTabModelSelectorNotifications() {
    TabModelSelector selector = mActivity.getTabModelSelector();
    mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(selector) {

        @Override
        public void onPageLoadStarted(Tab tab, String url) {
            hideContextualSearch(StateChangeReason.UNKNOWN);
            mDidBasePageLoadJustStart = true;
        }

        @Override
        public void onCrash(Tab tab, boolean sadTabShown) {
            if (sadTabShown) {
                // Hide contextual search if the foreground tab crashed
                hideContextualSearch(StateChangeReason.UNKNOWN);
            }
        }

        @Override
        public void onClosingStateChanged(Tab tab, boolean closing) {
            if (closing)
                hideContextualSearch(StateChangeReason.UNKNOWN);
        }
    };
    for (TabModel tabModel : selector.getModels()) {
        tabModel.addObserver(mTabModelObserver);
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) TabModelSelectorTabObserver(org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver) TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 23 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class LayoutManagerChrome method tabCreated.

/**
     * 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);
}
Also used : LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) Tab(org.chromium.chrome.browser.tab.Tab)

Example 24 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class LayoutManagerDocument method initLayoutTabFromHost.

@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null)
        return;
    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null)
        return;
    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null)
        return;
    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int themeColor = tab.getThemeColor();
    // TODO(xingliu): Remove this override themeColor for Blimp tabs. See crbug.com/644774.
    if (tab.isBlimpTab() && tab.getBlimpContents() != null) {
        themeColor = tab.getBlimpContents().getThemeColor();
    }
    boolean canUseLiveTexture = tab.isBlimpTab() || tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;
    boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground(mContext.getResources(), tab, themeColor), ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
    if (needsUpdate)
        requestUpdate();
    mHost.requestRender();
}
Also used : LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) Tab(org.chromium.chrome.browser.tab.Tab) DocumentTabModelSelector(org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector) TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)

Example 25 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class LayoutManagerDocument method init.

@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeDelegate, DynamicResourceLoader dynamicResourceLoader) {
    // Add any SceneOverlays to a layout.
    addAllSceneOverlays();
    // Save state
    mContextualSearchDelegate = contextualSearchDelegate;
    // Initialize Event Filters
    mStaticEdgeEventFilter.setTabModelSelector(selector);
    // Initialize Layouts
    mStaticLayout.setTabModelSelector(selector, content);
    // Initialize Contextual Search Panel
    mContextualSearchPanel.setManagementDelegate(contextualSearchDelegate);
    // Set back flow communication
    if (contextualSearchDelegate != null) {
        contextualSearchDelegate.setContextualSearchPanel(mContextualSearchPanel);
    }
    mReaderModePanel.setManagerDelegate(readerModeDelegate);
    if (readerModeDelegate != null) {
        readerModeDelegate.setReaderModePanel(mReaderModePanel);
    }
    // Set the dynamic resource loader for all overlay panels.
    mOverlayPanelManager.setDynamicResourceLoader(dynamicResourceLoader);
    mOverlayPanelManager.setContainerView(androidContentContainer);
    mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(selector) {

        @Override
        public void onContentChanged(Tab tab) {
            initLayoutTabFromHost(tab.getId());
        }

        @Override
        public void onBackgroundColorChanged(Tab tab, int color) {
            initLayoutTabFromHost(tab.getId());
        }

        @Override
        public void onDidChangeThemeColor(Tab tab, int color) {
            initLayoutTabFromHost(tab.getId());
        }
    };
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeDelegate, dynamicResourceLoader);
}
Also used : LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) Tab(org.chromium.chrome.browser.tab.Tab) TabModelSelectorTabObserver(org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)

Aggregations

Tab (org.chromium.chrome.browser.tab.Tab)116 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)13 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)10 LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)9 SuppressLint (android.annotation.SuppressLint)8 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)8 Intent (android.content.Intent)5 FrameLayout (android.widget.FrameLayout)4 ContentViewCore (org.chromium.content.browser.ContentViewCore)4 WebContents (org.chromium.content_public.browser.WebContents)4 Activity (android.app.Activity)3 Bitmap (android.graphics.Bitmap)3 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)3 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Bundle (android.os.Bundle)2 StrictMode (android.os.StrictMode)2 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2