Search in sources :

Example 36 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class OverlayPanelContent method loadUrl.

// ============================================================================================
// ContentViewCore related
// ============================================================================================
/**
 * Load a URL; this will trigger creation of a new ContentViewCore if being loaded immediately,
 * otherwise one is created when the panel's content becomes visible.
 * @param url The URL that should be loaded.
 * @param shouldLoadImmediately If a URL should be loaded immediately or wait until visibility
 *                        changes.
 */
public void loadUrl(String url, boolean shouldLoadImmediately) {
    mPendingUrl = null;
    if (!shouldLoadImmediately) {
        mPendingUrl = url;
    } else {
        createNewContentView();
        mLoadedUrl = url;
        mDidStartLoadingUrl = true;
        mIsProcessingPendingNavigation = true;
        if (!mContentDelegate.handleInterceptLoadUrl(mContentViewCore, url)) {
            mContentViewCore.getWebContents().getNavigationController().loadUrl(new LoadUrlParams(url));
        }
    }
}
Also used : LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 37 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class DownloadUtils method showDownloadManager.

/**
 * Displays the download manager UI. Note the UI is different on tablets and on phones.
 * @return Whether the UI was shown.
 */
public static boolean showDownloadManager(@Nullable Activity activity, @Nullable Tab tab) {
    if (!isDownloadHomeEnabled())
        return false;
    // Figure out what tab was last being viewed by the user.
    if (activity == null)
        activity = ApplicationStatus.getLastTrackedFocusedActivity();
    if (tab == null && activity instanceof ChromeTabbedActivity) {
        tab = ((ChromeTabbedActivity) activity).getActivityTab();
    }
    Context appContext = ContextUtils.getApplicationContext();
    if (DeviceFormFactor.isTablet(appContext)) {
        // Download Home shows up as a tab on tablets.
        LoadUrlParams params = new LoadUrlParams(UrlConstants.DOWNLOADS_URL);
        if (tab == null || !tab.isInitialized()) {
            // Open a new tab, which pops Chrome into the foreground.
            TabDelegate delegate = new TabDelegate(false);
            delegate.createNewTab(params, TabLaunchType.FROM_CHROME_UI, null);
        } else {
            // Download Home shows up inside an existing tab, but only if the last Activity was
            // the ChromeTabbedActivity.
            tab.loadUrl(params);
            // Bring Chrome to the foreground, if possible.
            Intent intent = Tab.createBringTabToFrontIntent(tab.getId());
            if (intent != null) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                IntentUtils.safeStartActivity(appContext, intent);
            }
        }
    } else {
        // Download Home shows up as a new Activity on phones.
        Intent intent = new Intent();
        intent.setClass(appContext, DownloadActivity.class);
        if (tab != null)
            intent.putExtra(EXTRA_IS_OFF_THE_RECORD, tab.isIncognito());
        if (activity == null) {
            // Stands alone in its own task.
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            appContext.startActivity(intent);
        } else {
            // Sits on top of another Activity.
            intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
            activity.startActivity(intent);
        }
    }
    return true;
}
Also used : Context(android.content.Context) ChromeTabbedActivity(org.chromium.chrome.browser.ChromeTabbedActivity) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams) TabDelegate(org.chromium.chrome.browser.tabmodel.document.TabDelegate)

Example 38 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class ExternalNavigationDelegateImpl method clobberCurrentTab.

@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;
    }
}
Also used : Referrer(org.chromium.content_public.common.Referrer) Intent(android.content.Intent) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams) Uri(android.net.Uri)

Example 39 with LoadUrlParams

use of org.chromium.content_public.browser.LoadUrlParams in project AndroidChromium by JackyAndroid.

the class WebappActivity method initializeUI.

private void initializeUI(Bundle savedInstanceState) {
    // We do not load URL when restoring from saved instance states.
    if (savedInstanceState == null && mWebappInfo.isInitialized()) {
        if (TextUtils.isEmpty(getActivityTab().getUrl())) {
            getActivityTab().loadUrl(new LoadUrlParams(mWebappInfo.uri().toString(), PageTransition.AUTO_TOPLEVEL));
        }
    } else {
        if (NetworkChangeNotifier.isOnline())
            getActivityTab().reloadIgnoringCache();
    }
    getActivityTab().addObserver(createTabObserver());
    getActivityTab().getTabWebContentsDelegateAndroid().setDisplayMode(WebDisplayMode.Standalone);
// TODO(dominickn): send the web app into fullscreen if mDisplayMode is
// WebDisplayMode.Fullscreen. See crbug.com/581522
}
Also used : LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Aggregations

LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)39 Tab (org.chromium.chrome.browser.tab.Tab)9 Intent (android.content.Intent)6 Referrer (org.chromium.content_public.common.Referrer)5 TabDelegate (org.chromium.chrome.browser.tabmodel.document.TabDelegate)4 PendingIntent (android.app.PendingIntent)3 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)3 Context (android.content.Context)2 CustomTabsSessionToken (android.support.customtabs.CustomTabsSessionToken)2 AlertDialog (android.support.v7.app.AlertDialog)2 View (android.view.View)2 CalledByNative (org.chromium.base.annotations.CalledByNative)2 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)2 AsyncTabCreationParams (org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams)2 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 SparseIntArray (android.util.SparseIntArray)1 OnClickListener (android.view.View.OnClickListener)1