Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(647)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java

Issue 2766493002: Revert of [Android] Do not restore NTPs from disk unless they are selected. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
index c8e9287a2810e7fbeee7a4b31a95ab7dba9c15c4..ceebac54bd3b1568a71acb26f1aa60276922cb88 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistentStore.java
@@ -27,7 +27,6 @@
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.browser.TabState;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
-import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabIdManager;
import org.chromium.content_public.browser.LoadUrlParams;
@@ -277,11 +276,19 @@
// Add current tabs to save because they did not get a save signal yet.
Tab currentStandardTab = TabModelUtils.getCurrentTab(mTabModelSelector.getModel(false));
- addTabToSaveQueueIfApplicable(currentStandardTab);
-
+ if (currentStandardTab != null && !mTabsToSave.contains(currentStandardTab)
+ && currentStandardTab.isTabStateDirty()
+ // For content URI, the read permission granted to an activity is not
+ // persistent.
+ && !isTabUrlContentScheme(currentStandardTab)) {
+ mTabsToSave.addLast(currentStandardTab);
+ }
Tab currentIncognitoTab = TabModelUtils.getCurrentTab(mTabModelSelector.getModel(true));
- addTabToSaveQueueIfApplicable(currentIncognitoTab);
-
+ if (currentIncognitoTab != null && !mTabsToSave.contains(currentIncognitoTab)
+ && currentIncognitoTab.isTabStateDirty()
+ && !isTabUrlContentScheme(currentIncognitoTab)) {
+ mTabsToSave.addLast(currentIncognitoTab);
+ }
// Wait for the current tab to save.
if (mSaveTabTask != null) {
// Cancel calls get() to wait for this to finish internally if it has to.
@@ -290,7 +297,11 @@
if (mSaveTabTask.cancel(false) && !mSaveTabTask.mStateSaved) {
// The task was successfully cancelled. We should try to save this state again.
Tab cancelledTab = mSaveTabTask.mTab;
- addTabToSaveQueueIfApplicable(cancelledTab);
+ if (!mTabsToSave.contains(cancelledTab)
+ && cancelledTab.isTabStateDirty()
+ && !isTabUrlContentScheme(cancelledTab)) {
+ mTabsToSave.addLast(cancelledTab);
+ }
}
mSaveTabTask = null;
@@ -319,14 +330,6 @@
}
}
- @VisibleForTesting
- void initializeRestoreVars(boolean ignoreIncognitoFiles) {
- mCancelNormalTabLoads = false;
- mCancelIncognitoTabLoads = ignoreIncognitoFiles;
- mNormalTabsRestored = new SparseIntArray();
- mIncognitoTabsRestored = new SparseIntArray();
- }
-
/**
* Restore saved state. Must be called before any tabs are added to the list.
*
@@ -345,8 +348,10 @@
waitForMigrationToFinish();
logExecutionTime("LoadStateTime", time);
- initializeRestoreVars(ignoreIncognitoFiles);
-
+ mCancelNormalTabLoads = false;
+ mCancelIncognitoTabLoads = ignoreIncognitoFiles;
+ mNormalTabsRestored = new SparseIntArray();
+ mIncognitoTabsRestored = new SparseIntArray();
try {
long timeLoadingState = SystemClock.uptimeMillis();
assert mTabModelSelector.getModel(true).getCount() == 0;
@@ -416,7 +421,10 @@
}
// Initialize variables.
- initializeRestoreVars(false);
+ mCancelNormalTabLoads = false;
+ mCancelIncognitoTabLoads = false;
+ mNormalTabsRestored = new SparseIntArray();
+ mIncognitoTabsRestored = new SparseIntArray();
try {
long time = SystemClock.uptimeMillis();
@@ -546,16 +554,7 @@
}
}
- /**
- * Handles restoring an individual tab.
- *
- * @param tabToRestore Meta data about the tab to be restored.
- * @param tabState The previously serialized state of the tab to be restored.
- * @param setAsActive Whether the tab should be set as the active tab as part of the
- * restoration process.
- */
- @VisibleForTesting
- protected void restoreTab(
+ private void restoreTab(
TabRestoreDetails tabToRestore, TabState tabState, boolean setAsActive) {
// If we don't have enough information about the Tab, bail out.
boolean isIncognito = isIncognitoTabBeingRestored(tabToRestore, tabState);
@@ -595,11 +594,6 @@
mTabCreatorManager.getTabCreator(isIncognito).createFrozenTab(
tabState, tabToRestore.id, restoredIndex);
} else {
- if (NewTabPage.isNTPUrl(tabToRestore.url) && !setAsActive) {
- Log.i(TAG, "Skipping restore of non-selected NTP.");
- return;
- }
-
Log.w(TAG, "Failed to restore TabState; creating Tab with last known URL.");
Tab fallbackTab = mTabCreatorManager.getTabCreator(isIncognito).createNewTab(
new LoadUrlParams(tabToRestore.url), TabModel.TabLaunchType.FROM_RESTORE, null);
@@ -690,28 +684,10 @@
}
public void addTabToSaveQueue(Tab tab) {
- addTabToSaveQueueIfApplicable(tab);
+ if (!mTabsToSave.contains(tab) && tab.isTabStateDirty() && !isTabUrlContentScheme(tab)) {
+ mTabsToSave.addLast(tab);
+ }
saveNextTab();
- }
-
- /**
- * @return Whether the specified tab is in any pending save operations.
- */
- @VisibleForTesting
- boolean isTabPendingSave(Tab tab) {
- return (mSaveTabTask != null && mSaveTabTask.mTab.equals(tab)) || mTabsToSave.contains(tab);
- }
-
- private void addTabToSaveQueueIfApplicable(Tab tab) {
- if (tab == null) return;
- if (mTabsToSave.contains(tab) || !tab.isTabStateDirty() || isTabUrlContentScheme(tab)) {
- return;
- }
-
- if (NewTabPage.isNTPUrl(tab.getUrl()) && !tab.canGoBack() && !tab.canGoForward()) {
- return;
- }
- mTabsToSave.addLast(tab);
}
public void removeTabFromQueues(Tab tab) {
@@ -1068,12 +1044,7 @@
return nextId;
}
- /**
- * Triggers the next save tab task. Clients do not need to call this as it will be triggered
- * automatically by calling {@link #addTabToSaveQueue(Tab)}.
- */
- @VisibleForTesting
- void saveNextTab() {
+ private void saveNextTab() {
if (mSaveTabTask != null) return;
if (!mTabsToSave.isEmpty()) {
Tab tab = mTabsToSave.removeFirst();
@@ -1282,11 +1253,7 @@
}
}
- /**
- * Provides additional meta data to restore an individual tab.
- */
- @VisibleForTesting
- protected static final class TabRestoreDetails {
+ private static final class TabRestoreDetails {
public final int id;
public final int originalIndex;
public final String url;
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698