org.chromium.chrome.browser.TabState Java Examples

The following examples show how to use org.chromium.chrome.browser.TabState. 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: WebappActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Saves the tab data out to a file.
 */
void saveState(File activityDirectory) {
    String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(), false);
    File tabFile = new File(activityDirectory, tabFileName);

    // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
    try {
        long time = SystemClock.elapsedRealtime();
        TabState.saveState(tabFile, getActivityTab().getState(), false);
        RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappSaveState",
                SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #2
Source File: WebappActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Saves the tab data out to a file.
 */
void saveState(File activityDirectory) {
    String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(), false);
    File tabFile = new File(activityDirectory, tabFileName);

    // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    StrictMode.allowThreadDiskWrites();
    try {
        long time = SystemClock.elapsedRealtime();
        TabState.saveState(tabFile, getActivityTab().getState(), false);
        RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappSaveState",
                SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #3
Source File: Tab.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Restores member fields from the given TabState.
 * @param state TabState containing information about this Tab.
 */
private void restoreFieldsFromState(TabState state) {
    assert state != null;
    mAppAssociatedWith = state.openerAppId;
    mFrozenContentsState = state.contentsState;
    mSyncId = (int) state.syncId;
    mShouldPreserve = state.shouldPreserve;
    mTimestampMillis = state.timestampMillis;
    mUrl = state.getVirtualUrlFromState();

    mThemeColor = state.hasThemeColor() ? state.getThemeColor() : getDefaultThemeColor();

    mTitle = state.getDisplayTitleFromState();
    mIsTitleDirectionRtl = mTitle != null
            && LocalizationUtils.getFirstStrongCharacterDirection(mTitle)
                    == LocalizationUtils.RIGHT_TO_LEFT;
}
 
Example #4
Source File: Tab.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Restores member fields from the given TabState.
 * @param state TabState containing information about this Tab.
 */
private void restoreFieldsFromState(TabState state) {
    assert state != null;
    mAppAssociatedWith = state.openerAppId;
    mFrozenContentsState = state.contentsState;
    mSyncId = (int) state.syncId;
    mShouldPreserve = state.shouldPreserve;
    mTimestampMillis = state.timestampMillis;
    mUrl = state.getVirtualUrlFromState();

    mThemeColor = state.hasThemeColor() ? state.getThemeColor() : getDefaultThemeColor();

    mTitle = state.getDisplayTitleFromState();
    mIsTitleDirectionRtl = mTitle != null
            && LocalizationUtils.getFirstStrongCharacterDirection(mTitle)
                    == LocalizationUtils.RIGHT_TO_LEFT;
}
 
Example #5
Source File: TabPersistentStore.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(CleanUpTabStateDataInfo tabStateInfo) {
    if (mDestroyed || tabStateInfo.mTabFileNames == null) return;

    for (String fileName : tabStateInfo.mTabFileNames) {
        Pair<Integer, Boolean> data = TabState.parseInfoFromFilename(fileName);
        if (data != null) {
            TabModel model = mTabModelSelector.getModel(data.second);
            if (mDeleteAllFiles || (TabModelUtils.getTabById(model, data.first) == null
                    && tabStateInfo.mOtherTabIds.get(data.first) == null)) {
                // It might be more efficient to use a single task for all files, but
                // the number of files is expected to be very small.
                deleteFileAsync(fileName);
            }
        }
    }
}
 
Example #6
Source File: Tab.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Restores member fields from the given TabState.
 * @param state TabState containing information about this Tab.
 */
private void restoreFieldsFromState(TabState state) {
    assert state != null;
    mAppAssociatedWith = state.openerAppId;
    mFrozenContentsState = state.contentsState;
    mSyncId = (int) state.syncId;
    mShouldPreserve = state.shouldPreserve;
    mTimestampMillis = state.timestampMillis;
    mUrl = state.getVirtualUrlFromState();

    mThemeColor = state.hasThemeColor() ? state.getThemeColor() : getDefaultThemeColor();

    mTitle = state.getDisplayTitleFromState();
    mIsTitleDirectionRtl = mTitle != null
            && LocalizationUtils.getFirstStrongCharacterDirection(mTitle)
                    == LocalizationUtils.RIGHT_TO_LEFT;
}
 
Example #7
Source File: TabPersistentStore.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(TabState tabState) {
    if (mDestroyed || isCancelled()) return;

    boolean isIncognito = isIncognitoTabBeingRestored(mTabToRestore, tabState);
    boolean isLoadCancelled = (isIncognito && mCancelIncognitoTabLoads)
            || (!isIncognito && mCancelNormalTabLoads);
    if (!isLoadCancelled) restoreTab(mTabToRestore, tabState, false);

    loadNextTab();
}
 
Example #8
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** @return An opaque "state" object that can be persisted to storage. */
public TabState getState() {
    if (!isInitialized()) return null;
    TabState tabState = new TabState();
    tabState.contentsState = getWebContentsState();
    tabState.openerAppId = mAppAssociatedWith;
    tabState.parentId = mParentId;
    tabState.shouldPreserve = mShouldPreserve;
    tabState.syncId = mSyncId;
    tabState.timestampMillis = mTimestampMillis;
    tabState.themeColor = getThemeColor();
    return tabState;
}
 
Example #9
Source File: TabPersistentStore.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected TabState doInBackground(Void... voids) {
    if (mDestroyed || isCancelled()) return null;
    try {
        return TabState.restoreTabState(getStateDirectory(), mTabToRestore.id);
    } catch (Exception e) {
        Log.w(TAG, "Unable to read state: " + e);
        return null;
    }
}
 
Example #10
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostExecute(TabState tabState) {
    if (mDestroyed || isCancelled()) return;

    boolean isIncognito = isIncognitoTabBeingRestored(mTabToRestore, tabState);
    boolean isLoadCancelled = (isIncognito && mCancelIncognitoTabLoads)
            || (!isIncognito && mCancelNormalTabLoads);
    if (!isLoadCancelled) restoreTab(mTabToRestore, tabState, false);

    loadNextTab();
}
 
Example #11
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Determines if a Tab being restored is definitely an Incognito Tab.
 *
 * This function can fail to determine if a Tab is incognito if not enough data about the Tab
 * was successfully saved out.
 *
 * @return True if the tab is definitely Incognito, false if it's not or if it's undecideable.
 */
private boolean isIncognitoTabBeingRestored(TabRestoreDetails tabDetails, TabState tabState) {
    if (tabState != null) {
        // The Tab's previous state was completely restored.
        return tabState.isIncognito();
    } else if (tabDetails.isIncognito != null) {
        // The TabState couldn't be restored, but we have some information about the tab.
        return tabDetails.isIncognito;
    } else {
        // The tab's type is undecideable.
        return false;
    }
}
 
Example #12
Source File: TabPersistentStore.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void restoreTab(TabRestoreDetails tabToRestore, boolean setAsActive) {
    // As we do this in startup, and restoring the active tab's state is critical, we permit
    // this read in the event that the prefetch task is not available. Either:
    // 1. The user just upgraded, has not yet set the new active tab id pref yet. Or
    // 2. restoreTab is used to preempt async queue and restore immediately on the UI thread.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        long time = SystemClock.uptimeMillis();
        TabState state;
        int restoredTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
        if (restoredTabId == tabToRestore.id && mPrefetchActiveTabTask != null) {
            long timeWaitingForPrefetch = SystemClock.uptimeMillis();
            state = mPrefetchActiveTabTask.get();
            logExecutionTime("RestoreTabPrefetchTime", timeWaitingForPrefetch);
        } else {
            // Necessary to do on the UI thread as a last resort.
            state = TabState.restoreTabState(getStateDirectory(), tabToRestore.id);
        }
        logExecutionTime("RestoreTabTime", time);
        restoreTab(tabToRestore, state, setAsActive);
    } catch (Exception e) {
        // Catch generic exception to prevent a corrupted state from crashing the app
        // at startup.
        Log.d(TAG, "loadTabs exception: " + e.toString(), e);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #13
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void startPrefetchActiveTabTask(Executor executor) {
    final int activeTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
    if (activeTabId == Tab.INVALID_TAB_ID) return;
    mPrefetchActiveTabTask = new AsyncTask<Void, Void, TabState>() {
        @Override
        protected TabState doInBackground(Void... params) {
            return TabState.restoreTabState(getStateDirectory(), activeTabId);
        }
    }.executeOnExecutor(executor);
}
 
Example #14
Source File: ChromeTabCreator.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public Tab createFrozenTab(TabState state, int id, int index) {
    Tab tab = Tab.createFrozenTabFromState(
            id, mActivity, state.isIncognito(), mNativeWindow, state.parentId, state);
    boolean selectTab = mOrderController.willOpenInForeground(TabLaunchType.FROM_RESTORE,
            state.isIncognito());
    tab.initialize(
            null, mTabContentManager, createDefaultTabDelegateFactory(), !selectTab, false);
    assert state.isIncognito() == mIncognito;
    mTabModel.addTab(tab, index, TabLaunchType.FROM_RESTORE);
    return tab;
}
 
Example #15
Source File: TabbedModeTabPersistencePolicy.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Upgrades users from an old version of Chrome when the state file was still in the root
 * directory.
 */
@WorkerThread
private void performLegacyMigration() {
    Log.w(TAG, "Starting to perform legacy migration.");
    File newFolder = getOrCreateStateDirectory();
    File[] newFiles = newFolder.listFiles();
    // Attempt migration if we have no tab state file in the new directory.
    if (newFiles == null || newFiles.length == 0) {
        File oldFolder = ContextUtils.getApplicationContext().getFilesDir();
        File modelFile = new File(oldFolder, LEGACY_SAVED_STATE_FILE);
        if (modelFile.exists()) {
            if (!modelFile.renameTo(new File(newFolder, getStateFileName()))) {
                Log.e(TAG, "Failed to rename file: " + modelFile);
            }
        }

        File[] files = oldFolder.listFiles();
        if (files != null) {
            for (File file : files) {
                if (TabState.parseInfoFromFilename(file.getName()) != null) {
                    if (!file.renameTo(new File(newFolder, file.getName()))) {
                        Log.e(TAG, "Failed to rename file: " + file);
                    }
                }
            }
        }
    }
    setLegacyFileMigrationPref();
    Log.w(TAG, "Finished performing legacy migration.");
}
 
Example #16
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Returns an ByteBuffer representing the state of the Tab's WebContents. */
private ByteBuffer getWebContentsStateAsByteBuffer() {
    if (mPendingLoadParams == null) {
        return TabState.getContentsStateAsByteBuffer(this);
    } else {
        Referrer referrer = mPendingLoadParams.getReferrer();
        return TabState.createSingleNavigationStateAsByteBuffer(
                mPendingLoadParams.getUrl(),
                referrer != null ? referrer.getUrl() : null,
                // Policy will be ignored for null referrer url, 0 is just a placeholder.
                referrer != null ? referrer.getPolicy() : 0,
                isIncognito());
    }
}
 
Example #17
Source File: TabPersistentStore.java    From delion with Apache License 2.0 5 votes vote down vote up
private void startPrefetchActiveTabTask() {
    final int activeTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
    if (activeTabId == Tab.INVALID_TAB_ID) return;
    mPrefetchActiveTabTask = new AsyncTask<Void, Void, TabState>() {
        @Override
        protected TabState doInBackground(Void... params) {
            return TabState.restoreTabState(getStateDirectory(), activeTabId);
        }
    }.executeOnExecutor(getPrefetchExecutor());
}
 
Example #18
Source File: TabPersister.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Saves the TabState with the given ID.
 * @param tabId ID of the Tab.
 * @param encrypted Whether or not the TabState is encrypted.
 * @param state TabState for the Tab.
 */
public boolean saveTabState(int tabId, boolean encrypted, TabState state) {
    if (state == null) return false;

    try {
        TabState.saveState(getTabStateFile(tabId, encrypted), state, encrypted);
        return true;
    } catch (OutOfMemoryError e) {
        Log.e(TAG, "Out of memory error while attempting to save tab state.  Erasing.");
        deleteTabState(tabId, encrypted);
    }

    return false;
}
 
Example #19
Source File: TabPersistentStore.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Determines if a Tab being restored is definitely an Incognito Tab.
 *
 * This function can fail to determine if a Tab is incognito if not enough data about the Tab
 * was successfully saved out.
 *
 * @return True if the tab is definitely Incognito, false if it's not or if it's undecideable.
 */
private boolean isIncognitoTabBeingRestored(TabRestoreDetails tabDetails, TabState tabState) {
    if (tabState != null) {
        // The Tab's previous state was completely restored.
        return tabState.isIncognito();
    } else if (tabDetails.isIncognito != null) {
        // The TabState couldn't be restored, but we have some information about the tab.
        return tabDetails.isIncognito;
    } else {
        // The tab's type is undecideable.
        return false;
    }
}
 
Example #20
Source File: TabPersistentStore.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void startPrefetchActiveTabTask(Executor executor) {
    final int activeTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
    if (activeTabId == Tab.INVALID_TAB_ID) return;
    mPrefetchActiveTabTask = new AsyncTask<Void, Void, TabState>() {
        @Override
        protected TabState doInBackground(Void... params) {
            return TabState.restoreTabState(getStateDirectory(), activeTabId);
        }
    }.executeOnExecutor(executor);
}
 
Example #21
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected TabState doInBackground(Void... voids) {
    if (mDestroyed || isCancelled()) return null;
    try {
        return TabState.restoreTabState(getStateDirectory(), mTabToRestore.id);
    } catch (Exception e) {
        Log.w(TAG, "Unable to read state: " + e);
        return null;
    }
}
 
Example #22
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void restoreTab(TabRestoreDetails tabToRestore, boolean setAsActive) {
    // As we do this in startup, and restoring the active tab's state is critical, we permit
    // this read in the event that the prefetch task is not available. Either:
    // 1. The user just upgraded, has not yet set the new active tab id pref yet. Or
    // 2. restoreTab is used to preempt async queue and restore immediately on the UI thread.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        long time = SystemClock.uptimeMillis();
        TabState state;
        int restoredTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
        if (restoredTabId == tabToRestore.id && mPrefetchActiveTabTask != null) {
            long timeWaitingForPrefetch = SystemClock.uptimeMillis();
            state = mPrefetchActiveTabTask.get();
            logExecutionTime("RestoreTabPrefetchTime", timeWaitingForPrefetch);
        } else {
            // Necessary to do on the UI thread as a last resort.
            state = TabState.restoreTabState(getStateDirectory(), tabToRestore.id);
        }
        logExecutionTime("RestoreTabTime", time);
        restoreTab(tabToRestore, state, setAsActive);
    } catch (Exception e) {
        // Catch generic exception to prevent a corrupted state from crashing the app
        // at startup.
        Log.d(TAG, "loadTabs exception: " + e.toString(), e);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #23
Source File: ChromeTabCreator.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public Tab createFrozenTab(TabState state, int id, int index) {
    Tab tab = Tab.createFrozenTabFromState(
            id, mActivity, state.isIncognito(), mNativeWindow, state.parentId, state);
    boolean selectTab = mOrderController.willOpenInForeground(TabLaunchType.FROM_RESTORE,
            state.isIncognito());
    tab.initialize(
            null, mTabContentManager, createDefaultTabDelegateFactory(), !selectTab, false);
    assert state.isIncognito() == mIncognito;
    mTabModel.addTab(tab, index, TabLaunchType.FROM_RESTORE);
    return tab;
}
 
Example #24
Source File: IncognitoNotificationService.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Whether deleting all the incognito files was successful.
 */
private boolean deleteIncognitoStateFilesInDirectory(File directory) {
    File[] allTabStates = directory.listFiles();
    if (allTabStates == null) return true;

    boolean deletionSuccessful = true;
    for (int i = 0; i < allTabStates.length; i++) {
        String fileName = allTabStates[i].getName();
        Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(fileName);
        if (tabInfo == null || !tabInfo.second) continue;
        deletionSuccessful &= allTabStates[i].delete();
    }
    return deletionSuccessful;
}
 
Example #25
Source File: CustomTabTabPersistencePolicy.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected Void doInBackground(Void... voids) {
    if (mDestroyed) return null;

    mTabIdsByMetadataFile = new HashMap<>();
    mUnreferencedTabIds = new HashSet<>();

    File[] stateFiles = getOrCreateStateDirectory().listFiles();
    if (stateFiles == null) return null;

    Set<Integer> allTabIds = new HashSet<>();
    Set<Integer> allReferencedTabIds = new HashSet<>();
    List<File> metadataFiles = new ArrayList<>();
    for (File file : stateFiles) {
        if (TabPersistentStore.isStateFile(file.getName())) {
            metadataFiles.add(file);

            SparseBooleanArray tabIds = new SparseBooleanArray();
            mTabIdsByMetadataFile.put(file, tabIds);
            getTabsFromStateFile(tabIds, file);
            for (int i = 0; i < tabIds.size(); i++) {
                allReferencedTabIds.add(tabIds.keyAt(i));
            }
            continue;
        }

        Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(file.getName());
        if (tabInfo == null) continue;
        allTabIds.add(tabInfo.first);
    }

    mUnreferencedTabIds.addAll(allTabIds);
    mUnreferencedTabIds.removeAll(allReferencedTabIds);

    mDeletableMetadataFiles = getMetadataFilesForDeletion(
            System.currentTimeMillis(), metadataFiles);
    return null;
}
 
Example #26
Source File: TabbedModeTabPersistencePolicy.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Upgrades users from an old version of Chrome when the state file was still in the root
 * directory.
 */
@WorkerThread
private void performLegacyMigration() {
    Log.w(TAG, "Starting to perform legacy migration.");
    File newFolder = getOrCreateStateDirectory();
    File[] newFiles = newFolder.listFiles();
    // Attempt migration if we have no tab state file in the new directory.
    if (newFiles == null || newFiles.length == 0) {
        File oldFolder = ContextUtils.getApplicationContext().getFilesDir();
        File modelFile = new File(oldFolder, LEGACY_SAVED_STATE_FILE);
        if (modelFile.exists()) {
            if (!modelFile.renameTo(new File(newFolder, getStateFileName()))) {
                Log.e(TAG, "Failed to rename file: " + modelFile);
            }
        }

        File[] files = oldFolder.listFiles();
        if (files != null) {
            for (File file : files) {
                if (TabState.parseInfoFromFilename(file.getName()) != null) {
                    if (!file.renameTo(new File(newFolder, file.getName()))) {
                        Log.e(TAG, "Failed to rename file: " + file);
                    }
                }
            }
        }
    }
    setLegacyFileMigrationPref();
    Log.w(TAG, "Finished performing legacy migration.");
}
 
Example #27
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** @return An opaque "state" object that can be persisted to storage. */
public TabState getState() {
    if (!isInitialized()) return null;
    TabState tabState = new TabState();
    tabState.contentsState = getWebContentsState();
    tabState.openerAppId = mAppAssociatedWith;
    tabState.parentId = mParentId;
    tabState.shouldPreserve = mShouldPreserve;
    tabState.syncId = mSyncId;
    tabState.timestampMillis = mTimestampMillis;
    tabState.themeColor = getThemeColor();
    return tabState;
}
 
Example #28
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** Returns an object representing the state of the Tab's WebContents. */
private TabState.WebContentsState getWebContentsState() {
    if (mFrozenContentsState != null) return mFrozenContentsState;

    // Native call returns null when buffer allocation needed to serialize the state failed.
    ByteBuffer buffer = getWebContentsStateAsByteBuffer();
    if (buffer == null) return null;

    TabState.WebContentsState state = new TabState.WebContentsStateNative(buffer);
    state.setVersion(TabState.CONTENTS_STATE_CURRENT_VERSION);
    return state;
}
 
Example #29
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** Returns an ByteBuffer representing the state of the Tab's WebContents. */
private ByteBuffer getWebContentsStateAsByteBuffer() {
    if (mPendingLoadParams == null) {
        return TabState.getContentsStateAsByteBuffer(this);
    } else {
        Referrer referrer = mPendingLoadParams.getReferrer();
        return TabState.createSingleNavigationStateAsByteBuffer(
                mPendingLoadParams.getUrl(),
                referrer != null ? referrer.getUrl() : null,
                // Policy will be ignored for null referrer url, 0 is just a placeholder.
                referrer != null ? referrer.getPolicy() : 0,
                isIncognito());
    }
}
 
Example #30
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new, "frozen" tab from a saved state. This can be used for background tabs restored
 * on cold start that should be loaded when switched to. initialize() needs to be called
 * afterwards to complete the second level initialization.
 */
public static Tab createFrozenTabFromState(
        int id, ChromeActivity activity, boolean incognito,
        WindowAndroid nativeWindow, int parentId, TabState state) {
    assert state != null;
    return new Tab(id, parentId, incognito, activity, nativeWindow,
            TabLaunchType.FROM_RESTORE, TabCreationState.FROZEN_ON_RESTORE, state);
}