Commit fcee7f4d authored by Matt Jones's avatar Matt Jones Committed by Commit Bot

Remove obsolete concepts from BottomSheetController

This patch removes two concepts from the BottomSheetController:
- Full show request: This was relevant when a function to preload
  content existed. Since that function was removed long ago, the map
  tracking these requests is no longer useful. Content that needs to
  pre-load can be done on a per-feature basis outside of BottomSheet
  code.
- Shown for tab: This concept prevented a sheet content from auto-
  peeking multiple times for a single web page. No features currently
  use this concept and, if needed, could be implemented on a per-
  feature basis.

Bug: 986310
Change-Id: I7b965cab4434cded6e729290af5413affc110edb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745398
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686605}
parent 2cd0f18a
...@@ -27,10 +27,8 @@ import org.chromium.chrome.browser.widget.ScrimView.ScrimParams; ...@@ -27,10 +27,8 @@ import org.chromium.chrome.browser.widget.ScrimView.ScrimParams;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetContent; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetContent;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.StateChangeReason; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.StateChangeReason;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.PriorityQueue; import java.util.PriorityQueue;
import java.util.Set;
/** /**
* This class is responsible for managing the content shown by the {@link BottomSheet}. Features * This class is responsible for managing the content shown by the {@link BottomSheet}. Features
...@@ -57,15 +55,9 @@ public class BottomSheetController implements Destroyable { ...@@ -57,15 +55,9 @@ public class BottomSheetController implements Destroyable {
/** A queue for content that is waiting to be shown in the {@link BottomSheet}. */ /** A queue for content that is waiting to be shown in the {@link BottomSheet}. */
private PriorityQueue<BottomSheetContent> mContentQueue; private PriorityQueue<BottomSheetContent> mContentQueue;
/** A set of contents that have requested to be shown, rather than just preloading. */
private Set<BottomSheetContent> mFullShowRequestedSet;
/** Whether the controller is already processing a hide request for the tab. */ /** Whether the controller is already processing a hide request for the tab. */
private boolean mIsProcessingHideRequest; private boolean mIsProcessingHideRequest;
/** Track whether the sheet was shown for the current tab. */
private boolean mWasShownForCurrentTab;
/** Whether the bottom sheet is temporarily suppressed. */ /** Whether the bottom sheet is temporarily suppressed. */
private boolean mIsSuppressed; private boolean mIsSuppressed;
...@@ -103,7 +95,6 @@ public class BottomSheetController implements Destroyable { ...@@ -103,7 +95,6 @@ public class BottomSheetController implements Destroyable {
mSuppressSheetForContextualSearch = suppressSheetForContextualSearch; mSuppressSheetForContextualSearch = suppressSheetForContextualSearch;
mSnackbarManager = new SnackbarManager( mSnackbarManager = new SnackbarManager(
activity, mBottomSheet.findViewById(R.id.bottom_sheet_snackbar_container)); activity, mBottomSheet.findViewById(R.id.bottom_sheet_snackbar_container));
mFullShowRequestedSet = new HashSet<>();
// Initialize the queue with a comparator that checks content priority. // Initialize the queue with a comparator that checks content priority.
mContentQueue = new PriorityQueue<>(INITIAL_QUEUE_CAPACITY, mContentQueue = new PriorityQueue<>(INITIAL_QUEUE_CAPACITY,
...@@ -262,8 +253,8 @@ public class BottomSheetController implements Destroyable { ...@@ -262,8 +253,8 @@ public class BottomSheetController implements Destroyable {
* the browser (i.e. the tab switcher may be showing). * the browser (i.e. the tab switcher may be showing).
*/ */
private void unsuppressSheet() { private void unsuppressSheet() {
if (!mIsSuppressed || mTabProvider.get() == null || !mWasShownForCurrentTab if (!mIsSuppressed || mTabProvider.get() == null || isOtherUIObscuring()
|| isOtherUIObscuring() || VrModuleProvider.getDelegate().isInVr()) { || VrModuleProvider.getDelegate().isInVr()) {
return; return;
} }
mIsSuppressed = false; mIsSuppressed = false;
...@@ -299,13 +290,11 @@ public class BottomSheetController implements Destroyable { ...@@ -299,13 +290,11 @@ public class BottomSheetController implements Destroyable {
* state, or the browser is in a mode that does not support showing the sheet. * state, or the browser is in a mode that does not support showing the sheet.
*/ */
public boolean requestShowContent(BottomSheetContent content, boolean animate) { public boolean requestShowContent(BottomSheetContent content, boolean animate) {
// If pre-load failed, do nothing. The content will automatically be queued. // If load failed, do nothing. The content will automatically be queued.
mFullShowRequestedSet.add(content);
if (!loadInternal(content)) return false; if (!loadInternal(content)) return false;
if (!mBottomSheet.isSheetOpen() && !isOtherUIObscuring()) { if (!mBottomSheet.isSheetOpen() && !isOtherUIObscuring()) {
mBottomSheet.setSheetState(BottomSheet.SheetState.PEEK, animate); mBottomSheet.setSheetState(BottomSheet.SheetState.PEEK, animate);
} }
mWasShownForCurrentTab = true;
return true; return true;
} }
...@@ -345,8 +334,6 @@ public class BottomSheetController implements Destroyable { ...@@ -345,8 +334,6 @@ public class BottomSheetController implements Destroyable {
* @param animate Whether the sheet should animate when hiding. * @param animate Whether the sheet should animate when hiding.
*/ */
public void hideContent(BottomSheetContent content, boolean animate) { public void hideContent(BottomSheetContent content, boolean animate) {
mFullShowRequestedSet.remove(content);
if (content != mBottomSheet.getCurrentSheetContent()) { if (content != mBottomSheet.getCurrentSheetContent()) {
mContentQueue.remove(content); mContentQueue.remove(content);
return; return;
...@@ -405,9 +392,7 @@ public class BottomSheetController implements Destroyable { ...@@ -405,9 +392,7 @@ public class BottomSheetController implements Destroyable {
BottomSheetContent nextContent = mContentQueue.poll(); BottomSheetContent nextContent = mContentQueue.poll();
mBottomSheet.showContent(nextContent); mBottomSheet.showContent(nextContent);
if (mFullShowRequestedSet.contains(nextContent)) { mBottomSheet.setSheetState(BottomSheet.SheetState.PEEK, true);
mBottomSheet.setSheetState(BottomSheet.SheetState.PEEK, true);
}
} }
/** /**
...@@ -416,14 +401,10 @@ public class BottomSheetController implements Destroyable { ...@@ -416,14 +401,10 @@ public class BottomSheetController implements Destroyable {
*/ */
private void clearRequestsAndHide() { private void clearRequestsAndHide() {
clearRequests(mContentQueue.iterator()); clearRequests(mContentQueue.iterator());
clearRequests(mFullShowRequestedSet.iterator());
BottomSheetContent currentContent = mBottomSheet.getCurrentSheetContent(); BottomSheetContent currentContent = mBottomSheet.getCurrentSheetContent();
if (currentContent != null && !currentContent.hasCustomLifecycle()) { if (currentContent != null && !currentContent.hasCustomLifecycle()) {
if (mContentQueue.isEmpty() && mFullShowRequestedSet.isEmpty()) { if (mContentQueue.isEmpty()) mIsSuppressed = false;
mWasShownForCurrentTab = false;
mIsSuppressed = false;
}
hideContent(currentContent, /* animate= */ true); hideContent(currentContent, /* animate= */ true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment