Search in sources :

Example 86 with Tab

use of org.chromium.chrome.browser.tab.Tab 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)

Example 87 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class FullScreenActivity method createTab.

/**
     * Creates the {@link Tab} used by the FullScreenActivity.
     * If the {@code savedInstanceState} exists, then the user did not intentionally close the app
     * by swiping it away in the recent tasks list.  In that case, we try to restore the tab from
     * disk.
     */
private Tab createTab() {
    Tab tab = null;
    boolean unfreeze = false;
    int tabId = Tab.INVALID_TAB_ID;
    String tabUrl = null;
    if (getSavedInstanceState() != null) {
        tabId = getSavedInstanceState().getInt(BUNDLE_TAB_ID, Tab.INVALID_TAB_ID);
        tabUrl = getSavedInstanceState().getString(BUNDLE_TAB_URL);
    }
    if (tabId != Tab.INVALID_TAB_ID && tabUrl != null && getActivityDirectory() != null) {
        // Restore the tab.
        TabState tabState = TabState.restoreTabState(getActivityDirectory(), tabId);
        tab = new Tab(tabId, Tab.INVALID_TAB_ID, false, this, getWindowAndroid(), TabLaunchType.FROM_RESTORE, TabCreationState.FROZEN_ON_RESTORE, tabState);
        unfreeze = true;
    }
    if (tab == null) {
        tab = new Tab(Tab.INVALID_TAB_ID, Tab.INVALID_TAB_ID, false, this, getWindowAndroid(), TabLaunchType.FROM_CHROME_UI, null, null);
    }
    tab.initialize(null, getTabContentManager(), createTabDelegateFactory(), false, unfreeze);
    mWebContentsObserver = new WebContentsObserver(tab.getWebContents()) {

        @Override
        public void didCommitProvisionalLoadForFrame(long frameId, boolean isMainFrame, String url, int transitionType) {
            if (isMainFrame) {
                // Notify the renderer to permanently hide the top controls since they do
                // not apply to fullscreen content views.
                getActivityTab().updateTopControlsState(getActivityTab().getTopControlsStateConstraints(), true);
            }
        }
    };
    return tab;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) TabState(org.chromium.chrome.browser.TabState) WebContentsObserver(org.chromium.content_public.browser.WebContentsObserver)

Example 88 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class TabPersistentStore method saveNextTab.

private void saveNextTab() {
    if (mSaveTabTask != null)
        return;
    if (!mTabsToSave.isEmpty()) {
        Tab tab = mTabsToSave.removeFirst();
        mSaveTabTask = new SaveTabTask(tab);
        mSaveTabTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
    } else {
        saveTabListAsynchronously();
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 89 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class TabWindowManager method getIncognitoTabCount.

/**
     * @return The total number of incognito tabs across all tab model selectors.
     */
public int getIncognitoTabCount() {
    int count = 0;
    for (int i = 0; i < mSelectors.size(); i++) {
        if (mSelectors.get(i) != null) {
            count += mSelectors.get(i).getModel(true).getCount();
        }
    }
    // Count tabs that are moving between activities (e.g. a tab that was recently reparented
    // and hasn't been attached to its new activity yet).
    SparseArray<AsyncTabParams> asyncTabParams = AsyncTabParamsManager.getAsyncTabParams();
    for (int i = 0; i < asyncTabParams.size(); i++) {
        Tab tab = asyncTabParams.valueAt(i).getTabToReparent();
        if (tab != null && tab.isIncognito())
            count++;
    }
    return count;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 90 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class VrShellDelegate method enterVRIfNecessary.

/**
     * Enters VR Shell, displaying browser UI and tab contents in VR.
     *
     * This function performs native initialization, and so must only be called after native
     * libraries are ready.
     * @param inWebVR If true should begin displaying WebVR content rather than the VrShell UI.
     * @return Whether or not we are in VR when this function returns.
     */
@CalledByNative
public boolean enterVRIfNecessary(boolean inWebVR) {
    if (!mVrShellEnabled || mNativeVrShellDelegate == 0)
        return false;
    Tab tab = mActivity.getActivityTab();
    // entered without any current tabs.
    if (tab == null || tab.getContentViewCore() == null) {
        return false;
    }
    if (mInVr)
        return true;
    // VrShell must be initialized in Landscape mode due to a bug in the GVR library.
    mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    if (!createVrShell()) {
        mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        return false;
    }
    addVrViews();
    setupVrModeWindowFlags();
    mVrShell.initializeNative(tab, this);
    if (inWebVR)
        mVrShell.setWebVrModeEnabled(true);
    mVrShell.setVrModeEnabled(true);
    mInVr = true;
    tab.updateFullscreenEnabledState();
    return true;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

Tab (org.chromium.chrome.browser.tab.Tab)116 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)13 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)10 LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)9 SuppressLint (android.annotation.SuppressLint)8 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)8 Intent (android.content.Intent)5 FrameLayout (android.widget.FrameLayout)4 ContentViewCore (org.chromium.content.browser.ContentViewCore)4 WebContents (org.chromium.content_public.browser.WebContents)4 Activity (android.app.Activity)3 Bitmap (android.graphics.Bitmap)3 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)3 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Bundle (android.os.Bundle)2 StrictMode (android.os.StrictMode)2 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2