Commit 1f0b7c2a authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Disable start surface for low end device

This CL also fixes the new tab button is missing on start
tab switcher surface.

Screenshots:
https://drive.google.com/a/google.com/file/d/1R4_oyeIz6_VuwMellLzPI7zQ2ef04AWX/view?usp=sharing
https://drive.google.com/a/google.com/file/d/1R0ASrrY8v50Z9E2bbGI-al_kKrjlI16p/view?usp=sharing

Bug: 1042006
Change-Id: Ie9663daf6cc0cb32c63975d65adfce9bb990ef4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003289Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732482}
parent 27b3a2a2
......@@ -412,7 +412,8 @@ public class FeatureUtilities {
* @return Whether the Start Surface is enabled.
*/
public static boolean isStartSurfaceEnabled() {
return isFlagEnabled(ChromePreferenceKeys.FLAGS_CACHED_START_SURFACE_ENABLED, false);
return isFlagEnabled(ChromePreferenceKeys.FLAGS_CACHED_START_SURFACE_ENABLED, false)
&& !SysUtils.isLowEndDevice();
}
private static void cachePaintPreviewTestEnabled() {
......
......@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.partnercustomizations.HomepageManager;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.base.PageTransition;
......@@ -180,10 +181,11 @@ public final class ReturnToChromeExperimentsUtil {
* @return Whether Start Surface should be shown as the home page, otherwise false.
*/
public static boolean shouldShowStartSurfaceAsTheHomePage() {
// Note that we should only show StartSurface as the HomePage if Single Pane is enabled and
// HomePage is not customized.
// Note that we should only show StartSurface as the HomePage if Single Pane is enabled,
// HomePage is not customized and accessibility is not enabled.
String homePageUrl = HomepageManager.getHomepageUri();
return FeatureUtilities.isStartSurfaceSinglePaneEnabled()
&& (TextUtils.isEmpty(homePageUrl) || NewTabPage.isNTPUrl(homePageUrl));
&& (TextUtils.isEmpty(homePageUrl) || NewTabPage.isNTPUrl(homePageUrl))
&& !AccessibilityUtil.isAccessibilityEnabled();
}
}
......@@ -28,6 +28,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.toolbar.IncognitoStateProvider;
import org.chromium.chrome.browser.ui.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.components.search_engines.TemplateUrlService.TemplateUrlServiceObserver;
import org.chromium.ui.modelutil.PropertyModel;
......@@ -55,15 +56,13 @@ class StartSurfaceToolbarMediator {
mTemplateUrlObserver = new TemplateUrlServiceObserver() {
@Override
public void onTemplateURLServiceChanged() {
updateLogoVisibility(mOverviewModeState,
TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
updateLogoVisibility(TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
}
};
TemplateUrlServiceFactory.get().addObserver(mTemplateUrlObserver);
mIsGoogleSearchEngine = TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle();
updateLogoVisibility(
mOverviewModeState, TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
updateLogoVisibility(TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
}
void destroy() {
......@@ -115,6 +114,7 @@ class StartSurfaceToolbarMediator {
void onAccessibilityStatusChanged(boolean enabled) {
mPropertyModel.set(ACCESSIBILITY_ENABLED, enabled);
updateNewTabButtonVisibility();
}
void onBottomToolbarVisibilityChanged(boolean isVisible) {}
......@@ -128,10 +128,9 @@ class StartSurfaceToolbarMediator {
@Override
public void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) {
boolean isShownTabswitcherState =
overviewModeState == OverviewModeState.SHOWN_TABSWITCHER;
mPropertyModel.set(NEW_TAB_BUTTON_IS_VISIBLE, isShownTabswitcherState);
updateLogoVisibility(overviewModeState, mIsGoogleSearchEngine);
mOverviewModeState = overviewModeState;
updateNewTabButtonVisibility();
updateLogoVisibility(mIsGoogleSearchEngine);
}
@Override
public void onOverviewModeFinishedShowing() {
......@@ -148,9 +147,7 @@ class StartSurfaceToolbarMediator {
mOverviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
}
private void updateLogoVisibility(
@OverviewModeState int overviewModeState, boolean isGoogleSearchEngine) {
mOverviewModeState = overviewModeState;
private void updateLogoVisibility(boolean isGoogleSearchEngine) {
mIsGoogleSearchEngine = isGoogleSearchEngine;
boolean shouldShowLogo =
(mOverviewModeState == OverviewModeState.SHOWN_HOMEPAGE
......@@ -158,4 +155,13 @@ class StartSurfaceToolbarMediator {
&& mIsGoogleSearchEngine;
mPropertyModel.set(LOGO_IS_VISIBLE, shouldShowLogo);
}
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
|| AccessibilityUtil.isAccessibilityEnabled();
mPropertyModel.set(NEW_TAB_BUTTON_IS_VISIBLE, isShownTabswitcherState);
}
}
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