Search in sources :

Example 1 with NavigationParams

use of org.chromium.components.navigation_interception.NavigationParams in project AndroidChromium by JackyAndroid.

the class ReaderModePanel method createNewOverlayPanelContent.

@Override
public OverlayPanelContent createNewOverlayPanelContent() {
    OverlayContentDelegate delegate = new OverlayContentDelegate() {

        /**
         * Track if a navigation/load is the first one for this content.
         */
        private boolean mIsInitialLoad = true;

        @Override
        public void onContentViewCreated(ContentViewCore contentView) {
            mContentViewDelegate.setOverlayPanelContentViewCore(contentView);
            WebContents distilledWebContents = contentView.getWebContents();
            if (distilledWebContents == null)
                return;
            WebContents sourceWebContents = mManagerDelegate.getBasePageWebContents();
            if (sourceWebContents == null)
                return;
            DomDistillerTabUtils.distillAndView(sourceWebContents, distilledWebContents);
        }

        @Override
        public void onContentViewDestroyed() {
            mContentViewDelegate.releaseOverlayPanelContentViewCore();
            mIsInitialLoad = true;
        }

        @Override
        public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler, NavigationParams navigationParams) {
            // clicks.
            if (mIsInitialLoad) {
                mIsInitialLoad = false;
                return true;
            }
            if (!navigationParams.isExternalProtocol) {
                mManagerDelegate.createNewTab(navigationParams.url);
                return false;
            }
            return true;
        }
    };
    return new OverlayPanelContent(delegate, new OverlayContentProgressObserver(), mActivity);
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) OverlayContentProgressObserver(org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressObserver) ExternalNavigationHandler(org.chromium.chrome.browser.externalnav.ExternalNavigationHandler) ContentViewCore(org.chromium.content.browser.ContentViewCore) OverlayContentDelegate(org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate) OverlayPanelContent(org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContent) NavigationParams(org.chromium.components.navigation_interception.NavigationParams)

Aggregations

OverlayContentDelegate (org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate)1 OverlayContentProgressObserver (org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressObserver)1 OverlayPanelContent (org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContent)1 ExternalNavigationHandler (org.chromium.chrome.browser.externalnav.ExternalNavigationHandler)1 NavigationParams (org.chromium.components.navigation_interception.NavigationParams)1 ContentViewCore (org.chromium.content.browser.ContentViewCore)1 WebContents (org.chromium.content_public.browser.WebContents)1