Chromium Code Reviews| 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!
|
| + } |
| } |