Search in sources :

Example 11 with TabModel

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

the class FindToolbar method deactivate.

/**
 * Call this just before closing the find toolbar.
 * @param clearSelection Whether the selection on the page should be cleared.
 */
public void deactivate(boolean clearSelection) {
    if (!mActive)
        return;
    if (mObserver != null)
        mObserver.onFindToolbarHidden();
    setResultsBarVisibility(false);
    mTabModelSelector.removeObserver(mTabModelSelectorObserver);
    for (TabModel model : mTabModelSelector.getModels()) {
        model.removeObserver(mTabModelObserver);
    }
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindResultListener(null);
    mCurrentTab.getTabWebContentsDelegateAndroid().setFindMatchRectsListener(null);
    mCurrentTab.removeObserver(mTabObserver);
    UiUtils.hideKeyboard(mFindQuery);
    if (mFindQuery.getText().length() > 0) {
        clearResults();
        mFindInPageBridge.stopFinding(clearSelection);
    }
    mFindInPageBridge.destroy();
    mFindInPageBridge = null;
    mCurrentTab = null;
    mActive = false;
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 12 with TabModel

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

the class IncognitoToggleButtonTablet method setTabModelSelector.

/**
 * Sets the {@link TabModelSelector} that will be queried for information about the state of
 * the system.
 * @param selector A {@link TabModelSelector} that represents the state of the system.
 */
public void setTabModelSelector(TabModelSelector selector) {
    mTabModelSelector = selector;
    if (selector != null) {
        updateButtonResource();
        updateButtonVisibility();
        mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {

            @Override
            public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
                updateButtonResource();
            }
        };
        mTabModelSelector.addObserver(mTabModelSelectorObserver);
        mTabModelObserver = new EmptyTabModelObserver() {

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                updateButtonVisibility();
            }

            @Override
            public void willCloseTab(Tab tab, boolean animate) {
                updateButtonVisibility();
            }

            @Override
            public void tabRemoved(Tab tab) {
                updateButtonVisibility();
            }
        };
        for (TabModel model : mTabModelSelector.getModels()) {
            model.addObserver(mTabModelObserver);
        }
    }
}
Also used : EmptyTabModelSelectorObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver) Tab(org.chromium.chrome.browser.tab.Tab) TabLaunchType(org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType) TabModel(org.chromium.chrome.browser.tabmodel.TabModel) EmptyTabModelObserver(org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver)

Example 13 with TabModel

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

the class EmptyBackgroundViewWrapper method shouldShowEmptyContainer.

private boolean shouldShowEmptyContainer() {
    TabModel model = mTabModelSelector.getModel(false);
    if (model == null) {
        return false;
    }
    boolean isIncognitoEmpty = mTabModelSelector.getModel(true).getCount() == 0;
    boolean incognitoSelected = mTabModelSelector.isIncognitoSelected();
    // 3. We're in the normal TabModel OR there are no tabs present in either model
    return model.getCount() == 0 && !mOverviewModeBehavior.overviewVisible() && (!incognitoSelected || isIncognitoEmpty);
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 14 with TabModel

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

the class TabWebContentsDelegateAndroid method activateContents.

@Override
public void activateContents() {
    boolean activityIsDestroyed = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        activityIsDestroyed = mTab.getActivity().isDestroyed();
    }
    if (activityIsDestroyed || !mTab.isInitialized()) {
        Log.e(TAG, "Activity destroyed before calling activateContents().  Bailing out.");
        return;
    }
    TabModel model = getTabModel();
    int index = model.indexOf(mTab);
    if (index == TabModel.INVALID_TAB_INDEX)
        return;
    TabModelUtils.setIndex(model, index);
    bringActivityToForeground();
}
Also used : TabModel(org.chromium.chrome.browser.tabmodel.TabModel)

Example 15 with TabModel

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

the class ToolbarManager method initializeWithNative.

/**
     * Initialize the manager with the components that had native initialization dependencies.
     * <p>
     * Calling this must occur after the native library have completely loaded.
     *
     * @param tabModelSelector     The selector that handles tab management.
     * @param fullscreenManager    The manager in charge of interacting with the fullscreen feature.
     * @param findToolbarManager   The manager for find in page.
     * @param overviewModeBehavior The overview mode manager.
     * @param layoutDriver         A {@link LayoutManager} instance used to watch for scene changes.
     */
public void initializeWithNative(TabModelSelector tabModelSelector, ChromeFullscreenManager fullscreenManager, final FindToolbarManager findToolbarManager, final OverviewModeBehavior overviewModeBehavior, final LayoutManager layoutDriver, OnClickListener tabSwitcherClickHandler, OnClickListener newTabClickHandler, OnClickListener bookmarkClickHandler, OnClickListener customTabsBackClickHandler) {
    assert !mInitializedWithNative;
    mTabModelSelector = tabModelSelector;
    mToolbar.getLocationBar().updateVisualsForState();
    mToolbar.getLocationBar().setUrlToPageUrl();
    mToolbar.setFullscreenManager(fullscreenManager);
    mToolbar.setOnTabSwitcherClickHandler(tabSwitcherClickHandler);
    mToolbar.setOnNewTabClickHandler(newTabClickHandler);
    mToolbar.setBookmarkClickHandler(bookmarkClickHandler);
    mToolbar.setCustomTabCloseClickHandler(customTabsBackClickHandler);
    mToolbar.setLayoutUpdateHost(layoutDriver);
    mToolbarModel.initializeWithNative();
    mToolbar.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {

        @Override
        public void onViewDetachedFromWindow(View v) {
            Context context = mToolbar.getContext();
            HomepageManager.getInstance(context).removeListener(mHomepageStateListener);
            mTabModelSelector.removeObserver(mTabModelSelectorObserver);
            for (TabModel model : mTabModelSelector.getModels()) {
                model.removeObserver(mTabModelObserver);
            }
            if (mBookmarkBridge != null) {
                mBookmarkBridge.destroy();
                mBookmarkBridge = null;
            }
            if (mTemplateUrlObserver != null) {
                TemplateUrlService.getInstance().removeObserver(mTemplateUrlObserver);
                mTemplateUrlObserver = null;
            }
            // Remove all previously attached observers from the FindToolbarManager.
            if (mFindToolbarManager != null) {
                for (FindToolbarObserver observer : mFindToolbarObservers) {
                    mFindToolbarManager.removeObserver(observer);
                }
            }
            if (overviewModeBehavior != null) {
                overviewModeBehavior.removeOverviewModeObserver(mOverviewModeObserver);
            }
            if (layoutDriver != null) {
                layoutDriver.removeSceneChangeObserver(mSceneChangeObserver);
            }
        }

        @Override
        public void onViewAttachedToWindow(View v) {
            // As we have only just registered for notifications, any that were sent prior to
            // this may have been missed.
            // Calling refreshSelectedTab in case we missed the initial selection notification.
            refreshSelectedTab();
        }
    });
    mFindToolbarManager = findToolbarManager;
    assert fullscreenManager != null;
    mFullscreenManager = fullscreenManager;
    mNativeLibraryReady = false;
    // Add observers to the FindToolbarManager.
    if (mFindToolbarManager != null) {
        for (FindToolbarObserver observer : mFindToolbarObservers) {
            mFindToolbarManager.addObserver(observer);
        }
    }
    if (overviewModeBehavior != null) {
        overviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
    }
    if (layoutDriver != null)
        layoutDriver.addSceneChangeObserver(mSceneChangeObserver);
    onNativeLibraryReady();
    mInitializedWithNative = true;
}
Also used : Context(android.content.Context) FindToolbarObserver(org.chromium.chrome.browser.widget.findinpage.FindToolbarObserver) OnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener) View(android.view.View) 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