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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetNewTabController.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/widget/bottomsheet/BottomSheetNewTabController.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetNewTabController.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetNewTabController.java
index 9b825225398c5c20b90e552bb033ccd4c8500b8e..4af6d38469ec6fa3144830312e05040a23c6fbf5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetNewTabController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetNewTabController.java
@@ -22,7 +22,7 @@ public class BottomSheetNewTabController extends EmptyBottomSheetObserver {
private LayoutManagerChrome mLayoutManager;
private TabModelSelector mTabModelSelector;
- private boolean mIsShowingNewTab;
+ private boolean mIsShowingNewTabUi;
/**
* Creates a new {@link BottomSheetNewTabController}.
@@ -56,7 +56,10 @@ public class BottomSheetNewTabController extends EmptyBottomSheetObserver {
* @param isIncognito Whether to display the incognito new tab UI.
*/
public void displayNewTabUi(boolean isIncognito) {
- mIsShowingNewTab = true;
+ mIsShowingNewTabUi = true;
+
+ // Tell the model that a new tab may be added soon.
+ mTabModelSelector.getModel(isIncognito).setIsPendingTabAdd(true);
// Select the correct model, immediately ending animations so that the sheet content is not
// in transition while the sheet is opening.
@@ -82,31 +85,24 @@ public class BottomSheetNewTabController extends EmptyBottomSheetObserver {
}
/**
- * Called when the activity containing the {@link BottomSheet} processes a url view intent.
- * The new tab UI will be hidden.
+ * @return Whether the the new tab UI is showing.
*/
- public void onProcessUrlViewIntent() {
- if (!mIsShowingNewTab) return;
-
- mIsShowingNewTab = false;
- mLayoutManager.hideOverview(true);
+ public boolean isShowingNewTabUi() {
+ return mIsShowingNewTabUi;
}
@Override
public void onLoadUrl(String url) {
- onProcessUrlViewIntent();
- }
+ if (!mIsShowingNewTabUi) return;
- /**
- * @return Whether the the new tab UI is showing.
- */
- public boolean isShowingNewTab() {
- return mIsShowingNewTab;
+ mIsShowingNewTabUi = false;
+ mLayoutManager.hideOverview(true);
+ onNewTabUiHidden();
}
@Override
public void onSheetOpened() {
- if (!mIsShowingNewTab) return;
+ if (!mIsShowingNewTabUi) return;
// Transition from the tab switcher toolbar to the normal toolbar.
mToolbar.showNormalToolbar();
@@ -118,7 +114,7 @@ public class BottomSheetNewTabController extends EmptyBottomSheetObserver {
@Override
public void onSheetReleased() {
- if (!mIsShowingNewTab) return;
+ if (!mIsShowingNewTabUi) return;
// Start transitioning back to the tab switcher toolbar when the sheet is released to help
// smooth out animations.
@@ -129,9 +125,9 @@ public class BottomSheetNewTabController extends EmptyBottomSheetObserver {
@Override
public void onSheetClosed() {
- if (!mIsShowingNewTab) return;
+ if (!mIsShowingNewTabUi) return;
- mIsShowingNewTab = false;
+ mIsShowingNewTabUi = false;
// If the incognito tab model is showing, but has no tabs, this indicates that the model
// was switched during the creation of an incognito ntp and the user closed the sheet
@@ -143,5 +139,13 @@ public class BottomSheetNewTabController extends EmptyBottomSheetObserver {
// Transition back to the tab switcher toolbar if the tab switcher is sill visible.
if (mLayoutManager.overviewVisible()) mToolbar.showTabSwitcherToolbar();
+
+ onNewTabUiHidden();
+ }
+
+ /** Called after the new tab UI is hidden. Resets properties on the tab models. */
+ private void onNewTabUiHidden() {
+ mTabModelSelector.getModel(false).setIsPendingTabAdd(false);
+ mTabModelSelector.getModel(true).setIsPendingTabAdd(false);
}
}

Powered by Google App Engine
This is Rietveld 408576698