Search in sources :

Example 1 with TabModelSelector

use of org.chromium.chrome.browser.tabmodel.TabModelSelector 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 2 with TabModelSelector

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

the class ContextualSearchManager method openResolvedSearchUrlInNewTab.

@Override
public void openResolvedSearchUrlInNewTab() {
    if (mSearchRequest != null && mSearchRequest.getSearchUrlForPromotion() != null) {
        TabModelSelector tabModelSelector = mActivity.getTabModelSelector();
        tabModelSelector.openNewTab(new LoadUrlParams(mSearchRequest.getSearchUrlForPromotion()), TabLaunchType.FROM_LINK, tabModelSelector.getCurrentTab(), tabModelSelector.isIncognitoSelected());
    }
}
Also used : TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 3 with TabModelSelector

use of org.chromium.chrome.browser.tabmodel.TabModelSelector 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 4 with TabModelSelector

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

the class LayoutManagerDocumentTabSwitcher method init.

@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeManagerDelegate, DynamicResourceLoader dynamicResourceLoader) {
    super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeManagerDelegate, dynamicResourceLoader);
    mTitleCache = mHost.getTitleCache();
    TabModelSelector documentTabSelector = ChromeApplication.getDocumentTabModelSelector();
    mOverviewListLayout.setTabModelSelector(documentTabSelector, content);
    mOverviewLayout.setTabModelSelector(documentTabSelector, content);
    // TODO(changwan): do we really need this?
    startShowing(getDefaultLayout(), false);
}
Also used : TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector)

Example 5 with TabModelSelector

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

the class ChromeDownloadDelegate method closeBlankTab.

/**
     * Close a blank tab just opened for the download purpose.
     * @return true iff the tab was (already) closed.
     */
private boolean closeBlankTab() {
    if (mTab == null) {
        // We do not want caller to dismiss infobar.
        return true;
    }
    WebContents contents = mTab.getWebContents();
    boolean isInitialNavigation = contents == null || contents.getNavigationController().isInitialNavigation();
    if (isInitialNavigation) {
        // Tab is created just for download, close it.
        Activity activity = mTab.getWindowAndroid().getActivity().get();
        if (!(activity instanceof ChromeActivity))
            return true;
        TabModelSelector selector = ((ChromeActivity) activity).getTabModelSelector();
        return selector == null ? true : selector.closeTab(mTab);
    }
    return false;
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) TabModelSelector(org.chromium.chrome.browser.tabmodel.TabModelSelector) ChromeActivity(org.chromium.chrome.browser.ChromeActivity) Activity(android.app.Activity) ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Aggregations

TabModelSelector (org.chromium.chrome.browser.tabmodel.TabModelSelector)10 Tab (org.chromium.chrome.browser.tab.Tab)3 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)3 Activity (android.app.Activity)2 ChromeActivity (org.chromium.chrome.browser.ChromeActivity)2 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)1 ContextualSearchObserver (org.chromium.chrome.browser.contextualsearch.ContextualSearchObserver)1 EmptyTabModelObserver (org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)1 SingleTabModelSelector (org.chromium.chrome.browser.tabmodel.SingleTabModelSelector)1 TabSelectionType (org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType)1 TabReparentingParams (org.chromium.chrome.browser.tabmodel.TabReparentingParams)1 DocumentTabModelSelector (org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector)1 LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)1 WebContents (org.chromium.content_public.browser.WebContents)1