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

The following examples show how to use org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.OverrideUrlLoadingResult. 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: ExternalNavigationDelegateImpl.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public OverrideUrlLoadingResult clobberCurrentTab(
        String url, String referrerUrl, Tab tab) {
    int transitionType = PageTransition.LINK;
    LoadUrlParams loadUrlParams = new LoadUrlParams(url, transitionType);
    if (!TextUtils.isEmpty(referrerUrl)) {
        Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
        loadUrlParams.setReferrer(referrer);
    }
    if (tab != null) {
        tab.loadUrl(loadUrlParams);
        return OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB;
    } else {
        assert false : "clobberCurrentTab was called with an empty tab.";
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setPackage(getPackageName());
        startActivity(intent);
        return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT;
    }
}
 
Example #3
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 #4
Source File: ExternalNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public OverrideUrlLoadingResult clobberCurrentTab(
        String url, String referrerUrl, Tab tab) {
    int transitionType = PageTransition.LINK;
    LoadUrlParams loadUrlParams = new LoadUrlParams(url, transitionType);
    if (!TextUtils.isEmpty(referrerUrl)) {
        Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
        loadUrlParams.setReferrer(referrer);
    }
    if (tab != null) {
        tab.loadUrl(loadUrlParams);
        return OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB;
    } else {
        assert false : "clobberCurrentTab was called with an empty tab.";
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName());
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setPackage(getPackageName());
        startActivity(intent, false);
        return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT;
    }
}
 
Example #5
Source File: ExternalNavigationDelegateImpl.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public OverrideUrlLoadingResult clobberCurrentTab(
        String url, String referrerUrl, Tab tab) {
    int transitionType = PageTransition.LINK;
    LoadUrlParams loadUrlParams = new LoadUrlParams(url, transitionType);
    if (!TextUtils.isEmpty(referrerUrl)) {
        Referrer referrer = new Referrer(referrerUrl, Referrer.REFERRER_POLICY_ALWAYS);
        loadUrlParams.setReferrer(referrer);
    }
    if (tab != null) {
        tab.loadUrl(loadUrlParams);
        return OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB;
    } else {
        assert false : "clobberCurrentTab was called with an empty tab.";
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        String packageName = ContextUtils.getApplicationContext().getPackageName();
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, packageName);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setPackage(packageName);
        startActivity(intent, false);
        return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT;
    }
}
 
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: 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 #8
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 #9
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 #10
Source File: InterceptNavigationDelegateImpl.java    From delion with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
public OverrideUrlLoadingResult getLastOverrideUrlLoadingResultForTests() {
    return mLastOverrideUrlLoadingResult;
}
 
Example #11
Source File: InterceptNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
public OverrideUrlLoadingResult getLastOverrideUrlLoadingResultForTests() {
    return mLastOverrideUrlLoadingResult;
}
 
Example #12
Source File: InterceptNavigationDelegateImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
public OverrideUrlLoadingResult getLastOverrideUrlLoadingResultForTests() {
    return mLastOverrideUrlLoadingResult;
}
 
Example #13
Source File: ExternalNavigationDelegate.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Clobber the current tab and try not to pass an intent when it should be handled by Chrome
 * so that we can deliver HTTP referrer information safely.
 *
 * @param url The new URL after clobbering the current tab.
 * @param referrerUrl The HTTP referrer URL.
 * @param tab The current tab.
 * @return OverrideUrlLoadingResult (if the tab has been clobbered, or we're launching an
 *         intent.)
 */
OverrideUrlLoadingResult clobberCurrentTab(String url, String referrerUrl, Tab tab);
 
Example #14
Source File: ExternalNavigationDelegate.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Clobber the current tab and try not to pass an intent when it should be handled by Chrome
 * so that we can deliver HTTP referrer information safely.
 *
 * @param url The new URL after clobbering the current tab.
 * @param referrerUrl The HTTP referrer URL.
 * @param tab The current tab.
 * @return OverrideUrlLoadingResult (if the tab has been clobbered, or we're launching an
 *         intent.)
 */
OverrideUrlLoadingResult clobberCurrentTab(String url, String referrerUrl, Tab tab);
 
Example #15
Source File: ExternalNavigationDelegate.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Clobber the current tab and try not to pass an intent when it should be handled by Chrome
 * so that we can deliver HTTP referrer information safely.
 *
 * @param url The new URL after clobbering the current tab.
 * @param referrerUrl The HTTP referrer URL.
 * @param tab The current tab.
 * @return OverrideUrlLoadingResult (if the tab has been clobbered, or we're launching an
 *         intent.)
 */
OverrideUrlLoadingResult clobberCurrentTab(String url, String referrerUrl, Tab tab);