Search in sources :

Example 1 with SwipeRefreshHandler

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

the class Tab method setContentViewCore.

/**
     * Completes the {@link ContentViewCore} specific initialization around a native WebContents
     * pointer. {@link #getNativePage()} will still return the {@link NativePage} if there is one.
     * All initialization that needs to reoccur after a web contents swap should be added here.
     * <p />
     * NOTE: If you attempt to pass a native WebContents that does not have the same incognito
     * state as this tab this call will fail.
     *
     * @param cvc The content view core that needs to be set as active view for the tab.
     */
private void setContentViewCore(ContentViewCore cvc) {
    try {
        TraceEvent.begin("ChromeTab.setContentViewCore");
        NativePage previousNativePage = mNativePage;
        mNativePage = null;
        destroyNativePageInternal(previousNativePage);
        if (mContentViewCore != null) {
            mContentViewCore.setObscuredByAnotherView(false);
        }
        mContentViewCore = cvc;
        cvc.getContainerView().setOnHierarchyChangeListener(this);
        cvc.getContainerView().setOnSystemUiVisibilityChangeListener(this);
        // accessibility. http://crbug.com/416663
        if (mContentViewParent != null) {
            assert false;
            mContentViewParent.removeAllViews();
        }
        mContentViewParent = new TabContentViewParent(mThemedApplicationContext, this);
        mContentViewParent.addView(cvc.getContainerView(), 0, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this);
        mWebContentsObserver = new TabWebContentsObserver(mContentViewCore.getWebContents(), this);
        if (mContentViewClient != null) {
            mContentViewCore.setContentViewClient(mContentViewClient);
        }
        mDownloadDelegate = new ChromeDownloadDelegate(mThemedApplicationContext, this);
        assert mNativeTabAndroid != 0;
        nativeInitWebContents(mNativeTabAndroid, mIncognito, mContentViewCore.getWebContents(), mWebContentsDelegate, new TabContextMenuPopulator(mDelegateFactory.createContextMenuPopulator(this), this));
        // valid infobar container, no need to recreate one.
        if (mInfoBarContainer == null) {
            // The InfoBarContainer needs to be created after the ContentView has been natively
            // initialized.
            mInfoBarContainer = new InfoBarContainer(mThemedApplicationContext, getId(), mContentViewParent, this);
        } else {
            mInfoBarContainer.onParentViewChanged(getId(), mContentViewParent);
        }
        mInfoBarContainer.setContentViewCore(mContentViewCore);
        mSwipeRefreshHandler = new SwipeRefreshHandler(mThemedApplicationContext, this);
        updateThemeColorIfNeeded(false);
        notifyContentChanged();
        // For browser tabs, we want to set accessibility focus to the page
        // when it loads. This is not the default behavior for embedded
        // web views.
        mContentViewCore.setShouldSetAccessibilityFocusOnPageLoad(true);
        setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigationDelegate(this));
        if (mGestureStateListener == null) {
            mGestureStateListener = createGestureStateListener();
        }
        cvc.addGestureStateListener(mGestureStateListener);
    } finally {
        TraceEvent.end("ChromeTab.setContentViewCore");
    }
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage) LayoutParams(android.widget.FrameLayout.LayoutParams) SwipeRefreshHandler(org.chromium.chrome.browser.SwipeRefreshHandler) InfoBarContainer(org.chromium.chrome.browser.infobar.InfoBarContainer) FrameLayout(android.widget.FrameLayout) ChromeDownloadDelegate(org.chromium.chrome.browser.download.ChromeDownloadDelegate)

Aggregations

FrameLayout (android.widget.FrameLayout)1 LayoutParams (android.widget.FrameLayout.LayoutParams)1 FrozenNativePage (org.chromium.chrome.browser.FrozenNativePage)1 NativePage (org.chromium.chrome.browser.NativePage)1 SwipeRefreshHandler (org.chromium.chrome.browser.SwipeRefreshHandler)1 ChromeDownloadDelegate (org.chromium.chrome.browser.download.ChromeDownloadDelegate)1 InfoBarContainer (org.chromium.chrome.browser.infobar.InfoBarContainer)1