// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.tasks.tab_management;
import android.app.Activity;
import android.content.Context;
import android.util.Pair;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.chromium.base.supplier.LazyOneshotSupplier;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplier;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.back_press.BackPressManager;
import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider;
import org.chromium.chrome.browser.data_sharing.DataSharingTabManager;
import org.chromium.chrome.browser.hub.HubManager;
import org.chromium.chrome.browser.hub.Pane;
import org.chromium.chrome.browser.incognito.reauth.IncognitoReauthController;
import org.chromium.chrome.browser.layouts.LayoutStateProvider;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher;
import org.chromium.chrome.browser.profiles.ProfileProvider;
import org.chromium.chrome.browser.tab_group_sync.TabGroupUiActionHandler;
import org.chromium.chrome.browser.tab_ui.TabContentManager;
import org.chromium.chrome.browser.tab_ui.TabSwitcher;
import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider;
import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.ui.messages.snackbar.SnackbarManager;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator;
import org.chromium.ui.modaldialog.ModalDialogManager;
import java.util.function.DoubleConsumer;
/** Interface to get access to components concerning tab management. */
public interface TabManagementDelegate {
/**
* Create the {@link TabGroupUi}.
*
* @param activity The {@link Activity} that creates this surface.
* @param parentView The parent view of this UI.
* @param browserControlsStateProvider The {@link BrowserControlsStateProvider} of the top
* controls.
* @param incognitoStateProvider Observable provider of incognito state.
* @param scrimCoordinator The {@link ScrimCoordinator} to control scrim view.
* @param omniboxFocusStateSupplier Supplier to access the focus state of the omnibox.
* @param bottomSheetController The {@link BottomSheetController} for the current activity.
* @param dataSharingTabManager The {@link} DataSharingTabManager managing communication between
* UI and DataSharing services.
* @param tabModelSelector Gives access to the current set of {@TabModel}.
* @param tabContentManager Gives access to the tab content.
* @param tabCreatorManager Manages creation of tabs.
* @param layoutStateProviderSupplier Supplies the {@link LayoutStateProvider}.
* @param modalDialogManager Used to show confirmation dialogs.
* @return The {@link TabGroupUi}.
*/
TabGroupUi createTabGroupUi(
@NonNull Activity activity,
@NonNull ViewGroup parentView,
@NonNull BrowserControlsStateProvider browserControlsStateProvider,
@NonNull IncognitoStateProvider incognitoStateProvider,
@NonNull ScrimCoordinator scrimCoordinator,
@NonNull ObservableSupplier<Boolean> omniboxFocusStateSupplier,
@NonNull BottomSheetController bottomSheetController,
@NonNull DataSharingTabManager dataSharingTabManager,
@NonNull TabModelSelector tabModelSelector,
@NonNull TabContentManager tabContentManager,
@NonNull TabCreatorManager tabCreatorManager,
@NonNull OneshotSupplier<LayoutStateProvider> layoutStateProviderSupplier,
@NonNull ModalDialogManager modalDialogManager);
/**
* Create a {@link TabSwitcher} and {@link Pane} for the Hub.
*
* @param activity The {@link Activity} that hosts the pane.
* @param lifecycleDispatcher The lifecycle dispatcher for the activity.
* @param profileProviderSupplier The supplier for profiles.
* @param tabModelSelector For access to {@link TabModel}.
* @param tabContentManager For management of thumbnails.
* @param tabCreatorManager For creating new tabs.
* @param browserControlsStateProvider For determining thumbnail size.
* @param multiWindowModeStateDispatcher For managing behavior in multi-window.
* @param rootUiScrimCoordinator The root UI coordinator's scrim coordinator. On LFF this is
* unused as the root UI's scrim coordinator is used for the show/hide animation.
* @param snackbarManager The activity level snackbar manager.
* @param modalDialogManager The modal dialog manager for the activity.
* @param bottomSheetController The {@link BottomSheetController} for the current activity.
* @param dataSharingTabManager The {@link} DataSharingTabManager managing communication between
* UI and DataSharing services.
* @param incognitoReauthControllerSupplier The incognito reauth controller supplier.
* @param newTabButtonOnClickListener The listener for clicking the new tab button.
* @param isIncognito Whether this is an incognito pane.
* @param onToolbarAlphaChange Observer to notify when alpha changes during animations.
* @param backPressManager Manages different back press handlers throughout the app.
*/
Pair<TabSwitcher, Pane> createTabSwitcherPane(
@NonNull Activity activity,
@NonNull ActivityLifecycleDispatcher lifecycleDispatcher,
@NonNull OneshotSupplier<ProfileProvider> profileProviderSupplier,
@NonNull TabModelSelector tabModelSelector,
@NonNull TabContentManager tabContentManager,
@NonNull TabCreatorManager tabCreatorManager,
@NonNull BrowserControlsStateProvider browserControlsStateProvider,
@NonNull MultiWindowModeStateDispatcher multiWindowModeStateDispatcher,
@NonNull ScrimCoordinator rootUiScrimCoordinator,
@NonNull SnackbarManager snackbarManager,
@NonNull ModalDialogManager modalDialogManager,
@NonNull BottomSheetController bottomSheetController,
@NonNull DataSharingTabManager dataSharingTabManager,
@Nullable OneshotSupplier<IncognitoReauthController> incognitoReauthControllerSupplier,
@NonNull OnClickListener newTabButtonOnClickListener,
boolean isIncognito,
@NonNull DoubleConsumer onToolbarAlphaChange,
@NonNull BackPressManager backPressManager);
/**
* Create a {@link TabGroupsPane} for the Hub.
*
* @param context Used to inflate UI.
* @param tabModelSelector Used to pull tab data from.
* @param onToolbarAlphaChange Observer to notify when alpha changes during animations.
* @param profileProviderSupplier The supplier for profiles.
* @param hubManagerSupplier Supplier ultimately used to get the pane manager to switch panes.
* @param tabGroupUiActionHandlerSupplier Supplier for the controller used to open hidden
* groups.
* @param modalDialogManagerSupplier Used to show confirmation dialogs.
* @return The pane implementation that displays and allows interactions with tab groups.
*/
Pane createTabGroupsPane(
@NonNull Context context,
@NonNull TabModelSelector tabModelSelector,
@NonNull DoubleConsumer onToolbarAlphaChange,
@NonNull OneshotSupplier<ProfileProvider> profileProviderSupplier,
@NonNull LazyOneshotSupplier<HubManager> hubManagerSupplier,
@NonNull Supplier<TabGroupUiActionHandler> tabGroupUiActionHandlerSupplier,
@NonNull Supplier<ModalDialogManager> modalDialogManagerSupplier);
}