Commit 312e5135 authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

Refactor the OverviewModeObserver interface

This CL mainly focus on moving the onOverviewModeStateChanged() signal
out of the OverviewModeObserver interface. That signal only matters when
StartSurface is enabled, so the signal is merged to
StartSurface.StateObserver.onStateChanged.

With the above change, this CL allows features to attach the
StartSurface.StateObserver to StartSurface via the ObservableSupplier
pattern.

In addition, this CL renames OverviewModeState to StartSurfaceState.

Change-Id: Iebaa907fca4baf6a1fee819b31fbd57370126dbc
Bug: 1108496
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315823
Commit-Queue: Mei Liang <meiliang@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814994}
parent 148bc98c
......@@ -291,7 +291,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/compositor/layouts/LayoutUpdateHost.java",
"java/src/org/chromium/chrome/browser/compositor/layouts/OverviewModeBehavior.java",
"java/src/org/chromium/chrome/browser/compositor/layouts/OverviewModeController.java",
"java/src/org/chromium/chrome/browser/compositor/layouts/OverviewModeState.java",
"java/src/org/chromium/chrome/browser/compositor/layouts/SceneChangeObserver.java",
"java/src/org/chromium/chrome/browser/compositor/layouts/StaticLayout.java",
"java/src/org/chromium/chrome/browser/compositor/layouts/ToolbarSwipeLayout.java",
......
......@@ -9,6 +9,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.supplier.OneshotSupplierImpl;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.profiles.Profile;
......@@ -90,7 +91,8 @@ public class StartSurfaceCoordinator implements StartSurface {
// TODO(http://crbug.com/1093421): Remove dependency on ChromeActivity.
public StartSurfaceCoordinator(ChromeActivity activity, ScrimCoordinator scrimCoordinator,
BottomSheetController sheetController) {
BottomSheetController sheetController,
OneshotSupplierImpl<StartSurface> startSurfaceOneshotSupplier) {
mActivity = activity;
mScrimCoordinator = scrimCoordinator;
mSurfaceMode = computeSurfaceMode();
......@@ -118,7 +120,8 @@ public class StartSurfaceCoordinator implements StartSurface {
mSurfaceMode, mActivity.getNightModeStateProvider(),
mActivity.getBrowserControlsManager(), this::isActivityFinishingOrDestroyed,
excludeMVTiles,
StartSurfaceConfiguration.START_SURFACE_SHOW_STACK_TAB_SWITCHER.getValue());
StartSurfaceConfiguration.START_SURFACE_SHOW_STACK_TAB_SWITCHER.getValue(),
startSurfaceOneshotSupplier);
// Show feed loading image.
if (mStartSurfaceMediator.shouldShowFeedPlaceholder()) {
......@@ -126,6 +129,7 @@ public class StartSurfaceCoordinator implements StartSurface {
mActivity, mTasksSurface.getBodyViewContainer(), false);
mFeedLoadingCoordinator.setUpLoadingView();
}
startSurfaceOneshotSupplier.set(this);
}
boolean isShowingTabSwitcher() {
......@@ -150,8 +154,13 @@ public class StartSurfaceCoordinator implements StartSurface {
}
@Override
public void setStateChangeObserver(StartSurface.StateObserver observer) {
mStartSurfaceMediator.setStateChangeObserver(observer);
public void addStateChangeObserver(StateObserver observer) {
mStartSurfaceMediator.addStateChangeObserver(observer);
}
@Override
public void removeStateChangeObserver(StateObserver observer) {
mStartSurfaceMediator.removeStateChangeObserver(observer);
}
@Override
......
......@@ -7,6 +7,7 @@ package org.chromium.chrome.features.start_surface;
import android.content.Context;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplierImpl;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider;
import org.chromium.chrome.browser.compositor.layouts.Layout;
......@@ -28,7 +29,9 @@ public class StartSurfaceDelegate {
}
public static StartSurface createStartSurface(ChromeActivity activity,
ScrimCoordinator scrimCoordinator, BottomSheetController sheetController) {
return new StartSurfaceCoordinator(activity, scrimCoordinator, sheetController);
ScrimCoordinator scrimCoordinator, BottomSheetController sheetController,
OneshotSupplierImpl<StartSurface> startSurfaceOneshotSupplier) {
return new StartSurfaceCoordinator(
activity, scrimCoordinator, sheetController, startSurfaceOneshotSupplier);
}
}
\ No newline at end of file
......@@ -60,7 +60,6 @@ import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone;
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.compositor.layouts.StaticLayout;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.device.DeviceClassManager;
......@@ -358,7 +357,7 @@ public class InstantStartTest {
TestThreadUtils.runOnUiThreadBlocking(() -> {
startSurfaceCoordinator.getController().setOverviewState(
OverviewModeState.SHOWN_TABSWITCHER);
StartSurfaceState.SHOWN_TABSWITCHER);
});
CriteriaHelper.pollUiThread(startSurfaceCoordinator::isSecondaryTaskInitPendingForTesting);
......
......@@ -7,7 +7,6 @@ package org.chromium.chrome.features.start_surface;
import android.os.SystemClock;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
/** Interface to communicate with the start surface. */
......@@ -23,23 +22,29 @@ public interface StartSurface {
/**
* An observer that is notified when the start surface internal state, excluding
* the states notified in {@link OverviewModeObserver}, is changed.
*
* TODO(crbug.com/1115757): After crrev.com/c/2315823, Overview state and Startsurface state are
* two different things, let's audit the usage of this observer.
*/
interface StateObserver {
/**
* Called when the internal state is changed.
* @param overviewModeState the {@link OverviewModeState}.
* @param overviewModeState the {@link StartSurfaceState}.
* @param shouldShowTabSwitcherToolbar Whether or not should show the Tab switcher toolbar.
*/
void onStateChanged(
@OverviewModeState int overviewModeState, boolean shouldShowTabSwitcherToolbar);
@StartSurfaceState int overviewModeState, boolean shouldShowTabSwitcherToolbar);
}
/**
* Set the given {@link StateObserver}.
* Note that this will override the previous observer.
* @param observer The given observer.
* @param observer Registers {@code observer} for the {@link StartSurfaceState} changes.
*/
void setStateChangeObserver(StateObserver observer);
void addStateChangeObserver(StateObserver observer);
/**
* @param observer Unregisters {@code observer} for the {@link StartSurfaceState} changes.
*/
void removeStateChangeObserver(StateObserver observer);
/**
* Defines an interface to pass out tab selecting event.
......@@ -114,10 +119,10 @@ public interface StartSurface {
void showOverview(boolean animate);
/**
* Sets the state {@link OverviewModeState}.
* @param state the {@link OverviewModeState} to show.
* Sets the state {@link StartSurfaceState}.
* @param state the {@link StartSurfaceState} to show.
*/
void setOverviewState(@OverviewModeState int state);
void setOverviewState(@StartSurfaceState int state);
/**
* Called by the TabSwitcherLayout when the system back button is pressed.
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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.compositor.layouts;
package org.chromium.chrome.features.start_surface;
import androidx.annotation.IntDef;
......@@ -10,20 +10,22 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* The internal state of the overview mode except show and hide events notified in the {@link
* OverviewModeBehavior.OverviewModeObserver}.
* The internal state of the StartSurface.
*/
@IntDef({OverviewModeState.NOT_SHOWN, OverviewModeState.SHOWN_HOMEPAGE,
OverviewModeState.SHOWN_TABSWITCHER, OverviewModeState.SHOWN_TABSWITCHER_TWO_PANES,
OverviewModeState.SHOWN_TABSWITCHER_TASKS_ONLY,
OverviewModeState.SHOWN_TABSWITCHER_OMNIBOX_ONLY, OverviewModeState.DISABLED,
OverviewModeState.SHOWING_TABSWITCHER, OverviewModeState.SHOWING_START,
OverviewModeState.SHOWING_HOMEPAGE, OverviewModeState.SHOWING_PREVIOUS,
OverviewModeState.SHOWN_TABSWITCHER_TRENDY_TERMS})
@IntDef({StartSurfaceState.NOT_SHOWN, StartSurfaceState.SHOWN_HOMEPAGE,
StartSurfaceState.SHOWN_TABSWITCHER, StartSurfaceState.SHOWN_TABSWITCHER_TWO_PANES,
StartSurfaceState.SHOWN_TABSWITCHER_TASKS_ONLY,
StartSurfaceState.SHOWN_TABSWITCHER_OMNIBOX_ONLY, StartSurfaceState.DISABLED,
StartSurfaceState.SHOWING_TABSWITCHER, StartSurfaceState.SHOWING_START,
StartSurfaceState.SHOWING_HOMEPAGE, StartSurfaceState.SHOWING_PREVIOUS,
StartSurfaceState.SHOWN_TABSWITCHER_TRENDY_TERMS})
@Retention(RetentionPolicy.SOURCE)
public @interface OverviewModeState {
public @interface StartSurfaceState {
int NOT_SHOWN = 0;
// TODO(crbug.com/1115757): After crrev.com/c/2315823, Overview state and Startsurface state are
// two different things, let's audit all the state here.
// When overview is visible, it will be in one of the SHOWN states.
int SHOWN_HOMEPAGE = 1;
int SHOWN_TABSWITCHER = 2;
......
......@@ -5,4 +5,5 @@
start_surface_public_java_sources = [
"//chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurface.java",
"//chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurfaceConfiguration.java",
"//chrome/android/features/start_surface/public/java/src/org/chromium/chrome/features/start_surface/StartSurfaceState.java",
]
......@@ -10,6 +10,7 @@ import android.view.ViewGroup;
import androidx.annotation.IntDef;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplierImpl;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider;
import org.chromium.chrome.browser.compositor.layouts.Layout;
......@@ -114,7 +115,8 @@ public interface TabManagementDelegate {
* @return the {@link StartSurface}
*/
StartSurface createStartSurface(ChromeActivity activity, ScrimCoordinator scrimCoordinator,
BottomSheetController sheetController);
BottomSheetController sheetController,
OneshotSupplierImpl<StartSurface> startSurfaceOneshotSupplier);
/**
* Create a {@link TabGroupModelFilter} for the given {@link TabModel}.
......
......@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import org.chromium.base.SysUtils;
import org.chromium.base.annotations.UsedByReflection;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplierImpl;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider;
import org.chromium.chrome.browser.compositor.layouts.Layout;
......@@ -93,8 +94,10 @@ public class TabManagementDelegateImpl implements TabManagementDelegate {
@Override
public StartSurface createStartSurface(ChromeActivity activity,
ScrimCoordinator scrimCoordinator, BottomSheetController sheetController) {
return StartSurfaceDelegate.createStartSurface(activity, scrimCoordinator, sheetController);
ScrimCoordinator scrimCoordinator, BottomSheetController sheetController,
OneshotSupplierImpl<StartSurface> startSurfaceOneshotSupplier) {
return StartSurfaceDelegate.createStartSurface(
activity, scrimCoordinator, sheetController, startSurfaceOneshotSupplier);
}
@Override
......
......@@ -65,7 +65,6 @@ import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone;
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeController;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.compositor.layouts.phone.StackLayout;
import org.chromium.chrome.browser.cookies.CookiesFetcher;
import org.chromium.chrome.browser.crypto.CipherFactory;
......@@ -159,6 +158,7 @@ import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
import org.chromium.chrome.browser.vr.VrModuleProvider;
import org.chromium.chrome.features.start_surface.StartSurface;
import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration;
import org.chromium.chrome.features.start_surface.StartSurfaceState;
import org.chromium.components.browser_ui.util.BrowserControlsVisibilityDelegate;
import org.chromium.components.browser_ui.util.ComposedBrowserControlsVisibilityDelegate;
import org.chromium.components.embedder_support.util.UrlConstants;
......@@ -561,8 +561,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
if (tabManagementDelegate != null) {
StartSurface startSurface = tabManagementDelegate.createStartSurface(this,
mRootUiCoordinator.getScrimCoordinator(),
mRootUiCoordinator.getBottomSheetController());
mStartSurfaceSupplier.set(startSurface);
mRootUiCoordinator.getBottomSheetController(), mStartSurfaceSupplier);
}
}
mLayoutManager = new LayoutManagerChromePhone(compositorViewHolder, mContentContainer,
......@@ -626,7 +625,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
if (isInOverviewMode() && !StartSurfaceConfiguration.isStartSurfaceEnabled()) {
hideOverview();
} else {
showOverview(OverviewModeState.SHOWING_TABSWITCHER);
showOverview(StartSurfaceState.SHOWING_TABSWITCHER);
}
};
OnClickListener newTabClickHandler = v -> {
......@@ -649,7 +648,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
Supplier<Boolean> showStartSurfaceSupplier = () -> {
if (ReturnToChromeExperimentsUtil.shouldShowStartSurfaceAsTheHomePageOnPhone(
isTablet())) {
showOverview(OverviewModeState.SHOWING_HOMEPAGE);
showOverview(StartSurfaceState.SHOWING_HOMEPAGE);
return true;
}
return false;
......@@ -931,13 +930,13 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
getOnCreateTimestampMs());
}
mOverviewShownOnStart = true;
showOverview(OverviewModeState.SHOWING_START);
showOverview(StartSurfaceState.SHOWING_START);
return;
}
if (getActivityTab() == null && !isOverviewVisible) {
mOverviewShownOnStart = true;
showOverview(OverviewModeState.SHOWING_START);
showOverview(StartSurfaceState.SHOWING_START);
}
if (isMainIntentFromLauncher(getIntent()) && mOverviewModeController.overviewVisible()) {
......@@ -1812,7 +1811,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
// the tab and go back to the start surface.
if (type == TabLaunchType.FROM_START_SURFACE) {
getCurrentTabModel().closeTab(currentTab);
showOverview(OverviewModeState.SHOWING_PREVIOUS);
showOverview(StartSurfaceState.SHOWING_PREVIOUS);
return true;
}
......@@ -1885,7 +1884,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
getCurrentTabModel().closeTab(tabToClose, false, true, false);
// If there is no next tab to open, enter overview mode.
if (!hasNextTab) showOverview(OverviewModeState.SHOWING_START);
if (!hasNextTab) showOverview(StartSurfaceState.SHOWING_START);
}, CLOSE_TAB_ON_MINIMIZE_DELAY_MS);
}
}
......@@ -1984,11 +1983,14 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
}
}
private void showOverview(@OverviewModeState int state) {
assert (state == OverviewModeState.SHOWING_TABSWITCHER
|| state == OverviewModeState.SHOWING_HOMEPAGE
|| state == OverviewModeState.SHOWING_PREVIOUS
|| state == OverviewModeState.SHOWING_START);
// TODO(crbug.com/1115757): After crrev.com/c/2315823, Overview state and Startsurface state are
// two different things, we actual can split this into two methods: showOverview() and
// showStartSurface(state). Let's do some auditing and clean up before perform the actual split.
private void showOverview(@StartSurfaceState int state) {
assert (state == StartSurfaceState.SHOWING_TABSWITCHER
|| state == StartSurfaceState.SHOWING_HOMEPAGE
|| state == StartSurfaceState.SHOWING_PREVIOUS
|| state == StartSurfaceState.SHOWING_START);
if (mStartSurfaceSupplier.get() != null) {
mStartSurfaceSupplier.get().getController().setOverviewState(state);
}
......@@ -2029,7 +2031,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
if (TabUiFeatureUtilities.supportInstantStart(isTablet())
|| (getTabModelSelector().isTabStateInitialized()
&& isLayoutManagerCreated())) {
showOverview(OverviewModeState.SHOWING_HOMEPAGE);
showOverview(StartSurfaceState.SHOWING_HOMEPAGE);
}
return true;
}
......
......@@ -16,10 +16,6 @@ public class EmptyOverviewModeObserver implements OverviewModeObserver {
@Override
public void onOverviewModeFinishedShowing() {}
@Override
public void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) {}
@Override
public void onOverviewModeStartedHiding(boolean showToolbar, boolean delayAnimation) {}
......
......@@ -117,14 +117,7 @@ public class LayoutManagerChrome
TabManagementDelegate tabManagementDelegate =
TabManagementModuleProvider.getDelegate();
assert tabManagementDelegate != null;
startSurface.setStateChangeObserver(new StartSurface.StateObserver() {
@Override
public void onStateChanged(@OverviewModeState int overviewModeState,
boolean shouldShowTabSwitcherToolbar) {
notifyObserversStateChanged(
overviewModeState, shouldShowTabSwitcherToolbar);
}
});
final ObservableSupplier<? extends BrowserControlsStateProvider>
browserControlsSupplier = mHost.getBrowserControlsManagerSupplier();
mOverviewLayout = tabManagementDelegate.createStartSurfaceLayout(context, this,
......@@ -623,14 +616,4 @@ public class LayoutManagerChrome
}
});
}
private void notifyObserversStateChanged(
@OverviewModeState int overviewModeState, boolean shouldShowTabSwitcherToolbar) {
mOverviewModeBehaviorSupplier.onAvailable((unused) -> {
for (OverviewModeObserver overviewModeObserver : mOverviewModeObservers) {
overviewModeObserver.onOverviewModeStateChanged(
overviewModeState, shouldShowTabSwitcherToolbar);
}
});
}
}
......@@ -25,13 +25,6 @@ public interface OverviewModeBehavior {
*/
void onOverviewModeFinishedShowing();
/**
* Called when the internal state is changed.
* @param showTabSwitcherToolbar Whether or not request showing the Tab switcher toolbar.
*/
void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar);
/**
* Called when overview mode starts hiding.
* @param showToolbar Whether or not to show the normal toolbar when animating out of
......
......@@ -15,7 +15,6 @@ import org.chromium.base.ObserverList;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
......@@ -32,6 +31,7 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.ButtonData;
import org.chromium.chrome.browser.toolbar.ButtonDataProvider;
import org.chromium.chrome.browser.user_education.IPHCommandBuilder;
import org.chromium.chrome.features.start_surface.StartSurfaceState;
import org.chromium.components.feature_engagement.EventConstants;
import org.chromium.components.feature_engagement.FeatureConstants;
import org.chromium.components.feature_engagement.Tracker;
......@@ -153,8 +153,8 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
return mButtonData;
}
public ButtonData getForStartSurface(@OverviewModeState int overviewModeState) {
if (overviewModeState != OverviewModeState.SHOWN_HOMEPAGE) {
public ButtonData getForStartSurface(@StartSurfaceState int overviewModeState) {
if (overviewModeState != StartSurfaceState.SHOWN_HOMEPAGE) {
mButtonData.canShow = false;
return mButtonData;
}
......
......@@ -18,13 +18,12 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.base.TraceEvent;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.ActivityTabProvider.ActivityTabTabObserver;
import org.chromium.chrome.browser.compositor.layouts.EmptyOverviewModeObserver;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.homepage.HomepageManager;
import org.chromium.chrome.browser.homepage.HomepagePolicyManager;
......@@ -33,7 +32,10 @@ import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.settings.SettingsLauncher;
import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tasks.ReturnToChromeExperimentsUtil;
import org.chromium.chrome.browser.toolbar.ThemeColorProvider.TintObserver;
import org.chromium.chrome.features.start_surface.StartSurface;
import org.chromium.chrome.features.start_surface.StartSurfaceState;
import org.chromium.ui.widget.ChromeImageButton;
/**
......@@ -56,18 +58,17 @@ public class HomeButton extends ChromeImageButton
/** The {@link ActivityTabProvider} used to know if the active tab is on the NTP. */
private ActivityTabProvider mActivityTabProvider;
/** The {@link OverviewModeBehavior} used to observe overview state changes. */
private OverviewModeBehavior mOverviewModeBehavior;
/** The {@link OvervieModeObserver} observing the OverviewModeBehavior */
private OverviewModeBehavior.OverviewModeObserver mOverviewModeObserver;
// Test related members
private static boolean sSaveContextMenuForTests;
private ContextMenu mMenuForTests;
private SettingsLauncher mSettingsLauncher;
private ObservableSupplier<StartSurface> mStartSurfaceSupplier;
private Callback<StartSurface> mStartSurfaceSupplierObserver;
private StartSurface mStartSurface;
private StartSurface.StateObserver mStartSurfaceStateObserver;
public HomeButton(Context context, AttributeSet attrs) {
super(context, attrs);
......@@ -76,18 +77,6 @@ public class HomeButton extends ChromeImageButton
HomepageManager.getInstance().addListener(this);
updateContextMenuListener();
mOverviewModeObserver = new EmptyOverviewModeObserver() {
@Override
public void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) {
if (overviewModeState == OverviewModeState.SHOWN_HOMEPAGE) {
updateButtonEnabledState(false);
} else {
updateButtonEnabledState(null);
}
}
};
mSettingsLauncher = new SettingsLauncherImpl();
}
......@@ -104,9 +93,12 @@ public class HomeButton extends ChromeImageButton
HomepageManager.getInstance().removeListener(this);
if (mOverviewModeBehavior != null) {
mOverviewModeBehavior.removeOverviewModeObserver(mOverviewModeObserver);
mOverviewModeObserver = null;
if (mStartSurfaceSupplier != null) {
mStartSurfaceSupplier.removeObserver(mStartSurfaceSupplierObserver);
}
if (mStartSurface != null) {
mStartSurface.removeStateChangeObserver(mStartSurfaceStateObserver);
}
}
......@@ -115,10 +107,26 @@ public class HomeButton extends ChromeImageButton
mThemeColorProvider.addTintObserver(this);
}
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {
assert overviewModeBehavior != null;
mOverviewModeBehavior = overviewModeBehavior;
mOverviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
public void setStartSurfaceSupplier(ObservableSupplier<StartSurface> startSurfaceSupplier) {
assert ReturnToChromeExperimentsUtil.shouldShowStartSurfaceAsTheHomePage();
mStartSurfaceSupplier = startSurfaceSupplier;
mStartSurfaceSupplierObserver = (startSurface) -> {
// TODO(crbug.com/1084528): Replace with OneShotSupplier when it is available.
assert startSurface != null;
assert mStartSurface == null : "The StartSurface should be set at most once.";
mStartSurface = startSurface;
mStartSurfaceStateObserver = (newState, shouldShowToolbar) -> {
if (newState == StartSurfaceState.SHOWN_HOMEPAGE) {
updateButtonEnabledState(false);
} else {
updateButtonEnabledState(null);
}
};
startSurface.addStateChangeObserver(mStartSurfaceStateObserver);
};
mStartSurfaceSupplier.addObserver(mStartSurfaceSupplierObserver);
}
@Override
......
......@@ -42,7 +42,6 @@ import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.OverviewModeObserver;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.compositor.layouts.SceneChangeObserver;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.findinpage.FindToolbarManager;
......@@ -93,7 +92,9 @@ import org.chromium.chrome.browser.ui.appmenu.MenuButtonDelegate;
import org.chromium.chrome.browser.ui.native_page.NativePage;
import org.chromium.chrome.browser.user_education.UserEducationHelper;
import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
import org.chromium.chrome.features.start_surface.StartSurface;
import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration;
import org.chromium.chrome.features.start_surface.StartSurfaceState;
import org.chromium.components.browser_ui.styles.ChromeColors;
import org.chromium.components.browser_ui.widget.scrim.ScrimCoordinator;
import org.chromium.components.search_engines.TemplateUrl;
......@@ -149,7 +150,7 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
private BookmarkBridge.BookmarkModelObserver mBookmarksObserver;
private FindToolbarObserver mFindToolbarObserver;
private OverviewModeObserver mOverviewModeObserver;
private @OverviewModeState int mOverviewModeState = OverviewModeState.NOT_SHOWN;
private @StartSurfaceState int mStartSurfaceState = StartSurfaceState.NOT_SHOWN;
private OverviewModeBehavior mOverviewModeBehavior;
private OneshotSupplier<OverviewModeBehavior> mOverviewModeBehaviorSupplier;
......@@ -195,6 +196,9 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
private Supplier<Boolean> mShowStartSurfaceSupplier;
private final ScrimCoordinator mScrimCoordinator;
private StartSurface mStartSurface;
private StartSurface.StateObserver mStartSurfaceStateObserver;
/**
* Creates a ToolbarManager object.
* @param controlsSizer The {@link BrowserControlsSizer} for the activity.
......@@ -219,6 +223,7 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
* @param overviewModeBehaviorSupplier Supplier of the overview mode manager for the current
* profile.
* @param tabModelSelectorSupplier Supplier of the {@link TabModelSelector}.
* @param startSurfaceSupplier Supplier of the StartSurface.
*/
public ToolbarManager(ChromeActivity activity, BrowserControlsSizer controlsSizer,
FullscreenManager fullscreenManager, ToolbarControlContainer controlContainer,
......@@ -234,7 +239,8 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
OneshotSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier,
OneshotSupplier<AppMenuCoordinator> appMenuCoordinatorSupplier,
boolean shouldShowUpdateBadge,
ObservableSupplier<TabModelSelector> tabModelSelectorSupplier) {
ObservableSupplier<TabModelSelector> tabModelSelectorSupplier,
OneshotSupplier<StartSurface> startSurfaceSupplier) {
TraceEvent.begin("ToolbarManager.ToolbarManager");
mActivity = activity;
mBrowserControlsSizer = controlsSizer;
......@@ -321,8 +327,7 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mToolbar = createTopToolbarCoordinator(controlContainer, toolbarLayout, buttonDataProviders,
browsingModeThemeColorProvider, startSurfaceMenuButtonCoordinator, invalidator,
identityDiscController);
identityDiscController, startSurfaceSupplier);
mActionModeController =
new ActionModeController(mActivity, mActionBarDelegate, toolbarActionModeCallback);
......@@ -575,14 +580,6 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
updateButtonStatus();
}
@Override
public void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) {
assert StartSurfaceConfiguration.isStartSurfaceEnabled();
mOverviewModeState = overviewModeState;
mToolbar.updateTabSwitcherToolbarState(showTabSwitcherToolbar);
}
@Override
public void onOverviewModeStartedHiding(boolean showToolbar, boolean delayAnimation) {
mToolbar.setTabSwitcherMode(false, showToolbar, delayAnimation);
......@@ -622,6 +619,16 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mFindToolbarManager = findToolbarManager;
mFindToolbarManager.addObserver(mFindToolbarObserver);
startSurfaceSupplier.onAvailable(mCallbackController.makeCancelable((startSurface) -> {
mStartSurface = startSurface;
mStartSurfaceStateObserver = (newState, shouldShowToolbar) -> {
assert StartSurfaceConfiguration.isStartSurfaceEnabled();
mToolbar.updateTabSwitcherToolbarState(shouldShowToolbar);
};
mStartSurface.addStateChangeObserver(mStartSurfaceStateObserver);
}));
TraceEvent.end("ToolbarManager.ToolbarManager");
}
......@@ -630,20 +637,26 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
List<ButtonDataProvider> buttonDataProviders,
ThemeColorProvider browsingModeThemeColorProvider,
MenuButtonCoordinator startSurfaceMenuButtonCoordinator, Invalidator invalidator,
IdentityDiscController identityDiscController) {
IdentityDiscController identityDiscController,
OneshotSupplier<StartSurface> startSurfaceSupplier) {
TopToolbarCoordinator toolbar = new TopToolbarCoordinator(controlContainer, toolbarLayout,
mLocationBarModel, mToolbarTabController,
new UserEducationHelper(mActivity, mHandler, TrackerFactory::getTrackerForProfile),
buttonDataProviders, mOverviewModeBehaviorSupplier, browsingModeThemeColorProvider,
mAppThemeColorProvider, mMenuButtonCoordinator, startSurfaceMenuButtonCoordinator,
mMenuButtonCoordinator.getMenuButtonHelperSupplier(), mTabModelSelectorSupplier,
mHomeButtonVisibilitySupplier, mIdentityDiscStateSupplier, (client) -> {
mHomeButtonVisibilitySupplier, mIdentityDiscStateSupplier,
(client)
-> {
if (invalidator != null) {
invalidator.invalidate(client);
} else {
client.run();
}
}, () -> identityDiscController.getForStartSurface(mOverviewModeState));
},
()
-> identityDiscController.getForStartSurface(mStartSurfaceState),
startSurfaceSupplier);
mHomepageStateListener =
() -> mHomeButtonVisibilitySupplier.set(HomepageManager.isHomepageEnabled());
HomepageManager.getInstance().addListener(mHomepageStateListener);
......@@ -940,6 +953,12 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mCallbackController = null;
}
if (mStartSurface != null) {
mStartSurface.removeStateChangeObserver(mStartSurfaceStateObserver);
mStartSurface = null;
mStartSurfaceStateObserver = null;
}
mActivity.unregisterComponentCallbacks(mComponentCallbacks);
mComponentCallbacks = null;
ChromeAccessibilityUtil.get().removeObserver(this);
......
......@@ -28,6 +28,7 @@ import org.chromium.chrome.browser.toolbar.TabSwitcherButtonView;
import org.chromium.chrome.browser.toolbar.ThemeColorProvider;
import org.chromium.chrome.browser.toolbar.menu_button.MenuButtonCoordinator;
import org.chromium.chrome.browser.user_education.UserEducationHelper;
import org.chromium.chrome.features.start_surface.StartSurface;
import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
......@@ -59,7 +60,8 @@ public class StartSurfaceToolbarCoordinator {
OneshotSupplier<OverviewModeBehavior> overviewModeBehaviorSupplier,
ObservableSupplier<Boolean> identityDiscStateSupplier, ThemeColorProvider provider,
MenuButtonCoordinator menuButtonCoordinator,
Supplier<ButtonData> identityDiscButtonSupplier) {
Supplier<ButtonData> identityDiscButtonSupplier,
OneshotSupplier<StartSurface> startSurfaceSupplier) {
mStub = startSurfaceToolbarStub;
overviewModeBehaviorSupplier.onAvailable(
......@@ -94,7 +96,8 @@ public class StartSurfaceToolbarCoordinator {
StartSurfaceConfiguration.START_SURFACE_HIDE_INCOGNITO_SWITCH_NO_TAB.getValue(),
StartSurfaceConfiguration.START_SURFACE_HIDE_INCOGNITO_SWITCH.getValue(),
StartSurfaceConfiguration.START_SURFACE_SHOW_STACK_TAB_SWITCHER.getValue(),
menuButtonCoordinator, identityDiscStateSupplier, identityDiscButtonSupplier);
menuButtonCoordinator, identityDiscStateSupplier, identityDiscButtonSupplier,
startSurfaceSupplier);
mThemeColorProvider = provider;
mMenuButtonCoordinator = menuButtonCoordinator;
......
......@@ -26,12 +26,13 @@ import android.view.View;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.Callback;
import org.chromium.base.CallbackController;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.OneshotSupplier;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.compositor.layouts.EmptyOverviewModeObserver;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.OverviewModeObserver;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.IncognitoStateProvider;
......@@ -42,6 +43,8 @@ import org.chromium.chrome.browser.toolbar.ButtonData;
import org.chromium.chrome.browser.toolbar.menu_button.MenuButtonCoordinator;
import org.chromium.chrome.browser.user_education.IPHCommandBuilder;
import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
import org.chromium.chrome.features.start_surface.StartSurface;
import org.chromium.chrome.features.start_surface.StartSurfaceState;
import org.chromium.components.search_engines.TemplateUrlService.TemplateUrlServiceObserver;
import org.chromium.ui.modelutil.PropertyModel;
......@@ -60,17 +63,22 @@ class StartSurfaceToolbarMediator {
private OverviewModeBehavior mOverviewModeBehavior;
private OverviewModeObserver mOverviewModeObserver;
private MenuButtonCoordinator mMenuButtonCoordinator;
@OverviewModeState
@StartSurfaceState
private int mOverviewModeState;
private boolean mIsGoogleSearchEngine;
private StartSurface mStartSurface;
private StartSurface.StateObserver mStartSurfaceStateObserver;
private CallbackController mCallbackController = new CallbackController();
StartSurfaceToolbarMediator(PropertyModel model, Callback<IPHCommandBuilder> showIPHCallback,
boolean hideIncognitoSwitchWhenNoTabs, boolean hideIncognitoSwitchOnHomePage,
boolean showNewTabAndIdentityDiscAtStart, MenuButtonCoordinator menuButtonCoordinator,
ObservableSupplier<Boolean> identityDiscStateSupplier,
Supplier<ButtonData> identityDiscButtonSupplier) {
Supplier<ButtonData> identityDiscButtonSupplier,
OneshotSupplier<StartSurface> startSurfaceSupplier) {
mPropertyModel = model;
mOverviewModeState = OverviewModeState.NOT_SHOWN;
mOverviewModeState = StartSurfaceState.NOT_SHOWN;
mShowIPHCallback = showIPHCallback;
mHideIncognitoSwitchWhenNoTabs = hideIncognitoSwitchWhenNoTabs;
mHideIncognitoSwitchOnHomePage = hideIncognitoSwitchOnHomePage;
......@@ -82,6 +90,20 @@ class StartSurfaceToolbarMediator {
if (!canShowHint && !mPropertyModel.get(IDENTITY_DISC_IS_VISIBLE)) return;
updateIdentityDisc(mIdentityDiscButtonSupplier.get());
});
startSurfaceSupplier.onAvailable(mCallbackController.makeCancelable(this::setStartSurface));
}
void setStartSurface(StartSurface startSurface) {
mStartSurface = startSurface;
mStartSurfaceStateObserver = (newState, shouldShowToolbar) -> {
mOverviewModeState = newState;
updateIncognitoSwitchVisibility();
updateNewTabButtonVisibility();
updateLogoVisibility(mIsGoogleSearchEngine);
updateIdentityDisc(mIdentityDiscButtonSupplier.get());
};
startSurface.addStateChangeObserver(mStartSurfaceStateObserver);
}
void onNativeLibraryReady() {
......@@ -109,6 +131,13 @@ class StartSurfaceToolbarMediator {
if (mOverviewModeObserver != null) {
mOverviewModeBehavior.removeOverviewModeObserver(mOverviewModeObserver);
}
if (mStartSurface != null) {
mStartSurface.removeStateChangeObserver(mStartSurfaceStateObserver);
}
if (mCallbackController != null) {
mCallbackController.destroy();
mCallbackController = null;
}
}
void setOnNewTabClickHandler(View.OnClickListener listener) {
......@@ -134,7 +163,7 @@ class StartSurfaceToolbarMediator {
}
private void updateIncognitoSwitchVisibility() {
if (mOverviewModeState == OverviewModeState.SHOWN_HOMEPAGE && mHideIncognitoSwitchOnHomePage
if (mOverviewModeState == StartSurfaceState.SHOWN_HOMEPAGE && mHideIncognitoSwitchOnHomePage
|| mShowNewTabAndIdentityDiscAtStart) {
mPropertyModel.set(INCOGNITO_SWITCHER_VISIBLE, false);
return;
......@@ -184,20 +213,11 @@ class StartSurfaceToolbarMediator {
mOverviewModeBehavior = overviewModeBehavior;
mOverviewModeObserver = new EmptyOverviewModeObserver() {
@Override
public void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) {
mOverviewModeState = overviewModeState;
updateIncognitoSwitchVisibility();
updateNewTabButtonVisibility();
updateLogoVisibility(mIsGoogleSearchEngine);
updateIdentityDisc(mIdentityDiscButtonSupplier.get());
}
@Override
public void onOverviewModeStartedShowing(boolean showToolbar) {
updateIncognitoSwitchVisibility();
if (mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_OMNIBOX_ONLY
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_TRENDY_TERMS
if (mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_OMNIBOX_ONLY
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_TRENDY_TERMS
|| mShowNewTabAndIdentityDiscAtStart) {
mPropertyModel.set(NEW_TAB_BUTTON_AT_START, true);
}
......@@ -222,10 +242,10 @@ class StartSurfaceToolbarMediator {
private void updateLogoVisibility(boolean isGoogleSearchEngine) {
mIsGoogleSearchEngine = isGoogleSearchEngine;
boolean shouldShowLogo =
(mOverviewModeState == OverviewModeState.SHOWN_HOMEPAGE
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_TASKS_ONLY
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_OMNIBOX_ONLY
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_TRENDY_TERMS)
(mOverviewModeState == StartSurfaceState.SHOWN_HOMEPAGE
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_TASKS_ONLY
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_OMNIBOX_ONLY
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_TRENDY_TERMS)
&& mIsGoogleSearchEngine;
mPropertyModel.set(LOGO_IS_VISIBLE, shouldShowLogo);
}
......@@ -250,16 +270,16 @@ class StartSurfaceToolbarMediator {
private void updateNewTabButtonVisibility() {
// This toolbar is only shown for tab switcher when accessibility is enabled. Note that
// OverviewListLayout will be shown as the tab switcher instead of the star surface.
boolean isShownTabswitcherState = mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_TASKS_ONLY
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_OMNIBOX_ONLY
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_TRENDY_TERMS
boolean isShownTabswitcherState = mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_TASKS_ONLY
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_OMNIBOX_ONLY
|| mOverviewModeState == StartSurfaceState.SHOWN_TABSWITCHER_TRENDY_TERMS
|| ChromeAccessibilityUtil.get().isAccessibilityEnabled();
mPropertyModel.set(NEW_TAB_BUTTON_IS_VISIBLE, isShownTabswitcherState);
}
@VisibleForTesting
@OverviewModeState
@StartSurfaceState
int getOverviewModeStateForTesting() {
return mOverviewModeState;
}
......
......@@ -42,6 +42,7 @@ import org.chromium.chrome.browser.toolbar.menu_button.MenuButton;
import org.chromium.chrome.browser.toolbar.menu_button.MenuButtonCoordinator;
import org.chromium.chrome.browser.ui.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.user_education.UserEducationHelper;
import org.chromium.chrome.features.start_surface.StartSurface;
import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration;
import org.chromium.components.browser_ui.widget.ClipDrawableProgressBar;
......@@ -109,6 +110,7 @@ public class TopToolbarCoordinator implements Toolbar {
* invalidate the drawing surface. This will give the object that registers as the host
* for the {@link Invalidator} a chance to defer the actual invalidate to sync drawing.
* @param identityDiscButtonSupplier Supplier of Identity Disc button.
* @param startSurfaceSupplier Supplier of the StartSurface.
*/
public TopToolbarCoordinator(ToolbarControlContainer controlContainer,
ToolbarLayout toolbarLayout, ToolbarDataProvider toolbarDataProvider,
......@@ -123,8 +125,8 @@ public class TopToolbarCoordinator implements Toolbar {
ObservableSupplier<TabModelSelector> tabModelSelectorSupplier,
ObservableSupplier<Boolean> homeButtonVisibilitySupplier,
ObservableSupplier<Boolean> identityDiscStateSupplier,
Callback<Runnable> invalidatorCallback,
Supplier<ButtonData> identityDiscButtonSupplier) {
Callback<Runnable> invalidatorCallback, Supplier<ButtonData> identityDiscButtonSupplier,
OneshotSupplier<StartSurface> startSurfaceSupplier) {
mToolbarLayout = toolbarLayout;
mMenuButtonCoordinator = browsingModeMenuButtonCoordinator;
mOptionalButtonController = new OptionalBrowsingModeButtonController(buttonDataProviders,
......@@ -145,7 +147,8 @@ public class TopToolbarCoordinator implements Toolbar {
controlContainer.getRootView().findViewById(R.id.tab_switcher_toolbar_stub),
userEducationHelper, overviewModeBehaviorSupplier,
identityDiscStateSupplier, overviewThemeColorProvider,
overviewModeMenuButtonCoordinator, identityDiscButtonSupplier);
overviewModeMenuButtonCoordinator, identityDiscButtonSupplier,
startSurfaceSupplier);
} else {
mTabSwitcherModeCoordinatorPhone = new TabSwitcherModeTTCoordinatorPhone(
controlContainer.getRootView().findViewById(R.id.tab_switcher_toolbar_stub),
......
......@@ -538,7 +538,7 @@ public class RootUiCoordinator
mScrimCoordinator, mActionModeControllerCallback, mFindToolbarManager,
mProfileSupplier, mBookmarkBridgeSupplier, mCanAnimateBrowserControls,
mOverviewModeBehaviorSupplier, mAppMenuSupplier, shouldShowMenuUpdateBadge(),
mTabModelSelectorSupplier);
mTabModelSelectorSupplier, mStartSurfaceSupplier);
if (!mActivity.supportsAppMenu()) {
mToolbarManager.getToolbar().disableMenuButton();
}
......
......@@ -30,9 +30,9 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.features.start_surface.StartSurfaceState;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ViewUtils;
......@@ -136,7 +136,7 @@ public final class ShareButtonControllerTest {
-> mActivityTestRule.getActivity()
.getStartSurface()
.getController()
.setOverviewState(OverviewModeState.SHOWING_START));
.setOverviewState(StartSurfaceState.SHOWING_START));
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().getLayoutManager().showOverview(false));
......
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