org.chromium.chrome.browser.externalnav.ExternalNavigationHandler Java Examples

The following examples show how to use org.chromium.chrome.browser.externalnav.ExternalNavigationHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextualSearchManager.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler,
        NavigationParams navigationParams) {
    mTabRedirectHandler.updateNewUrlLoading(navigationParams.pageTransitionType,
            navigationParams.isRedirect,
            navigationParams.hasUserGesture || navigationParams.hasUserGestureCarryover,
            mActivity.getLastUserInteractionTime(), TabRedirectHandler.INVALID_ENTRY_INDEX);
    ExternalNavigationParams params = new ExternalNavigationParams.Builder(
            navigationParams.url, false, navigationParams.referrer,
            navigationParams.pageTransitionType, navigationParams.isRedirect)
            .setApplicationMustBeInForeground(true)
            .setRedirectHandler(mTabRedirectHandler)
            .setIsMainFrame(navigationParams.isMainFrame)
            .build();
    if (externalNavHandler.shouldOverrideUrlLoading(params)
            != OverrideUrlLoadingResult.NO_OVERRIDE) {
        mSearchPanel.maximizePanelThenPromoteToTab(StateChangeReason.TAB_PROMOTION,
                INTERCEPT_NAVIGATION_PROMOTION_ANIMATION_DURATION_MS);
        return false;
    }
    if (navigationParams.isExternalProtocol) {
        return false;
    }
    return true;
}
 
Example #2
Source File: ContextualSearchManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler,
        NavigationParams navigationParams) {
    mTabRedirectHandler.updateNewUrlLoading(navigationParams.pageTransitionType,
            navigationParams.isRedirect,
            navigationParams.hasUserGesture || navigationParams.hasUserGestureCarryover,
            mActivity.getLastUserInteractionTime(), TabRedirectHandler.INVALID_ENTRY_INDEX);
    ExternalNavigationParams params = new ExternalNavigationParams.Builder(
            navigationParams.url, false, navigationParams.referrer,
            navigationParams.pageTransitionType, navigationParams.isRedirect)
            .setApplicationMustBeInForeground(true)
            .setRedirectHandler(mTabRedirectHandler)
            .setIsMainFrame(navigationParams.isMainFrame)
            .build();
    if (externalNavHandler.shouldOverrideUrlLoading(params)
            != OverrideUrlLoadingResult.NO_OVERRIDE) {
        mSearchPanel.maximizePanelThenPromoteToTab(StateChangeReason.TAB_PROMOTION,
                INTERCEPT_NAVIGATION_PROMOTION_ANIMATION_DURATION_MS);
        return false;
    }
    if (navigationParams.isExternalProtocol) {
        return false;
    }
    return true;
}
 
Example #3
Source File: InterceptNavigationDelegateImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public boolean shouldIgnoreNewTab(String url, boolean incognito) {
    if (mAuthenticatorHelper != null && mAuthenticatorHelper.handleAuthenticatorUrl(url)) {
        return true;
    }

    ExternalNavigationParams params = new ExternalNavigationParams.Builder(url, incognito)
            .setTab(mTab)
            .setOpenInNewTab(true)
            .build();
    return mExternalNavHandler.shouldOverrideUrlLoading(params)
            != ExternalNavigationHandler.OverrideUrlLoadingResult.NO_OVERRIDE;
}
 
Example #4
Source File: ContextualSearchManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldInterceptNavigation(
        ExternalNavigationHandler externalNavHandler, NavigationParams navigationParams) {
    mTabRedirectHandler.updateNewUrlLoading(navigationParams.pageTransitionType,
            navigationParams.isRedirect,
            navigationParams.hasUserGesture || navigationParams.hasUserGestureCarryover,
            mActivity.getLastUserInteractionTime(), TabRedirectHandler.INVALID_ENTRY_INDEX);
    ExternalNavigationParams params =
            new ExternalNavigationParams
                    .Builder(navigationParams.url, false, navigationParams.referrer,
                            navigationParams.pageTransitionType,
                            navigationParams.isRedirect)
                    .setApplicationMustBeInForeground(true)
                    .setRedirectHandler(mTabRedirectHandler)
                    .setIsMainFrame(navigationParams.isMainFrame)
                    .build();
    if (externalNavHandler.shouldOverrideUrlLoading(params)
            != OverrideUrlLoadingResult.NO_OVERRIDE) {
        mSearchPanel.maximizePanelThenPromoteToTab(StateChangeReason.TAB_PROMOTION,
                INTERCEPT_NAVIGATION_PROMOTION_ANIMATION_DURATION_MS);
        return false;
    }
    if (navigationParams.isExternalProtocol) {
        return false;
    }
    return true;
}
 
Example #5
Source File: InterceptNavigationDelegateImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of {@link InterceptNavigationDelegateImpl} with the given
 * {@link ExternalNavigationHandler}.
 */
public InterceptNavigationDelegateImpl(ExternalNavigationHandler externalNavHandler, Tab tab) {
    mTab = tab;
    mExternalNavHandler = externalNavHandler;
    mAuthenticatorHelper = ((ChromeApplication) mTab.getApplicationContext())
            .createAuthenticatorNavigationInterceptor(mTab);
}
 
Example #6
Source File: InterceptNavigationDelegateImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
public boolean shouldIgnoreNewTab(String url, boolean incognito) {
    if (mAuthenticatorHelper != null && mAuthenticatorHelper.handleAuthenticatorUrl(url)) {
        return true;
    }

    ExternalNavigationParams params = new ExternalNavigationParams.Builder(url, incognito)
            .setTab(mTab)
            .setOpenInNewTab(true)
            .build();
    return mExternalNavHandler.shouldOverrideUrlLoading(params)
            != ExternalNavigationHandler.OverrideUrlLoadingResult.NO_OVERRIDE;
}
 
Example #7
Source File: CustomTabDelegateFactory.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public InterceptNavigationDelegateImpl createInterceptNavigationDelegate(Tab tab) {
    if (mIsOpenedByChrome) {
        mNavigationDelegate = new ExternalNavigationDelegateImpl(tab);
    } else {
        mNavigationDelegate = new CustomTabNavigationDelegate(tab, tab.getAppAssociatedWith());
    }
    mNavigationHandler = new ExternalNavigationHandler(mNavigationDelegate);
    return new InterceptNavigationDelegateImpl(mNavigationHandler, tab);
}
 
Example #8
Source File: CustomTabDelegateFactory.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public InterceptNavigationDelegateImpl createInterceptNavigationDelegate(Tab tab) {
    if (mIsOpenedByChrome) {
        mNavigationDelegate = new ExternalNavigationDelegateImpl(tab);
    } else {
        mNavigationDelegate = new CustomTabNavigationDelegate(tab, tab.getAppAssociatedWith());
    }
    mNavigationHandler = new ExternalNavigationHandler(mNavigationDelegate);
    return new InterceptNavigationDelegateImpl(mNavigationHandler, tab);
}
 
Example #9
Source File: InterceptNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
public boolean shouldIgnoreNewTab(String url, boolean incognito) {
    if (mAuthenticatorHelper != null && mAuthenticatorHelper.handleAuthenticatorUrl(url)) {
        return true;
    }

    ExternalNavigationParams params = new ExternalNavigationParams.Builder(url, incognito)
            .setTab(mTab)
            .setOpenInNewTab(true)
            .build();
    return mExternalNavHandler.shouldOverrideUrlLoading(params)
            != ExternalNavigationHandler.OverrideUrlLoadingResult.NO_OVERRIDE;
}
 
Example #10
Source File: InterceptNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new instance of {@link InterceptNavigationDelegateImpl} with the given
 * {@link ExternalNavigationHandler}.
 */
public InterceptNavigationDelegateImpl(ExternalNavigationHandler externalNavHandler, Tab tab) {
    mTab = tab;
    mExternalNavHandler = externalNavHandler;
    mAuthenticatorHelper = ((ChromeApplication) mTab.getApplicationContext())
            .createAuthenticatorNavigationInterceptor(mTab);
}
 
Example #11
Source File: CustomTabDelegateFactory.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return The {@link ExternalNavigationHandler} in this tab. For test purpose only.
 */
@VisibleForTesting
ExternalNavigationHandler getExternalNavigationHandler() {
    return mNavigationHandler;
}
 
Example #12
Source File: InterceptNavigationDelegateImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new instance of {@link InterceptNavigationDelegateImpl} with the given
 * {@link ExternalNavigationHandler}.
 */
public InterceptNavigationDelegateImpl(ExternalNavigationHandler externalNavHandler, Tab tab) {
    mTab = tab;
    mExternalNavHandler = externalNavHandler;
    mAuthenticatorHelper = AppHooks.get().createAuthenticatorNavigationInterceptor(mTab);
}
 
Example #13
Source File: InterceptNavigationDelegateImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor of {@link InterceptNavigationDelegateImpl}.
 */
public InterceptNavigationDelegateImpl(Tab tab) {
    this(new ExternalNavigationHandler(tab), tab);
}
 
Example #14
Source File: CustomTabDelegateFactory.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return The {@link ExternalNavigationHandler} in this tab. For test purpose only.
 */
@VisibleForTesting
ExternalNavigationHandler getExternalNavigationHandler() {
    return mNavigationHandler;
}
 
Example #15
Source File: ReaderModePanel.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@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) {
                closePanel(StateChangeReason.UNKNOWN, false);
                return;
            }

            WebContents sourceWebContents = mManagerDelegate.getBasePageWebContents();
            if (sourceWebContents == null) {
                closePanel(StateChangeReason.UNKNOWN, false);
                return;
            }

            DomDistillerTabUtils.distillAndView(sourceWebContents, distilledWebContents);
        }

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

        @Override
        public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler,
                NavigationParams navigationParams) {
            // The initial load will be the distilled content; don't try to open a new tab if
            // this is the case. All other navigations on distilled pages will come from link
            // 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);
}
 
Example #16
Source File: OverlayPanelContent.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public InterceptNavigationDelegateImpl() {
    Tab tab = mActivity.getActivityTab();
    mExternalNavHandler = (tab != null && tab.getContentViewCore() != null)
            ? new ExternalNavigationHandler(tab) : null;
}
 
Example #17
Source File: InterceptNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor of {@link InterceptNavigationDelegateImpl}.
 */
public InterceptNavigationDelegateImpl(Tab tab) {
    this(new ExternalNavigationHandler(tab), tab);
}
 
Example #18
Source File: OverlayPanelContent.java    From delion with Apache License 2.0 4 votes vote down vote up
public InterceptNavigationDelegateImpl() {
    Tab tab = mActivity.getActivityTab();
    mExternalNavHandler = (tab != null && tab.getContentViewCore() != null)
            ? new ExternalNavigationHandler(tab) : null;
}
 
Example #19
Source File: ReaderModePanel.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@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) {
            // The initial load will be the distilled content; don't try to open a new tab if
            // this is the case. All other navigations on distilled pages will come from link
            // 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);
}
 
Example #20
Source File: OverlayPanelContent.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public InterceptNavigationDelegateImpl() {
    Tab tab = mActivity.getActivityTab();
    mExternalNavHandler = (tab != null && tab.getContentViewCore() != null)
            ? new ExternalNavigationHandler(tab) : null;
}
 
Example #21
Source File: InterceptNavigationDelegateImpl.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Default constructor of {@link InterceptNavigationDelegateImpl}.
 */
public InterceptNavigationDelegateImpl(Tab tab) {
    this(new ExternalNavigationHandler(tab), tab);
}
 
Example #22
Source File: CustomTabDelegateFactory.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return The {@link ExternalNavigationHandler} in this tab. For test purpose only.
 */
@VisibleForTesting
ExternalNavigationHandler getExternalNavigationHandler() {
    return mNavigationHandler;
}
 
Example #23
Source File: CustomTabDelegateFactory.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public InterceptNavigationDelegateImpl createInterceptNavigationDelegate(Tab tab) {
    mNavigationDelegate = new CustomTabNavigationDelegate(tab, tab.getAppAssociatedWith());
    mNavigationHandler = new ExternalNavigationHandler(mNavigationDelegate);
    return new InterceptNavigationDelegateImpl(mNavigationHandler, tab);
}
 
Example #24
Source File: ReaderModePanel.java    From delion with Apache License 2.0 4 votes vote down vote up
@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) {
            // The initial load will be the distilled content; don't try to open a new tab if
            // this is the case. All other navigations on distilled pages will come from link
            // 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);
}
 
Example #25
Source File: OverlayContentDelegate.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Determine if a particular navigation should be intercepted.
 * @param externalNavHandler External navigation handler for the activity the panel is in.
 * @param navigationParams The navigation params for the current navigation.
 * @return True if the navigation should be intercepted.
 */
public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler,
        NavigationParams navigationParams) {
    return true;
}
 
Example #26
Source File: OverlayContentDelegate.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Determine if a particular navigation should be intercepted.
 * @param externalNavHandler External navigation handler for the activity the panel is in.
 * @param navigationParams The navigation params for the current navigation.
 * @return True if the navigation should be intercepted.
 */
public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler,
        NavigationParams navigationParams) {
    return true;
}
 
Example #27
Source File: OverlayContentDelegate.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Determine if a particular navigation should be intercepted.
 * @param externalNavHandler External navigation handler for the activity the panel is in.
 * @param navigationParams The navigation params for the current navigation.
 * @return True if the navigation should be intercepted.
 */
public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler,
        NavigationParams navigationParams) {
    return true;
}