org.chromium.chrome.browser.tabmodel.document.DocumentTabModelInfo.DocumentList Java Examples

The following examples show how to use org.chromium.chrome.browser.tabmodel.document.DocumentTabModelInfo.DocumentList. 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: StorageDelegate.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Update tab entries based on metadata.
 * @param metadataBytes Metadata from last time Chrome was alive.
 * @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
 * @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
 */
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
        List<Integer> recentlyClosedTabIdList) {
    if (metadataBytes != null) {
        DocumentList list = null;
        try {
            list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
        } catch (IOException e) {
            Log.e(TAG, "I/O exception", e);
        }
        if (list == null) return;

        for (int i = 0; i < list.entries.length; i++) {
            DocumentEntry savedEntry = list.entries[i];
            int tabId = savedEntry.tabId;

            // If the tab ID isn't in the list, it must have been closed after Chrome died.
            if (entryMap.indexOfKey(tabId) < 0) {
                recentlyClosedTabIdList.add(tabId);
                continue;
            }

            // Restore information about the Tab.
            entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
        }
    }
}
 
Example #2
Source File: StorageDelegate.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Update tab entries based on metadata.
 * @param metadataBytes Metadata from last time Chrome was alive.
 * @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
 * @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
 */
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
        List<Integer> recentlyClosedTabIdList) {
    if (metadataBytes != null) {
        DocumentList list = null;
        try {
            list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
        } catch (IOException e) {
            Log.e(TAG, "I/O exception", e);
        }
        if (list == null) return;

        for (int i = 0; i < list.entries.length; i++) {
            DocumentEntry savedEntry = list.entries[i];
            int tabId = savedEntry.tabId;

            // If the tab ID isn't in the list, it must have been closed after Chrome died.
            if (entryMap.indexOfKey(tabId) < 0) {
                recentlyClosedTabIdList.add(tabId);
                continue;
            }

            // Restore information about the Tab.
            entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
        }
    }
}
 
Example #3
Source File: StorageDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Update tab entries based on metadata.
 * @param metadataBytes Metadata from last time Chrome was alive.
 * @param entryMap Map to fill with {@link DocumentTabModel.Entry}s about Tabs.
 * @param recentlyClosedTabIdList List to fill with IDs of recently closed tabs.
 */
private void updateTabEntriesFromMetadata(byte[] metadataBytes, SparseArray<Entry> entryMap,
        List<Integer> recentlyClosedTabIdList) {
    if (metadataBytes != null) {
        DocumentList list = null;
        try {
            list = MessageNano.mergeFrom(new DocumentList(), metadataBytes);
        } catch (IOException e) {
            Log.e(TAG, "I/O exception", e);
        }
        if (list == null) return;

        for (int i = 0; i < list.entries.length; i++) {
            DocumentEntry savedEntry = list.entries[i];
            int tabId = savedEntry.tabId;

            // If the tab ID isn't in the list, it must have been closed after Chrome died.
            if (entryMap.indexOfKey(tabId) < 0) {
                recentlyClosedTabIdList.add(tabId);
                continue;
            }

            // Restore information about the Tab.
            entryMap.get(tabId).canGoBack = savedEntry.canGoBack;
        }
    }
}