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

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

Issue 1027463003: [Android] Add an API to restore a tab with a given ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | no next file » | 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 f7e4408ca003b74eb4a81b741f86025705e4c64c..0e821b961949847f1136c565c972d7803e49613b 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
@@ -303,22 +303,51 @@ public class TabPersistentStore extends TabPersister {
loadNextTab();
}
+ /** TODO(tedchoc): Remove this after migrating all callers to restoreTabStateForUrl. */
+ public boolean restoreTabState(String url) {
+ return restoreTabStateForUrl(url);
+ }
+
/**
* If a tab is being restored with the given url, then restore the tab
* in a frozen state synchronously.
*
* @return Whether the tab was restored.
*/
- public boolean restoreTabState(String url) {
+ public boolean restoreTabStateForUrl(String url) {
+ return restoreTabStateInternal(url, Tab.INVALID_TAB_ID);
+ }
+
+ /**
+ * If a tab is being restored with the given id, then restore the tab
+ * in a frozen state synchronously.
+ *
+ * @return Whether the tab was restored.
+ */
+ public boolean restoreTabStateForId(int id) {
+ return restoreTabStateInternal(null, id);
+ }
+
+ private boolean restoreTabStateInternal(String url, int id) {
TabRestoreDetails tabToRestore = null;
- if (mLoadTabTask != null && TextUtils.equals(mLoadTabTask.mTabToRestore.url, url)) {
- // Steal the task of restoring the tab from the active load tab task.
- mLoadTabTask.cancel(false);
- tabToRestore = mLoadTabTask.mTabToRestore;
- loadNextTab(); // Queue up async task to load next tab after we're done here.
- } else {
- tabToRestore = getTabToRestoreByUrl(url);
+ if (mLoadTabTask != null) {
+ if ((url == null && mLoadTabTask.mTabToRestore.id == id)
+ || (url != null && TextUtils.equals(mLoadTabTask.mTabToRestore.url, url))) {
+ // Steal the task of restoring the tab from the active load tab task.
+ mLoadTabTask.cancel(false);
+ tabToRestore = mLoadTabTask.mTabToRestore;
+ loadNextTab(); // Queue up async task to load next tab after we're done here.
+ }
}
+
+ if (tabToRestore == null) {
+ if (url == null) {
+ tabToRestore = getTabToRestoreById(id);
+ } else {
+ tabToRestore = getTabToRestoreByUrl(url);
+ }
+ }
+
if (tabToRestore != null) {
mTabsToRestore.remove(tabToRestore);
return restoreTab(tabToRestore, false);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698