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

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

Issue 2899053004: [Home] Ensure incognito tab model is created when NTP opened (Closed)
Patch Set: [Home] Ensure incognito tab model is created when NTP opened Created 3 years, 7 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
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/IncognitoTabModel.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/IncognitoTabModel.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/IncognitoTabModel.java
index 6ce844fcf5c4c4c90433cf73e2a93ab3895ca534..69aaf771647db25db5a2d5440193c99360b596bc 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/IncognitoTabModel.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/IncognitoTabModel.java
@@ -36,6 +36,7 @@ public class IncognitoTabModel implements TabModel {
private final ObserverList<TabModelObserver> mObservers = new ObserverList<TabModelObserver>();
private TabModel mDelegateModel;
private boolean mIsAddingTab;
+ private boolean mIsPendingTabAdd;
/**
* Constructor for IncognitoTabModel.
@@ -72,7 +73,8 @@ public class IncognitoTabModel implements TabModel {
*/
protected void destroyIncognitoIfNecessary() {
ThreadUtils.assertOnUiThread();
- if (!isEmpty() || mDelegateModel instanceof EmptyTabModel || mIsAddingTab) {
+ if (!isEmpty() || mDelegateModel instanceof EmptyTabModel || mIsAddingTab
+ || mIsPendingTabAdd) {
return;
}
@@ -81,7 +83,8 @@ public class IncognitoTabModel implements TabModel {
// Only delete the incognito profile if there are no incognito tabs open in any tab
// model selector as the profile is shared between them.
- if (profile != null && !mDelegate.doIncognitoTabsExist()) {
+ if (profile != null && !mDelegate.doIncognitoTabsExist()
+ && TabWindowManager.getInstance().canDestroyIncognitoProfile()) {
Ted C 2017/05/24 17:56:08 I think this should go into the delegate doIncogni
Theresa 2017/05/24 18:35:46 Done.
IncognitoNotificationManager.dismissIncognitoNotification();
profile.destroyWhenAppropriate();
@@ -212,6 +215,7 @@ public class IncognitoTabModel implements TabModel {
@Override
public void addTab(Tab tab, int index, TabLaunchType type) {
mIsAddingTab = true;
+ mIsPendingTabAdd = false;
ensureTabModelImpl();
mDelegateModel.addTab(tab, index, type);
mIsAddingTab = false;
@@ -241,4 +245,18 @@ public class IncognitoTabModel implements TabModel {
public void openMostRecentlyClosedTab() {
}
+ @Override
+ public void setIsPendingTabAdd(boolean isPendingTabAdd) {
+ mIsPendingTabAdd = isPendingTabAdd;
+ if (mIsPendingTabAdd) {
+ ensureTabModelImpl();
+ } else {
+ destroyIncognitoIfNecessary();
+ }
+ }
+
+ @Override
+ public boolean isPendingTabAdd() {
+ return mIsPendingTabAdd;
Theresa 2017/05/24 16:52:08 Ted, should this also return true if mIsAddingTab
Ted C 2017/05/24 17:56:08 I don't think we need to. The mIsAddingTab is don
Theresa 2017/05/24 18:35:46 Excellent, thanks!
+ }
}

Powered by Google App Engine
This is Rietveld 408576698