Java Code Examples for org.chromium.chrome.browser.document.DocumentUtils#getLastShownTabIdFromPrefs()

The following examples show how to use org.chromium.chrome.browser.document.DocumentUtils#getLastShownTabIdFromPrefs() . 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: DocumentModeAssassin.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Kicks off tasks for the new state of the pipeline.
 *
 * We don't wait for the DocumentTabModel to finish parsing its metadata file before proceeding
 * with migration because it doesn't have actionable information:
 *
 * 1) WE DON'T NEED TO RE-POPULATE THE "RECENTLY CLOSED" LIST:
 *    The metadata file contains a list of tabs Chrome knew about before it died, which
 *    could differ from the list of tabs in Android Overview.  The canonical list of
 *    live tabs, however, has always been the ones displayed by the Android Overview.
 *
 * 2) RETARGETING MIGRATED TABS FROM THE HOME SCREEN IS A CORNER CASE:
 *    The only downside here is that Chrome ends up creating a new tab for a home screen
 *    shortcut the first time they start Chrome after migration.  This was already
 *    broken for document mode during cold starts, anyway.
 */
private final void startStage(int newStage) {
    ThreadUtils.assertOnUiThread();
    if (!mIsPipelineActive) return;

    if (newStage == STAGE_INITIALIZED) {
        Log.d(TAG, "Migrating user into tabbed mode.");
        int selectedTabId = DocumentUtils.getLastShownTabIdFromPrefs(getContext(), false);
        copyTabStateFiles(selectedTabId);
    } else if (newStage == STAGE_COPY_TAB_STATES_DONE) {
        Log.d(TAG, "Writing tabbed mode metadata file.");
        writeTabModelMetadata(mMigratedTabIds);
    } else if (newStage == STAGE_WRITE_TABMODEL_METADATA_DONE) {
        Log.d(TAG, "Changing user preference.");
        switchToTabbedMode();
    } else if (newStage == STAGE_CHANGE_SETTINGS_DONE) {
        Log.d(TAG, "Cleaning up document mode data.");
        deleteDocumentModeData();
    }
}
 
Example 2
Source File: DocumentTabModelImpl.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a DocumentTabModel.
 * @param activityDelegate Delegate to use for accessing the ActivityManager.
 * @param storageDelegate Delegate to use for accessing persistent storage.
 * @param tabCreatorManager Used to create Tabs.
 * @param isIncognito Whether or not the TabList is managing incognito tabs.
 * @param prioritizedTabId ID of the tab to prioritize when loading.
 * @param context Context to use for accessing SharedPreferences.
 */
public DocumentTabModelImpl(ActivityDelegate activityDelegate, StorageDelegate storageDelegate,
        TabCreatorManager tabCreatorManager, boolean isIncognito, int prioritizedTabId,
        Context context) {
    super(isIncognito);
    mActivityDelegate = activityDelegate;
    mStorageDelegate = storageDelegate;
    mContext = context;

    mCurrentState = STATE_UNINITIALIZED;
    mTabIdList = new ArrayList<Integer>();
    mEntryMap = new SparseArray<Entry>();
    mHistoricalTabs = new ArrayList<Integer>();

    mLastShownTabId = DocumentUtils.getLastShownTabIdFromPrefs(mContext, isIncognito());

    // Restore the tab list.
    setCurrentState(STATE_READ_RECENT_TASKS_START);
    mStorageDelegate.restoreTabEntries(
            isIncognito, activityDelegate, mEntryMap, mTabIdList, mHistoricalTabs);
    setCurrentState(STATE_READ_RECENT_TASKS_END);
}
 
Example 3
Source File: DocumentModeAssassin.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Kicks off tasks for the new state of the pipeline.
 *
 * We don't wait for the DocumentTabModel to finish parsing its metadata file before proceeding
 * with migration because it doesn't have actionable information:
 *
 * 1) WE DON'T NEED TO RE-POPULATE THE "RECENTLY CLOSED" LIST:
 *    The metadata file contains a list of tabs Chrome knew about before it died, which
 *    could differ from the list of tabs in Android Overview.  The canonical list of
 *    live tabs, however, has always been the ones displayed by the Android Overview.
 *
 * 2) RETARGETING MIGRATED TABS FROM THE HOME SCREEN IS A CORNER CASE:
 *    The only downside here is that Chrome ends up creating a new tab for a home screen
 *    shortcut the first time they start Chrome after migration.  This was already
 *    broken for document mode during cold starts, anyway.
 */
private final void startStage(int newStage) {
    ThreadUtils.assertOnUiThread();
    if (!mIsPipelineActive) return;

    if (newStage == STAGE_INITIALIZED) {
        Log.d(TAG, "Migrating user into tabbed mode.");
        int selectedTabId = DocumentUtils.getLastShownTabIdFromPrefs(getContext(), false);
        copyTabStateFiles(selectedTabId);
    } else if (newStage == STAGE_COPY_TAB_STATES_DONE) {
        Log.d(TAG, "Writing tabbed mode metadata file.");
        writeTabModelMetadata(mMigratedTabIds);
    } else if (newStage == STAGE_WRITE_TABMODEL_METADATA_DONE) {
        Log.d(TAG, "Changing user preference.");
        switchToTabbedMode();
    } else if (newStage == STAGE_CHANGE_SETTINGS_DONE) {
        Log.d(TAG, "Cleaning up document mode data.");
        deleteDocumentModeData();
    }
}
 
Example 4
Source File: DocumentTabModelImpl.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a DocumentTabModel.
 * @param activityDelegate Delegate to use for accessing the ActivityManager.
 * @param storageDelegate Delegate to use for accessing persistent storage.
 * @param tabCreatorManager Used to create Tabs.
 * @param isIncognito Whether or not the TabList is managing incognito tabs.
 * @param prioritizedTabId ID of the tab to prioritize when loading.
 * @param context Context to use for accessing SharedPreferences.
 */
public DocumentTabModelImpl(ActivityDelegate activityDelegate, StorageDelegate storageDelegate,
        TabCreatorManager tabCreatorManager, boolean isIncognito, int prioritizedTabId,
        Context context) {
    super(isIncognito, false);
    mActivityDelegate = activityDelegate;
    mStorageDelegate = storageDelegate;
    mContext = context;

    mCurrentState = STATE_UNINITIALIZED;
    mTabIdList = new ArrayList<Integer>();
    mEntryMap = new SparseArray<Entry>();
    mHistoricalTabs = new ArrayList<Integer>();

    mLastShownTabId = DocumentUtils.getLastShownTabIdFromPrefs(mContext, isIncognito());

    // Restore the tab list.
    setCurrentState(STATE_READ_RECENT_TASKS_START);
    mStorageDelegate.restoreTabEntries(
            isIncognito, activityDelegate, mEntryMap, mTabIdList, mHistoricalTabs);
    setCurrentState(STATE_READ_RECENT_TASKS_END);
}
 
Example 5
Source File: DocumentModeAssassin.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Kicks off tasks for the new state of the pipeline.
 *
 * We don't wait for the DocumentTabModel to finish parsing its metadata file before proceeding
 * with migration because it doesn't have actionable information:
 *
 * 1) WE DON'T NEED TO RE-POPULATE THE "RECENTLY CLOSED" LIST:
 *    The metadata file contains a list of tabs Chrome knew about before it died, which
 *    could differ from the list of tabs in Android Overview.  The canonical list of
 *    live tabs, however, has always been the ones displayed by the Android Overview.
 *
 * 2) RETARGETING MIGRATED TABS FROM THE HOME SCREEN IS A CORNER CASE:
 *    The only downside here is that Chrome ends up creating a new tab for a home screen
 *    shortcut the first time they start Chrome after migration.  This was already
 *    broken for document mode during cold starts, anyway.
 */
private final void startStage(int newStage) {
    ThreadUtils.assertOnUiThread();
    if (!mIsPipelineActive) return;

    if (newStage == STAGE_INITIALIZED) {
        Log.d(TAG, "Migrating user into tabbed mode.");
        int selectedTabId = DocumentUtils.getLastShownTabIdFromPrefs(getContext(), false);
        copyTabStateFiles(selectedTabId);
    } else if (newStage == STAGE_COPY_TAB_STATES_DONE) {
        Log.d(TAG, "Writing tabbed mode metadata file.");
        writeTabModelMetadata(mMigratedTabIds);
    } else if (newStage == STAGE_WRITE_TABMODEL_METADATA_DONE) {
        Log.d(TAG, "Changing user preference.");
        switchToTabbedMode();
    } else if (newStage == STAGE_CHANGE_SETTINGS_DONE) {
        Log.d(TAG, "Cleaning up document mode data.");
        deleteDocumentModeData();
    }
}
 
Example 6
Source File: DocumentTabModelImpl.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a DocumentTabModel.
 * @param activityDelegate Delegate to use for accessing the ActivityManager.
 * @param storageDelegate Delegate to use for accessing persistent storage.
 * @param tabCreatorManager Used to create Tabs.
 * @param isIncognito Whether or not the TabList is managing incognito tabs.
 * @param prioritizedTabId ID of the tab to prioritize when loading.
 * @param context Context to use for accessing SharedPreferences.
 */
public DocumentTabModelImpl(ActivityDelegate activityDelegate, StorageDelegate storageDelegate,
        TabCreatorManager tabCreatorManager, boolean isIncognito, int prioritizedTabId,
        Context context) {
    super(isIncognito, false);
    mActivityDelegate = activityDelegate;
    mStorageDelegate = storageDelegate;
    mContext = context;

    mCurrentState = STATE_UNINITIALIZED;
    mTabIdList = new ArrayList<Integer>();
    mEntryMap = new SparseArray<Entry>();
    mHistoricalTabs = new ArrayList<Integer>();

    mLastShownTabId = DocumentUtils.getLastShownTabIdFromPrefs(mContext, isIncognito());

    // Restore the tab list.
    setCurrentState(STATE_READ_RECENT_TASKS_START);
    mStorageDelegate.restoreTabEntries(
            isIncognito, activityDelegate, mEntryMap, mTabIdList, mHistoricalTabs);
    setCurrentState(STATE_READ_RECENT_TASKS_END);
}