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

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

Issue 2448433003: Finish ChromeTabbedActivity if its tabs have been merged into another instance (Closed)
Patch Set: Fix typo Created 4 years, 2 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/ChromeTabbedActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
index b1bafafddc97e1a2999df62c3d5430a6dbe55f7a..d5d44d9eb75f0560262dac7dff366eee2343f297 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -186,6 +186,9 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
private static final String ACTION_CLOSE_TABS =
"com.google.android.apps.chrome.ACTION_CLOSE_TABS";
+ /** The task id of the activity that tabs were merged into. */
+ private static int sMergedInstanceTaskId;
+
private final ActivityStopMetrics mActivityStopMetrics = new ActivityStopMetrics();
private FindToolbarManager mFindToolbarManager;
@@ -1093,6 +1096,25 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
@Override
+ protected boolean isStartedUpCorrectly(Intent intent) {
+ // If tabs from this instance were merged into a different ChromeTabbedActivity instance
+ // then this instance should not be created. This may happen if the process is restarted
+ // e.g. on upgrade or from about://flags. See crbug.com/657418
+ boolean tabsMergedIntoAnotherInstance =
+ sMergedInstanceTaskId != 0 && sMergedInstanceTaskId != getTaskId();
+ if (tabsMergedIntoAnotherInstance) {
+ // Currently only two instances of ChromeTabbedActivity may be running at any given
+ // time. If tabs were merged into another instance and this instance is being killed due
+ // to incorrect startup, then no other instances should exist. Reset the merged instance
+ // task id.
+ setMergedInstanceTaskId(0);
+ return false;
+ }
+
+ return super.isStartedUpCorrectly(intent);
+ }
+
+ @Override
public void terminateIncognitoSession() {
getTabModelSelector().getModel(true).closeAllTabs();
}
@@ -1197,6 +1219,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
MultiWindowUtils.getInstance().getOpenInOtherWindowActivity(this);
if (targetActivity == null) return;
+ // When a second instance is created, the merged instance task id should be cleared.
+ setMergedInstanceTaskId(0);
Intent intent = new Intent(this, targetActivity);
MultiWindowUtils.setOpenInOtherWindowIntentExtras(intent, this, targetActivity);
@@ -1616,6 +1640,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
// 4. Ask TabPersistentStore to merge state.
RecordUserAction.record("Android.MergeState.Live");
mTabModelSelectorImpl.mergeState();
+
+ setMergedInstanceTaskId(getTaskId());
}
/**
@@ -1662,4 +1688,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
(ToolbarControlContainer) findViewById(R.id.control_container),
getTabModelSelector(), getControlContainerHeightResource(), true);
}
+
+ private static void setMergedInstanceTaskId(int mergedInstanceTaskId) {
+ sMergedInstanceTaskId = mergedInstanceTaskId;
+ }
}
« 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