Search in sources :

Example 21 with LoadUrlParams

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

the class Tab method openNewTab.

@CalledByNative
protected void openNewTab(String url, String extraHeaders, ResourceRequestBody postData, int disposition, boolean hasParent, boolean isRendererInitiated) {
    if (isClosing())
        return;
    boolean incognito = isIncognito();
    TabLaunchType tabLaunchType = TabLaunchType.FROM_LONGPRESS_FOREGROUND;
    Tab parentTab = hasParent ? this : null;
    switch(disposition) {
        // fall through
        case WindowOpenDisposition.NEW_WINDOW:
        case WindowOpenDisposition.NEW_FOREGROUND_TAB:
            break;
        // fall through
        case WindowOpenDisposition.NEW_POPUP:
        case WindowOpenDisposition.NEW_BACKGROUND_TAB:
            tabLaunchType = TabLaunchType.FROM_LONGPRESS_BACKGROUND;
            break;
        case WindowOpenDisposition.OFF_THE_RECORD:
            assert incognito;
            incognito = true;
            break;
        default:
            assert false;
    }
    // is not accessible, then we can't open a new tab.
    if (shouldIgnoreNewTab(url, incognito) || getTabModelSelector() == null)
        return;
    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setVerbatimHeaders(extraHeaders);
    loadUrlParams.setPostData(postData);
    loadUrlParams.setIsRendererInitiated(isRendererInitiated);
    getTabModelSelector().openNewTab(loadUrlParams, tabLaunchType, parentTab, incognito);
}
Also used : LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams) TabLaunchType(org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 22 with LoadUrlParams

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

the class Tab method unfreezeContents.

/**
     * Restores the WebContents from its saved state.  This should only be called if the tab is
     * frozen with a saved TabState, and NOT if it was frozen for a lazy load.
     * @return Whether or not the restoration was successful.
     */
protected boolean unfreezeContents() {
    try {
        TraceEvent.begin("Tab.unfreezeContents");
        assert mFrozenContentsState != null;
        assert getContentViewCore() == null;
        WebContents webContents = mFrozenContentsState.restoreContentsFromByteBuffer(isHidden());
        if (webContents == null) {
            // State restore failed, just create a new empty web contents as that is the best
            // that can be done at this point. TODO(jcivelli) http://b/5910521 - we should show
            // an error page instead of a blank page in that case (and the last loaded URL).
            webContents = WebContentsFactory.createWebContents(isIncognito(), isHidden());
            mTabUma = new TabUma(TabCreationState.FROZEN_ON_RESTORE_FAILED);
            mFailedToRestore = true;
        }
        mFrozenContentsState = null;
        initContentViewCore(webContents);
        if (mFailedToRestore) {
            String url = TextUtils.isEmpty(mUrl) ? UrlConstants.NTP_URL : mUrl;
            loadUrl(new LoadUrlParams(url, PageTransition.GENERATED));
        }
        return !mFailedToRestore;
    } finally {
        TraceEvent.end("Tab.unfreezeContents");
    }
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 23 with LoadUrlParams

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

the class TabContextMenuItemDelegate method onOpenInOtherWindow.

@Override
public void onOpenInOtherWindow(String url, Referrer referrer) {
    TabDelegate tabDelegate = new TabDelegate(mTab.isIncognito());
    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setReferrer(referrer);
    tabDelegate.createTabInOtherWindow(loadUrlParams, mTab.getActivity(), mTab.getParentId());
}
Also used : TabDelegate(org.chromium.chrome.browser.tabmodel.document.TabDelegate) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 24 with LoadUrlParams

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

the class ToolbarManager method openHomepage.

@Override
public void openHomepage() {
    RecordUserAction.record("Home");
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab == null)
        return;
    Context context = mToolbar.getContext();
    String homePageUrl = HomepageManager.getHomepageUri(context);
    if (TextUtils.isEmpty(homePageUrl)) {
        homePageUrl = UrlConstants.NTP_URL;
    }
    currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE));
}
Also used : Context(android.content.Context) Tab(org.chromium.chrome.browser.tab.Tab) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams)

Example 25 with LoadUrlParams

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

the class FullScreenActivity method preInflationStartup.

@Override
public void preInflationStartup() {
    super.preInflationStartup();
    setTabCreators(createTabDelegate(false), createTabDelegate(true));
    setTabModelSelector(new SingleTabModelSelector(this, false, false) {

        @Override
        public Tab openNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent, boolean incognito) {
            getTabCreator(incognito).createNewTab(loadUrlParams, type, parent);
            return null;
        }
    });
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) LoadUrlParams(org.chromium.content_public.browser.LoadUrlParams) TabLaunchType(org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType) SingleTabModelSelector(org.chromium.chrome.browser.tabmodel.SingleTabModelSelector)

Aggregations

LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)35 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 SharedPreferences (android.content.SharedPreferences)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 SparseIntArray (android.util.SparseIntArray)1